Example usage for javax.swing AbstractAction isEnabled

List of usage examples for javax.swing AbstractAction isEnabled

Introduction

In this page you can find the example usage for javax.swing AbstractAction isEnabled.

Prototype

public boolean isEnabled() 

Source Link

Document

Returns true if the action is enabled.

Usage

From source file:net.sf.jabref.gui.RightClickMenu.java

/**
 * @param move For add: if true, remove from previous groups
 *///from  w  ww .  j  av a  2  s  .  com
private void insertNodes(JMenu menu, GroupTreeNode node, BibEntry[] selection, boolean add, boolean move) {
    final AbstractAction action = getAction(node, selection, add, move);

    if (node.getChildCount() == 0) {
        JMenuItem menuItem = new JMenuItem(action);
        setGroupFontAndIcon(menuItem, node.getGroup());
        menu.add(menuItem);
        if (action.isEnabled()) {
            menu.setEnabled(true);
        }
        return;
    }

    JMenu submenu;
    if (node.getGroup() instanceof AllEntriesGroup) {
        for (int i = 0; i < node.getChildCount(); ++i) {
            insertNodes(menu, (GroupTreeNode) node.getChildAt(i), selection, add, move);
        }
    } else {
        submenu = new JMenu('[' + node.getGroup().getName() + ']');
        setGroupFontAndIcon(submenu, node.getGroup());
        // setEnabled(true) is done above/below if at least one menu
        // entry (item or submenu) is enabled
        submenu.setEnabled(action.isEnabled());
        JMenuItem menuItem = new JMenuItem(action);
        setGroupFontAndIcon(menuItem, node.getGroup());
        submenu.add(menuItem);
        submenu.add(new Separator());
        for (int i = 0; i < node.getChildCount(); ++i) {
            insertNodes(submenu, (GroupTreeNode) node.getChildAt(i), selection, add, move);
        }
        menu.add(submenu);
        if (submenu.isEnabled()) {
            menu.setEnabled(true);
        }
    }
}

From source file:net.sf.jabref.gui.ImportInspectionDialog.java

private void insertNodes(JMenu menu, GroupTreeNode node) {
    final AbstractAction action = getAction(node);

    if (node.getNumberOfChildren() == 0) {
        menu.add(action);/*from  w  w w.j  a v  a 2  s. c o m*/
        if (action.isEnabled()) {
            menu.setEnabled(true);
        }
        return;
    }

    JMenu submenu;
    if (node.getGroup() instanceof AllEntriesGroup) {
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(menu, child);
        }
    } else {
        submenu = new JMenu('[' + node.getName() + ']');
        // setEnabled(true) is done above/below if at least one menu
        // entry (item or submenu) is enabled
        submenu.setEnabled(action.isEnabled());
        submenu.add(action);
        submenu.add(new JPopupMenu.Separator());
        for (GroupTreeNode child : node.getChildren()) {
            insertNodes(submenu, child);
        }
        menu.add(submenu);
        if (submenu.isEnabled()) {
            menu.setEnabled(true);
        }
    }
}