1 19 20 package org.netbeans.modules.apisupport.project.ui.wizard.action; 21 22 import java.awt.Component ; 23 import java.awt.EventQueue ; 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.Collection ; 27 import java.util.Collections ; 28 import java.util.Enumeration ; 29 import java.util.Iterator ; 30 import java.util.LinkedHashSet ; 31 import java.util.List ; 32 import java.util.Vector ; 33 import javax.swing.DefaultComboBoxModel ; 34 import javax.swing.DefaultListCellRenderer ; 35 import javax.swing.DefaultListModel ; 36 import javax.swing.JCheckBox ; 37 import javax.swing.JComboBox ; 38 import javax.swing.JComponent ; 39 import javax.swing.JLabel ; 40 import javax.swing.JList ; 41 import javax.swing.JTextField ; 42 import javax.swing.KeyStroke ; 43 import javax.swing.ListCellRenderer ; 44 import javax.swing.event.DocumentEvent ; 45 import javax.swing.event.PopupMenuEvent ; 46 import javax.swing.event.PopupMenuListener ; 47 import javax.swing.plaf.UIResource ; 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 70 final class GUIRegistrationPanel extends BasicWizardIterator.Panel { 71 72 private final RequestProcessor SFS_RP = new RequestProcessor(GUIRegistrationPanel.class.getName()); 73 private static final String ACTIONS_DIR = "Actions"; 75 private FileSystem sfs; 76 77 private final ListCellRenderer POSITION_RENDERER = new PositionRenderer(); 78 private static final String POSITION_HERE = getMessage("CTL_PositionHere"); 79 private static final String POSITION_SEPARATOR = " - "; 81 private DataModel data; 82 83 private final JComponent [] gmiGroup; 84 private final JComponent [] toolbarGroup; 85 private final JComponent [] shortcutGroup; 86 private final JComponent [] fileTypeGroup; 87 private final JComponent [] 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 [] { 101 menu, menuTxt, menuPosition, menuPositionTxt, menuSeparatorAfter, menuSeparatorBefore 102 }; 103 toolbarGroup = new JComponent [] { 104 toolbar, toolbarTxt, toolbarPosition, toolbarPositionTxt 105 }; 106 shortcutGroup = new JComponent [] { 107 shortcutsList, keyStrokeTxt, keyStrokeChange, keyStrokeRemove 108 }; 109 fileTypeGroup = new JComponent [] { 110 ftContentType, ftContentTypeTxt, ftPosition, ftPositionTxt, ftSeparatorAfter, ftSeparatorBefore 111 }; 112 editorGroup = new JComponent [] { 113 edContentType, edContentTypeTxt, edPosition, edPositionTxt, edSeparatorAfter, edSeparatorBefore 114 }; 115 readSFS(); 116 } 117 118 private void setEditable(final JComboBox combo) { 119 combo.setEditable(true); 120 if (combo.getEditor().getEditorComponent() instanceof JTextField ) { 121 JTextField txt = (JTextField ) combo.getEditor().getEditorComponent(); 122 txt.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() { 124 public void insertUpdate(DocumentEvent e) { 125 if (!CustomizerComponentFactory.isWaitModel(combo.getModel())) { 126 checkValidity(); 127 } 128 } 129 }); 130 } 131 } 132 133 protected String getPanelName() { 134 return getMessage("LBL_GUIRegistration_Title"); 135 } 136 137 private String getCategoryPath() { 138 String path = UIUtil.getSFSPath(category, ACTIONS_DIR); 139 return path == null ? ACTIONS_DIR + '/' + "Tools" : path; } 141 142 protected void storeToDataModel() { 143 if (!checkValidity()) { 145 return; 146 } 147 data.setCategory(getCategoryPath()); 149 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 data.setToolbarEnabled(globalToolbarButton.isSelected()); 159 if (globalToolbarButton.isSelected()) { 160 data.setToolbar(getSelectedLayerPresenter(toolbar).getFullPath()); 161 data.setToolbarPosition((Position) toolbarPosition.getSelectedItem()); 162 } 163 data.setKeyboardShortcutEnabled(globalKeyboardShortcut.isSelected()); 165 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 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 213 boolean checkValidity() { 214 boolean result = false; 215 if (globalKeyboardShortcut.isSelected() && ((DefaultListModel )shortcutsList.getModel()).isEmpty()) { 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 groupCheckBox, JComboBox menu, JComboBox position) { 232 boolean result = !groupCheckBox.isSelected() || 233 (getSelectedItem(menu) != null && getSelectedItem(position) != null); 234 return result; 235 } 236 237 private void setGroupEnabled(JComponent [] 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 c) { 253 return c instanceof JComboBox && 254 CustomizerComponentFactory.hasOnlyValue(((JComboBox ) 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); loadComboAndPositions("Toolbars", toolbar, toolbarPosition, null); loadComboAndPositions("Loaders", ftContentType, ftPosition, "Actions"); loadComboAndPositions("Editors", edContentType, edPosition, "Popup"); } 265 266 private void loadComboAndPositions(final String startFolder, 267 final JComboBox combo, 268 final JComboBox comboPositions, 269 final String subFolderName) { 270 loadComboAndPositions(startFolder, combo, comboPositions, subFolderName, false); 271 } 272 273 274 private void loadComboAndPositions(final String startFolder, 275 final JComboBox combo, 276 final JComboBox comboPositions, 277 final String subFolderName, 278 final boolean editable) { 279 combo.setModel(CustomizerComponentFactory.createComboWaitModel()); 280 SFS_RP.post(new Runnable () { 281 public void run() { 282 Util.err.log("Loading " + startFolder + " from SFS...."); 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 folders = subFolderName == null 292 ? getFolders(parentDF) : getFoldersByName(parentDF, subFolderName); 293 EventQueue.invokeLater(new Runnable () { 294 public void run() { 295 Collection <LayerItemPresenter> sorted = new LinkedHashSet (); 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 DefaultComboBoxModel model = new DefaultComboBoxModel (); 306 for (Iterator it = sorted.iterator(); it.hasNext(); ) { 307 model.addElement(it.next()); 308 } 309 combo.setModel(model); 310 if (editable) { 311 setEditable(combo); 312 } 313 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 positionsCombo) { 328 329 assert parent != null; 330 assert positionsCombo != null; 331 positionsCombo.setModel(CustomizerComponentFactory.createComboWaitModel()); 332 SFS_RP.post(new Runnable () { 333 public void run() { 334 DataObject[] kids = DataFolder.findFolder(parent.getFileObject()).getChildren(); 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 () { 340 public void run() { 341 createPositionModel(positionsCombo, files, parent); 342 } 343 }); 344 } 345 }); 346 } 347 348 private void createPositionModel(final JComboBox positionsCombo, 349 final FileObject[] files, 350 final LayerItemPresenter parent) { 351 DefaultComboBoxModel newModel = new DefaultComboBoxModel (); 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 getSelectedItem(final JComboBox combo) { 366 Object item = combo.getSelectedItem(); 367 return (item == CustomizerComponentFactory.WAIT_VALUE || item == CustomizerComponentFactory.EMPTY_VALUE) ? null : item; 368 } 369 370 private static LayerItemPresenter getSelectedLayerPresenter(final JComboBox 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 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 getMessage(String key) { 396 return NbBundle.getMessage(GUIRegistrationPanel.class, key); 397 } 398 399 404 private void initComponents() { 406 java.awt.GridBagConstraints gridBagConstraints; 407 408 categoryTxt = new javax.swing.JLabel (); 409 category = new javax.swing.JComboBox (); 410 globalMenuItem = new javax.swing.JCheckBox (); 411 menuTxt = new javax.swing.JLabel (); 412 menu = new javax.swing.JComboBox (); 413 menuPositionTxt = new javax.swing.JLabel (); 414 menuPosition = new javax.swing.JComboBox (); 415 menuSeparatorPanel = new javax.swing.JPanel (); 416 menuSeparatorBefore = new javax.swing.JCheckBox (); 417 menuSeparatorAfter = new javax.swing.JCheckBox (); 418 globalToolbarButton = new javax.swing.JCheckBox (); 419 toolbarTxt = new javax.swing.JLabel (); 420 toolbar = new javax.swing.JComboBox (); 421 toolbarPositionTxt = new javax.swing.JLabel (); 422 toolbarPosition = new javax.swing.JComboBox (); 423 globalKeyboardShortcut = new javax.swing.JCheckBox (); 424 keyStrokeTxt = new javax.swing.JLabel (); 425 jScrollPane1 = new javax.swing.JScrollPane (); 426 shortcutsList = new JList (new DefaultListModel ()); 427 keyStrokeChange = new javax.swing.JButton (); 428 keyStrokeRemove = new javax.swing.JButton (); 429 filler = new javax.swing.JLabel (); 430 fileTypeContext = new javax.swing.JCheckBox (); 431 ftContentTypeTxt = new javax.swing.JLabel (); 432 ftContentType = new javax.swing.JComboBox (); 433 ftPositionTxt = new javax.swing.JLabel (); 434 ftPosition = new javax.swing.JComboBox (); 435 ftSeparatorPanel = new javax.swing.JPanel (); 436 ftSeparatorBefore = new javax.swing.JCheckBox (); 437 ftSeparatorAfter = new javax.swing.JCheckBox (); 438 editorContext = new javax.swing.JCheckBox (); 439 edContentTypeTxt = new javax.swing.JLabel (); 440 edContentType = new javax.swing.JComboBox (); 441 edPositionTxt = new javax.swing.JLabel (); 442 edPosition = new javax.swing.JComboBox (); 443 edSeparatorPanel = new javax.swing.JPanel (); 444 edSeparatorBefore = new javax.swing.JCheckBox (); 445 edSeparatorAfter = new javax.swing.JCheckBox (); 446 447 setLayout(new java.awt.GridBagLayout ()); 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 (); 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 (); 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 (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 (0, 0, 0, 0)); 470 globalMenuItem.addActionListener(new java.awt.event.ActionListener () { 471 public void actionPerformed(java.awt.event.ActionEvent evt) { 472 globalMenuItemActionPerformed(evt); 473 } 474 }); 475 476 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 487 gridBagConstraints.gridx = 0; 488 gridBagConstraints.gridy = 2; 489 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 490 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 491 add(menuTxt, gridBagConstraints); 492 493 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 506 gridBagConstraints.gridx = 0; 507 gridBagConstraints.gridy = 3; 508 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 509 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 510 add(menuPositionTxt, gridBagConstraints); 511 512 menuPosition.setRenderer(POSITION_RENDERER); 513 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (3, 12, 3, 0); 521 add(menuPosition, gridBagConstraints); 522 523 menuSeparatorPanel.setLayout(new java.awt.FlowLayout (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 (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 (0, 0, 0, 0)); 532 menuSeparatorPanel.add(menuSeparatorAfter); 533 534 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (0, 0, 0, 0)); 545 globalToolbarButton.addActionListener(new java.awt.event.ActionListener () { 546 public void actionPerformed(java.awt.event.ActionEvent evt) { 547 globalToolbarButtonActionPerformed(evt); 548 } 549 }); 550 551 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 562 gridBagConstraints.gridx = 0; 563 gridBagConstraints.gridy = 6; 564 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 565 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 566 add(toolbarTxt, gridBagConstraints); 567 568 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 581 gridBagConstraints.gridx = 0; 582 gridBagConstraints.gridy = 7; 583 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 584 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 585 add(toolbarPositionTxt, gridBagConstraints); 586 587 toolbarPosition.setRenderer(POSITION_RENDERER); 588 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (0, 0, 0, 0)); 601 globalKeyboardShortcut.addActionListener(new java.awt.event.ActionListener () { 602 public void actionPerformed(java.awt.event.ActionEvent evt) { 603 globalKeyboardShortcutActionPerformed(evt); 604 } 605 }); 606 607 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 618 gridBagConstraints.gridx = 0; 619 gridBagConstraints.gridy = 9; 620 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 621 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 622 add(keyStrokeTxt, gridBagConstraints); 623 624 shortcutsList.setVisibleRowCount(3); 625 shortcutsList.addListSelectionListener(new javax.swing.event.ListSelectionListener () { 626 public void valueChanged(javax.swing.event.ListSelectionEvent evt) { 627 shortcutsListChanged(evt); 628 } 629 }); 630 631 jScrollPane1.setViewportView(shortcutsList); 632 633 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 () { 645 public void actionPerformed(java.awt.event.ActionEvent evt) { 646 keyStrokeChangeActionPerformed(evt); 647 } 648 }); 649 650 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 () { 661 public void actionPerformed(java.awt.event.ActionEvent evt) { 662 keyStrokeRemoveActionPerformed(evt); 663 } 664 }); 665 666 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (3, 12, 3, 0); 673 add(keyStrokeRemove, gridBagConstraints); 674 675 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 0, 0, 0)); 687 fileTypeContext.addActionListener(new java.awt.event.ActionListener () { 688 public void actionPerformed(java.awt.event.ActionEvent evt) { 689 fileTypeContextActionPerformed(evt); 690 } 691 }); 692 693 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 704 gridBagConstraints.gridx = 0; 705 gridBagConstraints.gridy = 12; 706 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 707 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 708 add(ftContentTypeTxt, gridBagConstraints); 709 710 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 723 gridBagConstraints.gridx = 0; 724 gridBagConstraints.gridy = 13; 725 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 726 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 727 add(ftPositionTxt, gridBagConstraints); 728 729 ftPosition.setRenderer(POSITION_RENDERER); 730 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (3, 12, 3, 0); 738 add(ftPosition, gridBagConstraints); 739 740 ftSeparatorPanel.setLayout(new java.awt.FlowLayout (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 (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 (0, 0, 0, 0)); 749 ftSeparatorPanel.add(ftSeparatorAfter); 750 751 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (0, 0, 0, 0)); 762 editorContext.addActionListener(new java.awt.event.ActionListener () { 763 public void actionPerformed(java.awt.event.ActionEvent evt) { 764 editorContextActionPerformed(evt); 765 } 766 }); 767 768 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 779 gridBagConstraints.gridx = 0; 780 gridBagConstraints.gridy = 16; 781 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 782 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 783 add(edContentTypeTxt, gridBagConstraints); 784 785 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 798 gridBagConstraints.gridx = 0; 799 gridBagConstraints.gridy = 17; 800 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 801 gridBagConstraints.insets = new java.awt.Insets (3, 18, 3, 0); 802 add(edPositionTxt, gridBagConstraints); 803 804 edPosition.setRenderer(POSITION_RENDERER); 805 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (3, 12, 3, 0); 813 add(edPosition, gridBagConstraints); 814 815 edSeparatorPanel.setLayout(new java.awt.FlowLayout (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 (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 (0, 0, 0, 0)); 824 edSeparatorPanel.add(edSeparatorAfter); 825 826 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (3, 18, 0, 0); 832 add(edSeparatorPanel, gridBagConstraints); 833 834 } 836 private void shortcutsListChanged(javax.swing.event.ListSelectionEvent evt) { setShortcutGroupEnabled(); 838 } 840 private void keyStrokeRemoveActionPerformed(java.awt.event.ActionEvent evt) { DefaultListModel lm = (DefaultListModel )shortcutsList.getModel(); 842 Object [] 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 } 856 private void editorContextActionPerformed(java.awt.event.ActionEvent evt) { setGroupEnabled(editorGroup, editorContext.isSelected()); 858 checkValidity(); 859 } 861 private void fileTypeContextActionPerformed(java.awt.event.ActionEvent evt) { setGroupEnabled(fileTypeGroup, fileTypeContext.isSelected()); 863 checkValidity(); 864 } 866 private void globalMenuItemActionPerformed(java.awt.event.ActionEvent evt) { setGroupEnabled(gmiGroup, globalMenuItem.isSelected()); 868 869 checkValidity(); 870 } 872 private void globalToolbarButtonActionPerformed(java.awt.event.ActionEvent evt) { setGroupEnabled(toolbarGroup, globalToolbarButton.isSelected()); 874 checkValidity(); 875 } 877 private void globalKeyboardShortcutActionPerformed(java.awt.event.ActionEvent evt) { setShortcutGroupEnabled(); 879 checkValidity(); 880 } 882 private void keyStrokeChangeActionPerformed(java.awt.event.ActionEvent evt) { KeyStroke [] keyStrokes = ShortcutEnterPanel.showDialog(); 884 if (keyStrokes != null && keyStrokes.length > 0) { 885 String newShortcut = UIUtil.keyStrokesToString(keyStrokes); 886 DefaultListModel lm = (DefaultListModel )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 } 896 897 private javax.swing.JComboBox category; 899 private javax.swing.JLabel categoryTxt; 900 private javax.swing.JComboBox edContentType; 901 private javax.swing.JLabel edContentTypeTxt; 902 private javax.swing.JComboBox edPosition; 903 private javax.swing.JLabel edPositionTxt; 904 private javax.swing.JCheckBox edSeparatorAfter; 905 private javax.swing.JCheckBox edSeparatorBefore; 906 private javax.swing.JPanel edSeparatorPanel; 907 javax.swing.JCheckBox editorContext; 908 javax.swing.JCheckBox fileTypeContext; 909 private javax.swing.JLabel filler; 910 private javax.swing.JComboBox ftContentType; 911 private javax.swing.JLabel ftContentTypeTxt; 912 private javax.swing.JComboBox ftPosition; 913 private javax.swing.JLabel ftPositionTxt; 914 private javax.swing.JCheckBox ftSeparatorAfter; 915 private javax.swing.JCheckBox ftSeparatorBefore; 916 private javax.swing.JPanel ftSeparatorPanel; 917 private javax.swing.JCheckBox globalKeyboardShortcut; 918 javax.swing.JCheckBox globalMenuItem; 919 javax.swing.JCheckBox globalToolbarButton; 920 private javax.swing.JScrollPane jScrollPane1; 921 private javax.swing.JButton keyStrokeChange; 922 private javax.swing.JButton keyStrokeRemove; 923 private javax.swing.JLabel keyStrokeTxt; 924 private javax.swing.JComboBox menu; 925 private javax.swing.JComboBox menuPosition; 926 private javax.swing.JLabel menuPositionTxt; 927 private javax.swing.JCheckBox menuSeparatorAfter; 928 private javax.swing.JCheckBox menuSeparatorBefore; 929 private javax.swing.JPanel menuSeparatorPanel; 930 private javax.swing.JLabel menuTxt; 931 private javax.swing.JList shortcutsList; 932 private javax.swing.JComboBox toolbar; 933 private javax.swing.JComboBox toolbarPosition; 934 private javax.swing.JLabel toolbarPositionTxt; 935 private javax.swing.JLabel toolbarTxt; 936 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 967 private FileSystem getSFS() { 968 assert !EventQueue.isDispatchThread() : "Called from ETD!"; if (sfs == null) { 970 try { 971 sfs = LayerUtils.getEffectiveSystemFilesystem(data.getProject()); 973 } catch (IOException ex) { 974 Util.err.notify(ex); 975 sfs = FileUtil.createMemoryFileSystem(); 976 } 977 } 978 return sfs; 979 } 980 981 985 private Enumeration <DataFolder> getFoldersByName(final DataFolder startFolder, final String subFoldersName) { 986 Enumeration <DataFolder> folders = getFolders(startFolder); 987 Vector result = new Vector (); 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 <DataFolder> getFolders(DataFolder folder) { 999 List <DataFolder> folders = new ArrayList (); 1000 getFolders(folder, folders); return Collections.enumeration(folders); 1002 } 1003 1004 private static void getFolders(DataFolder folder, List <DataFolder> folders) { 1005 Enumeration e = folder.children(); 1006 while (e.hasMoreElements()) { 1007 Object 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 implements ListCellRenderer , UIResource { 1017 1018 public PositionRenderer () { 1019 setOpaque(true); 1020 } 1021 1022 public Component getListCellRendererComponent( 1023 JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 1024 setName("ComboBox.listRenderer"); 1027 String 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 before = pos.getBeforeName() == null ? "" : pos.getBeforeName() + POSITION_SEPARATOR; 1035 String 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 public String getName() { 1054 String name = super.getName(); 1055 return name == null ? "ComboBox.renderer" : name; } 1057 1058 } 1059 1060 private class PML implements PopupMenuListener { 1061 1062 private JComboBox menu; 1063 private JComboBox position; 1064 1065 PML(JComboBox menu, JComboBox position) { 1066 this.menu = menu; 1067 this.position = position; 1068 } 1069 1070 public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { 1071 LayerItemPresenter item = getSelectedLayerPresenter(menu); 1072 if (item != null) { 1073 loadPositionsCombo(item, position); 1074 } 1075 } 1076 1077 public void popupMenuWillBecomeVisible(PopupMenuEvent e) { 1078 } 1080 1081 public void popupMenuCanceled(PopupMenuEvent e) { 1082 popupMenuWillBecomeInvisible(null); 1083 } 1084 1085 } 1086 1087} 1088 | Popular Tags |