@Override public void valueChanged(@Nullable TreeSelectionEvent e) { Component selectedComponent = myContentPanel.getSelectedComponent(); if (selectedComponent == myColorPickerPanel) { Color color = myColorPicker.getColor(); myNewResourceAction.setEnabled(false); myResultResourceName = ResourceHelper.colorToString(color); updateResourceNameStatus(); } else { boolean isProjectPanel = selectedComponent == myProjectPanel.myComponent; ResourcePanel panel = isProjectPanel ? myProjectPanel : mySystemPanel; ResourceItem element = getSelectedElement(panel.myTreeBuilder, ResourceItem.class); setOKActionEnabled(element != null); myNewResourceAction.setEnabled( isProjectPanel && !panel.myTreeBuilder.getSelectedElements().isEmpty()); if (element == null) { myResultResourceName = null; } else { String prefix = panel == myProjectPanel ? "@" : ANDROID; myResultResourceName = prefix + element.getName(); } panel.showPreview(element); } notifyResourcePickerListeners(myResultResourceName); }
protected void handleSelection(final KettleQueryEntry value) { final DesignTimeContext designTimeContext = getDesignTimeContext(); final Action editParameterAction = getEditParameterAction(); try { setPanelEnabled(true, datasourcePanel); final KettleEmbeddedQueryEntry selectedQuery = (KettleEmbeddedQueryEntry) value; // This change event gets fired twice, causing the dialog to update twice.. let's stop that. if ((lastSelectedQuery == null) || (selectedQuery != lastSelectedQuery)) { lastSelectedQuery = selectedQuery; updateQueryName(selectedQuery.getName()); selectedQuery.refreshQueryUIComponents( datasourcePanel, designTimeContext, new PreviewChangeListener()); } editParameterAction.setEnabled(true); } catch (Exception e1) { designTimeContext.error(e1); editParameterAction.setEnabled(false); } catch (Throwable t1) { designTimeContext.error(new RuntimeException("Fatal error", t1)); editParameterAction.setEnabled(false); } }
public void adjustFeedback() { actionCancel.setEnabled(true); actionChooseNone.setEnabled(true); if (getSwingFocus() == null) { actionChooseSelected.setEnabled(false); } else { actionChooseSelected.setEnabled(true); } }
// From GraphSelectionListener Interface public void valueChanged(GraphSelectionEvent e) { super.valueChanged(e); // Group Button only Enabled if a cell is selected boolean enabled = !graph.isSelectionEmpty(); hide.setEnabled(enabled); expand.setEnabled(enabled); expandAll.setEnabled(enabled); collapse.setEnabled(enabled); }
public void setChannel(int chan) { currentChannel = chan; channelLabel.setText("Now tuned to channel: " + currentChannel); // enable/disable the Actions as appropriate downAction.setEnabled(currentChannel > MIN_CHANNEL); upAction.setEnabled(currentChannel < MAX_CHANNEL); gotoFavoriteAction.setEnabled(currentChannel != favoriteChannel); setFavoriteAction.setEnabled(currentChannel != favoriteChannel); }
public JToolBar createToolBar() { JToolBar toolbar = super.createToolBar(); // Hide hide = new AbstractAction() { public void actionPerformed(ActionEvent e) { graph.getGraphLayoutCache().hideCells(graph.getSelectionCells(), true); } }; URL url = getClass().getClassLoader().getResource("com/jgraph/example/adapter/image/hide.gif"); hide.putValue(Action.SMALL_ICON, new ImageIcon(url)); hide.setEnabled(false); toolbar.addSeparator(); toolbar.add(hide); toolbar.addSeparator(); // Collapse collapse = new AbstractAction() { public void actionPerformed(ActionEvent e) { graph.getGraphLayoutCache().collapse(graph.getSelectionCells()); } }; url = getClass().getClassLoader().getResource("com/jgraph/example/adapter/image/collapse.gif"); collapse.putValue(Action.SMALL_ICON, new ImageIcon(url)); collapse.setEnabled(false); toolbar.add(collapse); // Expand expand = new AbstractAction() { public void actionPerformed(ActionEvent e) { graph.getGraphLayoutCache().expand(graph.getSelectionCells()); } }; url = getClass().getClassLoader().getResource("com/jgraph/example/adapter/image/expand.gif"); expand.putValue(Action.SMALL_ICON, new ImageIcon(url)); expand.setEnabled(false); toolbar.add(expand); // ExpandAll expandAll = new AbstractAction() { public void actionPerformed(ActionEvent e) { graph.getGraphLayoutCache().expand(graph.getDescendants(graph.getSelectionCells())); } }; url = getClass().getClassLoader().getResource("com/jgraph/example/adapter/image/expandAll.gif"); expandAll.putValue(Action.SMALL_ICON, new ImageIcon(url)); expandAll.setEnabled(false); toolbar.add(expandAll); return toolbar; }
// inherit doc comment protected JPopupMenu createPopupMenu() { if (TABLE.getSelectionModel().isSelectionEmpty()) { return null; } JPopupMenu menu = new SkinPopupMenu(); menu.add(new SkinMenuItem(LAUNCH_ACTION)); if (getMediaType().equals(MediaType.getAudioMediaType())) { menu.add(new SkinMenuItem(LAUNCH_OS_ACTION)); } if (hasExploreAction()) { menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION)); } if (areAllSelectedFilesMP4s()) { menu.add(DEMUX_MP4_AUDIO_ACTION); DEMUX_MP4_AUDIO_ACTION.setEnabled( !((DemuxMP4AudioAction) DEMUX_MP4_AUDIO_ACTION).isDemuxing()); } menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION)); if (areAllSelectedFilesPlayable()) { menu.add(createAddToPlaylistSubMenu()); } menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION)); menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION)); menu.addSeparator(); menu.add(new SkinMenuItem(DELETE_ACTION)); menu.addSeparator(); int[] rows = TABLE.getSelectedRows(); boolean dirSelected = false; boolean fileSelected = false; for (int i = 0; i < rows.length; i++) { File f = DATA_MODEL.get(rows[i]).getFile(); if (f.isDirectory()) { dirSelected = true; // if (IncompleteFileManager.isTorrentFolder(f)) // torrentSelected = true; } else fileSelected = true; if (dirSelected && fileSelected) break; } DELETE_ACTION.setEnabled(true); LibraryFilesTableDataLine line = DATA_MODEL.get(rows[0]); menu.add(createSearchSubMenu(line)); return menu; }
@Override public void show(Component c, int x, int y) { if (c instanceof JTextComponent) { JTextComponent textArea = (JTextComponent) c; boolean flg = Objects.nonNull(textArea.getSelectedText()); cutAction.setEnabled(flg); copyAction.setEnabled(flg); deleteAction.setEnabled(flg); super.show(c, x, y); } }
// inherit doc comment protected JPopupMenu createPopupMenu() { if (TABLE.getSelectionModel().isSelectionEmpty()) return null; JPopupMenu menu = new SkinPopupMenu(); menu.add(new SkinMenuItem(LAUNCH_ACTION)); menu.add(new SkinMenuItem(LAUNCH_OS_ACTION)); if (hasExploreAction()) { menu.add(new SkinMenuItem(OPEN_IN_FOLDER_ACTION)); } menu.add(new SkinMenuItem(CREATE_TORRENT_ACTION)); menu.add(createAddToPlaylistSubMenu()); menu.add(new SkinMenuItem(SEND_TO_FRIEND_ACTION)); menu.add(new SkinMenuItem(SEND_TO_ITUNES_ACTION)); menu.addSeparator(); menu.add(new SkinMenuItem(DELETE_ACTION)); int[] rows = TABLE.getSelectedRows(); boolean dirSelected = false; boolean fileSelected = false; for (int i = 0; i < rows.length; i++) { File f = DATA_MODEL.get(rows[i]).getFile(); if (f.isDirectory()) { dirSelected = true; // if (IncompleteFileManager.isTorrentFolder(f)) // torrentSelected = true; } else fileSelected = true; if (dirSelected && fileSelected) break; } if (dirSelected) { DELETE_ACTION.setEnabled(true); } else { DELETE_ACTION.setEnabled(true); } menu.addSeparator(); menu.add(new SkinMenuItem(importToPlaylistAction)); menu.add(new SkinMenuItem(exportPlaylistAction)); menu.add(new SkinMenuItem(cleanupPlaylistAction)); menu.add(new SkinMenuItem(refreshID3TagsAction)); menu.addSeparator(); LibraryPlaylistsTableDataLine line = DATA_MODEL.get(rows[0]); menu.add(createSearchSubMenu(line)); return menu; }
private void enableOrDisableActions() { int idx = archetypeList.getSelectedIndex(); if (archetypeList.getSelectedIndex() == -1) { deleteArchetypeAction.setEnabled(false); return; } if (StringUtils.equalsIgnoreCase("generic", listData.get(idx).getName())) { deleteArchetypeAction.setEnabled(false); return; } exportArchetypeAction.setEnabled(true); deleteArchetypeAction.setEnabled(true); }
private void handlePerspectiveSelect(PerspectiveSelectionEvent event) { String perspectiveID = event.getSelectedPerspective().getID(); boolean isDesign = DESIGN_PERSPECTIVE_ID.equals(perspectiveID); boolean isResults = RESULTS_PERSPECTIVE_ID.equals(perspectiveID); for (MenuComponent menuComponent : menuComponents) if (!(menuComponent instanceof ContextualMenuComponent)) { Action action = menuComponent.getAction(); if (action instanceof DesignOnlyAction) action.setEnabled(isDesign); else if (action instanceof DesignOrResultsAction) action.setEnabled(isDesign || isResults); } }
/** Updates components based on current state. In particular enabledness is set appropriately. */ private void updateState() { boolean isActive = matchWorker_ != null; startAction_.setEnabled(!isActive); stopAction_.setEnabled(isActive); for (int i = 0; i < components_.length; i++) { components_[i].setEnabled(!isActive); } if (!isActive && progBar_ != null) { progBar_.setValue(0); progBar_.setMinimum(0); progBar_.setMaximum(1); progBar_.setString(" "); } }
public void caretUpdate(CaretEvent e) { // when the cursor moves on _textView // this method will be called. Then, we // must determine what the line number is // and update the line number view Element root = textView.getDocument().getDefaultRootElement(); int line = root.getElementIndex(e.getDot()); root = root.getElement(line); int col = root.getElementIndex(e.getDot()); lineNumberView.setText(line + ":" + col); // if text is selected then enable copy and cut boolean isSelection = e.getDot() != e.getMark(); copyAction.setEnabled(isSelection); cutAction.setEnabled(isSelection); }
/** Create a new archetype. */ private void makeNewAchetype() { Archetype archetype = new Archetype(); archetype.setName("New Archetype"); listData.add(archetype); archetypeList.setSelectedIndex(listData.size() - 1); saveListAction.setEnabled(true); }
/** @return */ public Action getFindAction() { Action ret = actionMap.get(ACTION_FIND); if (ret == null) { ret = new AbstractAction(ACTION_FIND, getIcon("find.png", IconSize.SMALL)) { private static final long serialVersionUID = 1L; private FindReplaceDialog dialog; @Override public void actionPerformed(ActionEvent event) { try { if (dialog == null) { dialog = new FindReplaceDialog(debuggerFrame, DialogType.SEARCH); } dialog.setVisible(true); } catch (HeadlessException e) { showError("Error opening file: " + e); } } }; ret.putValue(Action.SHORT_DESCRIPTION, "Find in script."); ret.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke('F', menuActionMods)); ret.putValue(Action.MNEMONIC_KEY, new Integer('F')); ret.setEnabled(false); actionMap.put(ACTION_FIND, ret); } return ret; }
public void enforce() { logger_.error("xx", new Throwable("looky")); Set transitions = actions_.keySet(); logger_.debug("Machine state = " + machine_.getState()); for (Iterator i = transitions.iterator(); i.hasNext(); ) { ServiceTransition t = (ServiceTransition) i.next(); logger_.debug("Transition = " + t); logger_.debug("Can trans = " + machine_.canTransition(t)); Action action = (Action) actions_.get(t); logger_.debug("Action clas= " + action.getClass().getName()); action.setEnabled(machine_.canTransition(t)); } // for (Iterator i = ServiceTransition.iterator(); i.hasNext(); ) { // ServiceTransition t = (ServiceTransition) i.next(); // Action action = (Action) actions_.get(t); // action.setEnabled(machine_.canTransition(t)); // // // action = startAction // // state = started // // transition = initialize // // } }
public void acceleratorChanged() { ArrayList<AcceleratorSeq> sclSeqs = new ArrayList<AcceleratorSeq>(); List<AcceleratorSeq> scl; if (accelerator != null) { sclSeqs.add(accelerator.getSequence("SCLMed")); sclSeqs.add(accelerator.getSequence("SCLHigh")); scl = AcceleratorSeq.orderSequences(sclSeqs); setSelectedSequence(AcceleratorSeqCombo.getInstance("scl", scl)); rfCavs = getSelectedSequence().getAllNodesOfType("SCLCavity"); if (myWindow() != null) myWindow().createRFPane(); // setHasChanges(true); if (snapAction != null) snapAction.setEnabled(true); } // initialize PVLogger ConnectionDictionary dict = PVLogger.newLoggingConnectionDictionary(); if (dict != null) { pvLogger = new PVLogger(dict); } else { ConnectionPreferenceController.displayPathPreferenceSelector(); dict = PVLogger.newLoggingConnectionDictionary(); pvLogger = new PVLogger(dict); } }
/** * Enable/disable an AbstractAction * * @param actionName the key that maps this action in actionTable * @param b true to enable or false to disable the action */ public static synchronized void setActionEnabled(final Integer actionKey, final boolean b) { Action aa = actionTable.get(actionKey); if (aa != null) { aa.setEnabled(b); } }
private void initDialog(final DesignTimeContext designTimeContext) { if (designTimeContext == null) { throw new NullPointerException(); } this.designTimeContext = designTimeContext; editParameterAction = new EditParameterAction(); editParameterAction.setEnabled(false); queryListModel = new DefaultListModel(); queryNameList = new JList(queryListModel); queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); queryNameList.setVisibleRowCount(5); queryNameList.addListSelectionListener(new QueryNameListSelectionListener()); fileTextField = new JTextField(30); fileTextField.setEnabled(false); fileTextField.getDocument().addDocumentListener(new FileSyncHandler()); stepsList = new JList(); stepsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); stepsList.addListSelectionListener(new StepsListListener()); nameTextField = new JTextField(30); nameTextField.setEnabled(false); nameTextField.getDocument().addDocumentListener(new NameSyncHandler()); setTitle(Messages.getString("KettleDataSourceDialog.Title")); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setModal(true); super.init(); }
/** * Rewire the save action with the documents update listener interface. This is necessary because * the document is discarded on each reload, i.e. on every change of the character set. */ private void wireupSaveButton() { saveAction.setEnabled(false); textArea .getDocument() .addDocumentListener( new DocumentListener() { public void insertUpdate(DocumentEvent e) { activateSaveButton(); } public void removeUpdate(DocumentEvent e) { activateSaveButton(); } public void changedUpdate(DocumentEvent e) { activateSaveButton(); } private void activateSaveButton() { if (!saveAction.isEnabled()) { if (getTargetFile().getFile().canWrite()) { saveAction.setEnabled(true); } else { messageBox.info(getLocalizer().localize("message.read-only")); } } } }); }
/** * The disconnect method will stop the eventreplayer, and send null to the other peers, to stop * their reading from their streams. The GUI-menu is updated appropriately. */ public void disconnect() { setTitle("Disconnected"); active = false; if (connected == true) { er.stopStreamToQueue(); ert.interrupt(); setDocumentFilter(null); connected = false; setLocked(false); } deregisterOnPort(); Disconnect.setEnabled(false); Connect.setEnabled(true); Listen.setEnabled(true); Save.setEnabled(true); SaveAs.setEnabled(true); }
/** * Mouse Listener methods. * * <p>spv */ public void mouseTriggered(MouseEvent me) { if (me.isPopupTrigger()) { actionJumpToError.setEnabled(parseError != null && parseError.hasLineNumbers()); ((GUIMultiModel) handler.getGUIPlugin()).doEnables(); contextPopup.show(me.getComponent(), me.getX(), me.getY()); } }
/** * Handles the selection rows in the library window, enabling or disabling buttons and chat menu * items depending on the values in the selected rows. * * @param row the index of the first row that is selected */ public void handleSelection(int row) { int[] sel = TABLE.getSelectedRows(); if (sel.length == 0) { handleNoSelection(); return; } File selectedFile = getFile(sel[0]); // always turn on Launch, Delete, Magnet Lookup, Bitzi Lookup LAUNCH_ACTION.setEnabled(true); LAUNCH_OS_ACTION.setEnabled(true); DELETE_ACTION.setEnabled(true); SEND_TO_ITUNES_ACTION.setEnabled(true); if (selectedFile != null && !selectedFile.getName().endsWith(".torrent")) { CREATE_TORRENT_ACTION.setEnabled(sel.length == 1); } if (selectedFile != null) { SEND_TO_FRIEND_ACTION.setEnabled(sel.length == 1); } if (sel.length == 1 && selectedFile.isFile() && selectedFile.getParentFile() != null) { OPEN_IN_FOLDER_ACTION.setEnabled(true); } else { OPEN_IN_FOLDER_ACTION.setEnabled(false); } if (sel.length == 1) { LibraryMediator.instance() .getLibraryCoverArt() .setFile(getSelectedLibraryLines()[0].getFile()); } }
/* * @see org.argouml.uml.diagram.static_structure.ui.FigClassifierBox#buildAddMenu() */ @Override protected ArgoJMenu buildAddMenu() { ArgoJMenu addMenu = super.buildAddMenu(); Action addEnumerationLiteral = new ActionAddEnumerationLiteral(); addEnumerationLiteral.setEnabled(isSingleTarget()); addMenu.add(addEnumerationLiteral); return addMenu; }
public ActionMap getActionMap() { ActionMap map = createActionMap(); nextAction = map.get(NEXT); nextAction.putValue(Action.NAME, getString("reservation_wizard.add_appointment")); nextAction.putValue(Action.SMALL_ICON, getIcon("icon.new")); nextAction.setEnabled(false); map.get(FINISH).setEnabled(false); return map; }
/** * Handles the selection rows in the library window, enabling or disabling buttons and chat menu * items depending on the values in the selected rows. * * @param row the index of the first row that is selected */ public void handleSelection(int row) { int[] sel = TABLE.getSelectedRows(); if (sel.length == 0) { handleNoSelection(); return; } File selectedFile = getFile(sel[0]); // always turn on Launch, Delete, Magnet Lookup, Bitzi Lookup LAUNCH_ACTION.setEnabled(true); LAUNCH_OS_ACTION.setEnabled(true); DELETE_ACTION.setEnabled(true); if (selectedFile != null && !selectedFile.getName().endsWith(".torrent")) { CREATE_TORRENT_ACTION.setEnabled(sel.length == 1); } if (selectedFile != null) { SEND_TO_FRIEND_ACTION.setEnabled(sel.length == 1); if (getMediaType().equals(MediaType.getAnyTypeMediaType())) { boolean atLeastOneIsPlayable = false; for (int i : sel) { File f = getFile(i); if (MediaPlayer.isPlayableFile(f) || hasExtension(f.getAbsolutePath(), "mp4")) { atLeastOneIsPlayable = true; break; } } SEND_TO_ITUNES_ACTION.setEnabled(atLeastOneIsPlayable); } else { SEND_TO_ITUNES_ACTION.setEnabled( getMediaType().equals(MediaType.getAudioMediaType()) || hasExtension(selectedFile.getAbsolutePath(), "mp4")); } } if (sel.length == 1 && selectedFile.isFile() && selectedFile.getParentFile() != null) { OPEN_IN_FOLDER_ACTION.setEnabled(true); } else { OPEN_IN_FOLDER_ACTION.setEnabled(false); } if (sel.length == 1) { LibraryMediator.instance().getLibraryCoverArt().setFile(selectedFile); } // boolean anyBeingShared = isAnyBeingShared(); // WIFI_SHARE_ACTION.setEnabled(!anyBeingShared); // WIFI_UNSHARE_ACTION.setEnabled(!anyBeingShared); }
/** Synchronizes the state of the actions to the current state of this host. */ private void updateActions() { final DeviceController currentDeviceController = getDeviceController(); final boolean deviceControllerSet = currentDeviceController != null; final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing(); final boolean deviceSetup = deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup(); getAction(CaptureAction.ID).setEnabled(deviceControllerSet); getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing); getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup); final boolean projectChanged = this.projectManager.getCurrentProject().isChanged(); final boolean projectSavedBefore = this.projectManager.getCurrentProject().getFilename() != null; final boolean dataAvailable = this.dataContainer.hasCapturedData(); getAction(SaveProjectAction.ID).setEnabled(projectChanged); getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged); getAction(SaveDataFileAction.ID).setEnabled(dataAvailable); getAction(ZoomInAction.ID).setEnabled(dataAvailable); getAction(ZoomOutAction.ID).setEnabled(dataAvailable); getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable); getAction(ZoomFitAction.ID).setEnabled(dataAvailable); final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData(); getAction(GotoTriggerAction.ID).setEnabled(triggerEnable); // Update the cursor actions accordingly... final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled(); for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c); getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled); } getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors); getAction(GotoLastCursorAction.ID).setEnabled(enableCursors); getAction(SetCursorModeAction.ID).setEnabled(dataAvailable); getAction(SetCursorModeAction.ID) .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled())); boolean anyCursorSet = false; for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c); anyCursorSet |= cursorPositionSet; final Action action = getAction(SetCursorAction.getCursorId(c)); action.setEnabled(dataAvailable); action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet)); } getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet); }
private Action buildClearModelAction() { Action action = new AbstractAction("clear model") { public void actionPerformed(ActionEvent event) { SCAbstractPanelTest.this.clearModel(); } }; action.setEnabled(true); return action; }
private Action buildResetPropertyAction() { Action action = new AbstractAction("reset property") { public void actionPerformed(ActionEvent event) { SCAbstractPanelTest.this.resetProperty(); } }; action.setEnabled(true); return action; }
private Action buildBackdoorAction() { Action action = new AbstractAction("test backdoor") { public void actionPerformed(ActionEvent event) { ClasspathPanelTest.this.testBackdoor(); } }; action.setEnabled(true); return action; }