KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > wizard > action > GUIRegistrationPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.ui.wizard.action;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.EventQueue JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.util.ArrayList JavaDoc;
26 import java.util.Collection JavaDoc;
27 import java.util.Collections JavaDoc;
28 import java.util.Enumeration JavaDoc;
29 import java.util.Iterator JavaDoc;
30 import java.util.LinkedHashSet JavaDoc;
31 import java.util.List JavaDoc;
32 import java.util.Vector JavaDoc;
33 import javax.swing.DefaultComboBoxModel JavaDoc;
34 import javax.swing.DefaultListCellRenderer JavaDoc;
35 import javax.swing.DefaultListModel JavaDoc;
36 import javax.swing.JCheckBox JavaDoc;
37 import javax.swing.JComboBox JavaDoc;
38 import javax.swing.JComponent JavaDoc;
39 import javax.swing.JLabel JavaDoc;
40 import javax.swing.JList JavaDoc;
41 import javax.swing.JTextField JavaDoc;
42 import javax.swing.KeyStroke JavaDoc;
43 import javax.swing.ListCellRenderer JavaDoc;
44 import javax.swing.event.DocumentEvent JavaDoc;
45 import javax.swing.event.PopupMenuEvent JavaDoc;
46 import javax.swing.event.PopupMenuListener JavaDoc;
47 import javax.swing.plaf.UIResource JavaDoc;
48 import org.netbeans.modules.apisupport.project.Util;
49 import org.netbeans.modules.apisupport.project.layers.LayerUtils;
50 import org.netbeans.modules.apisupport.project.ui.UIUtil;
51 import org.netbeans.modules.apisupport.project.ui.UIUtil.LayerItemPresenter;
52 import org.netbeans.modules.apisupport.project.ui.customizer.CustomizerComponentFactory;
53 import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator;
54 import org.netbeans.modules.apisupport.project.ui.wizard.action.DataModel.Position;
55 import org.openide.WizardDescriptor;
56 import org.openide.filesystems.FileObject;
57 import org.openide.filesystems.FileSystem;
58 import org.openide.filesystems.FileUtil;
59 import org.openide.loaders.DataFolder;
60 import org.openide.loaders.DataObject;
61 import org.openide.util.HelpCtx;
62 import org.openide.util.NbBundle;
63 import org.openide.util.RequestProcessor;
64
65 /**
66  * The second panel in the <em>New Action Wizard</em>.
67  *
68  * @author Martin Krauskopf
69  */

70 final class GUIRegistrationPanel extends BasicWizardIterator.Panel {
71     
72     private final RequestProcessor SFS_RP = new RequestProcessor(GUIRegistrationPanel.class.getName());
73     private static final String JavaDoc ACTIONS_DIR = "Actions"; // NOI18N
74

75     private FileSystem sfs;
76     
77     private final ListCellRenderer JavaDoc POSITION_RENDERER = new PositionRenderer();
78     private static final String JavaDoc POSITION_HERE = getMessage("CTL_PositionHere");
79     private static final String JavaDoc POSITION_SEPARATOR = " - "; // NOI18N
80

81     private DataModel data;
82     
83     private final JComponent JavaDoc[] gmiGroup;
84     private final JComponent JavaDoc[] toolbarGroup;
85     private final JComponent JavaDoc[] shortcutGroup;
86     private final JComponent JavaDoc[] fileTypeGroup;
87     private final JComponent JavaDoc[] editorGroup;
88     
89     public GUIRegistrationPanel(final WizardDescriptor setting, final DataModel data) {
90         super(setting);
91         this.data = data;
92         initComponents();
93         initAccesibility();
94         putClientProperty("NewFileWizard_Title", getMessage("LBL_ActionWizardTitle"));
95         
96         menu.addPopupMenuListener(new PML(menu, menuPosition));
97         toolbar.addPopupMenuListener(new PML(toolbar, toolbarPosition));
98         ftContentType.addPopupMenuListener(new PML(ftContentType, ftPosition));
99         edContentType.addPopupMenuListener(new PML(edContentType, edPosition));
100         gmiGroup = new JComponent JavaDoc[] {
101             menu, menuTxt, menuPosition, menuPositionTxt, menuSeparatorAfter, menuSeparatorBefore
102         };
103         toolbarGroup = new JComponent JavaDoc[] {
104             toolbar, toolbarTxt, toolbarPosition, toolbarPositionTxt
105         };
106         shortcutGroup = new JComponent JavaDoc[] {
107             shortcutsList, keyStrokeTxt, keyStrokeChange, keyStrokeRemove
108         };
109         fileTypeGroup = new JComponent JavaDoc[] {
110             ftContentType, ftContentTypeTxt, ftPosition, ftPositionTxt, ftSeparatorAfter, ftSeparatorBefore
111         };
112         editorGroup = new JComponent JavaDoc[] {
113             edContentType, edContentTypeTxt, edPosition, edPositionTxt, edSeparatorAfter, edSeparatorBefore
114         };
115         readSFS();
116     }
117     
118     private void setEditable(final JComboBox JavaDoc combo) {
119         combo.setEditable(true);
120         if (combo.getEditor().getEditorComponent() instanceof JTextField JavaDoc) {
121             JTextField JavaDoc txt = (JTextField JavaDoc) combo.getEditor().getEditorComponent();
122             // XXX check if there are not multiple (--> redundant) listeners
123
txt.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
124                 public void insertUpdate(DocumentEvent JavaDoc e) {
125                     if (!CustomizerComponentFactory.isWaitModel(combo.getModel())) {
126                         checkValidity();
127                     }
128                 }
129             });
130         }
131     }
132     
133     protected String JavaDoc getPanelName() {
134         return getMessage("LBL_GUIRegistration_Title");
135     }
136     
137     private String JavaDoc getCategoryPath() {
138         String JavaDoc path = UIUtil.getSFSPath(category, ACTIONS_DIR);
139         return path == null ? ACTIONS_DIR + '/' + "Tools" : path; // NOI18N
140
}
141     
142     protected void storeToDataModel() {
143         // XXX this is just a prevention for the case when the user press Back button - should be ensured by a wizard (issue 63142)
144
if (!checkValidity()) {
145             return;
146         }
147         // second panel data (GUI Registration)
148
data.setCategory(getCategoryPath());
149         // global menu item
150
data.setGlobalMenuItemEnabled(globalMenuItem.isSelected());
151         if (globalMenuItem.isSelected()) {
152             data.setGMIParentMenu(getSelectedLayerPresenter(menu).getFullPath());
153             data.setGMIPosition((Position) menuPosition.getSelectedItem());
154             data.setGMISeparatorAfter(menuSeparatorAfter.isSelected());
155             data.setGMISeparatorBefore(menuSeparatorBefore.isSelected());
156         }
157         // global toolbar button
158
data.setToolbarEnabled(globalToolbarButton.isSelected());
159         if (globalToolbarButton.isSelected()) {
160             data.setToolbar(getSelectedLayerPresenter(toolbar).getFullPath());
161             data.setToolbarPosition((Position) toolbarPosition.getSelectedItem());
162         }
163         // global keyboard shortcut
164
data.setKeyboardShortcutEnabled(globalKeyboardShortcut.isSelected());
165         // file type context menu item
166
data.setFileTypeContextEnabled(fileTypeContext.isSelected());
167         if (fileTypeContext.isSelected()) {
168             data.setFTContextType(getSelectedLayerPresenter(ftContentType).getFullPath());
169             data.setFTContextPosition((Position) ftPosition.getSelectedItem());
170             data.setFTContextSeparatorBefore(ftSeparatorBefore.isSelected());
171             data.setFTContextSeparatorAfter(ftSeparatorAfter.isSelected());
172         }
173         // editor context menu item
174
data.setEditorContextEnabled(editorContext.isSelected());
175         if (editorContext.isSelected()) {
176             data.setEdContextType(getSelectedLayerPresenter(edContentType).getFullPath());
177             data.setEdContextPosition((Position) edPosition.getSelectedItem());
178             data.setEdContextSeparatorBefore(edSeparatorBefore.isSelected());
179             data.setEdContextSeparatorAfter(edSeparatorAfter.isSelected());
180         }
181     }
182     
183     protected void readFromDataModel() {
184         initializeGlobalAction();
185         checkValidity();
186     }
187     
188     private void initializeGlobalAction() {
189         globalMenuItem.setSelected(true);
190         
191         globalMenuItem.setEnabled(true);
192         setGroupEnabled(gmiGroup, globalMenuItem.isSelected());
193         
194         globalToolbarButton.setEnabled(true);
195         setGroupEnabled(toolbarGroup, globalToolbarButton.isSelected());
196         
197         boolean alwaysEnabled = data.isAlwaysEnabled();
198         globalKeyboardShortcut.setEnabled(alwaysEnabled);
199         setShortcutGroupEnabled();
200         
201         if (alwaysEnabled) {
202             fileTypeContext.setSelected(false);
203             editorContext.setSelected(false);
204         }
205         fileTypeContext.setEnabled(!alwaysEnabled);
206         setGroupEnabled(fileTypeGroup, fileTypeContext.isSelected());
207         
208         editorContext.setEnabled(!alwaysEnabled);
209         setGroupEnabled(editorGroup, editorContext.isSelected());
210     }
211     
212     /** Package private for unit tests only. */
213     boolean checkValidity() {
214         boolean result = false;
215         if (globalKeyboardShortcut.isSelected() && ((DefaultListModel JavaDoc)shortcutsList.getModel()).isEmpty()) { // NOI18N
216
setError(getMessage("MSG_YouMustSpecifyShortcut"));
217         } else if (!check(globalMenuItem, menu, menuPosition) ||
218                 !check(globalToolbarButton, toolbar, toolbarPosition) ||
219                 !check(fileTypeContext, ftContentType, ftPosition) ||
220                 !check(editorContext, edContentType, edPosition)) {
221             markInvalid();
222         } else if (!Util.isValidSFSPath(getCategoryPath())) {
223             setError(getMessage("ERR_Category_Invalid"));
224         } else {
225             markValid();
226             result = true;
227         }
228         return result;
229     }
230     
231     private boolean check(JCheckBox JavaDoc groupCheckBox, JComboBox JavaDoc menu, JComboBox JavaDoc position) {
232         boolean result = !groupCheckBox.isSelected() ||
233                 (getSelectedItem(menu) != null && getSelectedItem(position) != null);
234         return result;
235     }
236     
237     private void setGroupEnabled(JComponent JavaDoc[] group, boolean enabled) {
238         for (int i = 0; i < group.length; i++) {
239             if (group[i] != null) {
240                 group[i].setEnabled(enabled && !isEmptyCombo(group[i]));
241             }
242         }
243     }
244
245     private void setShortcutGroupEnabled() {
246         boolean isEnabled = globalKeyboardShortcut.isSelected();
247         setGroupEnabled(shortcutGroup, isEnabled);
248         isEnabled = isEnabled && shortcutsList.getSelectedValues().length > 0;
249         keyStrokeRemove.setEnabled(isEnabled);
250     }
251
252     private boolean isEmptyCombo(JComponent JavaDoc c) {
253         return c instanceof JComboBox JavaDoc &&
254                 CustomizerComponentFactory.hasOnlyValue(((JComboBox JavaDoc) c).getModel(), CustomizerComponentFactory.EMPTY_VALUE);
255     }
256     
257     private void readSFS() {
258         markInvalid();
259         loadComboAndPositions(ACTIONS_DIR, category, null, null, true);
260         loadComboAndPositions("Menu", menu, menuPosition, null); // NOI18N
261
loadComboAndPositions("Toolbars", toolbar, toolbarPosition, null); // NOI18N
262
loadComboAndPositions("Loaders", ftContentType, ftPosition, "Actions"); // NOI18N
263
loadComboAndPositions("Editors", edContentType, edPosition, "Popup"); // NOI18N
264
}
265     
266     private void loadComboAndPositions(final String JavaDoc startFolder,
267             final JComboBox JavaDoc combo,
268             final JComboBox JavaDoc comboPositions,
269             final String JavaDoc subFolderName) {
270         loadComboAndPositions(startFolder, combo, comboPositions, subFolderName, false);
271     }
272     
273     /** See {@link #getFoldersByName(DataFolder, String)} for subFolderName explanation . */
274     private void loadComboAndPositions(final String JavaDoc startFolder,
275             final JComboBox JavaDoc combo,
276             final JComboBox JavaDoc comboPositions,
277             final String JavaDoc subFolderName,
278             final boolean editable) {
279         combo.setModel(CustomizerComponentFactory.createComboWaitModel());
280         SFS_RP.post(new Runnable JavaDoc() {
281             public void run() {
282                 Util.err.log("Loading " + startFolder + " from SFS...."); // NOI18N
283
final FileObject parent = getSFS().getRoot().getFileObject(startFolder);
284                 final DataFolder parentDF = (parent != null ? DataFolder.findFolder(parent) : null);
285                 if (parentDF == null) {
286                     Util.err.log("Could not find " + startFolder);
287                     setEmptyModel(combo);
288                     setEmptyModel(comboPositions);
289                     return;
290                 }
291                 final Enumeration JavaDoc folders = subFolderName == null
292                         ? getFolders(parentDF) : getFoldersByName(parentDF, subFolderName);
293                 EventQueue.invokeLater(new Runnable JavaDoc() {
294                     public void run() {
295                         Collection JavaDoc<LayerItemPresenter> sorted = new LinkedHashSet JavaDoc();
296                         while (folders.hasMoreElements()) {
297                             DataFolder folder = (DataFolder) folders.nextElement();
298                             sorted.add(new LayerItemPresenter(folder.getPrimaryFile(), parent, subFolderName != null));
299                         }
300                         if (sorted.size() == 0) {
301                             setEmptyModel(combo);
302                             setEmptyModel(comboPositions);
303                         } else {
304                             // create model
305
DefaultComboBoxModel JavaDoc model = new DefaultComboBoxModel JavaDoc();
306                             for (Iterator JavaDoc it = sorted.iterator(); it.hasNext(); ) {
307                                 model.addElement(it.next());
308                             }
309                             combo.setModel(model);
310                             if (editable) {
311                                 setEditable(combo);
312                             }
313                             // load positions combo
314
if (comboPositions != null) {
315                                 loadPositionsCombo((LayerItemPresenter) combo.getSelectedItem(),
316                                         comboPositions);
317                             }
318                         }
319                     }
320                 });
321             }
322         });
323     }
324
325     private void loadPositionsCombo(
326             final LayerItemPresenter parent,
327             final JComboBox JavaDoc positionsCombo) {
328         
329         assert parent != null;
330         assert positionsCombo != null;
331         positionsCombo.setModel(CustomizerComponentFactory.createComboWaitModel());
332         SFS_RP.post(new Runnable JavaDoc() {
333             public void run() {
334                 DataObject[] kids = DataFolder.findFolder(parent.getFileObject()).getChildren(); // #71820: sort!
335
final FileObject[] files = new FileObject[kids.length];
336                 for (int i = 0; i < kids.length; i++) {
337                     files[i] = kids[i].getPrimaryFile();
338                 }
339                 EventQueue.invokeLater(new Runnable JavaDoc() {
340                     public void run() {
341                         createPositionModel(positionsCombo, files, parent);
342                     }
343                 });
344             }
345         });
346     }
347     
348     private void createPositionModel(final JComboBox JavaDoc positionsCombo,
349             final FileObject[] files,
350             final LayerItemPresenter parent) {
351         DefaultComboBoxModel JavaDoc newModel = new DefaultComboBoxModel JavaDoc();
352         LayerItemPresenter previous = null;
353         for (int i = 0; i < files.length; i++) {
354             LayerItemPresenter current = new LayerItemPresenter(
355                     files[i],
356                     parent.getFileObject());
357             newModel.addElement(createPosition(previous, current));
358             previous = current;
359         }
360         newModel.addElement(createPosition(previous, null));
361         positionsCombo.setModel(newModel);
362         checkValidity();
363     }
364    
365     private static Object JavaDoc getSelectedItem(final JComboBox JavaDoc combo) {
366         Object JavaDoc item = combo.getSelectedItem();
367         return (item == CustomizerComponentFactory.WAIT_VALUE || item == CustomizerComponentFactory.EMPTY_VALUE) ? null : item;
368     }
369     
370     private static LayerItemPresenter getSelectedLayerPresenter(final JComboBox JavaDoc combo) {
371         return (LayerItemPresenter) getSelectedItem(combo);
372     }
373     
374     private static Position createPosition(LayerItemPresenter first, LayerItemPresenter second) {
375         return new Position(
376                 first == null ? null : first.getFileObject().getNameExt(),
377                 second == null ? null : second.getFileObject().getNameExt(),
378                 first == null ? null : first.getDisplayName(),
379                 second == null ? null : second.getDisplayName());
380     }
381     
382     private void setEmptyModel(JComboBox JavaDoc combo) {
383         if (combo != null) {
384             combo.setModel(CustomizerComponentFactory.createComboEmptyModel());
385             combo.setEnabled(false);
386             combo.setEditable(false);
387             checkValidity();
388         }
389     }
390     
391     protected HelpCtx getHelp() {
392         return new HelpCtx(GUIRegistrationPanel.class);
393     }
394     
395     private static String JavaDoc getMessage(String JavaDoc key) {
396         return NbBundle.getMessage(GUIRegistrationPanel.class, key);
397     }
398     
399     /** This method is called from within the constructor to
400      * initialize the form.
401      * WARNING: Do NOT modify this code. The content of this method is
402      * always regenerated by the Form Editor.
403      */

404     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
405
private void initComponents() {
406         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
407
408         categoryTxt = new javax.swing.JLabel JavaDoc();
409         category = new javax.swing.JComboBox JavaDoc();
410         globalMenuItem = new javax.swing.JCheckBox JavaDoc();
411         menuTxt = new javax.swing.JLabel JavaDoc();
412         menu = new javax.swing.JComboBox JavaDoc();
413         menuPositionTxt = new javax.swing.JLabel JavaDoc();
414         menuPosition = new javax.swing.JComboBox JavaDoc();
415         menuSeparatorPanel = new javax.swing.JPanel JavaDoc();
416         menuSeparatorBefore = new javax.swing.JCheckBox JavaDoc();
417         menuSeparatorAfter = new javax.swing.JCheckBox JavaDoc();
418         globalToolbarButton = new javax.swing.JCheckBox JavaDoc();
419         toolbarTxt = new javax.swing.JLabel JavaDoc();
420         toolbar = new javax.swing.JComboBox JavaDoc();
421         toolbarPositionTxt = new javax.swing.JLabel JavaDoc();
422         toolbarPosition = new javax.swing.JComboBox JavaDoc();
423         globalKeyboardShortcut = new javax.swing.JCheckBox JavaDoc();
424         keyStrokeTxt = new javax.swing.JLabel JavaDoc();
425         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
426         shortcutsList = new JList JavaDoc(new DefaultListModel JavaDoc());
427         keyStrokeChange = new javax.swing.JButton JavaDoc();
428         keyStrokeRemove = new javax.swing.JButton JavaDoc();
429         filler = new javax.swing.JLabel JavaDoc();
430         fileTypeContext = new javax.swing.JCheckBox JavaDoc();
431         ftContentTypeTxt = new javax.swing.JLabel JavaDoc();
432         ftContentType = new javax.swing.JComboBox JavaDoc();
433         ftPositionTxt = new javax.swing.JLabel JavaDoc();
434         ftPosition = new javax.swing.JComboBox JavaDoc();
435         ftSeparatorPanel = new javax.swing.JPanel JavaDoc();
436         ftSeparatorBefore = new javax.swing.JCheckBox JavaDoc();
437         ftSeparatorAfter = new javax.swing.JCheckBox JavaDoc();
438         editorContext = new javax.swing.JCheckBox JavaDoc();
439         edContentTypeTxt = new javax.swing.JLabel JavaDoc();
440         edContentType = new javax.swing.JComboBox JavaDoc();
441         edPositionTxt = new javax.swing.JLabel JavaDoc();
442         edPosition = new javax.swing.JComboBox JavaDoc();
443         edSeparatorPanel = new javax.swing.JPanel JavaDoc();
444         edSeparatorBefore = new javax.swing.JCheckBox JavaDoc();
445         edSeparatorAfter = new javax.swing.JCheckBox JavaDoc();
446
447         setLayout(new java.awt.GridBagLayout JavaDoc());
448
449         categoryTxt.setLabelFor(category);
450         org.openide.awt.Mnemonics.setLocalizedText(categoryTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Category"));
451         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
452         gridBagConstraints.gridx = 0;
453         gridBagConstraints.gridy = 0;
454         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
455         add(categoryTxt, gridBagConstraints);
456
457         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
458         gridBagConstraints.gridx = 1;
459         gridBagConstraints.gridy = 0;
460         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
461         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
462         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
463         gridBagConstraints.weightx = 1.0;
464         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 0, 0);
465         add(category, gridBagConstraints);
466
467         org.openide.awt.Mnemonics.setLocalizedText(globalMenuItem, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_GlobalMenuItem"));
468         globalMenuItem.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
469         globalMenuItem.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
470         globalMenuItem.addActionListener(new java.awt.event.ActionListener JavaDoc() {
471             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
472                 globalMenuItemActionPerformed(evt);
473             }
474         });
475
476         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
477         gridBagConstraints.gridx = 0;
478         gridBagConstraints.gridy = 1;
479         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
480         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
481         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 3, 0);
482         add(globalMenuItem, gridBagConstraints);
483
484         menuTxt.setLabelFor(menu);
485         org.openide.awt.Mnemonics.setLocalizedText(menuTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Menu"));
486         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
487         gridBagConstraints.gridx = 0;
488         gridBagConstraints.gridy = 2;
489         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
490         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
491         add(menuTxt, gridBagConstraints);
492
493         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
494         gridBagConstraints.gridx = 1;
495         gridBagConstraints.gridy = 2;
496         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
497         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
498         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
499         gridBagConstraints.weightx = 1.0;
500         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
501         add(menu, gridBagConstraints);
502
503         menuPositionTxt.setLabelFor(menuPosition);
504         org.openide.awt.Mnemonics.setLocalizedText(menuPositionTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Position"));
505         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
506         gridBagConstraints.gridx = 0;
507         gridBagConstraints.gridy = 3;
508         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
509         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
510         add(menuPositionTxt, gridBagConstraints);
511
512         menuPosition.setRenderer(POSITION_RENDERER);
513         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
514         gridBagConstraints.gridx = 1;
515         gridBagConstraints.gridy = 3;
516         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
517         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
518         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
519         gridBagConstraints.weightx = 1.0;
520         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
521         add(menuPosition, gridBagConstraints);
522
523         menuSeparatorPanel.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 0));
524
525         org.openide.awt.Mnemonics.setLocalizedText(menuSeparatorBefore, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorBefore"));
526         menuSeparatorBefore.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
527         menuSeparatorPanel.add(menuSeparatorBefore);
528
529         org.openide.awt.Mnemonics.setLocalizedText(menuSeparatorAfter, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorAfter"));
530         menuSeparatorAfter.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 6, 0, 0));
531         menuSeparatorAfter.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
532         menuSeparatorPanel.add(menuSeparatorAfter);
533
534         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
535         gridBagConstraints.gridx = 0;
536         gridBagConstraints.gridy = 4;
537         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
538         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
539         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 0, 0);
540         add(menuSeparatorPanel, gridBagConstraints);
541
542         org.openide.awt.Mnemonics.setLocalizedText(globalToolbarButton, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_GlobalToolbarButton"));
543         globalToolbarButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
544         globalToolbarButton.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
545         globalToolbarButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
546             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
547                 globalToolbarButtonActionPerformed(evt);
548             }
549         });
550
551         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
552         gridBagConstraints.gridx = 0;
553         gridBagConstraints.gridy = 5;
554         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
555         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
556         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 3, 0);
557         add(globalToolbarButton, gridBagConstraints);
558
559         toolbarTxt.setLabelFor(toolbar);
560         org.openide.awt.Mnemonics.setLocalizedText(toolbarTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Toolbar"));
561         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
562         gridBagConstraints.gridx = 0;
563         gridBagConstraints.gridy = 6;
564         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
565         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
566         add(toolbarTxt, gridBagConstraints);
567
568         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
569         gridBagConstraints.gridx = 1;
570         gridBagConstraints.gridy = 6;
571         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
572         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
573         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
574         gridBagConstraints.weightx = 1.0;
575         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
576         add(toolbar, gridBagConstraints);
577
578         toolbarPositionTxt.setLabelFor(toolbarPosition);
579         org.openide.awt.Mnemonics.setLocalizedText(toolbarPositionTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Position"));
580         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
581         gridBagConstraints.gridx = 0;
582         gridBagConstraints.gridy = 7;
583         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
584         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
585         add(toolbarPositionTxt, gridBagConstraints);
586
587         toolbarPosition.setRenderer(POSITION_RENDERER);
588         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
589         gridBagConstraints.gridx = 1;
590         gridBagConstraints.gridy = 7;
591         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
592         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
593         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
594         gridBagConstraints.weightx = 1.0;
595         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
596         add(toolbarPosition, gridBagConstraints);
597
598         org.openide.awt.Mnemonics.setLocalizedText(globalKeyboardShortcut, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_GlobalKeyboardShortcut"));
599         globalKeyboardShortcut.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
600         globalKeyboardShortcut.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
601         globalKeyboardShortcut.addActionListener(new java.awt.event.ActionListener JavaDoc() {
602             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
603                 globalKeyboardShortcutActionPerformed(evt);
604             }
605         });
606
607         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
608         gridBagConstraints.gridx = 0;
609         gridBagConstraints.gridy = 8;
610         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
611         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
612         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 3, 0);
613         add(globalKeyboardShortcut, gridBagConstraints);
614
615         keyStrokeTxt.setLabelFor(menuPosition);
616         org.openide.awt.Mnemonics.setLocalizedText(keyStrokeTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_KeyStroke"));
617         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
618         gridBagConstraints.gridx = 0;
619         gridBagConstraints.gridy = 9;
620         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
621         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
622         add(keyStrokeTxt, gridBagConstraints);
623
624         shortcutsList.setVisibleRowCount(3);
625         shortcutsList.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
626             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
627                 shortcutsListChanged(evt);
628             }
629         });
630
631         jScrollPane1.setViewportView(shortcutsList);
632
633         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
634         gridBagConstraints.gridx = 1;
635         gridBagConstraints.gridy = 9;
636         gridBagConstraints.gridheight = 2;
637         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
638         gridBagConstraints.weightx = 1.0;
639         gridBagConstraints.weighty = 1.0;
640         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
641         add(jScrollPane1, gridBagConstraints);
642
643         org.openide.awt.Mnemonics.setLocalizedText(keyStrokeChange, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "CTL_Change"));
644         keyStrokeChange.addActionListener(new java.awt.event.ActionListener JavaDoc() {
645             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
646                 keyStrokeChangeActionPerformed(evt);
647             }
648         });
649
650         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
651         gridBagConstraints.gridx = 2;
652         gridBagConstraints.gridy = 9;
653         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
654         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
655         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
656         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
657         add(keyStrokeChange, gridBagConstraints);
658
659         org.openide.awt.Mnemonics.setLocalizedText(keyStrokeRemove, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/wizard/action/Bundle").getString("CTL_Remove"));
660         keyStrokeRemove.addActionListener(new java.awt.event.ActionListener JavaDoc() {
661             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
662                 keyStrokeRemoveActionPerformed(evt);
663             }
664         });
665
666         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
667         gridBagConstraints.gridx = 2;
668         gridBagConstraints.gridy = 10;
669         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
670         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
671         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
672         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
673         add(keyStrokeRemove, gridBagConstraints);
674
675         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
676         gridBagConstraints.gridx = 1;
677         gridBagConstraints.gridy = 19;
678         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
679         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
680         gridBagConstraints.weightx = 1.0;
681         gridBagConstraints.weighty = 1.0;
682         add(filler, gridBagConstraints);
683
684         org.openide.awt.Mnemonics.setLocalizedText(fileTypeContext, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_FileTypeContextMenuItem"));
685         fileTypeContext.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
686         fileTypeContext.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
687         fileTypeContext.addActionListener(new java.awt.event.ActionListener JavaDoc() {
688             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
689                 fileTypeContextActionPerformed(evt);
690             }
691         });
692
693         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
694         gridBagConstraints.gridx = 0;
695         gridBagConstraints.gridy = 11;
696         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
697         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
698         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 3, 0);
699         add(fileTypeContext, gridBagConstraints);
700
701         ftContentTypeTxt.setLabelFor(ftContentType);
702         org.openide.awt.Mnemonics.setLocalizedText(ftContentTypeTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_ContentType"));
703         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
704         gridBagConstraints.gridx = 0;
705         gridBagConstraints.gridy = 12;
706         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
707         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
708         add(ftContentTypeTxt, gridBagConstraints);
709
710         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
711         gridBagConstraints.gridx = 1;
712         gridBagConstraints.gridy = 12;
713         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
714         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
715         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
716         gridBagConstraints.weightx = 1.0;
717         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
718         add(ftContentType, gridBagConstraints);
719
720         ftPositionTxt.setLabelFor(ftPosition);
721         org.openide.awt.Mnemonics.setLocalizedText(ftPositionTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Position"));
722         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
723         gridBagConstraints.gridx = 0;
724         gridBagConstraints.gridy = 13;
725         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
726         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
727         add(ftPositionTxt, gridBagConstraints);
728
729         ftPosition.setRenderer(POSITION_RENDERER);
730         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
731         gridBagConstraints.gridx = 1;
732         gridBagConstraints.gridy = 13;
733         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
734         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
735         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
736         gridBagConstraints.weightx = 1.0;
737         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
738         add(ftPosition, gridBagConstraints);
739
740         ftSeparatorPanel.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 0));
741
742         org.openide.awt.Mnemonics.setLocalizedText(ftSeparatorBefore, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorBefore"));
743         ftSeparatorBefore.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
744         ftSeparatorPanel.add(ftSeparatorBefore);
745
746         org.openide.awt.Mnemonics.setLocalizedText(ftSeparatorAfter, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorAfter"));
747         ftSeparatorAfter.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 6, 0, 0));
748         ftSeparatorAfter.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
749         ftSeparatorPanel.add(ftSeparatorAfter);
750
751         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
752         gridBagConstraints.gridx = 0;
753         gridBagConstraints.gridy = 14;
754         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
755         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
756         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 0, 0);
757         add(ftSeparatorPanel, gridBagConstraints);
758
759         org.openide.awt.Mnemonics.setLocalizedText(editorContext, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_EditorContextMenuItem"));
760         editorContext.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
761         editorContext.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
762         editorContext.addActionListener(new java.awt.event.ActionListener JavaDoc() {
763             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
764                 editorContextActionPerformed(evt);
765             }
766         });
767
768         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
769         gridBagConstraints.gridx = 0;
770         gridBagConstraints.gridy = 15;
771         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
772         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
773         gridBagConstraints.insets = new java.awt.Insets JavaDoc(18, 0, 3, 0);
774         add(editorContext, gridBagConstraints);
775
776         edContentTypeTxt.setLabelFor(edContentType);
777         org.openide.awt.Mnemonics.setLocalizedText(edContentTypeTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_ContentType"));
778         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
779         gridBagConstraints.gridx = 0;
780         gridBagConstraints.gridy = 16;
781         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
782         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
783         add(edContentTypeTxt, gridBagConstraints);
784
785         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
786         gridBagConstraints.gridx = 1;
787         gridBagConstraints.gridy = 16;
788         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
789         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
790         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
791         gridBagConstraints.weightx = 1.0;
792         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
793         add(edContentType, gridBagConstraints);
794
795         edPositionTxt.setLabelFor(edPosition);
796         org.openide.awt.Mnemonics.setLocalizedText(edPositionTxt, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_Position"));
797         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
798         gridBagConstraints.gridx = 0;
799         gridBagConstraints.gridy = 17;
800         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
801         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 3, 0);
802         add(edPositionTxt, gridBagConstraints);
803
804         edPosition.setRenderer(POSITION_RENDERER);
805         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
806         gridBagConstraints.gridx = 1;
807         gridBagConstraints.gridy = 17;
808         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
809         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
810         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
811         gridBagConstraints.weightx = 1.0;
812         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 12, 3, 0);
813         add(edPosition, gridBagConstraints);
814
815         edSeparatorPanel.setLayout(new java.awt.FlowLayout JavaDoc(java.awt.FlowLayout.CENTER, 0, 0));
816
817         org.openide.awt.Mnemonics.setLocalizedText(edSeparatorBefore, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorBefore"));
818         edSeparatorBefore.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
819         edSeparatorPanel.add(edSeparatorBefore);
820
821         org.openide.awt.Mnemonics.setLocalizedText(edSeparatorAfter, org.openide.util.NbBundle.getMessage(GUIRegistrationPanel.class, "LBL_SeparatorAfter"));
822         edSeparatorAfter.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 6, 0, 0));
823         edSeparatorAfter.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
824         edSeparatorPanel.add(edSeparatorAfter);
825
826         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
827         gridBagConstraints.gridx = 0;
828         gridBagConstraints.gridy = 18;
829         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
830         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
831         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 18, 0, 0);
832         add(edSeparatorPanel, gridBagConstraints);
833
834     }// </editor-fold>//GEN-END:initComponents
835

836     private void shortcutsListChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_shortcutsListChanged
837
setShortcutGroupEnabled();
838     }//GEN-LAST:event_shortcutsListChanged
839

840     private void keyStrokeRemoveActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_keyStrokeRemoveActionPerformed
841
DefaultListModel JavaDoc lm = (DefaultListModel JavaDoc)shortcutsList.getModel();
842         Object JavaDoc[] selected = shortcutsList.getSelectedValues();
843         if (selected.length > 0) {
844             int idx = shortcutsList.getSelectionModel().getMinSelectionIndex();
845             for (int i = 0; i < selected.length; i++) {
846                 lm.removeElement(selected[i]);
847             }
848             if (lm.getSize() > 0) {
849                 idx = (idx > 0) ? idx -1 : 0;
850                shortcutsList.setSelectedIndex(idx);
851             }
852         }
853         checkValidity();
854     }//GEN-LAST:event_keyStrokeRemoveActionPerformed
855

856     private void editorContextActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_editorContextActionPerformed
857
setGroupEnabled(editorGroup, editorContext.isSelected());
858         checkValidity();
859     }//GEN-LAST:event_editorContextActionPerformed
860

861     private void fileTypeContextActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_fileTypeContextActionPerformed
862
setGroupEnabled(fileTypeGroup, fileTypeContext.isSelected());
863         checkValidity();
864     }//GEN-LAST:event_fileTypeContextActionPerformed
865

866     private void globalMenuItemActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_globalMenuItemActionPerformed
867
setGroupEnabled(gmiGroup, globalMenuItem.isSelected());
868         
869         checkValidity();
870     }//GEN-LAST:event_globalMenuItemActionPerformed
871

872     private void globalToolbarButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_globalToolbarButtonActionPerformed
873
setGroupEnabled(toolbarGroup, globalToolbarButton.isSelected());
874         checkValidity();
875     }//GEN-LAST:event_globalToolbarButtonActionPerformed
876

877     private void globalKeyboardShortcutActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_globalKeyboardShortcutActionPerformed
878
setShortcutGroupEnabled();
879         checkValidity();
880     }//GEN-LAST:event_globalKeyboardShortcutActionPerformed
881

882     private void keyStrokeChangeActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_keyStrokeChangeActionPerformed
883
KeyStroke JavaDoc[] keyStrokes = ShortcutEnterPanel.showDialog();
884         if (keyStrokes != null && keyStrokes.length > 0) {
885             String JavaDoc newShortcut = UIUtil.keyStrokesToString(keyStrokes);
886             DefaultListModel JavaDoc lm = (DefaultListModel JavaDoc)shortcutsList.getModel();
887             if (!lm.contains(newShortcut)) {
888                 lm.addElement(newShortcut);
889                 data.setKeyStroke(UIUtil.keyStrokesToLogicalString(keyStrokes));
890                 shortcutsList.setSelectedValue(newShortcut, true);
891                 checkValidity();
892             }
893         }
894     }//GEN-LAST:event_keyStrokeChangeActionPerformed
895

896     
897     // Variables declaration - do not modify//GEN-BEGIN:variables
898
private javax.swing.JComboBox JavaDoc category;
899     private javax.swing.JLabel JavaDoc categoryTxt;
900     private javax.swing.JComboBox JavaDoc edContentType;
901     private javax.swing.JLabel JavaDoc edContentTypeTxt;
902     private javax.swing.JComboBox JavaDoc edPosition;
903     private javax.swing.JLabel JavaDoc edPositionTxt;
904     private javax.swing.JCheckBox JavaDoc edSeparatorAfter;
905     private javax.swing.JCheckBox JavaDoc edSeparatorBefore;
906     private javax.swing.JPanel JavaDoc edSeparatorPanel;
907     javax.swing.JCheckBox JavaDoc editorContext;
908     javax.swing.JCheckBox JavaDoc fileTypeContext;
909     private javax.swing.JLabel JavaDoc filler;
910     private javax.swing.JComboBox JavaDoc ftContentType;
911     private javax.swing.JLabel JavaDoc ftContentTypeTxt;
912     private javax.swing.JComboBox JavaDoc ftPosition;
913     private javax.swing.JLabel JavaDoc ftPositionTxt;
914     private javax.swing.JCheckBox JavaDoc ftSeparatorAfter;
915     private javax.swing.JCheckBox JavaDoc ftSeparatorBefore;
916     private javax.swing.JPanel JavaDoc ftSeparatorPanel;
917     private javax.swing.JCheckBox JavaDoc globalKeyboardShortcut;
918     javax.swing.JCheckBox JavaDoc globalMenuItem;
919     javax.swing.JCheckBox JavaDoc globalToolbarButton;
920     private javax.swing.JScrollPane JavaDoc jScrollPane1;
921     private javax.swing.JButton JavaDoc keyStrokeChange;
922     private javax.swing.JButton JavaDoc keyStrokeRemove;
923     private javax.swing.JLabel JavaDoc keyStrokeTxt;
924     private javax.swing.JComboBox JavaDoc menu;
925     private javax.swing.JComboBox JavaDoc menuPosition;
926     private javax.swing.JLabel JavaDoc menuPositionTxt;
927     private javax.swing.JCheckBox JavaDoc menuSeparatorAfter;
928     private javax.swing.JCheckBox JavaDoc menuSeparatorBefore;
929     private javax.swing.JPanel JavaDoc menuSeparatorPanel;
930     private javax.swing.JLabel JavaDoc menuTxt;
931     private javax.swing.JList JavaDoc shortcutsList;
932     private javax.swing.JComboBox JavaDoc toolbar;
933     private javax.swing.JComboBox JavaDoc toolbarPosition;
934     private javax.swing.JLabel JavaDoc toolbarPositionTxt;
935     private javax.swing.JLabel JavaDoc toolbarTxt;
936     // End of variables declaration//GEN-END:variables
937

938     private void initAccesibility() {
939         this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_GuiRegistrationPanel"));
940         category.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_Category"));
941         edContentType.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_edContentType"));
942         edPosition.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_edPosition"));
943         edSeparatorAfter.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_edSeparatorAfter"));
944         edSeparatorBefore.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_edSeparatorBefore"));
945         editorContext.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_EditorContext"));
946         fileTypeContext.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_FileTypeContext"));
947         ftContentType.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ftContentType"));
948         ftPosition.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ftPosition"));
949         ftSeparatorAfter.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ftSeparatorAfter"));
950         ftSeparatorBefore.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ftSeparatorBefore"));
951         globalKeyboardShortcut.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_globalKeyboardShortcut"));
952         globalMenuItem.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_globalMenuItem"));
953         globalToolbarButton.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_globalToolbarButton"));
954         keyStrokeChange.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_keyStrokeChange"));
955         keyStrokeRemove.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_keyStrokeRemove"));
956         keyStrokeTxt.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_keyStrokeDef"));
957         shortcutsList.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_keyStrokeList"));
958         menu.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_menu"));
959         menuPosition.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_menuPosition"));
960         menuSeparatorAfter.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_menuSeparatorAfter"));
961         menuSeparatorBefore.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_menuSeparatorBefore"));
962         toolbar.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_toolbar"));
963         toolbarPosition.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_toolbarPosition"));
964     }
965     
966     /** Don't call me from EDT! */
967     private FileSystem getSFS() {
968         assert !EventQueue.isDispatchThread() : "Called from ETD!"; // NOI18N
969
if (sfs == null) {
970             try {
971                 // XXX takes very long time. Consider to call it when e.g. module is loaded
972
sfs = LayerUtils.getEffectiveSystemFilesystem(data.getProject());
973             } catch (IOException JavaDoc ex) {
974                 Util.err.notify(ex);
975                 sfs = FileUtil.createMemoryFileSystem();
976             }
977         }
978         return sfs;
979     }
980     
981     /**
982      * Actually really dedicated for Loader&hellip;Actions and
983      * Editors&hellip;Popup.
984      */

985     private Enumeration JavaDoc<DataFolder> getFoldersByName(final DataFolder startFolder, final String JavaDoc subFoldersName) {
986         Enumeration JavaDoc<DataFolder> folders = getFolders(startFolder);
987         Vector JavaDoc result = new Vector JavaDoc();
988         while (folders.hasMoreElements()) {
989             DataFolder dObj = (DataFolder) folders.nextElement();
990             if (subFoldersName.equals(dObj.getName()) &&
991                     dObj.getPrimaryFile().getParent() != startFolder.getPrimaryFile()) {
992                 result.add(dObj);
993             }
994         }
995         return result.elements();
996     }
997     
998     private static Enumeration JavaDoc<DataFolder> getFolders(DataFolder folder) {
999         List JavaDoc<DataFolder> folders = new ArrayList JavaDoc();
1000        getFolders(folder, folders); // #66144: depth-first, not breadth-first, search appropriate here
1001
return Collections.enumeration(folders);
1002    }
1003    
1004    private static void getFolders(DataFolder folder, List JavaDoc<DataFolder> folders) {
1005        Enumeration JavaDoc e = folder.children();
1006        while (e.hasMoreElements()) {
1007            Object JavaDoc o = e.nextElement();
1008            if (o instanceof DataFolder) {
1009                DataFolder f = (DataFolder) o;
1010                folders.add(f);
1011                getFolders(f, folders);
1012            }
1013        }
1014    }
1015    
1016    private static class PositionRenderer extends JLabel JavaDoc implements ListCellRenderer JavaDoc, UIResource JavaDoc {
1017        
1018        public PositionRenderer () {
1019            setOpaque(true);
1020        }
1021        
1022        public Component JavaDoc getListCellRendererComponent(
1023                JList JavaDoc list, Object JavaDoc value, int index, boolean isSelected, boolean cellHasFocus) {
1024            // #93658: GTK needs name to render cell renderer "natively"
1025
setName("ComboBox.listRenderer"); // NOI18N
1026

1027            String JavaDoc text;
1028            if (value == null || value == CustomizerComponentFactory.WAIT_VALUE) {
1029                text = CustomizerComponentFactory.WAIT_VALUE;
1030            } else if (value == CustomizerComponentFactory.EMPTY_VALUE) {
1031                text = CustomizerComponentFactory.EMPTY_VALUE;
1032            } else {
1033                Position pos = (Position) value;
1034                String JavaDoc before = pos.getBeforeName() == null ? "" : pos.getBeforeName() + POSITION_SEPARATOR;
1035                String JavaDoc after = pos.getAfterName() == null ? "" : POSITION_SEPARATOR + pos.getAfterName();
1036                text = before + POSITION_HERE + after;
1037            }
1038            setText(text);
1039            
1040            if ( isSelected ) {
1041                setBackground(list.getSelectionBackground());
1042                setForeground(list.getSelectionForeground());
1043            }
1044            else {
1045                setBackground(list.getBackground());
1046                setForeground(list.getForeground());
1047            }
1048            
1049            return this;
1050        }
1051        
1052        // #93658: GTK needs name to render cell renderer "natively"
1053
public String JavaDoc getName() {
1054            String JavaDoc name = super.getName();
1055            return name == null ? "ComboBox.renderer" : name; // NOI18N
1056
}
1057        
1058    }
1059    
1060    private class PML implements PopupMenuListener JavaDoc {
1061        
1062        private JComboBox JavaDoc menu;
1063        private JComboBox JavaDoc position;
1064        
1065        PML(JComboBox JavaDoc menu, JComboBox JavaDoc position) {
1066            this.menu = menu;
1067            this.position = position;
1068        }
1069        
1070        public void popupMenuWillBecomeInvisible(PopupMenuEvent JavaDoc e) {
1071            LayerItemPresenter item = getSelectedLayerPresenter(menu);
1072            if (item != null) {
1073                loadPositionsCombo(item, position);
1074            }
1075        }
1076        
1077        public void popupMenuWillBecomeVisible(PopupMenuEvent JavaDoc e) {
1078            // we don't care
1079
}
1080        
1081        public void popupMenuCanceled(PopupMenuEvent JavaDoc e) {
1082            popupMenuWillBecomeInvisible(null);
1083        }
1084        
1085    }
1086    
1087}
1088
Popular Tags