private void process(MouseEvent e) { textComponent.requestFocus(); boolean enabled = textComponent.isEnabled(); boolean editable = textComponent.isEditable(); boolean nonempty = !(textComponent.getText() == null || textComponent.getText().equals("")); boolean marked = textComponent.getSelectedText() != null; boolean pasteAvailable = Toolkit.getDefaultToolkit().getSystemClipboard() .getContents(null).isDataFlavorSupported(DataFlavor.stringFlavor); undoAction.setEnabled(enabled && editable && undoManager.canUndo()); redoAction.setEnabled(enabled && editable && undoManager.canRedo()); cutAction.setEnabled(enabled && editable && marked); copyAction.setEnabled(enabled && marked); pasteAction.setEnabled(enabled && editable && pasteAvailable); deleteAction.setEnabled(enabled && editable && marked); selectAllAction.setEnabled(enabled && nonempty); int nx = e.getX(); if (nx > 500) { nx = nx - popup.getSize().width; } popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height); } }
undoAction.setEnabled(enabled && editable && (lastActionSelected == Actions.CUT || lastActionSelected == Actions.PASTE)); cutAction.setEnabled(enabled && editable && marked); copyAction.setEnabled(enabled && marked); pasteAction.setEnabled(enabled && editable && pasteAvailable); selectAllAction.setEnabled(enabled && nonempty);
@Override public void internalFrameDeactivated(InternalFrameEvent e) { getActionMap(e).get(ActionCommands.EXPORT.toString()).setEnabled(false); getActionMap(e).get(ActionCommands.REFRESH.toString()).setEnabled(false); getActionMap(e).get(ActionCommands.WATCH.toString()).setEnabled(false); getActionMap(e).get(ActionCommands.ZOOM.toString()).setEnabled(false); // setSelected() does not fire ActionEvent -> both buttons have to be changed getMenuBar(e).getWatchMenuItem().setSelected(false); getToolBar(e).getWatchToggleButton().setSelected(false); }
private void setSolvingState(boolean solving) { quickOpenUnsolvedJList.setEnabled(!solving); quickOpenSolvedJList.setEnabled(!solving); if (solutionBusiness.hasImporter()) { importAction.setEnabled(!solving); } openAction.setEnabled(!solving); saveAction.setEnabled(!solving); if (solutionBusiness.hasExporter()) { exportAction.setEnabled(!solving); } solveAction.setEnabled(!solving); solveButton.setVisible(!solving); terminateSolvingEarlyAction.setEnabled(solving); terminateSolvingEarlyButton.setVisible(solving); if (solving) { terminateSolvingEarlyButton.requestFocus(); } else { solveButton.requestFocus(); } solutionPanel.setEnabled(!solving); progressBar.setIndeterminate(solving); progressBar.setStringPainted(solving); progressBar.setString(solving ? "Solving..." : null); indictmentHeatMapToggleButton.setEnabled(solutionPanel.isIndictmentHeatMapEnabled() && !solving); showConstraintMatchesDialogAction.setEnabled(!solving); }
openAction.setEnabled(true); JButton openButton = new JButton(openAction); saveAction = new SaveAction(); saveAction.setEnabled(false); JButton saveButton = new JButton(saveAction); JButton exportButton; if (solutionBusiness.hasExporter()) { exportAction = new ExportAction(); exportAction.setEnabled(false); exportButton = new JButton(exportAction); } else { solveAction.setEnabled(false); solveButton = new JButton(solveAction); terminateSolvingEarlyAction = new TerminateSolvingEarlyAction(); terminateSolvingEarlyAction.setEnabled(false); terminateSolvingEarlyButton = new JButton(terminateSolvingEarlyAction); terminateSolvingEarlyButton.setVisible(false);
undoAction.setEnabled(enabled && editable && (lastActionSelected == Actions.CUT || lastActionSelected == Actions.PASTE)); cutAction.setEnabled(enabled && editable && marked); copyAction.setEnabled(enabled && marked); pasteAction.setEnabled(enabled && editable && pasteAvailable); selectAllAction.setEnabled(enabled && nonempty);
@Override public void internalFrameActivated(InternalFrameEvent e) { for (int i=2; i < getMenuBar(e).getWindowMenu().getItemCount(); i++) { final JMenuItem item = getMenuBar(e).getWindowMenu().getItem(i); if (((WindowMenuItemAction)item.getAction()).getInternalFrame() == e.getInternalFrame()) { item.setSelected(true); break; } } getActionMap(e).get(ActionCommands.EXPORT.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.REFRESH.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.WATCH.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.ZOOM.toString()).setEnabled(true); getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(true); // setSelected() does not fire ActionEvent -> both buttons have to be changed getMenuBar(e).getWatchMenuItem().setSelected(getSelectedGCDocument(e).isWatched()); getToolBar(e).getWatchToggleButton().setSelected(getSelectedGCDocument(e).isWatched()); updateMenuItemState(e); }
@Override public void internalFrameClosing(InternalFrameEvent e) { JInternalFrame internalFrame = e.getInternalFrame(); internalFrame.removeInternalFrameListener(this); internalFrame.getRootPane().remove(internalFrame); if (internalFrame.getRootPane().getComponentCount() == 0) { getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(false); } // remove menuitem from menu and from button group JMenu windowMenu = getMenuBar(e).getWindowMenu(); for (int i = 2; i < windowMenu.getItemCount(); i++) { JMenuItem item = windowMenu.getItem(i); if (((WindowMenuItemAction) item.getAction()).getInternalFrame() == internalFrame) { getMenuBar(e).removeFromWindowMenuGroup(item); break; } } // if this internalFrame is the last to be open, update the menu state // -> otherwise any settings done by the user are lost if (getGCViewerGui(e).getDesktopPane().getComponentCount() == 1) { updateMenuItemState(e); // set same menustate, when the last is closed as is set for deactivated internalFrameDeactivated(e); } // if some thread is still loading, it should stop now getSelectedGCDocument(e).getGCResources().stream().forEach(gcResource -> gcResource.setIsReadCancelled(true)); }
private void updateNavigationButtons() { if (currentMatch == 0) { previousAction.setEnabled(false); } else if (currentMatch >= 1 && currentMatch <= (totalMatch - 1)) { previousAction.setEnabled(true); } if (currentMatch == (totalMatch - 1)) { nextAction.setEnabled(false); } else if (currentMatch < (totalMatch - 1)) { nextAction.setEnabled(true); } searchPanel.updateCounterLabel(currentMatch + 1, totalMatch); }
/** * Constructor. * @param textComponent JTextComponent instance. */ public Searcher(JTextComponent textComponent) { this.textComponent = textComponent; searchPanel = new SearchPanel(this, this, this, nextAction, previousAction); searchEngine = new SearchEngine(textComponent, PAINTER); nextAction.setEnabled(false); previousAction.setEnabled(false); }
void updateCounterLabel(int now, int total) { if (!counterLabel.isVisible()) { counterLabel.setVisible(true); } if (total == 0) { counterLabel.setText(" No match found "); nextAction.setEnabled(false); return; } counterLabel.setText(" " + now + " of " + total + " "); }
public void reFocus() { searchField.requestFocus(); String searchKey = searchField.getText(); searchField.setText(searchKey); searchField.setSelectionStart(0); searchField.setSelectionEnd(searchField.getText().length()); closeAction.setEnabled(true); }
@Override public void actionPerformed(ActionEvent actionEvent) { panel.setVisible(false); closeAction.setEnabled(false); panel.getParent().transferFocus(); } };
crossButton.setAction(closeAction); crossButton.setText("Done"); closeAction.setEnabled(false);
private void search(DocumentEvent documentEvent) { try { String word = documentEvent.getDocument().getText(0, documentEvent.getDocument().getLength()); if (word.isEmpty()) { nextAction.setEnabled(false); previousAction.setEnabled(false); searchPanel.reset(); textComponent.getHighlighter().removeAllHighlights(); return; } search(word); } catch (BadLocationException e) { e.printStackTrace(); } }
a.setEnabled(true); text = getUndoPresentationName(); a.putValue(Action.NAME, text); a.setEnabled(false); text = cantUndoText; a.putValue(Action.NAME, text); a.setEnabled(true); text = getRedoPresentationName(); a.putValue(Action.NAME, text); a.setEnabled(false); text = cantRedoText; a.putValue(Action.NAME, text);
public VectorImporter(Project project, Module module) { super(project, true); this.project = project; this.module = module; final IconApplication container = ApplicationManager.getApplication().getComponent(IconApplication.class); materialIconsController = container.getControllerFactory().getMaterialIconsController(); settingsController = container.getControllerFactory().getSettingsController(); defaultsController = container.getControllerFactory().getDefaultsController(); controller = new IconsImporterController(defaultsController, materialIconsController); initResRoot(); setTitle("Vector Drawable Importer"); getHelpAction().setEnabled(true); AssetSpinnerRenderer renderer = new AssetSpinnerRenderer(); //noinspection GtkPreferredJComboBoxRenderer assetSpinner.setRenderer(renderer); imageContainer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); updateImage(); } }); initSearch(); controller.addObserver(this); init(); pack(); }
public void setEnabled(boolean b) { super.setEnabled(b); if (customEditorAction != null) { customEditorAction.setEnabled(b); } }
getHelpAction().setEnabled(true);
public void setCancelled() { SwingUtilities.invokeLater(() -> { initWindow(); taskLabel .setText("Cancelled. Waiting for reasoner to terminate..."); cancelledAction.setEnabled(false); }); owlEditorKit.getOWLModelManager().getOWLReasonerManager() .killCurrentClassification(); }