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 42638
Collapse All | Expand All

(-)ant/project/src/org/netbeans/spi/project/support/ant/AntProjectHelper.java (+25 lines)
Lines 44-49 Link Here
44
import org.netbeans.spi.project.CacheDirectoryProvider;
44
import org.netbeans.spi.project.CacheDirectoryProvider;
45
import org.netbeans.spi.project.ProjectState;
45
import org.netbeans.spi.project.ProjectState;
46
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
46
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
47
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
47
import org.netbeans.spi.queries.SharabilityQueryImplementation;
48
import org.netbeans.spi.queries.SharabilityQueryImplementation;
48
import org.openide.ErrorManager;
49
import org.openide.ErrorManager;
49
import org.openide.filesystems.FileLock;
50
import org.openide.filesystems.FileLock;
Lines 990-993 Link Here
990
        return PropertyUtils.resolvePath(FileUtil.toFile(dir), path);
991
        return PropertyUtils.resolvePath(FileUtil.toFile(dir), path);
991
    }
992
    }
992
993
994
    /**
995
     * Creates simple implementation of 
996
     * {@link org.netbeans.spi.queries.FileEncodingQueryImplementation} returning
997
     * file encoding of project's files. It can be put only into project's
998
     * lookup, because it assumes that file passed to the query belongs to the
999
     * project.
1000
     * <p>The implementation uses given PropertyEvaluator and does following
1001
     * in this order:
1002
     * <ol>
1003
     *  <li>checks for property <code>encoding.&lt;file_extension></code> and
1004
     *    returns that value if presented</li>
1005
     *  <li>checks for property <code>encoding</code> and
1006
     *    returns that value if presented</li>
1007
     *  <li>returns value of system property file.encoding</li>
1008
     * </ol>
1009
     * This allows to set global encoding for all project files and also per
1010
     * file type specific encoding. 
1011
     * @param evaluator property evaluator of project's properties
1012
     * @return implementation of query which can be added to project's lookup
1013
     */
1014
    public FileEncodingQueryImplementation createSimpleFileEncodingQuery(PropertyEvaluator evaluator) {
1015
        return new SimpleFileEncodingQueryImpl(evaluator);
1016
    }
1017
    
993
}
1018
}
(-)ant/project/src/org/netbeans/spi/project/support/ant/SimpleFileEncodingQueryImpl.java (+51 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
package org.netbeans.spi.project.support.ant;
14
15
import java.beans.PropertyChangeListener;
16
import java.net.URI;
17
import java.util.Iterator;
18
import java.util.LinkedList;
19
import java.util.List;
20
import org.netbeans.api.project.FileOwnerQuery;
21
import org.netbeans.api.project.Project;
22
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
23
import org.openide.filesystems.FileObject;
24
25
/**
26
 * Simple file encoding query based on Ant properties. See 
27
 * {@link AntProjectHelper#createSimpleFileEncodingQuery} for more details. 
28
 * @author David Konecny
29
 */
30
final class SimpleFileEncodingQueryImpl implements FileEncodingQueryImplementation {
31
    
32
    private static final String ENCODING_PREFIX = "encoding";
33
    
34
    private PropertyEvaluator evaluator;
35
    
36
    public SimpleFileEncodingQueryImpl(PropertyEvaluator evaluator) {
37
        this.evaluator = evaluator;
38
    }
39
    
40
    public String getFileEncoding(FileObject file) {
41
        String res = evaluator.getProperty(ENCODING_PREFIX+"."+file.getExt());
42
        if (res == null) {
43
            res = evaluator.getProperty(ENCODING_PREFIX);
44
        }
45
        if (res == null) {
46
            res = System.getProperty("file.encoding");
47
        }
48
        return res;
49
    }
50
    
51
}
(-)ant/project/test/unit/src/org/netbeans/spi/project/support/ant/AntBasedTestUtil.java (+1 lines)
Lines 126-131 Link Here
126
                genFilesHelper,
126
                genFilesHelper,
127
                aux,
127
                aux,
128
                helper.createCacheDirectoryProvider(),
128
                helper.createCacheDirectoryProvider(),
129
                helper.createSimpleFileEncodingQuery(helper.getStandardPropertyEvaluator()),
129
                refHelper.createSubprojectProvider(),
130
                refHelper.createSubprojectProvider(),
130
                new TestAntArtifactProvider(),
131
                new TestAntArtifactProvider(),
131
                new ProjectXmlSavedHook() {
132
                new ProjectXmlSavedHook() {
(-)ant/project/test/unit/src/org/netbeans/spi/project/support/ant/SimpleFileEncodingQueryImplTest.java (+143 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.spi.project.support.ant;
15
16
import java.io.File;
17
import java.net.URI;
18
import org.netbeans.api.project.ProjectManager;
19
import org.netbeans.api.project.TestUtil;
20
import org.netbeans.api.project.ant.AntArtifact;
21
import org.netbeans.api.queries.FileEncodingQuery;
22
import org.netbeans.junit.NbTestCase;
23
import org.netbeans.modules.project.ant.AntBasedProjectFactorySingleton;
24
import org.netbeans.modules.project.ant.FileEncodingQueryImpl;
25
import org.netbeans.modules.projectapi.SimpleFileOwnerQueryImplementation;
26
import org.openide.filesystems.FileObject;
27
import org.openide.filesystems.FileUtil;
28
import org.openide.filesystems.Repository;
29
import org.openide.util.Lookup;
30
import org.openide.util.lookup.Lookups;
31
32
/**
33
 * Tests for SimpleFileEncodingQueryImpl
34
 *
35
 * @author David Konecny
36
 */
37
public class SimpleFileEncodingQueryImplTest extends NbTestCase {
38
    
39
    public SimpleFileEncodingQueryImplTest(java.lang.String testName) {
40
        super(testName);
41
    }
42
    
43
    private FileObject scratch;
44
    private FileObject projdir;
45
    private AntProjectHelper helper;
46
    
47
    protected void setUp() throws Exception {
48
        super.setUp();
49
        scratch = TestUtil.makeScratchDir(this);
50
        Repository.getDefault().addFileSystem(scratch.getFileSystem()); // so FileUtil.fromFile works
51
        TestUtil.setLookup(Lookups.fixed(new Object[] {
52
            new AntBasedProjectFactorySingleton(),
53
            AntBasedTestUtil.testAntBasedProjectType(),
54
            new FileEncodingQueryImpl(),
55
            new SimpleFileOwnerQueryImplementation(),
56
        }));
57
        projdir = FileUtil.createFolder(scratch, "proj");
58
        helper = ProjectGenerator.createProject(projdir, "test", "proj");
59
    }
60
61
    protected void tearDown() throws Exception {
62
        Repository.getDefault().removeFileSystem(scratch.getFileSystem());
63
        scratch = null;
64
        projdir = null;
65
        TestUtil.setLookup(Lookup.EMPTY);
66
        super.tearDown();
67
    }
68
    
69
    public void testGetFileEncoding() throws Exception {
70
        FileObject foreign = scratch.createData("some.file");
71
        String enc = FileEncodingQuery.getFileEncoding(foreign);
72
        assertEquals("Non-project file must have no encoding", null, enc);
73
        FileObject foreign2 = scratch.createFolder("sub").createData("some.java");
74
        enc = FileEncodingQuery.getFileEncoding(foreign2);
75
        assertEquals("Non-project file must have no encoding", null, enc);
76
        
77
        String OSEncoding = System.getProperty("file.encoding");
78
        FileObject projFile = projdir.createData("some.file");
79
        enc = FileEncodingQuery.getFileEncoding(projFile);
80
        assertEquals("Project file must have system encoding", OSEncoding, enc);
81
        FileObject projFile2 = projdir.createFolder("sub").createData("some.java");
82
        enc = FileEncodingQuery.getFileEncoding(projFile2);
83
        assertEquals("Project file must have system encoding", OSEncoding, enc);
84
        
85
        // configure encoding for .java files:
86
        EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
87
        ep.setProperty("encoding.java", "SOME.ENCODING.1");
88
        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
89
        enc = FileEncodingQuery.getFileEncoding(projFile2);
90
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
91
        enc = FileEncodingQuery.getFileEncoding(projFile);
92
        assertEquals("Project file must have system encoding", OSEncoding, enc);
93
94
        // configure encoding for .file files:
95
        ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
96
        ep.setProperty("encoding.file", "some.THING.else");
97
        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
98
        enc = FileEncodingQuery.getFileEncoding(projFile2);
99
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
100
        enc = FileEncodingQuery.getFileEncoding(projFile);
101
        assertEquals("Project file must have correct encoding", "some.THING.else", enc);
102
103
        // non-project files must still have not encoding
104
        enc = FileEncodingQuery.getFileEncoding(foreign);
105
        assertEquals("Non-project file must have no encoding", null, enc);
106
        enc = FileEncodingQuery.getFileEncoding(foreign2);
107
        assertEquals("Non-project file must have no encoding", null, enc);
108
109
        // test newly created java file must
110
        FileObject projFile3 = projdir.getFileObject("sub").createFolder("2").createData("foo.java");
111
        enc = FileEncodingQuery.getFileEncoding(projFile3);
112
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
113
114
        // remove some encodings
115
        ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
116
        ep.remove("encoding.file");
117
        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
118
        enc = FileEncodingQuery.getFileEncoding(projFile);
119
        assertEquals("Project file must have system encoding", OSEncoding, enc);
120
        enc = FileEncodingQuery.getFileEncoding(projFile2);
121
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
122
        enc = FileEncodingQuery.getFileEncoding(projFile3);
123
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
124
125
        // set default encoding for all files
126
        ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
127
        ep.setProperty("encoding", "UTF-8");
128
        helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
129
        enc = FileEncodingQuery.getFileEncoding(projFile);
130
        assertEquals("Project file must have system encoding", "UTF-8", enc);
131
        enc = FileEncodingQuery.getFileEncoding(projFile2);
132
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
133
        enc = FileEncodingQuery.getFileEncoding(projFile3);
134
        assertEquals("Project file must have correct encoding", "SOME.ENCODING.1", enc);
135
136
        // non-project files must still have not encoding
137
        enc = FileEncodingQuery.getFileEncoding(foreign);
138
        assertEquals("Non-project file must have no encoding", null, enc);
139
        enc = FileEncodingQuery.getFileEncoding(foreign2);
140
        assertEquals("Non-project file must have no encoding", null, enc);
141
    }
142
    
143
}
(-)apisupport/project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java (+2 lines)
Lines 119-124 Link Here
119
            new UnitTestForSourceQueryImpl(this),
119
            new UnitTestForSourceQueryImpl(this),
120
            new LogicalView(this),
120
            new LogicalView(this),
121
            new SubprojectProviderImpl(this),
121
            new SubprojectProviderImpl(this),
122
            helper.createSimpleFileEncodingQuery(evaluator()),
122
            fileBuilt,
123
            fileBuilt,
123
            new AccessibilityQueryImpl(this),
124
            new AccessibilityQueryImpl(this),
124
            new SourceLevelQueryImpl(this, evaluator()),
125
            new SourceLevelQueryImpl(this, evaluator()),
Lines 203-208 Link Here
203
        defaults.put("test.qa-functional.src.dir", "test/qa-functional/src"); // NOI18N
204
        defaults.put("test.qa-functional.src.dir", "test/qa-functional/src"); // NOI18N
204
        defaults.put("build.test.unit.classes.dir", "build/test/unit/classes"); // NOI18N
205
        defaults.put("build.test.unit.classes.dir", "build/test/unit/classes"); // NOI18N
205
        defaults.put("module.classpath", computeModuleClasspath());
206
        defaults.put("module.classpath", computeModuleClasspath());
207
        defaults.put("encoding", "UTF-8"); // XXX: Jesse must confirm this line
206
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
208
        // skip a bunch of properties irrelevant here - NBM stuff, etc.
207
        return PropertyUtils.sequentialPropertyEvaluator(predefs, new PropertyProvider[] {
209
        return PropertyUtils.sequentialPropertyEvaluator(predefs, new PropertyProvider[] {
208
            PropertyUtils.fixedPropertyProvider(stock),
210
            PropertyUtils.fixedPropertyProvider(stock),
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEProject.java (+1 lines)
Lines 148-153 Link Here
148
            new ProjectXmlSavedHookImpl(),
148
            new ProjectXmlSavedHookImpl(),
149
            new ProjectOpenedHookImpl(),
149
            new ProjectOpenedHookImpl(),
150
            new UnitTestForSourceQueryImpl(helper, evaluator()),
150
            new UnitTestForSourceQueryImpl(helper, evaluator()),
151
            helper.createSimpleFileEncodingQuery(evaluator()),
151
            new SourceLevelQueryImpl(helper, evaluator()),
152
            new SourceLevelQueryImpl(helper, evaluator()),
152
            sourcesHelper.createSources(),
153
            sourcesHelper.createSources(),
153
            helper.createSharabilityQuery(evaluator(), new String[] {
154
            helper.createSharabilityQuery(evaluator(), new String[] {
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties (-1 / +2 lines)
Lines 27-32 Link Here
27
LBL_CustomizeGeneral_DisplayName_JLabel=Project Name:
27
LBL_CustomizeGeneral_DisplayName_JLabel=Project Name:
28
LBL_CustomizeGeneral_Platform_JLabel=Java Platform:
28
LBL_CustomizeGeneral_Platform_JLabel=Java Platform:
29
LBL_CustomizeGeneral_Platform_JButton=Edit...
29
LBL_CustomizeGeneral_Platform_JButton=Edit...
30
LBL_CustomizeGeneral_Encoding_JLabel=Files Encoding:
30
LBL_CustomizeGeneral_RequiredProjects_JLabel=Required Projects:
31
LBL_CustomizeGeneral_RequiredProjects_JLabel=Required Projects:
31
LBL_CustomizeGeneral_RequiredProjects_JCheckBox=Rebuild Required Projects
32
LBL_CustomizeGeneral_RequiredProjects_JCheckBox=Rebuild Required Projects
32
33
Lines 124-127 Link Here
124
#MainClassWarning
125
#MainClassWarning
125
CTL_MainClassWarning_Title=Warning - Running {0} Project
126
CTL_MainClassWarning_Title=Warning - Running {0} Project
126
LBL_MainClassNotFound={0} project doesn't have a main class set.
127
LBL_MainClassNotFound={0} project doesn't have a main class set.
127
LBL_MainClassWarning_ChooseMainClass_OK=OK
128
LBL_MainClassWarning_ChooseMainClass_OK=OK
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerGeneral.form (+25 lines)
Lines 8-13 Link Here
8
      </Border>
8
      </Border>
9
    </Property>
9
    </Property>
10
  </Properties>
10
  </Properties>
11
  <AuxValues>
12
    <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
13
  </AuxValues>
11
14
12
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
15
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
13
  <SubComponents>
16
  <SubComponents>
Lines 61-66 Link Here
61
      <Constraints>
64
      <Constraints>
62
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
65
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
63
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="12" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
66
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="12" insetsRight="12" anchor="17" weightX="0.0" weightY="0.0"/>
67
        </Constraint>
68
      </Constraints>
69
    </Component>
70
    <Component class="javax.swing.JLabel" name="jLabelEncoding">
71
      <Properties>
72
        <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
73
          <ComponentRef name="jTextFieldEncoding"/>
74
        </Property>
75
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
76
          <ResourceString bundle="org/netbeans/modules/java/j2seproject/ui/customizer/Bundle.properties" key="LBL_CustomizeGeneral_Encoding_JLabel" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
77
        </Property>
78
      </Properties>
79
      <Constraints>
80
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
81
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="12" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
82
        </Constraint>
83
      </Constraints>
84
    </Component>
85
    <Component class="javax.swing.JTextField" name="jTextFieldEncoding">
86
      <Constraints>
87
        <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
88
          <GridBagConstraints gridX="-1" gridY="-1" gridWidth="0" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="12" insetsRight="12" anchor="18" weightX="0.0" weightY="0.0"/>
64
        </Constraint>
89
        </Constraint>
65
      </Constraints>
90
      </Constraints>
66
    </Component>
91
    </Component>
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerGeneral.java (-8 / +27 lines)
Lines 65-70 Link Here
65
    public void initValues() {
65
    public void initValues() {
66
        
66
        
67
        vps.register( jTextFieldDisplayName, J2SEProjectProperties.J2SE_PROJECT_NAME );
67
        vps.register( jTextFieldDisplayName, J2SEProjectProperties.J2SE_PROJECT_NAME );
68
        vps.register( jTextFieldEncoding, J2SEProjectProperties.FILES_ENCODING );
68
        vps.register( jCheckBoxReqPrj, J2SEProjectProperties.NO_DEPENDENCIES );
69
        vps.register( jCheckBoxReqPrj, J2SEProjectProperties.NO_DEPENDENCIES );
69
        initPlatforms(vps);
70
        initPlatforms(vps);
70
        
71
        
Lines 105-110 Link Here
105
        jLabelTarget = new javax.swing.JLabel();
106
        jLabelTarget = new javax.swing.JLabel();
106
        jComboBoxTarget = new javax.swing.JComboBox();
107
        jComboBoxTarget = new javax.swing.JComboBox();
107
        jButton1 = new javax.swing.JButton();
108
        jButton1 = new javax.swing.JButton();
109
        jLabelEncoding = new javax.swing.JLabel();
110
        jTextFieldEncoding = new javax.swing.JTextField();
108
        jLabelReqPrj = new javax.swing.JLabel();
111
        jLabelReqPrj = new javax.swing.JLabel();
109
        jScrollPane1 = new javax.swing.JScrollPane();
112
        jScrollPane1 = new javax.swing.JScrollPane();
110
        jListSubprojects = new javax.swing.JList();
113
        jListSubprojects = new javax.swing.JList();
Lines 115-140 Link Here
115
        setBorder(new javax.swing.border.EtchedBorder());
118
        setBorder(new javax.swing.border.EtchedBorder());
116
        jLabelProjectName.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_DisplayName_JLabel"));
119
        jLabelProjectName.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_DisplayName_JLabel"));
117
        gridBagConstraints = new java.awt.GridBagConstraints();
120
        gridBagConstraints = new java.awt.GridBagConstraints();
118
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
119
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
121
        gridBagConstraints.insets = new java.awt.Insets(12, 12, 12, 12);
122
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
120
        add(jLabelProjectName, gridBagConstraints);
123
        add(jLabelProjectName, gridBagConstraints);
121
124
122
        gridBagConstraints = new java.awt.GridBagConstraints();
125
        gridBagConstraints = new java.awt.GridBagConstraints();
123
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
126
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
124
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
127
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
125
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
126
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 12);
128
        gridBagConstraints.insets = new java.awt.Insets(12, 0, 12, 12);
129
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
127
        add(jTextFieldDisplayName, gridBagConstraints);
130
        add(jTextFieldDisplayName, gridBagConstraints);
128
131
129
        jLabelTarget.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JLabel"));
132
        jLabelTarget.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JLabel"));
130
        gridBagConstraints = new java.awt.GridBagConstraints();
133
        gridBagConstraints = new java.awt.GridBagConstraints();
131
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
132
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
134
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
135
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
133
        add(jLabelTarget, gridBagConstraints);
136
        add(jLabelTarget, gridBagConstraints);
134
137
135
        gridBagConstraints = new java.awt.GridBagConstraints();
138
        gridBagConstraints = new java.awt.GridBagConstraints();
136
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
137
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
139
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
140
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
138
        add(jComboBoxTarget, gridBagConstraints);
141
        add(jComboBoxTarget, gridBagConstraints);
139
142
140
        jButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JButton"));
143
        jButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_Platform_JButton"));
Lines 146-160 Link Here
146
149
147
        gridBagConstraints = new java.awt.GridBagConstraints();
150
        gridBagConstraints = new java.awt.GridBagConstraints();
148
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
151
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
149
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
150
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 12);
152
        gridBagConstraints.insets = new java.awt.Insets(0, 6, 12, 12);
153
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
151
        add(jButton1, gridBagConstraints);
154
        add(jButton1, gridBagConstraints);
152
155
153
        jLabelReqPrj.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_RequiredProjects_JLabel"));
156
        jLabelEncoding.setLabelFor(jTextFieldEncoding);
157
        jLabelEncoding.setText(java.util.ResourceBundle.getBundle("org/netbeans/modules/java/j2seproject/ui/customizer/Bundle").getString("LBL_CustomizeGeneral_Encoding_JLabel"));
158
        gridBagConstraints = new java.awt.GridBagConstraints();
159
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
160
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
161
        add(jLabelEncoding, gridBagConstraints);
162
154
        gridBagConstraints = new java.awt.GridBagConstraints();
163
        gridBagConstraints = new java.awt.GridBagConstraints();
155
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
164
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
165
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
166
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 12);
156
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
167
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
168
        add(jTextFieldEncoding, gridBagConstraints);
169
170
        jLabelReqPrj.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_RequiredProjects_JLabel"));
171
        gridBagConstraints = new java.awt.GridBagConstraints();
172
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
157
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 2, 12);
173
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 2, 12);
174
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
158
        add(jLabelReqPrj, gridBagConstraints);
175
        add(jLabelReqPrj, gridBagConstraints);
159
176
160
        jScrollPane1.setViewportView(jListSubprojects);
177
        jScrollPane1.setViewportView(jListSubprojects);
Lines 162-171 Link Here
162
        gridBagConstraints = new java.awt.GridBagConstraints();
179
        gridBagConstraints = new java.awt.GridBagConstraints();
163
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
180
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
164
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
181
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
182
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 6, 12);
165
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
183
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
166
        gridBagConstraints.weightx = 1.0;
184
        gridBagConstraints.weightx = 1.0;
167
        gridBagConstraints.weighty = 1.0;
185
        gridBagConstraints.weighty = 1.0;
168
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 6, 12);
169
        add(jScrollPane1, gridBagConstraints);
186
        add(jScrollPane1, gridBagConstraints);
170
187
171
        jCheckBoxReqPrj.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_RequiredProjects_JCheckBox"));
188
        jCheckBoxReqPrj.setText(org.openide.util.NbBundle.getMessage(CustomizerGeneral.class, "LBL_CustomizeGeneral_RequiredProjects_JCheckBox"));
Lines 173-181 Link Here
173
        gridBagConstraints = new java.awt.GridBagConstraints();
190
        gridBagConstraints = new java.awt.GridBagConstraints();
174
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
191
        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
175
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
192
        gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
193
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
176
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
194
        gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
177
        gridBagConstraints.weightx = 1.0;
195
        gridBagConstraints.weightx = 1.0;
178
        gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 12);
179
        add(jCheckBoxReqPrj, gridBagConstraints);
196
        add(jCheckBoxReqPrj, gridBagConstraints);
180
197
181
    }//GEN-END:initComponents
198
    }//GEN-END:initComponents
Lines 190-201 Link Here
190
    private javax.swing.JButton jButton1;
207
    private javax.swing.JButton jButton1;
191
    private javax.swing.JCheckBox jCheckBoxReqPrj;
208
    private javax.swing.JCheckBox jCheckBoxReqPrj;
192
    private javax.swing.JComboBox jComboBoxTarget;
209
    private javax.swing.JComboBox jComboBoxTarget;
210
    private javax.swing.JLabel jLabelEncoding;
193
    private javax.swing.JLabel jLabelProjectName;
211
    private javax.swing.JLabel jLabelProjectName;
194
    private javax.swing.JLabel jLabelReqPrj;
212
    private javax.swing.JLabel jLabelReqPrj;
195
    private javax.swing.JLabel jLabelTarget;
213
    private javax.swing.JLabel jLabelTarget;
196
    private javax.swing.JList jListSubprojects;
214
    private javax.swing.JList jListSubprojects;
197
    private javax.swing.JScrollPane jScrollPane1;
215
    private javax.swing.JScrollPane jScrollPane1;
198
    private javax.swing.JTextField jTextFieldDisplayName;
216
    private javax.swing.JTextField jTextFieldDisplayName;
217
    private javax.swing.JTextField jTextFieldEncoding;
199
    // End of variables declaration//GEN-END:variables
218
    // End of variables declaration//GEN-END:variables
200
        
219
        
201
    // Storing methods ---------------------------------------------------------
220
    // Storing methods ---------------------------------------------------------
(-)java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/J2SEProjectProperties.java (+8 lines)
Lines 84-89 Link Here
84
    public static final String DIST_JAVADOC_DIR = "dist.javadoc.dir";
84
    public static final String DIST_JAVADOC_DIR = "dist.javadoc.dir";
85
    public static final String NO_DEPENDENCIES="no.dependencies";
85
    public static final String NO_DEPENDENCIES="no.dependencies";
86
    public static final String DEBUG_TEST_CLASSPATH = "debug.test.classpath";
86
    public static final String DEBUG_TEST_CLASSPATH = "debug.test.classpath";
87
    public static final String FILES_ENCODING = "encoding";
87
    
88
    
88
    
89
    
89
    public static final String JAVADOC_PRIVATE="javadoc.private";
90
    public static final String JAVADOC_PRIVATE="javadoc.private";
Lines 143-148 Link Here
143
        new PropertyDescriptor( NO_DEPENDENCIES, PROJECT, INVERSE_BOOLEAN_PARSER ),
144
        new PropertyDescriptor( NO_DEPENDENCIES, PROJECT, INVERSE_BOOLEAN_PARSER ),
144
        new PropertyDescriptor( JAVA_PLATFORM, PROJECT, PLATFORM_PARSER ),
145
        new PropertyDescriptor( JAVA_PLATFORM, PROJECT, PLATFORM_PARSER ),
145
        new PropertyDescriptor( DEBUG_TEST_CLASSPATH, PROJECT, PATH_PARSER ),
146
        new PropertyDescriptor( DEBUG_TEST_CLASSPATH, PROJECT, PATH_PARSER ),
147
        new PropertyDescriptor( FILES_ENCODING, PROJECT, STRING_PARSER ),
146
        
148
        
147
        new PropertyDescriptor( JAVADOC_PRIVATE, PROJECT, BOOLEAN_PARSER ),
149
        new PropertyDescriptor( JAVADOC_PRIVATE, PROJECT, BOOLEAN_PARSER ),
148
        new PropertyDescriptor( JAVADOC_NO_TREE, PROJECT, INVERSE_BOOLEAN_PARSER ),
150
        new PropertyDescriptor( JAVADOC_NO_TREE, PROJECT, INVERSE_BOOLEAN_PARSER ),
Lines 336-341 Link Here
336
                                    if (JAVA_PLATFORM.equals(pd.name)) {
338
                                    if (JAVA_PLATFORM.equals(pd.name)) {
337
                                        assert defaultPlatform != null;
339
                                        assert defaultPlatform != null;
338
                                        updateSourceLevel(defaultPlatform.booleanValue(), newValueEncoded, ep);
340
                                        updateSourceLevel(defaultPlatform.booleanValue(), newValueEncoded, ep);
341
                                    }
342
                                    
343
                                    // if encoding was removed then remove the property
344
                                    if (FILES_ENCODING.equals(pd.name) && newValueEncoded.length() == 0) {
345
                                        ep.remove(pd.name);
346
                                        continue;
339
                                    }
347
                                    }
340
                                    
348
                                    
341
                                    ep.setProperty( pd.name, newValueEncoded );
349
                                    ep.setProperty( pd.name, newValueEncoded );
(-)projects/projectapi/src/META-INF/services/org.netbeans.spi.queries.FileEncodingQueryImplementation (+1 lines)
Added Link Here
1
org.netbeans.modules.projectapi.FileEncodingQueryImpl
(-)projects/projectapi/src/org/netbeans/modules/projectapi/FileEncodingQueryImpl.java (+43 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
package org.netbeans.modules.projectapi;
14
15
import java.net.URI;
16
import org.netbeans.api.project.FileOwnerQuery;
17
import org.netbeans.api.project.Project;
18
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
19
20
/**
21
 * Finds project owning given file, FileEncodingQueryImplementation impl in its
22
 * lookup and delegates question to it.
23
 * @author David Konecny
24
 */
25
public class FileEncodingQueryImpl implements FileEncodingQueryImplementation {
26
    
27
    /** Default constructor for lookup. */
28
    public FileEncodingQueryImpl() {}
29
30
    public String getFileEncoding(org.openide.filesystems.FileObject file) {
31
        Project project = FileOwnerQuery.getOwner(file);
32
        if (project != null) {
33
            FileEncodingQueryImplementation feq =
34
                    (FileEncodingQueryImplementation)project.getLookup().lookup(
35
                            FileEncodingQueryImplementation.class);
36
            if (feq != null) {
37
                return feq.getFileEncoding(file);
38
            }
39
        }
40
        return null;
41
    }
42
    
43
}
(-)projects/queries/src/org/netbeans/api/queries/FileEncodingQuery.java (+55 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
package org.netbeans.api.queries;
14
15
import java.util.Iterator;
16
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
17
import org.openide.filesystems.FileObject;
18
import org.openide.util.Lookup;
19
20
/**
21
 * Query to find encoding of a file. 
22
 * @see org.netbeans.api.java.queries.FileEncodingQueryImplementation
23
 * @author David Konecny
24
 * @since XXX
25
 */
26
public class FileEncodingQuery {
27
    
28
    private static final Lookup.Result/*<FileEncodingQueryImplementation>*/ implementations =
29
        Lookup.getDefault().lookup(new Lookup.Template(FileEncodingQueryImplementation.class));
30
31
    private FileEncodingQuery() {
32
    }
33
34
    /**
35
     * Returns encoding of the given file if it is known.
36
     * @param file FileObject in question
37
     * @return encoding of the file or null if nothing is known about
38
     *    file's encoding
39
     */
40
    public static String getFileEncoding(FileObject file) {
41
        if (file.isFolder()) {
42
            throw new IllegalArgumentException("Not a file: " + file); // NOI18N
43
        }
44
        Iterator it = implementations.allInstances().iterator();
45
        while (it.hasNext()) {
46
            FileEncodingQueryImplementation sqi = (FileEncodingQueryImplementation)it.next();
47
            String s = sqi.getFileEncoding(file);
48
            if (s != null) {
49
                return s;
50
            }
51
        }
52
        return null;
53
    }
54
55
}
(-)projects/queries/src/org/netbeans/spi/queries/FileEncodingQueryImplementation.java (+43 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 *
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 *
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
package org.netbeans.spi.queries;
14
15
import org.openide.filesystems.FileObject;
16
17
/**
18
 * Permits providers to return encoding of the file.
19
 * <p>
20
 * A default implementation is registered by the
21
 * <code>org.netbeans.modules.project.ant</code> module which looks up the
22
 * project corresponding to the file (if any) and checks whether that
23
 * project has an implementation of this interface in its lookup. If so, it
24
 * delegates to that implementation. Therefore it is not generally necessary
25
 * for a project type provider to register its own global implementation of
26
 * this query, if it depends on the ant project module and uses this style.
27
 * </p>
28
 * @see org.netbeans.api.queries.FileEncodingQuery
29
 * @see org.netbeans.api.queries.FileOwnerQuery
30
 * @see org.netbeans.api.project.Project#getLookup
31
 * @author David Konecny
32
 * @since XXX
33
 */
34
public interface FileEncodingQueryImplementation {
35
36
    /**
37
     * Returns file encoding. 
38
     * @param file FileObject in question
39
     * @return file encoding or null if nothing is known about file's encoding
40
     */
41
    public String getFileEncoding(FileObject file);
42
43
}

Return to bug 42638