This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 199534
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 561-566 Link Here
561
    
561
    
562
    @Override
562
    @Override
563
    public Object getAttribute(String attrName) {
563
    public Object getAttribute(String attrName) {
564
        if (attrName.equals("default-line-separator")) { // NOI18N
565
            return "\n"; // NOI18N
566
        }
564
        if (attrName.equals("isRemoteAndSlow")) { // NOI18N
567
        if (attrName.equals("isRemoteAndSlow")) { // NOI18N
565
            return Boolean.TRUE;
568
            return Boolean.TRUE;
566
        }
569
        }
(-)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.0
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 (+105 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.File;
45
import java.io.InputStream;
46
import javax.swing.SwingUtilities;
47
import javax.swing.text.BadLocationException;
48
import javax.swing.text.StyledDocument;
49
import org.netbeans.api.editor.mimelookup.MimePath;
50
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
51
import org.netbeans.junit.MockServices;
52
import org.netbeans.junit.NbTestCase;
53
import org.openide.cookies.EditorCookie;
54
import org.openide.filesystems.*;
55
import org.openide.loaders.DataObject;
56
import org.openide.util.Exceptions;
57
import org.openide.util.NbPreferences;
58
59
/**
60
 *
61
 * @author Alexander Simon
62
 */
63
public class LineSeparatorDataEditorSupportTest extends NbTestCase {
64
    private MimePath textMimePath;
65
66
    static {
67
        System.setProperty("org.openide.windows.DummyWindowManager.VISIBLE", "false");
68
    }
69
70
    public LineSeparatorDataEditorSupportTest(String s) {
71
        super(s);
72
    }
73
74
    @Override
75
    protected void setUp() throws Exception {
76
        MockServices.setServices(new Class[]{MockMimeLookup.class});
77
        textMimePath = MimePath.parse("text/plain");
78
        MockMimeLookup.setInstances(textMimePath, new NbEditorKit(), NbPreferences.forModule(getClass()));
79
    }
80
    
81
    public void testLineSeparator() throws Exception {
82
        File file = File.createTempFile("lineSeparator", ".txt", getWorkDir());
83
        FileObject fileObject = FileUtil.toFileObject(file);
84
        fileObject.setAttribute("default-line-separator", "\r");
85
        DataObject dataObject = DataObject.find(fileObject);
86
        EditorCookie editor = dataObject.getLookup().lookup(org.openide.cookies.EditorCookie.class);
87
        final StyledDocument doc = editor.openDocument();
88
        SwingUtilities.invokeAndWait(new Runnable() {
89
90
            @Override
91
            public void run() {
92
                try {
93
                    doc.insertString(doc.getLength(), ".\n", null);
94
                } catch (BadLocationException ex) {
95
                    Exceptions.printStackTrace(ex);
96
                }
97
            }
98
        });
99
        
100
        editor.saveDocument();
101
        InputStream inputStream = fileObject.getInputStream();
102
        assertEquals('.',inputStream.read());
103
        assertEquals('\r',inputStream.read());
104
    }
105
}
(-)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