Java Code Examples for org.openide.util.Utilities#disabledActionBeep()

The following examples show how to use org.openide.util.Utilities#disabledActionBeep() . 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: StepIntoActionProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void invokeAction() {
    Project p = MainProjectManager.getDefault ().getMainProject ();
    ActionProvider actionProvider = p.getLookup ().lookup (
            ActionProvider.class
        );
    if (Arrays.asList(actionProvider.getSupportedActions ()).contains(ActionProvider.COMMAND_DEBUG_STEP_INTO) &&
        actionProvider.isActionEnabled(ActionProvider.COMMAND_DEBUG_STEP_INTO, p.getLookup())) {

        actionProvider.invokeAction (
                ActionProvider.COMMAND_DEBUG_STEP_INTO,
                p.getLookup ()
            );
    } else {
        Utilities.disabledActionBeep();
        setEnabled (
            ActionsManager.ACTION_STEP_INTO,
            false
        );
    }
}
 
Example 2
Source File: GetLeftEditorAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Perform the action. Sets/unsets maximzed mode. */
 public void actionPerformed(java.awt.event.ActionEvent ev) {
     WindowManager wm = WindowManager.getDefault();
     MultiViewHandler handler = MultiViews.findMultiViewHandler(wm.getRegistry().getActivated());
     if (handler != null) {
         MultiViewPerspective pers = handler.getSelectedPerspective();
         MultiViewPerspective[] all = handler.getPerspectives();
         for (int i = 0; i < all.length; i++) {
             if (pers.getDisplayName().equals(all[i].getDisplayName())) {
                 int newIndex = i != 0 ? i -1 : all.length - 1;
   MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers);
   if (selectedDescr instanceof ContextAwareDescription) {
if (((ContextAwareDescription) selectedDescr).isSplitDescription()) {
    newIndex = i > 1 ? i - 2 : all.length - 1;
} else {
    newIndex = i != 0 ? i - 2 : all.length - 2;
}
   }
                 handler.requestActive(all[newIndex]);
   break;
             }
         }
     } else {
         Utilities.disabledActionBeep();
     }
 }
 
Example 3
Source File: GetRightEditorAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Perform the action. Sets/unsets maximzed mode. */
 public void actionPerformed(java.awt.event.ActionEvent ev) {
     WindowManager wm = WindowManager.getDefault();
     MultiViewHandler handler = MultiViews.findMultiViewHandler(wm.getRegistry().getActivated());
     if (handler != null) {
         MultiViewPerspective pers = handler.getSelectedPerspective();
         MultiViewPerspective[] all = handler.getPerspectives();
         for (int i = 0; i < all.length; i++) {
             if (pers.equals(all[i])) {
                 int newIndex = i != all.length  - 1 ? i + 1 : 0;
   MultiViewDescription selectedDescr = Accessor.DEFAULT.extractDescription(pers);
   if (selectedDescr instanceof ContextAwareDescription) {
if (((ContextAwareDescription) selectedDescr).isSplitDescription()) {
    newIndex = i != all.length  - 1 ? i + 2 : 1;
} else {
    newIndex = i != all.length  - 2 ? i + 2 : 0;
}
   }
                 handler.requestActive(all[newIndex]);
   break;
             }
         }
     } else {
         Utilities.disabledActionBeep();
     }
 }
 
Example 4
Source File: ExplorerActionsImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    PasteType[] arr;
    synchronized (this) {
        arr = this.pasteTypes;
    }
    if (arr != null && arr.length > 0) {
        try {
            arr[0].paste();
            return;
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    Utilities.disabledActionBeep();
}
 
Example 5
Source File: TreeTableView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked when an action occurs.
 */
@Override
public void actionPerformed(ActionEvent e) {
    if (treeTable.getSelectedColumn() != ((TreeTable) treeTable).getTreeColumnIndex()) {
        return;
    }

    Node[] nodes = manager.getSelectedNodes();

    if (nodes.length == 1) {
        Action a = nodes[0].getPreferredAction();

        if (a != null) {
            if (a.isEnabled()) {
                a.actionPerformed(new ActionEvent(nodes[0], ActionEvent.ACTION_PERFORMED, "")); // NOI18N
            } else {
                Utilities.disabledActionBeep();
            }
        }
    }
}
 
Example 6
Source File: TreeView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void performPreferredActionOnNodes(Node[] nodes) {
    if (nodes.length > 0) {
        Action a = nodes[0].getPreferredAction();
        if (a == null) {
            return;
        }
        for (int i=1; i<nodes.length; i++) {
            Action ai = nodes[i].getPreferredAction();
            if (ai == null || !ai.equals(a)) {
                return;
            }
        }

        // switch to replacement action if there is some
        a = takeAction(a, nodes);
        if (a != null && a.isEnabled()) {
            a.actionPerformed(new ActionEvent(
                    nodes.length == 1 ? nodes[0] : nodes,
                    ActionEvent.ACTION_PERFORMED, "")); // NOI18N
        } else {
            Utilities.disabledActionBeep();
        }
    }
}
 
Example 7
Source File: CallbackSystemAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Perform the action. Tries the performer and then scans the ActionMap
 * of selected topcomponent.
 */
public void actionPerformed(final ActionEvent ev) {
    // First try global context action.
    final Action action = GlobalManager.getDefault().findGlobalAction(getActionMapKey(), getSurviveFocusChange());

    if (action != null) {
        if (action.isEnabled()) {
            action.actionPerformed(ev);
        } else {
            Utilities.disabledActionBeep();
        }

        return;
    }

    final Object ap = getActionPerformer();

    if (ap != null) {
        org.openide.util.actions.ActionInvoker.invokeAction(
            this, ev, asynchronous(), new Runnable() {
                public void run() {
                    if (ap == getActionPerformer()) {
                        getActionPerformer().performAction(CallbackSystemAction.this);
                    }
                }
            }
        );

        return;
    }

    Utilities.disabledActionBeep();
}
 
Example 8
Source File: CallableSystemAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent ev) {
    if (isEnabled()) {
        org.openide.util.actions.ActionInvoker.invokeAction(
            this, ev, asynchronous(), new Runnable() {
                public void run() {
                    performAction();
                }
            }
        );
    } else {
        // Should not normally happen.
        Utilities.disabledActionBeep();
    }
}
 
Example 9
Source File: TreeView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    tree.stopEditing();
    int selRow = tree.getRowForLocation(e.getX(), e.getY());

    if ((selRow != -1) && SwingUtilities.isLeftMouseButton(e) && MouseUtils.isDoubleClick(e)) {
        // Default action.
        if (defaultActionEnabled) {
            TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
            Node node = Visualizer.findNode(selPath.getLastPathComponent());

            Action a = takeAction(node.getPreferredAction(), node);

            if (a != null) {
                if (a.isEnabled()) {
                    a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
                } else {
                    Utilities.disabledActionBeep();
                }

                e.consume();

                return;
            }
        }

        if (tree.isExpanded(selRow)) {
            tree.collapseRow(selRow);
        } else {
            tree.expandRow(selRow);
        }
    }
}
 
Example 10
Source File: PropertyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    Action wrapped = getWrapped();

    if (wrapped != null) {
        wrapped.actionPerformed(e);
    } else {
        Utilities.disabledActionBeep();
    }
}
 
Example 11
Source File: ListView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** This method is called when user double-clicks on some object or
* presses Enter key.
* @param index Index of object in current explored context
*/
final void performObjectAt(int index, int modifiers) {
    if ((index < 0) || (index >= model.getSize())) {
        return;
    }

    VisualizerNode v = (VisualizerNode) model.getElementAt(index);
    Node node = v.node;

    // if DefaultProcessor is set, the default action is notified to it overriding the default action on nodes
    if (defaultProcessor != null) {
        defaultProcessor.actionPerformed(new ActionEvent(node, 0, null, modifiers));

        return;
    }

    if (showParentNode && NodeListModel.findVisualizerDepth(model, v) == -1) {
        try {
            manager.setExploredContextAndSelection(node.getParentNode(), new Node[] { node });
        } catch (PropertyVetoException ex) {
            // OK, let it be
        }
        return;
    }

    // on double click - invoke default action, if there is any
    // (unless user holds CTRL key what means that we should always dive into the context)
    Action a = node.getPreferredAction();

    if ((a != null) && ((modifiers & InputEvent.CTRL_MASK) == 0)) {
        a = TreeView.takeAction(a, node);

        if (a.isEnabled()) {
            a.actionPerformed(new ActionEvent(node, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
        } else {
            Utilities.disabledActionBeep();
        }
    }
    // otherwise dive into the context
    else if (traversalAllowed && (!node.isLeaf())) {
        manager.setExploredContext(node, manager.getSelectedNodes());
    }
}
 
Example 12
Source File: NbPresenter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Shows a specified HelpCtx in IDE's help window.
* @param helpCtx thehelp to be shown
*/
private static void showHelp(HelpCtx helpCtx) {
    if (!helpCtx.display()) {
        Utilities.disabledActionBeep();
    }
}
 
Example 13
Source File: ProjectAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
static void runSequentially(final Queue<Project> queue, final LookupSensitiveAction a, final String command) {
    Project p = queue.remove();
    final ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
    if (ap == null) {
        return;
    }
    if (!Arrays.asList(ap.getSupportedActions()).contains(command)) {
        // #47160: was a supported command (e.g. on a freeform project) but was then removed.
        Utilities.disabledActionBeep();
        a.resultChanged(null);
        return;
    }
    LogRecord r = new LogRecord(Level.FINE, "PROJECT_ACTION"); // NOI18N
    r.setResourceBundle(NbBundle.getBundle(ProjectAction.class));
    r.setParameters(new Object[] {
        a.getClass().getName(),
        p.getClass().getName(),
        a.getValue(NAME)
    });
    r.setLoggerName(UILOG.getName());
    UILOG.log(r);
    Mutex.EVENT.writeAccess(new Runnable() {
        @Override public void run() {
            final AtomicBoolean started = new AtomicBoolean();
            ap.invokeAction(command, Lookups.singleton(new ActionProgress() {
                @Override protected void started() {
                    started.set(true);
                }
                @Override public void finished(boolean success) {
                    if (success && !queue.isEmpty()) { // OK, next...
                        runSequentially(queue, a, command);
                    } else { // stopping now; restore natural action enablement state
                        a.resultChanged(null);
                    }
                }
            }));
            if (started.get()) {
                a.setEnabled(false);
            } else if (!queue.isEmpty()) {
                // Did not run action for some reason; try others?
                runSequentially(queue, a, command);
            }
        }
    });
}