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

(-)413ef834207b (+152 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!-- Search for CHANGEME in this document when copying and using it: -->
3
<!--
4
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5
6
Copyright 2013 Oracle and/or its affiliates. All rights reserved.
7
8
Oracle and Java are registered trademarks of Oracle and/or its affiliates.
9
Other names may be trademarks of their respective owners.
10
11
The contents of this file are subject to the terms of either the GNU
12
General Public License Version 2 only ("GPL") or the Common
13
Development and Distribution License("CDDL") (collectively, the
14
"License"). You may not use this file except in compliance with the
15
License. You can obtain a copy of the License at
16
http://www.netbeans.org/cddl-gplv2.html
17
or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
18
specific language governing permissions and limitations under the
19
License.  When distributing the software, include this License Header
20
Notice in each file and include the License file at
21
nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
22
particular file as subject to the "Classpath" exception as provided
23
by Oracle in the GPL Version 2 section of the License file that
24
accompanied this code. If applicable, add the following below the
25
License Header, with the fields enclosed by brackets [] replaced by
26
your own identifying information:
27
"Portions Copyrighted [year] [name of copyright owner]"
28
29
Contributor(s):
30
31
The Original Software is NetBeans. The Initial Developer of the Original
32
Software is Sun Microsystems, Inc. Portions Copyright 2013 Sun
33
Microsystems, Inc. All Rights Reserved.
34
35
If you wish your version of this file to be governed by only the CDDL
36
or only the GPL Version 2, indicate your decision by adding
37
"[Contributor] elects to include this software in this distribution
38
under the [CDDL or GPL Version 2] license." If you do not indicate a
39
single choice of license, a recipient has the option to distribute
40
your version of this file under either the CDDL, the GPL Version 2 or
41
to extend the choice of license to its licensees as provided above.
42
However, if you add GPL Version 2 code and therefore, elected the GPL
43
Version 2 license, then the option applies only if the new code is
44
made subject to such option by the copyright holder.
45
-->
46
<?xml-stylesheet type="text/xml" href="../nbbuild/javadoctools/apichanges.xsl"?>
47
<!DOCTYPE apichanges PUBLIC "-//NetBeans//DTD API changes list 1.0//EN" "../nbbuild/javadoctools/apichanges.dtd">
48
49
<!--
50
51
INFO FOR PEOPLE ADDING CHANGES:
52
53
Check the DTD (apichanges.dtd) for details on the syntax. You do not
54
need to regenerate the HTML, as this is part of Javadoc generation; just
55
change the XML. Rough syntax of a change (several parts optional):
56
57
<change>
58
    <api name="compiler"/>
59
    <summary>Some brief description here, can use <b>XHTML</b></summary>
60
    <version major="1" minor="99"/>
61
    <date day="13" month="6" year="2001"/>
62
    <author login="jrhacker"/>
63
    <compatibility addition="yes"/>
64
    <description>
65
        The main description of the change here.
66
        Again can use full <b>XHTML</b> as needed.
67
    </description>
68
    <class package="org.openide.compiler" name="DoWhatIWantCompiler"/>
69
    <issue number="14309"/>
70
</change>
71
72
Also permitted elements: <package>, <branch>. <version> is API spec
73
version, recommended for all new changes. <compatibility> should say
74
if things were added/modified/deprecated/etc. and give all information
75
related to upgrading old code. List affected top-level classes and
76
link to issue numbers if applicable. See the DTD for more details.
77
78
Changes need not be in any particular order, they are sorted in various
79
ways by the stylesheet anyway.
80
81
Dates are assumed to mean "on the trunk". If you *also* make the same
82
change on a stabilization branch, use the <branch> tag to indicate this
83
and explain why the change was made on a branch in the <description>.
84
85
Please only change this file on the trunk! Rather: you can change it
86
on branches if you want, but these changes will be ignored; only the
87
trunk version of this file is important.
88
89
Deprecations do not count as incompatible, assuming that code using the
90
deprecated calls continues to see their documented behavior. But do
91
specify deprecation="yes" in <compatibility>.
92
93
This file is not a replacement for Javadoc: it is intended to list changes,
94
not describe the complete current behavior, for which ordinary documentation
95
is the proper place.
96
97
-->
98
99
<apichanges>
100
101
    <!-- First, a list of API names you may use: -->
102
    <apidefs>
103
        <!-- org.netbeans.spi.editor.hints -->
104
        <apidef name="EditorHintsBridgeSPI">Editor Hints Bridge</apidef>
105
    </apidefs>
106
107
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
109
    <changes>
110
111
        <change id="per-project-hints-from-preferences">
112
             <api name="EditorHintsBridgeSPI"/>
113
             <summary>Adding support method to create hints' ProjectSettings from project's Preferences</summary>
114
             <version major="1" minor="4"/>
115
             <date day="9" month="8" year="2013"/>
116
             <author login="jlahoda"/>
117
             <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
             <description>
119
                 Support method to create hints' ProjectSettings from project's Preferences added.
120
             </description>
121
             <class name="StandardProjectSettings" package="org.netbeans.spi.editor.hints.projects.support"/>
122
             <issue number="999999"/>
123
        </change>
124
125
    </changes>
126
127
    <!-- Now the surrounding HTML text and document structure: -->
128
129
    <htmlcontents>
130
<!-- Generated from apichanges.xml -->
131
    <head>
132
      <title>Change History for the Editor Hints SPI</title>
133
      <link rel="stylesheet" href="prose.css" type="text/css"/>
134
    </head>
135
    <body>
136
137
<p class="overviewlink"><a href="@TOP@/overview-summary.html">Overview</a></p>
138
139
<h1>Introduction</h1>
140
141
<p>This document lists changes made to the <a href="@TOP@/overview-summary.html">Editor Hints SPI</a>.</p>
142
143
<!-- The actual lists of changes, as summaries and details: -->
144
      <hr/>
145
      <standard-changelists module-code-name="org.netbeans.spi.editor.hints/0"/>
146
147
      <hr/><p>@FOOTER@</p>
148
149
    </body>
150
  </htmlcontents>
151
152
</apichanges>
(-)a/spi.editor.hints.projects/nbproject/project.properties (-1 / +2 lines)
Lines 1-5 Link Here
1
javac.source=1.7
1
javac.source=1.7
2
javac.compilerargs=-Xlint -Xlint:-serial
2
javac.compilerargs=-Xlint -Xlint:-serial
3
javadoc.arch=${basedir}/arch.xml
3
javadoc.arch=${basedir}/arch.xml
4
spec.version.base=1.3.0
4
javadoc.apichanges=${basedir}/apichanges.xml
5
spec.version.base=1.4.0
5
spec.version.base.fatal.warning=false
6
spec.version.base.fatal.warning=false
(-)a/spi.editor.hints.projects/src/org/netbeans/modules/editor/hints/projects/layer.xml (+16 lines)
Lines 18-22 Link Here
18
                </file>
18
                </file>
19
            </folder>
19
            </folder>
20
        </folder>
20
        </folder>
21
        <folder name="org-netbeans-modules-maven">
22
            <folder name="Lookup">
23
                <file name="EditorHints.instance">
24
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.project.LookupProvider" />
25
                    <attr name="instanceCreate" methodvalue="org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.createPreferencesBasedSettings" />
26
                </file>
27
            </folder>
28
            <folder name="Customizer">
29
                <file name="EditorHints.instance">
30
                    <attr name="instanceOf" stringvalue="org.netbeans.spi.project.ui.support.ProjectCustomizer$CompositeCategoryProvider" />
31
                    <attr name="instanceCreate" methodvalue="org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.createCustomizerProvider" />
32
                    <attr intvalue="1100" name="position"/>
33
                    <attr name="customizersFolder" stringvalue="Projects/hints/java-based" />
34
                </file>
35
            </folder>
36
        </folder>
21
    </folder>
37
    </folder>
22
</filesystem>
38
</filesystem>
(-)a/spi.editor.hints.projects/src/org/netbeans/spi/editor/hints/projects/PerProjectHintsPanelUI.java (-1 / +3 lines)
Lines 199-205 Link Here
199
    }
199
    }
200
    
200
    
201
    private void searchEnableDisable() {
201
    private void searchEnableDisable() {
202
        searchText.setEnabled(supportsFiltering.contains(((LanguageDescription) languageCombo.getSelectedItem()).mimeType));
202
        LanguageDescription selected = (LanguageDescription) languageCombo.getSelectedItem();
203
        
204
        searchText.setEnabled(selected != null && supportsFiltering.contains(selected.mimeType));
203
    }
205
    }
204
    
206
    
205
    /**
207
    /**
(-)a/spi.editor.hints.projects/src/org/netbeans/spi/editor/hints/projects/support/ProjectCustomizer.java (-2 / +4 lines)
Lines 46-51 Link Here
46
import java.io.IOException;
46
import java.io.IOException;
47
import javax.swing.JComponent;
47
import javax.swing.JComponent;
48
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
49
import org.netbeans.api.project.ProjectManager;
49
import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
50
import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
50
import org.netbeans.spi.editor.hints.projects.ProjectSettings;
51
import org.netbeans.spi.editor.hints.projects.ProjectSettings;
51
import org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.Standard;
52
import org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.Standard;
Lines 83-89 Link Here
83
84
84
    @Override
85
    @Override
85
    public JComponent createComponent(Category category, Lookup context) {
86
    public JComponent createComponent(Category category, Lookup context) {
86
        Project prj = context.lookup(Project.class);
87
        final Project prj = context.lookup(Project.class);
87
        
88
        
88
        assert prj != null;
89
        assert prj != null;
89
        
90
        
Lines 91-97 Link Here
91
        
92
        
92
        final ToolPreferences[] toSave = new ToolPreferences[1];
93
        final ToolPreferences[] toSave = new ToolPreferences[1];
93
        
94
        
94
        //TODO: should rather use store listener to avoid touching disk in AWT
95
        category.setOkButtonListener(new ActionListener() {
95
        category.setOkButtonListener(new ActionListener() {
96
            @Override public void actionPerformed(ActionEvent e) {
96
            @Override public void actionPerformed(ActionEvent e) {
97
                toSave[0] = settingsPanel.commit();
97
                toSave[0] = settingsPanel.commit();
Lines 105-110 Link Here
105
                        toSave[0].save();
105
                        toSave[0].save();
106
                        toSave[0] = null;
106
                        toSave[0] = null;
107
                    }
107
                    }
108
                    
109
                    ProjectManager.getDefault().saveProject(prj);
108
                } catch (IOException ex) {
110
                } catch (IOException ex) {
109
                    Exceptions.printStackTrace(ex);
111
                    Exceptions.printStackTrace(ex);
110
                }
112
                }
(-)a/spi.editor.hints.projects/src/org/netbeans/spi/editor/hints/projects/support/ProjectHintSettingPanel.java (-6 / +28 lines)
Lines 47-55 Link Here
47
import java.awt.Container;
47
import java.awt.Container;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.util.logging.Logger;
49
import java.util.logging.Logger;
50
import java.util.prefs.Preferences;
50
import javax.swing.JComponent;
51
import javax.swing.JComponent;
51
import org.netbeans.api.options.OptionsDisplayer;
52
import org.netbeans.api.options.OptionsDisplayer;
52
import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
53
import org.netbeans.modules.editor.tools.storage.api.ToolPreferences;
54
import org.netbeans.spi.editor.hints.projects.PerProjectHintsPanel.MimeType2Preferences;
55
import org.netbeans.spi.editor.hints.projects.ProjectSettings;
53
import org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.Standard;
56
import org.netbeans.spi.editor.hints.projects.support.StandardProjectSettings.Standard;
54
import org.openide.DialogDescriptor;
57
import org.openide.DialogDescriptor;
55
import org.openide.DialogDisplayer;
58
import org.openide.DialogDisplayer;
Lines 69-80 Link Here
69
    private final JComponent panelUI;
72
    private final JComponent panelUI;
70
    private final Standard projectSettings;
73
    private final Standard projectSettings;
71
    private       String settingsFileLocation;
74
    private       String settingsFileLocation;
72
    private       ToolPreferences perProjectToolPreferences;
75
    private       MimeType2Preferences perProjectPreferences;
76
    private       ToolPreferences toolPreferences;
73
    
77
    
74
    public ProjectHintSettingPanel(final Standard projectSettings, String customizersFolderLocation) {
78
    public ProjectHintSettingPanel(final Standard projectSettings, String customizersFolderLocation) {
75
        this.projectSettings = projectSettings;
79
        this.projectSettings = projectSettings;
76
        this.settingsFileLocation = projectSettings.getSettingsFileLocation();
80
        this.settingsFileLocation = projectSettings.hasLocation() ? projectSettings.getSettingsFileLocation() : null;
77
        this.perProjectToolPreferences = projectSettings.preferencesFrom(settingsFileLocation);
81
        settingsFileLocationChanged();
78
        FileObject customizersFolder;
82
        FileObject customizersFolder;
79
        
83
        
80
        try {
84
        try {
Lines 86-91 Link Here
86
90
87
        panel = PerProjectHintsPanel.create(customizersFolder);
91
        panel = PerProjectHintsPanel.create(customizersFolder);
88
        initComponents();
92
        initComponents();
93
        advanced.setVisible(projectSettings.hasLocation());
89
        if (projectSettings.getUseProjectSettings()) {
94
        if (projectSettings.getUseProjectSettings()) {
90
            useProjectSettings.setSelected(true);
95
            useProjectSettings.setSelected(true);
91
        } else {
96
        } else {
Lines 103-109 Link Here
103
        advanced.setEnabled(useProjectSettings.isSelected());
108
        advanced.setEnabled(useProjectSettings.isSelected());
104
109
105
        if (useProjectSettings.isSelected()) {
110
        if (useProjectSettings.isSelected()) {
106
            panel.setPerProjectSettings(perProjectToolPreferences);
111
            panel.setPerProjectSettings(perProjectPreferences);
107
        } else {
112
        } else {
108
            panel.setGlobalSettings();
113
            panel.setGlobalSettings();
109
        }
114
        }
Lines 122-128 Link Here
122
        projectSettings.setUseProjectSettings(useProjectSettings.isSelected());
127
        projectSettings.setUseProjectSettings(useProjectSettings.isSelected());
123
//        projectSettings.setSettingsFileLocation(new File(settingsFileLocation.getText()));
128
//        projectSettings.setSettingsFileLocation(new File(settingsFileLocation.getText()));
124
        panel.applyChanges();
129
        panel.applyChanges();
125
        return useProjectSettings.isSelected() ? perProjectToolPreferences : null;
130
        return useProjectSettings.isSelected() && toolPreferences != null ? toolPreferences : null;
126
    }
131
    }
127
    
132
    
128
    /**
133
    /**
Lines 231-237 Link Here
231
        DialogDescriptor dd = new DialogDescriptor(panel, Bundle.CAP_ProjectSpecificOptions(), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
236
        DialogDescriptor dd = new DialogDescriptor(panel, Bundle.CAP_ProjectSpecificOptions(), true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
232
        
237
        
233
        if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
238
        if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
234
            this.perProjectToolPreferences = projectSettings.preferencesFrom(settingsFileLocation = panel.getHintFileLocation());
239
            settingsFileLocation = panel.getHintFileLocation();
240
            settingsFileLocationChanged();
235
            settingsOriginChanged();
241
            settingsOriginChanged();
236
        }
242
        }
237
    }//GEN-LAST:event_advancedActionPerformed
243
    }//GEN-LAST:event_advancedActionPerformed
Lines 240-245 Link Here
240
        OptionsDisplayer.getDefault().open("Editor/Hints");
246
        OptionsDisplayer.getDefault().open("Editor/Hints");
241
    }//GEN-LAST:event_globalSettingsActionPerformed
247
    }//GEN-LAST:event_globalSettingsActionPerformed
242
248
249
    private void settingsFileLocationChanged() {
250
        if (projectSettings.hasLocation()) {
251
            final ToolPreferences toolPreferencesFin = toolPreferences = projectSettings.preferencesFrom(settingsFileLocation);
252
            perProjectPreferences = new MimeType2Preferences() {
253
                @Override public Preferences getPreferences(String mimeType) {
254
                    return toolPreferencesFin.getPreferences(ProjectSettings.HINTS_TOOL_ID, mimeType);
255
                }
256
            };
257
        } else {
258
            perProjectPreferences = new MimeType2Preferences() {
259
                @Override public Preferences getPreferences(String mimeType) {
260
                    return projectSettings.getProjectSettings(mimeType);
261
                }
262
            };
263
        }
264
    }
243
    // Variables declaration - do not modify//GEN-BEGIN:variables
265
    // Variables declaration - do not modify//GEN-BEGIN:variables
244
    private javax.swing.JButton advanced;
266
    private javax.swing.JButton advanced;
245
    private javax.swing.JButton globalSettings;
267
    private javax.swing.JButton globalSettings;
(-)a/spi.editor.hints.projects/src/org/netbeans/spi/editor/hints/projects/support/StandardProjectSettings.java (-6 / +37 lines)
Lines 124-129 Link Here
124
        };
124
        };
125
    }
125
    }
126
    
126
    
127
    /**Augment the given project's {@link Lookup} with the per-project hints settings.
128
     * 
129
     * @return a {@link LookupProvider} that augments the given project's {@link Lookup} with per-project settings
130
     * @since 1.4
131
     */
132
    public static @NonNull LookupProvider createPreferencesBasedSettings() {
133
        return new LookupProvider() {
134
            @Override public Lookup createAdditionalLookup(Lookup baseContext) {
135
                Project project = baseContext.lookup(Project.class);
136
                assert project != null;
137
                return Lookups.fixed(new Standard(project, KEY_USE_PROJECT, null, null));
138
            }
139
        };
140
    }
141
    
127
    /**Augments the project's customizer with the standard version of per-project hints customizer.
142
    /**Augments the project's customizer with the standard version of per-project hints customizer.
128
     * Similar to {@link #createCustomizerProvider(java.lang.String) }, but the <code>customizersFolder</code>
143
     * Similar to {@link #createCustomizerProvider(java.lang.String) }, but the <code>customizersFolder</code>
129
     * is read get from <code>customizersFolder</code> attribute of the given file. Intended to be put directly
144
     * is read get from <code>customizersFolder</code> attribute of the given file. Intended to be put directly
Lines 160-170 Link Here
160
175
161
        private final Project project;
176
        private final Project project;
162
        
177
        
163
        private final String keyUseProject;
178
        private final @NonNull String keyUseProject;
164
        private final String keyHintSettingsFile;
179
        private final @NullAllowed String keyHintSettingsFile;
165
        private final String defaultHintLocation;
180
        private final @NullAllowed String defaultHintLocation;
166
181
167
        public Standard(Project project, String keyUseProject, String keyHintSettingsFile, String defaultHintLocation) {
182
        public Standard(Project project, @NonNull String keyUseProject, @NullAllowed String keyHintSettingsFile, @NullAllowed String defaultHintLocation) {
168
            this.keyUseProject = keyUseProject;
183
            this.keyUseProject = keyUseProject;
169
            this.keyHintSettingsFile = keyHintSettingsFile;
184
            this.keyHintSettingsFile = keyHintSettingsFile;
170
            this.defaultHintLocation = defaultHintLocation;
185
            this.defaultHintLocation = defaultHintLocation;
Lines 185-206 Link Here
185
        }
200
        }
186
201
187
        public String getSettingsFileLocation() {
202
        public String getSettingsFileLocation() {
203
            assert hasLocation();
188
            String result = ProjectUtils.getPreferences(project, ProjectSettings.class, true).get(keyHintSettingsFile, null);
204
            String result = ProjectUtils.getPreferences(project, ProjectSettings.class, true).get(keyHintSettingsFile, null);
189
            
205
            
190
            return result != null ? result : defaultHintLocation;
206
            return result != null ? result : defaultHintLocation;
191
        }
207
        }
192
208
193
        public void setSettingsFileLocation(String settings) {
209
        public void setSettingsFileLocation(String settings) {
210
            assert hasLocation();
194
            ProjectUtils.getPreferences(project, ProjectSettings.class, true).put(keyHintSettingsFile, settings);
211
            ProjectUtils.getPreferences(project, ProjectSettings.class, true).put(keyHintSettingsFile, settings);
195
        }
212
        }
196
213
197
        @Override
214
        @Override
198
        public Preferences getProjectSettings(String mimeType) {
215
        public Preferences getProjectSettings(String mimeType) {
199
            URI settingsLocation = project.getProjectDirectory().toURI().resolve(getSettingsFileLocation());
216
            if (hasLocation()) {
200
            return ToolPreferences.from(settingsLocation).getPreferences(HINTS_TOOL_ID, mimeType);
217
                URI settingsLocation = project.getProjectDirectory().toURI().resolve(getSettingsFileLocation());
218
                return ToolPreferences.from(settingsLocation).getPreferences(HINTS_TOOL_ID, mimeType);
219
            } else {
220
                return ProjectUtils.getPreferences(project, ProjectSettings.class, true).node(mimeType);
221
            }
201
        }
222
        }
202
        
223
        
203
        public ToolPreferences preferencesFrom(String source) {
224
        public ToolPreferences preferencesFrom(String source) {
225
            assert hasLocation();
204
            URI settingsLocation = project.getProjectDirectory().toURI().resolve(getSettingsFileLocation());
226
            URI settingsLocation = project.getProjectDirectory().toURI().resolve(getSettingsFileLocation());
205
            return ToolPreferences.from(settingsLocation);
227
            return ToolPreferences.from(settingsLocation);
206
        }
228
        }
Lines 213-217 Link Here
213
            return FileUtil.toFile(project.getProjectDirectory());
235
            return FileUtil.toFile(project.getProjectDirectory());
214
        }
236
        }
215
        
237
        
238
        public boolean hasLocation() {
239
            return keyHintSettingsFile != null;
240
        }
241
        
242
        public void save() {
243
            if (hasLocation()) {
244
                
245
            }
246
        }
216
    }
247
    }
217
}
248
}

Return to bug 233821