當前位置: 首頁>>代碼示例>>Java>>正文


Java Action.isEnabled方法代碼示例

本文整理匯總了Java中javax.swing.Action.isEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java Action.isEnabled方法的具體用法?Java Action.isEnabled怎麽用?Java Action.isEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.Action的用法示例。


在下文中一共展示了Action.isEnabled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: actionPerformed

import javax.swing.Action; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent e) {
    if (!invokeDefaultAction((JTextComponent) e.getSource())) {
        Action actions[] = ImplementationProvider.getDefault().getGlyphGutterActions((JTextComponent) e.getSource());
        
        if (actions == null)
            return ;
        
        int nextAction = 0;
        
        while (nextAction < actions.length && actions[nextAction] != this)
            nextAction++;
        
        nextAction++;
        
        if (actions.length > nextAction) {
            Action a = actions[nextAction];
            if (a!=null && a.isEnabled()){
                a.actionPerformed(e);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:IsOverriddenAnnotationAction.java

示例2: performPreferredActionOnNodes

import javax.swing.Action; //導入方法依賴的package包/類
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();
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:TreeView.java

示例3: getPopupPresenter

import javax.swing.Action; //導入方法依賴的package包/類
public JMenuItem getPopupPresenter() {
    JMenuItem prop = new Actions.MenuItem(this, false);

    Action customizeAction = SystemAction.get(CustomizeAction.class);

    // Retrieve context sensitive action instance if possible.
    if (lookup != null) {
        customizeAction = ((ContextAwareAction) customizeAction).createContextAwareInstance(lookup);
    }

    if (customizeAction.isEnabled()) {
        JInlineMenu mi = new JInlineMenu();
        mi.setMenuItems(new JMenuItem[] { new Actions.MenuItem(customizeAction, false), prop });

        return mi;
    } else {
        for (Node n : nodes()) {
            for (Node.PropertySet ps : n.getPropertySets()) {
                if (ps.getProperties().length > 0) {
                    // OK, we have something to show!
                    return prop;
                }
            }
        }
        // else nothing to show, so show nothing
        return new JInlineMenu();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:PropertiesAction.java

示例4: getPreferredAction

import javax.swing.Action; //導入方法依賴的package包/類
@Override
public Action getPreferredAction() {
    FormEditor formEditor = FormEditor.getFormEditor(component.getFormModel());
    if (formEditor == null) {
        return null;
    }

    for (Action action : formEditor.getDefaultComponentActions()) {
        if (action.isEnabled()) {
            return action;
        }
    }

    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:RADComponentNode.java

示例5: actionPerformed

import javax.swing.Action; //導入方法依賴的package包/類
public void actionPerformed( ActionEvent e ) {
    if( 0 == getModel().getRowCount() )
        return;
    
    int currentRow = getSelectedRow();
    if( currentRow < 0 ) {
        currentRow = 0;
    } else if( !(isFoldingModel() && getFoldingModel().isGroupRow(currentRow)) ) {
        currentRow += (navigateToNextTask ? 1 : -1);
    }
    
    TaskListModel tlm = (TaskListModel)getModel();
    while( true ) {
        if( currentRow < 0 )
            currentRow = tlm.getRowCount()-1;
        else if( currentRow >= tlm.getRowCount() )
            currentRow = 0;
        Task t = tlm.getTaskAtRow( currentRow );
        if( null != t ) {
            getSelectionModel().setSelectionInterval( currentRow, currentRow );
            scrollRectToVisible( getCellRect( currentRow, 0, true ) );
            Action a = new OpenTaskAction( t );
            if( a.isEnabled() ) {
                a.actionPerformed( e );
            } else {
                TaskListTopComponent.findInstance().requestActive();
            }
            break;
        } else if( isFoldingModel() ) {
            FoldingTaskListModel.FoldingGroup fg = getFoldingModel().getGroupAtRow( currentRow );
            if( !fg.isExpanded() )
                fg.setExpanded( true );
        }
        currentRow += (navigateToNextTask ? 1 : -1);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:TaskListTable.java

示例6: isEnabled

import javax.swing.Action; //導入方法依賴的package包/類
@Override
public boolean isEnabled() {
    Action dAction = delegateAction;
    if (dAction != null && dAction != UNITIALIZED_ACTION) {
        return dAction.isEnabled();
    } else {
        return super.isEnabled();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:AbstractEditorAction.java

示例7: actionPerformed

import javax.swing.Action; //導入方法依賴的package包/類
/** 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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:CallbackSystemAction.java

示例8: isPopupEnabled

import javax.swing.Action; //導入方法依賴的package包/類
/** Tells if there is any action that is willing to provide
 * Presenter.Popup
 */
private boolean isPopupEnabled(Action toolsAction) {
    boolean en = false;
    Action[] copy = actions;

    // Get action conext.
    Lookup lookup;

    if (toolsAction instanceof Lookup.Provider) {
        lookup = ((Lookup.Provider) toolsAction).getLookup();
    } else {
        lookup = null;
    }

    for (int i = 0; i < copy.length; i++) {
        if (copy[i] == null) {
            continue;
        }
        // Get context aware action instance if needed.
        Action act;

        // Retrieve context aware action instance if possible.
        if ((lookup != null) && copy[i] instanceof ContextAwareAction) {
            act = ((ContextAwareAction) copy[i]).createContextAwareInstance(lookup);
            if (act == null) {
                throw new IllegalStateException("createContextAwareInstance for " + copy[i] + " returned null!");
            }
        } else {
            act = copy[i];
        }

        if (act.isEnabled()) {
            en = true;

            break;
        }
    }

    return en;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:43,代碼來源:ToolsAction.java

示例9: mouseClicked

import javax.swing.Action; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
    int row = table.rowAtPoint(e.getPoint());
    int column = table.columnAtPoint(e.getPoint());
    if (SwingUtilities.isLeftMouseButton(e)) {
        if (row == -1) return;
        row = sorter.modelIndex(row);
        if(MouseUtils.isDoubleClick(e)) {
            Action action = tableModel.getNodes()[row].getPreferredAction();
            if (action.isEnabled()) {
                action.actionPerformed(new ActionEvent(this, 0, "")); // NOI18N
            }
        } else {

            // seen column
            if(column == getSeenColumnIdx()) {
                final IssueNode in = (IssueNode) tableModel.getNodes()[row];
                getRequestProcessor().post(new Runnable() {
                    @Override
                    public void run() {
                        IssueStatusProvider.Status status = in.getStatus();
                        in.setSeen(status != IssueStatusProvider.Status.SEEN);
                    }
                });
            }
            // check for action
            CellAction[] actions = null;
            synchronized(cellActions) {
                Cell cell = new Cell(row, column);
                Set<CellAction> set = cellActions.get(cell);
                actions = set != null ? set.toArray(new CellAction[set.size()]) : null;
            }
            if(actions != null) {
                for (CellAction cellAction : actions) {
                    cellAction.actionPerformed(null);
                }
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:IssueTable.java

示例10: updateActions

import javax.swing.Action; //導入方法依賴的package包/類
/**
 * Ensures that undo/redo actions are enabled appropriately and have
 * descriptive text at all times.
 */
public void updateActions() {

	String text;

	Action a = RTextArea.getAction(RTextArea.UNDO_ACTION);
	if (canUndo()) {
		a.setEnabled(true);
		text = getUndoPresentationName();
		a.putValue(Action.NAME, text);
		a.putValue(Action.SHORT_DESCRIPTION, text);
	}
	else {
		if (a.isEnabled()) {
			a.setEnabled(false);
			text = cantUndoText;
			a.putValue(Action.NAME, text);
			a.putValue(Action.SHORT_DESCRIPTION, text);
		}
	}

	a = RTextArea.getAction(RTextArea.REDO_ACTION);
	if (canRedo()) {
		a.setEnabled(true);
		text = getRedoPresentationName();
		a.putValue(Action.NAME, text);
		a.putValue(Action.SHORT_DESCRIPTION, text);
	}
	else {
		if (a.isEnabled()) {
			a.setEnabled(false);
			text = cantRedoText;
			a.putValue(Action.NAME, text);
			a.putValue(Action.SHORT_DESCRIPTION, text);
		}
	}

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:42,代碼來源:RUndoManager.java

示例11: getDeleteDelegates

import javax.swing.Action; //導入方法依賴的package包/類
private List<Action> getDeleteDelegates () {
    Node[] nodes = getExplorerManager().getSelectedNodes();
    Action delegate = null;
    // works only for one node at the moment
    if (nodes.length == 1) {
        Action[] actions = nodes[0].getActions(true);
        for (Action a : actions) {
            if (a != null && Boolean.TRUE.equals(a.getValue(PROP_DELETE_ACTION)) && a.isEnabled()) {
                delegate = a;
            }
        }
    }
    return delegate == null ? Collections.<Action>emptyList() : Arrays.asList(delegate);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:RepositoryBrowserPanel.java

示例12: keyPressed

import javax.swing.Action; //導入方法依賴的package包/類
public @Override void keyPressed(KeyEvent e){
    if (e != null && popup != null && popup.isShowing()) {
        
        // get popup's registered keyboard actions
        ActionMap am = popup.getActionMap();
        InputMap  im = popup.getInputMap();
        
        // check whether popup registers keystroke
        KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
        Object obj = im.get(ks);
        LOG.log(Level.FINE, "Keystroke for event {0}: {1}; action-map-key={2}", new Object [] { e, ks, obj }); //NOI18N
        if (obj != null && !obj.equals("tooltip-no-action") //NOI18N ignore ToolTipSupport installed actions
        ) {
            // if yes, gets the popup's action for this keystroke, perform it 
            // and consume key event
            Action action = am.get(obj);
            LOG.log(Level.FINE, "Popup component''s action: {0}, {1}", new Object [] { action, action != null ? action.getValue(Action.NAME) : null }); //NOI18N

            if (action != null && action.isEnabled()) {
                action.actionPerformed(null);
                e.consume();
                return;
            }
        }

        if (e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH &&
            e.getKeyCode() != KeyEvent.VK_META
        ) {
            // hide tooltip if any was shown
            Utilities.getEditorUI(textComponent).getToolTipSupport().setToolTipVisible(false);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:PopupManager.java

示例13: getIsEnabled

import javax.swing.Action; //導入方法依賴的package包/類
protected boolean getIsEnabled(final Action a1) throws InterruptedException, InvocationTargetException {
    assertTrue("In AWT", EventQueue.isDispatchThread());
    
    return a1.isEnabled();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:6,代碼來源:ContextActionTest.java

示例14: addAction

import javax.swing.Action; //導入方法依賴的package包/類
protected @Override void addAction(JTextComponent component, JPopupMenu popupMenu, String actionName) {
    if (actionName != null) { // try if it's an action class name
        // Check for the TopComponent actions
        if (TopComponent.class.getName().equals(actionName)) {
            addTopComponentActions(component, popupMenu);
            return;

        } else { // not cloneable-editor actions

            // Try to load the action class
            Class saClass = null;
            try {
                ClassLoader loader = (ClassLoader)Lookup.getDefault().lookup(ClassLoader.class);
                saClass = Class.forName(actionName, false, loader);
            } catch (Throwable t) {
            }
            
            if (saClass != null && SystemAction.class.isAssignableFrom(saClass)) {
                Lookup contextLookup = getContextLookup(component);
                Action action = SystemAction.get(saClass);
                action = translateContextLookupAction(contextLookup, action);
                JMenuItem item = (action != null) ? createLocalizedMenuItem(action) : null;
                if (item != null) {
                    if (item instanceof DynamicMenuContent) {
                        Component[] cmps = ((DynamicMenuContent)item).getMenuPresenters();
                        for (int i = 0; i < cmps.length; i++) {
                            if(cmps[i] != null) {
                                popupMenu.add(cmps[i]);
                            } else {
                                popupMenu.addSeparator();
                            }
                        }
                    } else {
                        if (!(item instanceof JMenu)) {
                            if (Boolean.TRUE.equals(action.getValue(DynamicMenuContent.HIDE_WHEN_DISABLED)) && !action.isEnabled()) {
                                return;
                            }
                            assignAccelerator(
                                 (Keymap)Lookup.getDefault().lookup(Keymap.class),
                                 action,
                                 item
                            );
                        }
                        debugPopupMenuItem(item, action);
                        popupMenu.add(item);
                    }
                }

                return;
            }
        }

    }

    super.addAction(component, popupMenu, actionName);

}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:58,代碼來源:NbEditorKit.java

示例15: performObjectAt

import javax.swing.Action; //導入方法依賴的package包/類
/** 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());
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:47,代碼來源:ListView.java


注:本文中的javax.swing.Action.isEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。