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 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(FileObject.DEFAULT_LINE_SEPARATOR_ATTR)) {
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/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 / +9 lines)
 Lines 113-118    Link Here 
113
import org.netbeans.modules.editor.lib2.document.ReadWriteUtils;
113
import org.netbeans.modules.editor.lib2.document.ReadWriteUtils;
114
import org.netbeans.spi.lexer.MutableTextInput;
114
import org.netbeans.spi.lexer.MutableTextInput;
115
import org.netbeans.spi.lexer.TokenHierarchyControl;
115
import org.netbeans.spi.lexer.TokenHierarchyControl;
116
import org.openide.filesystems.FileObject;
116
import org.openide.util.RequestProcessor;
117
import org.openide.util.RequestProcessor;
117
import org.openide.util.RequestProcessor.Task;
118
import org.openide.util.RequestProcessor.Task;
118
import org.openide.util.WeakListeners;
119
import org.openide.util.WeakListeners;
 Lines 1386-1392    Link Here 
1386
            if (!inited) { // Fill line-separator properties
1387
            if (!inited) { // Fill line-separator properties
1387
                String lineSeparator = ReadWriteUtils.findFirstLineSeparator(buffer);
1388
                String lineSeparator = ReadWriteUtils.findFirstLineSeparator(buffer);
1388
                if (lineSeparator == null) {
1389
                if (lineSeparator == null) {
1389
                    lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1390
                    lineSeparator = (String) getProperty(FileObject.DEFAULT_LINE_SEPARATOR_ATTR);
1391
                    if (lineSeparator == null) {
1392
                        lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1393
                    }
1390
                }
1394
                }
1391
                putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, lineSeparator);
1395
                putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, lineSeparator);
1392
            }
1396
            }
 Lines 1430-1436    Link Here 
1430
            if (lineSeparator == null) {
1434
            if (lineSeparator == null) {
1431
                lineSeparator = (String) getProperty(BaseDocument.READ_LINE_SEPARATOR_PROP);
1435
                lineSeparator = (String) getProperty(BaseDocument.READ_LINE_SEPARATOR_PROP);
1432
                if (lineSeparator == null) {
1436
                if (lineSeparator == null) {
1433
                    lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1437
                    lineSeparator = (String) getProperty(FileObject.DEFAULT_LINE_SEPARATOR_ATTR);
1438
                    if (lineSeparator == null) {
1439
                        lineSeparator = ReadWriteUtils.getSystemLineSeparator();
1440
                    }
1434
                }
1441
                }
1435
            }
1442
            }
1436
            CharSequence docText = (CharSequence) getProperty(CharSequence.class);
1443
            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 / +11 lines)
 Lines 81-86    Link Here 
81
import org.netbeans.modules.editor.lib2.document.ReadWriteUtils;
81
import org.netbeans.modules.editor.lib2.document.ReadWriteUtils;
82
import org.netbeans.modules.editor.options.AnnotationTypesFolder;
82
import org.netbeans.modules.editor.options.AnnotationTypesFolder;
83
import org.openide.cookies.EditorCookie;
83
import org.openide.cookies.EditorCookie;
84
import org.openide.filesystems.FileObject;
84
import org.openide.loaders.DataLoaderPool;
85
import org.openide.loaders.DataLoaderPool;
85
import org.openide.loaders.DataObject;
86
import org.openide.loaders.DataObject;
86
import org.openide.loaders.OperationEvent;
87
import org.openide.loaders.OperationEvent;
 Lines 637-642    Link Here 
637
            
638
            
638
            final StyledDocument doc = ec.openDocument();
639
            final StyledDocument doc = ec.openDocument();
639
            final Reformat reformat = Reformat.get(doc);
640
            final Reformat reformat = Reformat.get(doc);
641
            String defaultLineSeparator = (String) file.getPrimaryFile().getAttribute(FileObject.DEFAULT_LINE_SEPARATOR_ATTR);
642
            if (defaultLineSeparator != null) {
643
                doc.putProperty(FileObject.DEFAULT_LINE_SEPARATOR_ATTR, defaultLineSeparator);
644
            }
640
            
645
            
641
            reformat.lock();
646
            reformat.lock();
642
            
647
            
 Lines 658-664    Link Here 
658
                
663
                
659
            } finally {
664
            } finally {
660
                reformat.unlock();
665
                reformat.unlock();
661
                doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, ReadWriteUtils.getSystemLineSeparator());
666
                defaultLineSeparator = (String) doc.getProperty(FileObject.DEFAULT_LINE_SEPARATOR_ATTR);
667
                if (defaultLineSeparator != null) {
668
                    doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, defaultLineSeparator);
669
                } else {
670
                    doc.putProperty(BaseDocument.READ_LINE_SEPARATOR_PROP, ReadWriteUtils.getSystemLineSeparator());
671
                }
662
                ec.saveDocument();
672
                ec.saveDocument();
663
            }
673
            }
664
            
674
            
(-)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(FileObject.DEFAULT_LINE_SEPARATOR_ATTR, "\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 (+22 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
                    FileObject.DEFAULT_LINE_SEPARATOR_ATTR defines file object attribute name to get default line separator.
62
                    File object can provide default line separator if it differs from
63
                    <code>System.getProperty("line.separator")</code>. Call
64
                    <code>fo.getAttribute(FileObject.DEFAULT_LINE_SEPARATOR_ATTR)</code> returns string with
65
                    default line separator. Default line separator will be used by the text
66
                    editor if saving new content to an initially empty file. Any other code
67
                    which creates file content programmatically must manually read this
68
                    property if it cares.
69
                </p>
70
            </description>
71
            <class package="org.openide.filesystems" name="FileObject"/>
72
            <issue number="199534"/>
73
        </change>
52
        <change id="FileObject.revert">
74
        <change id="FileObject.revert">
53
            <api name="filesystems"/>
75
            <api name="filesystems"/>
54
            <summary>Introduced <code>FileObject.revert</code></summary>
76
            <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.filesystems/src/org/openide/filesystems/FileObject.java (+13 lines)
 Lines 72-77    Link Here 
72
* @author Jaroslav Tulach, Petr Hamernik, Ian Formanek
72
* @author Jaroslav Tulach, Petr Hamernik, Ian Formanek
73
*/
73
*/
74
public abstract class FileObject extends Object implements Serializable {
74
public abstract class FileObject extends Object implements Serializable {
75
    /**
76
     * Name of default line separator attribute.
77
     * File object can provide default line separator if it differs from
78
     * <code>System.getProperty("line.separator")</code>. Call
79
     * <code>fo.getAttribute(DEFAULT_LINE_SEPARATOR_PROP)</code> returns string with
80
     * default line separator. Default line separator will be used by the text
81
     * editor if saving new content to an initially empty file. Any other code
82
     * which creates file content programmatically must manually read this
83
     * property if it cares.
84
     * @since 7.56
85
     */
86
    public static final String DEFAULT_LINE_SEPARATOR_ATTR = "default-line-separator"; //NOI18N
87
75
    /** generated Serialized Version UID */
88
    /** generated Serialized Version UID */
76
    static final long serialVersionUID = 85305031923497718L;
89
    static final long serialVersionUID = 85305031923497718L;
77
90
(-)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 (+1 lines)
 Lines 480-485    Link Here 
480
            c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
480
            c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
481
        }
481
        }
482
        final FileObject fo = this.getDataObject().getPrimaryFile();
482
        final FileObject fo = this.getDataObject().getPrimaryFile();
483
        doc.putProperty(FileObject.DEFAULT_LINE_SEPARATOR_ATTR, fo.getAttribute(FileObject.DEFAULT_LINE_SEPARATOR_ATTR));
483
        final Reader r;
484
        final Reader r;
484
        if (warnedEncodingFiles.contains(fo)) {
485
        if (warnedEncodingFiles.contains(fo)) {
485
            r = new InputStreamReader (stream, c);
486
            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