Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
View | Details | Raw Unified | Return to bug 199534 | Differences between
and this patch

Collapse All | Expand All

(-)a/dlight.remote.impl/nbproject/project.xml (-1 / +1 lines)
 Lines 85-91    Link Here 
85
                    <build-prerequisite/>
85
                    <build-prerequisite/>
86
                    <compile-dependency/>
86
                    <compile-dependency/>
87
                    <run-dependency>
87
                    <run-dependency>
88
                        <specification-version>7.36</specification-version>
88
                        <specification-version>7.56</specification-version>
89
                    </run-dependency>
89
                    </run-dependency>
90
                </dependency>
90
                </dependency>
91
                <dependency>
91
                <dependency>
(-)a/dlight.remote.impl/src/org/netbeans/modules/remote/impl/fs/RemoteFileObjectBase.java (+3 lines)
 Lines 554-559    Link Here 
554
    
554
    
555
    @Override
555
    @Override
556
    public Object getAttribute(String attrName) {
556
    public Object getAttribute(String attrName) {
557
        if (attrName.equals("default-line-separator")) { // NOI18N
558
            return "\n"; // NOI18N
559
        }
557
        if (attrName.equals("isRemoteAndSlow")) { // NOI18N
560
        if (attrName.equals("isRemoteAndSlow")) { // NOI18N
558
            return Boolean.TRUE;
561
            return Boolean.TRUE;
559
        }
562
        }
(-)a/editor.lib/apichanges.xml (+17 lines)
 Lines 107-112    Link Here 
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
108
109
    <changes>
109
    <changes>
110
         <change id="default-line-separator">
111
            <summary>Provides default line separator</summary>
112
            <version major="3" minor="19"/>
113
            <date day="13" month="1" year="2012"/>
114
            <author login="alexvsimon"/>
115
            <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
116
            <description>
117
                <p>
118
                    Defines name of default line separator property 
119
                    <code>DEFAULT_LINE_SEPARATOR_PROP</code>.
120
                    If property <code>getProperty(DEFAULT_LINE_SEPARATOR_PROP)</code> is defined, it will be used instead <code>System.getProperty("line.separator")</code>.
121
                    It will be used by the text editor if saving new content to an initially empty file.
122
                </p>
123
            </description>
124
            <class package="org.netbeans.editor" name="BaseDocument"/>
125
            <issue number="199534"/>
126
        </change>
110
127
111
        <change id="deprecating-formatting">
128
        <change id="deprecating-formatting">
112
            <summary>Deprecating old formatting API</summary>
129
            <summary>Deprecating old formatting API</summary>
(-)a/editor.lib/nbproject/project.properties (-1 / +1 lines)
 Lines 42-48    Link Here 
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=3.18.0
45
spec.version.base=3.19
46
is.autoload=true
46
is.autoload=true
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
(-)a/editor.lib/nbproject/project.xml (-1 / +1 lines)
 Lines 141-147    Link Here 
141
                    <build-prerequisite/>
141
                    <build-prerequisite/>
142
                    <compile-dependency/>
142
                    <compile-dependency/>
143
                    <run-dependency>
143
                    <run-dependency>
144
                        <specification-version>7.13</specification-version>
144
                        <specification-version>7.56</specification-version>
145
                    </run-dependency>
145
                    </run-dependency>
146
                </dependency>
146
                </dependency>
147
                <dependency>
147
                <dependency>
(-)a/editor.lib/src/org/netbeans/editor/BaseDocument.java (-2 / +15 lines)
 Lines 165-170    Link Here 
165
     */
165
     */
166
    public static final String WRITE_LINE_SEPARATOR_PROP = "write-line-separator"; // NOI18N
166
    public static final String WRITE_LINE_SEPARATOR_PROP = "write-line-separator"; // NOI18N
167
167
168
    /** Default line separator property for writing content into files.
169
     * It will be used by the text editor if saving new content to an initially empty file.
170
     * If it not set the platform default line separator is used.
171
     * @since 3.19
172
     */
173
    public static final String DEFAULT_LINE_SEPARATOR_PROP = "default-line-separator"; // NOI18N
174
168
    /** File name property */
175
    /** File name property */
169
    public static final String FILE_NAME_PROP = "file-name"; // NOI18N
176
    public static final String FILE_NAME_PROP = "file-name"; // NOI18N
170
177
 Lines 1386-1392    Link Here 
1386
            if (!inited) { // Fill line-separator properties
1393
            if (!inited) { // Fill line-separator properties
1387
                String lineSeparator = ReadWriteUtils.findFirstLineSeparator(buffer);
1394
                String lineSeparator = ReadWriteUtils.findFirstLineSeparator(buffer);
1388
                if (lineSeparator == null) {
1395
                if (lineSeparator == null) {
1389
                    lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1396
                    lineSeparator = (String) getProperty(BaseDocument.DEFAULT_LINE_SEPARATOR_PROP);
1397
                    if (lineSeparator == null) {
1398
                        lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1399
                    }
1390
                }
1400
                }
1391
                putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, lineSeparator);
1401
                putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, lineSeparator);
1392
            }
1402
            }
 Lines 1430-1436    Link Here 
1430
            if (lineSeparator == null) {
1440
            if (lineSeparator == null) {
1431
                lineSeparator = (String) getProperty(BaseDocument.READ_LINE_SEPARATOR_PROP);
1441
                lineSeparator = (String) getProperty(BaseDocument.READ_LINE_SEPARATOR_PROP);
1432
                if (lineSeparator == null) {
1442
                if (lineSeparator == null) {
1433
                    lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1443
                    lineSeparator = (String) getProperty(BaseDocument.DEFAULT_LINE_SEPARATOR_PROP);
1444
                    if (lineSeparator == null) {
1445
                        lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1446
                    }
1434
                }
1447
                }
1435
            }
1448
            }
1436
            CharSequence docText = (CharSequence) getProperty(CharSequence.class);
1449
            CharSequence docText = (CharSequence) getProperty(CharSequence.class);
(-)a/editor/nbproject/project.xml (-1 / +6 lines)
 Lines 167-173    Link Here 
167
                    <build-prerequisite/>
167
                    <build-prerequisite/>
168
                    <compile-dependency/>
168
                    <compile-dependency/>
169
                    <run-dependency>
169
                    <run-dependency>
170
                        <specification-version>7.55</specification-version>
170
                        <specification-version>7.56</specification-version>
171
                    </run-dependency>
171
                    </run-dependency>
172
                </dependency>
172
                </dependency>
173
                <dependency>
173
                <dependency>
 Lines 261-266    Link Here 
261
                        <recursive/>
261
                        <recursive/>
262
                    </test-dependency>
262
                    </test-dependency>
263
                    <test-dependency>
263
                    <test-dependency>
264
                        <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
265
                        <compile-dependency/>
266
                        <test/>
267
                    </test-dependency>
268
                    <test-dependency>
264
                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
269
                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
265
                        <recursive/>
270
                        <recursive/>
266
                    </test-dependency>
271
                    </test-dependency>
(-)a/editor/src/org/netbeans/modules/editor/EditorModule.java (-1 / +10 lines)
 Lines 637-642    Link Here 
637
            
637
            
638
            final StyledDocument doc = ec.openDocument();
638
            final StyledDocument doc = ec.openDocument();
639
            final Reformat reformat = Reformat.get(doc);
639
            final Reformat reformat = Reformat.get(doc);
640
            String defaultLineSeparator = (String) file.getPrimaryFile().getAttribute(BaseDocument.DEFAULT_LINE_SEPARATOR_PROP);
641
            if (defaultLineSeparator != null) {
642
                doc.putProperty(BaseDocument.DEFAULT_LINE_SEPARATOR_PROP, defaultLineSeparator);
643
            }
640
            
644
            
641
            reformat.lock();
645
            reformat.lock();
642
            
646
            
 Lines 658-664    Link Here 
658
                
662
                
659
            } finally {
663
            } finally {
660
                reformat.unlock();
664
                reformat.unlock();
661
                doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, ReadWriteUtils.getSystemLineSeparator());
665
                defaultLineSeparator = (String) doc.getProperty(BaseDocument.DEFAULT_LINE_SEPARATOR_PROP);
666
                if (defaultLineSeparator != null) {
667
                    doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, defaultLineSeparator);
668
                } else {
669
                    doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, ReadWriteUtils.getSystemLineSeparator());
670
                }
662
                ec.saveDocument();
671
                ec.saveDocument();
663
            }
672
            }
664
            
673
            
(-)a/editor/test/unit/src/org/netbeans/modules/editor/LineSeparatorDataEditorSupportTest.java (+493 lines)
Line 0    Link Here 
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2012 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.editor;
43
44
import java.io.ByteArrayInputStream;
45
import java.io.FileNotFoundException;
46
import java.io.IOException;
47
import java.util.logging.Level;
48
import java.util.prefs.Preferences;
49
import javax.swing.SwingUtilities;
50
import javax.swing.text.BadLocationException;
51
import javax.swing.text.StyledDocument;
52
import org.netbeans.api.editor.mimelookup.MimeLookup;
53
import org.netbeans.api.editor.mimelookup.MimePath;
54
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
55
import org.netbeans.junit.MockServices;
56
import org.netbeans.junit.NbTestCase;
57
import org.openide.cookies.EditCookie;
58
import org.openide.cookies.OpenCookie;
59
import org.openide.filesystems.FileLock;
60
import org.openide.filesystems.FileObject;
61
import org.openide.filesystems.FileStateInvalidException;
62
import org.openide.filesystems.FileSystem;
63
import org.openide.loaders.DataNode;
64
import org.openide.loaders.DataObject;
65
import org.openide.loaders.DataObjectExistsException;
66
import org.openide.loaders.MultiDataObject;
67
import org.openide.nodes.Children;
68
import org.openide.nodes.CookieSet;
69
import org.openide.nodes.Node;
70
import org.openide.text.DataEditorSupport;
71
import org.openide.util.Exceptions;
72
import org.openide.util.NbPreferences;
73
74
/**
75
 *
76
 * @author Alexander Simon
77
 */
78
public class LineSeparatorDataEditorSupportTest extends NbTestCase {
79
    // for file object support
80
81
    String content = "";
82
    long expectedSize = -1;
83
    java.util.Date date = new java.util.Date();
84
    LineSeparatorDataEditorSupportTest.MyFileObject fileObject;
85
    org.openide.filesystems.FileSystem fs;
86
    static LineSeparatorDataEditorSupportTest RUNNING;
87
    private MimePath textMimePath;
88
89
    static {
90
        //System.setProperty ("org.openide.util.Lookup", "org.openide.text.LineSeparatorDataEditorSupportTest$Lkp");
91
        System.setProperty("org.openide.windows.DummyWindowManager.VISIBLE", "false");
92
    }
93
94
    public LineSeparatorDataEditorSupportTest(String s) {
95
        super(s);
96
    }
97
98
    @Override
99
    protected Level logLevel() {
100
        return Level.FINE;
101
    }
102
103
    @Override
104
    protected void setUp() throws Exception {
105
        RUNNING = this;
106
        MockServices.setServices(new Class[]{MockMimeLookup.class, Pool.class});
107
        textMimePath = MimePath.parse("text/plain");
108
        MockMimeLookup.setInstances(textMimePath, new NbEditorKit(), NbPreferences.forModule(getClass()));
109
110
        fs = org.openide.filesystems.FileUtil.createMemoryFileSystem();
111
        org.openide.filesystems.Repository.getDefault().addFileSystem(fs);
112
        org.openide.filesystems.FileObject root = fs.getRoot();
113
        fileObject = new LineSeparatorDataEditorSupportTest.MyFileObject(org.openide.filesystems.FileUtil.createData(root, "my" + getName() + ".txt"));
114
    }
115
116
    @Override
117
    protected void tearDown() throws Exception {
118
        waitEQ();
119
120
        RUNNING = null;
121
        org.openide.filesystems.Repository.getDefault().removeFileSystem(fs);
122
    }
123
124
    @Override
125
    protected boolean runInEQ() {
126
        return false;
127
    }
128
129
    private void waitEQ() throws Exception {
130
        javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
131
132
            @Override
133
            public void run() {
134
            }
135
        });
136
    }
137
138
    LineSeparatorDataEditorSupportTest.DES support() throws Exception {
139
        assertNotNull(MimeLookup.getLookup(textMimePath).lookup(Preferences.class));
140
        DataObject tmpObj = DataObject.find(fileObject);
141
142
        assertEquals("My object was created", LineSeparatorDataEditorSupportTest.MyDataObject.class, tmpObj.getClass());
143
        Object cookie = tmpObj.getCookie(org.openide.cookies.OpenCookie.class);
144
        assertNotNull("Our object has this cookie", cookie);
145
        assertEquals("It is my cookie", LineSeparatorDataEditorSupportTest.DES.class, cookie.getClass());
146
147
        return (LineSeparatorDataEditorSupportTest.DES) cookie;
148
    }
149
150
    public void testLineSeparator() throws Exception {
151
        LineSeparatorDataEditorSupportTest.DES des = support();
152
        final StyledDocument doc = des.openDocument();
153
        SwingUtilities.invokeAndWait(new Runnable() {
154
155
            @Override
156
            public void run() {
157
                try {
158
                    doc.insertString(doc.getLength(), " Added text.\n", null);
159
                } catch (BadLocationException ex) {
160
                    Exceptions.printStackTrace(ex);
161
                }
162
            }
163
        });
164
        
165
        des.saveDocument();
166
        assertEquals(" Added text.\r", content);
167
    }
168
169
    /**
170
     * File object that let us know what is happening and delegates to certain
171
     * instance variables of the test.
172
     */
173
    private static final class MyFileObject extends org.openide.filesystems.FileObject {
174
175
        private org.openide.filesystems.FileObject delegate;
176
        private int openStreams;
177
        private Throwable previousStream;
178
179
        public MyFileObject(org.openide.filesystems.FileObject del) {
180
            delegate = del;
181
        }
182
183
        @Override
184
        public java.io.OutputStream getOutputStream(FileLock lock) throws IOException {
185
            if (openStreams != 0) {
186
                IOException e = new IOException("There is stream already, cannot write down!");
187
                if (previousStream != null) {
188
                    e.initCause(previousStream);
189
                }
190
                throw e;
191
            }
192
            class ContentStream extends java.io.ByteArrayOutputStream {
193
194
                public ContentStream() {
195
                    openStreams = -1;
196
                }
197
198
                @Override
199
                public void close() throws java.io.IOException {
200
                    if (openStreams != -1) {
201
                        IOException ex = new IOException("One output stream");
202
                        ex.initCause(previousStream);
203
                        throw ex;
204
                    }
205
                    //assertEquals("One output stream", -1, openStreams);
206
                    openStreams = 0;
207
                    previousStream = new Exception("Closed");
208
                    super.close();
209
                    RUNNING.content = new String(toByteArray());
210
                }
211
            }
212
            previousStream = new Exception("Output");
213
            return new ContentStream();
214
        }
215
216
        @Override
217
        public void delete(FileLock lock) throws IOException {
218
            delegate.delete(lock);
219
        }
220
221
        @Override
222
        public void setImportant(boolean b) {
223
            delegate.setImportant(b);
224
        }
225
226
        @Override
227
        public void addFileChangeListener(org.openide.filesystems.FileChangeListener fcl) {
228
            delegate.addFileChangeListener(fcl);
229
        }
230
231
        @Override
232
        public void removeFileChangeListener(org.openide.filesystems.FileChangeListener fcl) {
233
            delegate.removeFileChangeListener(fcl);
234
        }
235
236
        @Override
237
        public Object getAttribute(String attrName) {
238
            if (attrName.equals("default-line-separator")) {
239
                return "\r"; // NOI18N
240
            }
241
            return delegate.getAttribute(attrName);
242
        }
243
244
        @Override
245
        public FileObject createFolder(String name) throws IOException {
246
            throw new IOException("Not supported");
247
        }
248
249
        @Override
250
        public void rename(FileLock lock, String name, String ext) throws IOException {
251
            throw new IOException("Not supported");
252
        }
253
254
        @Override
255
        public void setAttribute(String attrName, Object value) throws IOException {
256
            delegate.setAttribute(attrName, value);
257
        }
258
259
        @Override
260
        public String getName() {
261
            return delegate.getName();
262
        }
263
264
        @Override
265
        public java.io.InputStream getInputStream() throws java.io.FileNotFoundException {
266
            if (openStreams < 0) {
267
                FileNotFoundException e = new FileNotFoundException("Already exists output stream");
268
                if (previousStream != null) {
269
                    e.initCause(previousStream);
270
                }
271
                throw e;
272
            }
273
274
            class IS extends ByteArrayInputStream {
275
276
                public IS(byte[] arr) {
277
                    super(arr);
278
                    openStreams++;
279
                }
280
281
                @Override
282
                public void close() throws IOException {
283
                    openStreams--;
284
                    super.close();
285
                }
286
            }
287
            previousStream = new Exception("Input");
288
289
            return new IS(RUNNING.content.getBytes());
290
        }
291
292
        @Override
293
        public FileSystem getFileSystem() throws FileStateInvalidException {
294
            return delegate.getFileSystem();
295
        }
296
297
        @Override
298
        public FileObject getFileObject(String name, String ext) {
299
            return null;
300
        }
301
302
        @Override
303
        public String getExt() {
304
            return delegate.getExt();
305
        }
306
307
        @Override
308
        public FileObject[] getChildren() {
309
            return null;
310
        }
311
312
        @Override
313
        public java.util.Enumeration getAttributes() {
314
            return delegate.getAttributes();
315
        }
316
317
        @Override
318
        public FileObject createData(String name, String ext) throws IOException {
319
            throw new IOException("Not supported");
320
        }
321
322
        @Override
323
        public FileObject getParent() {
324
            return delegate.getParent();
325
        }
326
327
        @Override
328
        public long getSize() {
329
            return RUNNING.expectedSize;
330
        }
331
332
        @Override
333
        public boolean isData() {
334
            return true;
335
        }
336
337
        @Override
338
        public boolean isFolder() {
339
            return false;
340
        }
341
342
        @Override
343
        public boolean isReadOnly() {
344
            return false;
345
        }
346
347
        @Override
348
        public boolean isRoot() {
349
            return false;
350
        }
351
352
        @Override
353
        public boolean isValid() {
354
            return delegate.isValid();
355
        }
356
357
        @Override
358
        public java.util.Date lastModified() {
359
            return RUNNING.date;
360
        }
361
362
        @Override
363
        public FileLock lock() throws IOException {
364
            return delegate.lock();
365
        }
366
367
        public Object writeReplace() {
368
            return new LineSeparatorDataEditorSupportTest.Replace();
369
        }
370
    }
371
372
    private static final class Replace extends Object implements java.io.Serializable {
373
374
        static final long serialVersionUID = 2L;
375
376
        public Object readResolve() {
377
            return RUNNING.fileObject;
378
        }
379
    }
380
381
    /**
382
     * Implementation of the DES
383
     */
384
    private static final class DES extends DataEditorSupport
385
            implements OpenCookie, EditCookie {
386
387
        public DES(DataObject obj, DataEditorSupport.Env env) {
388
            super(obj, env);
389
        }
390
391
        public org.openide.windows.CloneableTopComponent.Ref getRef() {
392
            return allEditors;
393
        }
394
    }
395
396
    /**
397
     * MyEnv that uses DataEditorSupport.Env
398
     */
399
    private static final class MyEnv extends DataEditorSupport.Env {
400
401
        static final long serialVersionUID = 1L;
402
403
        public MyEnv(DataObject obj) {
404
            super(obj);
405
        }
406
407
        @Override
408
        protected FileObject getFile() {
409
            return super.getDataObject().getPrimaryFile();
410
        }
411
412
        @Override
413
        public String getMimeType() {
414
            return "text/plain";
415
        }
416
417
        @Override
418
        protected FileLock takeLock() throws IOException {
419
            return super.getDataObject().getPrimaryFile().lock();
420
        }
421
    }
422
423
    public static final class Pool extends org.openide.loaders.DataLoaderPool {
424
425
        @Override
426
        protected java.util.Enumeration loaders() {
427
            return org.openide.util.Enumerations.singleton(LineSeparatorDataEditorSupportTest.MyLoader.get());
428
        }
429
    }
430
431
    public static final class MyLoader extends org.openide.loaders.UniFileLoader {
432
433
        public int primary;
434
435
        public static LineSeparatorDataEditorSupportTest.MyLoader get() {
436
            return LineSeparatorDataEditorSupportTest.MyLoader.findObject(LineSeparatorDataEditorSupportTest.MyLoader.class, true);
437
        }
438
439
        public MyLoader() {
440
            super(LineSeparatorDataEditorSupportTest.MyDataObject.class.getName());
441
            getExtensions().addExtension("txt");
442
        }
443
444
        protected String displayName() {
445
            return "MyPart";
446
        }
447
448
        @Override
449
        protected MultiDataObject createMultiObject(FileObject primaryFile) throws DataObjectExistsException, IOException {
450
            return new LineSeparatorDataEditorSupportTest.MyDataObject(this, primaryFile);
451
        }
452
453
        @Override
454
        protected MultiDataObject.Entry createPrimaryEntry(MultiDataObject obj, FileObject primaryFile) {
455
            primary++;
456
            return new org.openide.loaders.FileEntry(obj, primaryFile);
457
        }
458
    }
459
460
    public static final class MyDataObject extends MultiDataObject
461
            implements CookieSet.Factory {
462
463
        public MyDataObject(LineSeparatorDataEditorSupportTest.MyLoader l, FileObject folder) throws DataObjectExistsException {
464
            super(folder, l);
465
            getCookieSet().add(OpenCookie.class, this);
466
        }
467
468
        @Override
469
        public org.openide.nodes.Node.Cookie createCookie(Class klass) {
470
            return new LineSeparatorDataEditorSupportTest.DES(this, new LineSeparatorDataEditorSupportTest.MyEnv(this));
471
        }
472
473
        @Override
474
        protected Node createNodeDelegate() {
475
            return new LineSeparatorDataEditorSupportTest.MyNode(this, Children.LEAF);
476
        }
477
    }
478
479
    /*
480
     * Node which always returns non-null getHtmlDisplayName
481
     */
482
    public static final class MyNode extends DataNode {
483
484
        public MyNode(DataObject obj, Children ch) {
485
            super(obj, ch);
486
        }
487
488
        @Override
489
        public String getHtmlDisplayName() {
490
            return "<b>" + getDisplayName() + "</b>";
491
        }
492
    }
493
}
(-)a/openide.filesystems/apichanges.xml (+18 lines)
 Lines 49-54    Link Here 
49
        <apidef name="filesystems">Filesystems API</apidef>
49
        <apidef name="filesystems">Filesystems API</apidef>
50
    </apidefs>
50
    </apidefs>
51
    <changes>
51
    <changes>
52
         <change id="default-line-separator">
53
            <api name="filesystems"/>
54
            <summary>Provides default line separator</summary>
55
            <version major="7" minor="56"/>
56
            <date day="13" month="1" year="2012"/>
57
            <author login="alexvsimon"/>
58
            <compatibility addition="yes" binary="compatible" source="compatible" semantic="compatible" deprecation="no" deletion="no" modification="no"/>
59
            <description>
60
                <p>
61
                    File object can provide default line separator if it differs from <code>System.getProperty("line.separator")</code>.
62
                    Call <code>fo.getAttribute("default-line-separator")</code> return string with default line separator.
63
                    Default line separator will be used by the text editor if saving new content to an initially empty file.
64
                    Any other code which creates file content programmatically must manually read this property if it cares.
65
                </p>
66
            </description>
67
            <class package="org.openide.filesystems" name="FileObject"/>
68
            <issue number="199534"/>
69
        </change>
52
        <change id="FileObject.revert">
70
        <change id="FileObject.revert">
53
            <api name="filesystems"/>
71
            <api name="filesystems"/>
54
            <summary>Introduced <code>FileObject.revert</code></summary>
72
            <summary>Introduced <code>FileObject.revert</code></summary>
(-)a/openide.filesystems/manifest.mf (-1 / +1 lines)
 Lines 2-6    Link Here 
2
OpenIDE-Module: org.openide.filesystems
2
OpenIDE-Module: org.openide.filesystems
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
4
OpenIDE-Module-Layer: org/openide/filesystems/resources/layer.xml
5
OpenIDE-Module-Specification-Version: 7.55
5
OpenIDE-Module-Specification-Version: 7.56
6
6
(-)a/openide.loaders/manifest.mf (-1 / +1 lines)
 Lines 1-6    Link Here 
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.loaders
2
OpenIDE-Module: org.openide.loaders
3
OpenIDE-Module-Specification-Version: 7.34
3
OpenIDE-Module-Specification-Version: 7.35
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/openide/loaders/Bundle.properties
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
5
OpenIDE-Module-Provides: org.netbeans.modules.templates.v1_0
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
6
OpenIDE-Module-Layer: org/netbeans/modules/openide/loaders/layer.xml
(-)a/openide.loaders/nbproject/project.xml (-1 / +1 lines)
 Lines 122-128    Link Here 
122
                    <build-prerequisite/>
122
                    <build-prerequisite/>
123
                    <compile-dependency/>
123
                    <compile-dependency/>
124
                    <run-dependency>
124
                    <run-dependency>
125
                        <specification-version>7.55</specification-version>
125
                        <specification-version>7.56</specification-version>
126
                    </run-dependency>
126
                    </run-dependency>
127
                </dependency>
127
                </dependency>
128
                <dependency>
128
                <dependency>
(-)a/openide.loaders/src/org/openide/text/DataEditorSupport.java (+8 lines)
 Lines 125-130    Link Here 
125
    /** error manager for CloneableEditorSupport logging and error reporting */
125
    /** error manager for CloneableEditorSupport logging and error reporting */
126
    static final Logger ERR = Logger.getLogger("org.openide.text.DataEditorSupport"); // NOI18N
126
    static final Logger ERR = Logger.getLogger("org.openide.text.DataEditorSupport"); // NOI18N
127
127
128
    /** Default line separator property for writing content into files.
129
     * It will be used by the text editor if saving new content to an initially empty file.
130
     * Any other code which creates file content programmatically must manually read this property if it cares.
131
     * If it not set the platform default line separator is used.
132
     */
133
    private static final String DEFAULT_LINE_SEPARATOR_PROP = "default-line-separator"; // NOI18N
134
128
    /** Which data object we are associated with */
135
    /** Which data object we are associated with */
129
    private final DataObject obj;
136
    private final DataObject obj;
130
    /** listener to associated node's events */
137
    /** listener to associated node's events */
 Lines 480-485    Link Here 
480
            c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
487
            c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
481
        }
488
        }
482
        final FileObject fo = this.getDataObject().getPrimaryFile();
489
        final FileObject fo = this.getDataObject().getPrimaryFile();
490
        doc.putProperty(DEFAULT_LINE_SEPARATOR_PROP, fo.getAttribute(DEFAULT_LINE_SEPARATOR_PROP));
483
        final Reader r;
491
        final Reader r;
484
        if (warnedEncodingFiles.contains(fo)) {
492
        if (warnedEncodingFiles.contains(fo)) {
485
            r = new InputStreamReader (stream, c);
493
            r = new InputStreamReader (stream, c);

Return to bug 199534
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo