org.openide.util.actions.CallbackSystemAction Java Examples
The following examples show how to use
org.openide.util.actions.CallbackSystemAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NbEditorUI.java From netbeans with Apache License 2.0 | 6 votes |
private void detachSystemActionPerformer(JTextComponent c){ if (c == null) return; Action action = getEditorAction(c); if (action == null) return; Action globalSystemAction = getSystemAction(c); if (globalSystemAction == null) return; if (globalSystemAction instanceof CallbackSystemAction){ Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey(); ActionMap am = c.getActionMap(); if (am != null) { Object ea = am.get(key); if (action.equals(ea)) { am.remove(key); } } } }
Example #2
Source File: NbEditorUI.java From netbeans with Apache License 2.0 | 6 votes |
public void editorActivated() { Action ea = getEditorAction(); Action sa = getSystemAction(); if (ea != null && sa != null) { if (updatePerformer) { if (ea.isEnabled() && sa instanceof CallbackSystemAction) { ((CallbackSystemAction)sa).setActionPerformer(this); } } if (syncEnabling) { if (enabledPropertySyncL == null) { enabledPropertySyncL = new EnabledPropertySyncListener(sa); } ea.addPropertyChangeListener(enabledPropertySyncL); } } }
Example #3
Source File: FindSupport.java From netbeans with Apache License 2.0 | 6 votes |
private FindSupport(TopComponent tc) { this.tc = tc; bar = new FindBar(this); ActionMap actionMap = tc.getActionMap(); CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class); actionMap.put(a.getActionMapKey(), new FindAction(true)); actionMap.put(FIND_NEXT_ACTION, new FindAction(true)); actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false)); // Hack ensuring the same shortcuts as editor JEditorPane pane = new JEditorPane(); for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N Object name = action.getValue(Action.NAME); if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) { reuseShortcut(action); } } // PENDING the colors below should not be hardcoded highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66)); highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227)); pattern = Pattern.compile("$^"); // NOI18N }
Example #4
Source File: PageFlowScene.java From netbeans with Apache License 2.0 | 5 votes |
private WidgetAction createActionMap() { ActionMap actionMap = refPageFlowView.get().getActionMap(); CallbackSystemAction a = (CallbackSystemAction) SystemAction.get(DeleteAction.class); actionMap.put(a.getActionMapKey(), new PageFlowDeleteAction(this)); //Temporary workaround ISSUE# 107506 return new MyActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap()); //return ActionFactory.createActionMapAction(MapActionUtility.initInputMap(), MapActionUtility.initActionMap()); }
Example #5
Source File: CommitPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { boolean ret = super.processKeyBinding(ks, e, condition, pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
Example #6
Source File: VCSCommitPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { boolean ret = super.processKeyBinding(ks, e, condition, pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
Example #7
Source File: MergePanel.java From netbeans with Apache License 2.0 | 5 votes |
private void editorActivated(final JEditorPane editor) { //System.out.println("editor("+editor+") activated."); final Action copy = getAction (DefaultEditorKit.copyAction, editor); if (copy != null) { final CallbackSystemAction sysCopy = ((CallbackSystemAction) SystemAction.get (CopyAction.class)); final ActionPerformer perf = new ActionPerformer () { public void performAction (SystemAction action) { copy.actionPerformed (new ActionEvent (editor, 0, "")); // NOI18N } }; sysCopy.setActionPerformer(copy.isEnabled() ? perf : null); PropertyChangeListener copyListener; copy.addPropertyChangeListener(copyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { sysCopy.setActionPerformer(perf); } else if (sysCopy.getActionPerformer() == perf) { sysCopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
Example #8
Source File: DiffPanel.java From netbeans with Apache License 2.0 | 5 votes |
private void editorActivated(final JEditorPane editor) { //System.out.println("editor("+editor+") activated."); final Action copy = getAction (DefaultEditorKit.copyAction, editor); if (copy != null) { final CallbackSystemAction sysCopy = ((CallbackSystemAction) SystemAction.get (CopyAction.class)); final ActionPerformer perf = new ActionPerformer () { public void performAction (SystemAction action) { copy.actionPerformed (new ActionEvent (editor, 0, "")); // NOI18N } }; sysCopy.setActionPerformer(copy.isEnabled() ? perf : null); PropertyChangeListener copyListener; copy.addPropertyChangeListener(copyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { sysCopy.setActionPerformer(perf); } else if (sysCopy.getActionPerformer() == perf) { sysCopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
Example #9
Source File: DiffViewImpl.java From netbeans with Apache License 2.0 | 5 votes |
private void editorActivated(final JEditorPane editor) { final Action copy = getAction (DefaultEditorKit.copyAction, editor); if (copy != null) { final CallbackSystemAction sysCopy = ((CallbackSystemAction) SystemAction.get (CopyAction.class)); final ActionPerformer perf = new ActionPerformer () { public void performAction (SystemAction action) { copy.actionPerformed (new ActionEvent (editor, 0, "")); // NOI18N } }; sysCopy.setActionPerformer(copy.isEnabled() ? perf : null); PropertyChangeListener copyListener; copy.addPropertyChangeListener(copyListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("enabled".equals(evt.getPropertyName())) { // NOI18N if (((Boolean)evt.getNewValue()).booleanValue()) { sysCopy.setActionPerformer(perf); } else if (sysCopy.getActionPerformer() == perf) { sysCopy.setActionPerformer(null); } } } }); if (editor.equals(jEditorPane1)) copyL = copyListener; else copyP = copyListener; } }
Example #10
Source File: NbEditorUI.java From netbeans with Apache License 2.0 | 5 votes |
private void attachSystemActionPerformer(JTextComponent c){ if (c == null) return; Action action = getEditorAction(c); if (action == null) return; Action globalSystemAction = getSystemAction(c); if (globalSystemAction == null) return; if (globalSystemAction instanceof CallbackSystemAction){ Object key = ((CallbackSystemAction)globalSystemAction).getActionMapKey(); c.getActionMap ().put (key, action); } }
Example #11
Source File: CommitPanel.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) { boolean ret = super.processKeyBinding(ks, e, condition, pressed); // XXX #250546 Reason of overriding: to process global shortcut. if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) { Keymap km = Lookup.getDefault().lookup(Keymap.class); Action action = (km != null) ? km.getAction(ks) : null; if (action == null) { return false; } if (action instanceof CallbackSystemAction) { CallbackSystemAction csAction = (CallbackSystemAction) action; if (tabbedPane != null) { Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey()); if (a != null) { a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks))); return true; } } } return false; } else { return ret; } }
Example #12
Source File: DeleteActionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected Class<? extends CallbackSystemAction> actionClass() { return DeleteAction.class; }
Example #13
Source File: CopyActionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected Class<? extends CallbackSystemAction> actionClass() { return CopyAction.class; }
Example #14
Source File: CutActionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected Class<? extends CallbackSystemAction> actionClass() { return CutAction.class; }
Example #15
Source File: PasteActionTest.java From netbeans with Apache License 2.0 | 4 votes |
protected Class<? extends CallbackSystemAction> actionClass() { return PasteAction.class; }
Example #16
Source File: AbstractCallbackActionTestHidden.java From netbeans with Apache License 2.0 | 2 votes |
/** Which action to test. */ protected abstract Class<? extends CallbackSystemAction> actionClass();