当前位置: 首页>>代码示例>>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;未经允许,请勿转载。