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

(-)java/src/org/netbeans/modules/java/imptool/Bundle.properties (-1 / +10 lines)
Lines 39-45 Link Here
39
FQN_PANEL_NOROWS=There are no unresolved identifiers.
39
FQN_PANEL_NOROWS=There are no unresolved identifiers.
40
FQN_PANEL_TEXT=Type in the package names for the following unresolved identifiers. Click Finish to run the Import Management Tool with its default configuration. Click Next to examine or customize Import Management Tool actions. 
40
FQN_PANEL_TEXT=Type in the package names for the following unresolved identifiers. Click Finish to run the Import Management Tool with its default configuration. Click Next to examine or customize Import Management Tool actions. 
41
RESOLVE_PANEL_TEXT=Unused import statements will be removed. Packages and single-name imports will be changed as indicated in the Action column. You can override the default action for each entry. 
41
RESOLVE_PANEL_TEXT=Unused import statements will be removed. Packages and single-name imports will be changed as indicated in the Action column. You can override the default action for each entry. 
42
IMPORT_PANEL_TEXT=By default, import statements are created when fully qualified names (FQN) occur more than the Maximum FQN specified. You can override Import Management Tool defaults by choosing a different action in the Action column.
42
IMPORT_PANEL_TEXT=By default, import statements are created when fully qualified names (FQN) occur more than the Maximum FQN specified. Import management defaults can be set at the bottom of this window, and you can override the defaults for individual classes by choosing a different action in the Action column.
43
HINT_RESOLVE_PLACES=List of commonly used packages to search for unresolved identifiers.
43
HINT_RESOLVE_PLACES=List of commonly used packages to search for unresolved identifiers.
44
PROP_RESOLVE_PLACES=List of Well-Known Packages
44
PROP_RESOLVE_PLACES=List of Well-Known Packages
45
HINT_SOURCE_NAME=Name of class as it presently appears in source.
45
HINT_SOURCE_NAME=Name of class as it presently appears in source.
Lines 76-78 Link Here
76
ACS_ListTableViewA11yDesc=List table view.
76
ACS_ListTableViewA11yDesc=List table view.
77
ACS_TreeTableViewA11yName=Tree Table View
77
ACS_TreeTableViewA11yName=Tree Table View
78
ACS_TreeTableViewA11yDesc=Tree table view.
78
ACS_TreeTableViewA11yDesc=Tree table view.
79
80
LBL_SETTINGCOMBO=FQN/Import settings: 
81
LBL_ADVANCED=Advanced
82
CHOICE_MINFQN=Low noise - Minimze FQNs
83
CHOICE_DEFFQN=Default
84
CHOICE_MAXFQN=High noise - Maximize FQNs
85
CHOICE_CUSTOM=Custom settings
86
TT_FQN=Max FQNs=
87
TT_SI= Single import threshold=
(-)java/src/org/netbeans/modules/java/imptool/ImportPanel.form (-5 / +5 lines)
Lines 1-9 Link Here
1
<?xml version="1.0" encoding="UTF-8" ?>
1
<?xml version="1.0" encoding="UTF-8" ?>
2
2
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
3
<Form version="1.0" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
4
  <SyntheticProperties>
4
  <AuxValues>
5
    <SyntheticProperty 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"/>
5
    <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"/>
6
  </SyntheticProperties>
6
  </AuxValues>
7
7
8
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout">
8
  <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout">
9
    <Property name="verticalGap" type="int" value="12"/>
9
    <Property name="verticalGap" type="int" value="12"/>
Lines 11-25 Link Here
11
  <SubComponents>
11
  <SubComponents>
12
    <Component class="javax.swing.JTextArea" name="jTextArea1">
12
    <Component class="javax.swing.JTextArea" name="jTextArea1">
13
      <Properties>
13
      <Properties>
14
        <Property name="wrapStyleWord" type="boolean" value="true"/>
15
        <Property name="lineWrap" type="boolean" value="true"/>
16
        <Property name="editable" type="boolean" value="false"/>
14
        <Property name="editable" type="boolean" value="false"/>
17
        <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
15
        <Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
18
          <Connection code="javax.swing.UIManager.getFont(&quot;Label.font&quot;)" type="code"/>
16
          <Connection code="javax.swing.UIManager.getFont(&quot;Label.font&quot;)" type="code"/>
19
        </Property>
17
        </Property>
18
        <Property name="lineWrap" type="boolean" value="true"/>
20
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
19
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
21
          <ResourceString bundle="org/netbeans/modules/java/imptool/Bundle.properties" key="IMPORT_PANEL_TEXT" replaceFormat="Util.getString(&quot;{key}&quot;)"/>
20
          <ResourceString bundle="org/netbeans/modules/java/imptool/Bundle.properties" key="IMPORT_PANEL_TEXT" replaceFormat="Util.getString(&quot;{key}&quot;)"/>
22
        </Property>
21
        </Property>
22
        <Property name="wrapStyleWord" type="boolean" value="true"/>
23
        <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
23
        <Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
24
          <Connection code="javax.swing.UIManager.getColor(&quot;Label.foreground&quot;)" type="code"/>
24
          <Connection code="javax.swing.UIManager.getColor(&quot;Label.foreground&quot;)" type="code"/>
25
        </Property>
25
        </Property>
(-)java/src/org/netbeans/modules/java/imptool/ImportPanel.java (-3 / +10 lines)
Lines 29-35 Link Here
29
 * @author  thurka
29
 * @author  thurka
30
 */
30
 */
31
class ImportPanel extends RootPanel {
31
class ImportPanel extends RootPanel {
32
33
    /** Creates new form importPanel */
32
    /** Creates new form importPanel */
34
    public ImportPanel() {
33
    public ImportPanel() {
35
    }
34
    }
Lines 44-54 Link Here
44
43
45
        setLayout(new java.awt.BorderLayout(0, 12));
44
        setLayout(new java.awt.BorderLayout(0, 12));
46
45
47
        jTextArea1.setWrapStyleWord(true);
48
        jTextArea1.setLineWrap(true);
49
        jTextArea1.setEditable(false);
46
        jTextArea1.setEditable(false);
50
        jTextArea1.setFont(javax.swing.UIManager.getFont("Label.font"));
47
        jTextArea1.setFont(javax.swing.UIManager.getFont("Label.font"));
48
        jTextArea1.setLineWrap(true);
51
        jTextArea1.setText(Util.getString("IMPORT_PANEL_TEXT"));
49
        jTextArea1.setText(Util.getString("IMPORT_PANEL_TEXT"));
50
        jTextArea1.setWrapStyleWord(true);
52
        jTextArea1.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));
51
        jTextArea1.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));
53
        jTextArea1.setEnabled(false);
52
        jTextArea1.setEnabled(false);
54
        jTextArea1.setOpaque(false);
53
        jTextArea1.setOpaque(false);
Lines 70-75 Link Here
70
        initListTableView(dataSource.createRootImportNode());
69
        initListTableView(dataSource.createRootImportNode());
71
        getAccessibleContext().setAccessibleName(Util.getString("ACS_ImportPanelA11yName"));  // NOI18N
70
        getAccessibleContext().setAccessibleName(Util.getString("ACS_ImportPanelA11yName"));  // NOI18N
72
        getAccessibleContext().setAccessibleDescription(Util.getString("ACS_ImportPanelA11yDesc"));  // NOI18N
71
        getAccessibleContext().setAccessibleDescription(Util.getString("ACS_ImportPanelA11yDesc"));  // NOI18N
72
        SettingsPanel settingspanel = new SettingsPanel();
73
        add (settingspanel, BorderLayout.SOUTH);
74
        settingspanel.addActionListener (
75
            new java.awt.event.ActionListener () {
76
                public void actionPerformed (java.awt.event.ActionEvent event) {
77
                    initListTableView (dataSource.createRootImportNode());
78
                }
79
        });
73
    }
80
    }
74
81
75
    String noRowsText() {
82
    String noRowsText() {
(-)java/src/org/netbeans/modules/java/imptool/SettingsPanel.java (+328 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-2000 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
/*
14
 * SettingsPanel.java
15
 * 
16
 * Created on April 24, 2002, 5:40 PM
17
 */
18
19
package org.netbeans.modules.java.imptool;
20
import java.awt.BorderLayout;
21
import java.awt.event.ActionEvent;
22
import java.awt.event.ActionListener;
23
import java.beans.*;
24
import java.util.ArrayList;
25
import javax.swing.*;
26
import javax.swing.event.EventListenerList;
27
import org.openide.nodes.*;
28
import org.openide.TopManager;
29
import org.openide.ErrorManager;
30
import org.openide.options.SystemOption;
31
import org.openide.util.NbBundle;
32
import org.openide.util.SharedClassObject;
33
34
/** A panel that displays the settings for the import management tool.  Includes a combobox that
35
 *  contains some easy-to-use defaults (displays a &quot;custom&quot; item if the defaults have
36
 *  been changed in Tools | Options) and an Advanced button for manually setting the settings.
37
 *  <P>The defaults are more or less low-noise, default and high-noise, in terms of raising the
38
 *  amounts of single imports and fully qualified names to be used.
39
 * @author Tim Boudreau
40
 * @version 0.1
41
 */
42
public class SettingsPanel extends JPanel implements PropertyChangeListener {
43
        //defaults for minimal fqn
44
    private static final int MIN_FQN = 0;
45
    private static final int MIN_SI = 2;
46
        //defaults for default fqn - XXX nd to check actual defaults
47
    private static final int DEF_FQN = 4;
48
    private static final int DEF_SI = 4;
49
        //defaults for maximal fqn
50
    private static final int MAX_FQN = 100;
51
    private static final int MAX_SI = 100;
52
    /** Flag to stop ActionPerformed events from being fired. */    
53
    private boolean isSetting = true;
54
    private ImpToolSettings settingsOption;
55
    private JComboBox chooserCombo;
56
    private JButton advancedButton;
57
    private SettingData customItem = null;
58
    private SettingData[] modelData=null;
59
    /** Flag variable to indicate when to ignore propertyChangeEvents (e.g. when the
60
     * component is the initiator) */    
61
    private boolean isChanging;
62
    /** Utility field used by event firing mechanism. */
63
    private EventListenerList listenerList =  null;
64
    
65
    /** Creates a new instance of SettingsPanel */
66
    public SettingsPanel() {
67
        init();
68
    }
69
    
70
    /** Create the initial components. */    
71
    private void init() {
72
        setLayout(new BorderLayout());
73
        JTextArea jta = new JTextArea(NbBundle.getBundle(SettingsPanel.class).getString("LBL_SETTINGCOMBO")); //NOI18N
74
        jta.setEditable(false);
75
        jta.setFont(javax.swing.UIManager.getFont("Label.font"));
76
        jta.setDisabledTextColor(javax.swing.UIManager.getColor("Label.foreground"));
77
        jta.setEnabled(false);
78
        jta.setOpaque(false);
79
        add(jta, BorderLayout.WEST);  
80
        chooserCombo = new JComboBox();
81
        add(chooserCombo, BorderLayout.CENTER);
82
        advancedButton = new JButton(NbBundle.getMessage(SettingsPanel.class, "LBL_ADVANCED"));  //NOI18N
83
        add (advancedButton, BorderLayout.EAST);
84
        ActionListener acl = new ActionListener () {
85
            public void actionPerformed(ActionEvent ev) {
86
                if (ev.getSource()==chooserCombo) {
87
                    if (isSetting) return;
88
                    SettingsPanel.this.processChooserEvent();
89
                } else {
90
                    SettingsPanel.this.processButtonEvent();
91
                }
92
            }
93
        };
94
        chooserCombo.addActionListener (acl);
95
        advancedButton.addActionListener(acl);
96
        initializeChooser();
97
    }
98
    
99
    /** Initialize the chooser with data reflecting the defaults, and if the current
100
     * settings are not a default, a Custom setting item to reflect those settings,
101
     * which will be the selected item. */    
102
    private void initializeChooser() {
103
        chooserCombo.setModel(new DefaultComboBoxModel (createModelData()));
104
        updateComponent();
105
    }
106
107
    /** Create the model for the dataModel for the combo box. */    
108
    private SettingData[] createModelData () {
109
        customItem = new SettingData();
110
        SettingData min = 
111
            new SettingData (MIN_FQN, MIN_SI,
112
            NbBundle.getBundle(SettingsPanel.class).getString("CHOICE_MINFQN")
113
            ); //NOI18N
114
        boolean currIsPreset = customItem.equals (min);
115
        SettingData def = 
116
            new SettingData (DEF_FQN, DEF_SI,
117
            NbBundle.getBundle(SettingsPanel.class).getString("CHOICE_DEFFQN")
118
            ); //NOI18N
119
        currIsPreset |= customItem.equals (def);
120
        SettingData max = 
121
            new SettingData (MAX_FQN, MAX_SI,
122
            NbBundle.getBundle(SettingsPanel.class).getString("CHOICE_MAXFQN")
123
            ); //NOI18N
124
            //if there are some non-default settings in Options, use them and make default
125
        currIsPreset |= customItem.equals (max);
126
        if (currIsPreset) {
127
            modelData = new SettingData[] {
128
                min, def, max
129
            };
130
        } else {
131
            modelData = new SettingData[] {
132
                customItem, min, def, max
133
            };
134
        }
135
        return modelData;
136
    }
137
    
138
    /** Synchronize the combo-box and tooltip with the current settings.  If the
139
     * settings have changed, see if the setting is one of the defaults.  If not,
140
     * create (or select if already created) the Custom settings item and select it. */    
141
    public void updateComponent () {
142
        int itemIndex=-1;
143
        for (int i=0; i < modelData.length; i++) {
144
            if (modelData[i].isCurrent()) {
145
                itemIndex=i;
146
                break;
147
            }
148
        }
149
        isSetting = true;
150
        if (itemIndex >=0) {
151
            chooserCombo.setSelectedIndex(itemIndex);
152
        } else {
153
            if (modelData.length == 3) {
154
                addCustomItem();
155
            }
156
            chooserCombo.setSelectedIndex(0);
157
            customItem.update();
158
        }  
159
        isSetting = false;
160
    updateChooserTooltip();
161
    }
162
    
163
    /** Create the custom item and add it to the combo box. */    
164
    private void addCustomItem () {
165
        //regen the array w/ added CustomItem
166
        modelData = new SettingData[] {
167
            modelData[0], modelData[1], modelData[2], customItem
168
        };
169
        customItem.update();
170
        chooserCombo.setModel(new DefaultComboBoxModel (createModelData()));
171
    }
172
    
173
    /** Update the tooltip to reflect the current settings. */    
174
    private void updateChooserTooltip () {
175
        StringBuffer sb = new StringBuffer();
176
        sb.append (NbBundle.getBundle (SettingsPanel.class).getString ("TT_FQN")); //NOI18N
177
        sb.append (getSettings().getMaxFqn());
178
        sb.append (" "); //NOI18N
179
        sb.append (NbBundle.getBundle (SettingsPanel.class).getString ("TT_SI")); //NOI18N
180
        sb.append (getSettings().getSingleImports());
181
        chooserCombo.setToolTipText(sb.toString());
182
    }
183
    
184
    /** Is the current item one of the defaults? */    
185
    
186
    /** Called when the component gets a parent.  Adds a propertyChangeListener to
187
     * the settings node. */    
188
    public void addNotify() {
189
        getSettings().addPropertyChangeListener(this);
190
        super.addNotify();
191
    }
192
    
193
    /** Called when the component is removed from a window.  Remove listeners. */    
194
    public void removeNotify() {
195
        super.removeNotify();
196
        getSettings().removePropertyChangeListener(this);
197
    }
198
    
199
    /** Returns a SystemOption representing the settings for the import management tool. */    
200
    private ImpToolSettings getSettings() {
201
        if (settingsOption == null) {
202
            settingsOption = (ImpToolSettings) SharedClassObject.findObject (ImpToolSettings.class, true);
203
        }
204
        return settingsOption;
205
    }
206
    
207
    /** Handle a selection being made in the combo-box. */    
208
    private final void processChooserEvent() {
209
        SettingData selectedChoice = (SettingData) chooserCombo.getSelectedItem();
210
        ImpToolSettings its = getSettings();
211
        isChanging = true;
212
        its.setMaxFqn (selectedChoice.maxfqn);
213
        its.setSingleImports (selectedChoice.singleimports);
214
        isChanging = false;
215
        updateComponent();
216
        fireActionPerformed();
217
    }
218
    
219
    /** Handle the button being clicked by bringing up a property sheet. */    
220
    private synchronized final void processButtonEvent() {
221
        //display advanced dialog here
222
        Node n=null;
223
        try {
224
            n = new BeanNode (getSettings());
225
        } catch (IntrospectionException e) {
226
            ErrorManager errMan=TopManager.getDefault().getErrorManager();
227
            if (errMan!=null) {
228
                errMan.annotate(e, e.getMessage());
229
            }
230
        }
231
    TopManager.getDefault().getNodeOperation().showProperties(n);
232
    }
233
    
234
    /** Registers ActionListener to receive events.
235
     * @param listener The listener to register.
236
     */
237
    public synchronized void addActionListener(ActionListener listener) {
238
        if (listenerList == null ) {
239
            listenerList = new EventListenerList();
240
        }
241
        listenerList.add(ActionListener.class, listener);
242
    }    
243
    
244
    /** Removes ActionListener from the list of listeners.
245
     * @param listener The listener to remove.
246
     */
247
    public synchronized void removeActionListener(ActionListener listener) {
248
        listenerList.remove(ActionListener.class, listener);
249
    }
250
    
251
    /** Notifies all registered listeners about the event.
252
     *
253
     * @param event The event to be fired
254
     */
255
    private void fireActionPerformed() {
256
        if (isSetting) return;
257
        if (listenerList == null) return;
258
        ActionEvent event = new ActionEvent(this, 0, null);
259
        Object[] listeners = listenerList.getListenerList();
260
        for (int i = listeners.length-2; i>=0; i-=2) {
261
            if (listeners[i]==ActionListener.class) {
262
                ((ActionListener)listeners[i+1]).actionPerformed(event);
263
            }
264
        }
265
    }
266
    
267
    /** Called when a property change is fired on the settings object.  Since any change
268
     * we perform will result in two propertyChangeEvents, we must be careful not to
269
     * prematurely update the components and fire ActionPerformed events.
270
     * @param propertyChangeEvent The event in question */    
271
    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
272
        //don't update from here during property change because changing
273
        //presets creates two property change events.
274
        if (!isChanging) {
275
            updateComponent(); 
276
            fireActionPerformed();
277
        }
278
    }
279
280
    /** Wrapper class for the defaults. */    
281
    private class SettingData extends Object {
282
        private String name;
283
        int maxfqn = 0;
284
        int singleimports = 0;
285
286
        /** Create a new SettingData object which will initialize itself from the current
287
         * settings for the IDE. */        
288
        private SettingData () {
289
            update();
290
            name = NbBundle.getBundle (SettingsPanel.class).getString("CHOICE_CUSTOM"); //NOI18N
291
        }
292
        
293
        private void update () {
294
            ImpToolSettings its = getSettings();
295
            this.maxfqn = its.getMaxFqn();
296
            this.singleimports = its.getSingleImports();
297
        }
298
        
299
        /** Create a SettingData object and initialize it with explicit values. */        
300
        private SettingData (int maxfqn, int singleimports, String name) {
301
            this.maxfqn = maxfqn;
302
            this.singleimports = singleimports;
303
            this.name = name;
304
        }
305
        
306
        /** See if this item matches the current settings for the IDE. */        
307
        public boolean isCurrent () {
308
            ImpToolSettings its = getSettings();
309
            return (its.getMaxFqn() == maxfqn) && 
310
                   (its.getSingleImports() == singleimports);
311
        }
312
        
313
        public String toString () {
314
            return name;
315
        }
316
        
317
        /** See if the values represented by this item match another (does not compare the
318
         * name property). */        
319
        public boolean equals (Object o) {
320
            if (o.getClass() != SettingData.class) return false;
321
            boolean result = 
322
              ((((SettingData) o).maxfqn == maxfqn) &&
323
              (((SettingData) o).singleimports == singleimports));
324
            return result;
325
        }
326
    }
327
    
328
}

Return to bug 22432