当前位置: 首页>>代码示例>>Java>>正文


Java Actions类代码示例

本文整理汇总了Java中org.openide.awt.Actions的典型用法代码示例。如果您正苦于以下问题:Java Actions类的具体用法?Java Actions怎么用?Java Actions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Actions类属于org.openide.awt包,在下文中一共展示了Actions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActions

import org.openide.awt.Actions; //导入依赖的package包/类
@Override
public Action[] getActions(boolean context) {
    if (!context) {
        Action copyPath = Actions.forID("Edit", //NOI18N
                "org.netbeans.modules.utilities.CopyPathToClipboard"); //NOI18N
        return new Action[]{
                    SystemAction.get(OpenMatchingObjectsAction.class),
                    replacing && !matchingObject.isObjectValid()
                        ? new RefreshAction(matchingObject) : null,
                    null,
                    copyPath == null ? new CopyPathAction() : copyPath,
                    SystemAction.get(HideResultAction.class),
                    null,
                    SystemAction.get(SelectInAction.class),
                    SystemAction.get(MoreAction.class)
                };
    } else {
        return new Action[0];
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MatchingObjectNode.java

示例2: synchMenuPresenters

import org.openide.awt.Actions; //导入依赖的package包/类
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
    JComponent[] comps = new JComponent[1];
    for (JComponent item : items) {
        if (item instanceof Actions.MenuItem) {
            comps[0] = item;
            // update menu items to reflect Action.isEnabled
            ((Actions.MenuItem) item).synchMenuPresenters(comps);
        } else if(item instanceof JMenu) {
            JMenu jMenu = (JMenu) item;
            for (Component subItem : jMenu.getMenuComponents()) {
                if (subItem instanceof Actions.MenuItem) {
                    comps[0] = (JComponent) subItem;
                    // update menu items to reflect Action.isEnabled
                    ((Actions.MenuItem) subItem).synchMenuPresenters(comps);
                }
            }
        }
    }
    // returns most up-to date items
    return createMenuItems();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:RefactoringContextAction.java

示例3: getToolbarPresenter

import org.openide.awt.Actions; //导入依赖的package包/类
public Component getToolbarPresenter() {
    if (toolbarPresenter == null) {
        // gets the real action registered in the menu from layer
        Action a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachMainProject"); // NOI18N
        final Action attachProjectAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();
        
        // gets the real action registered in the menu from layer
        a = Actions.forID("Profile", "org.netbeans.modules.profiler.actions.AttachAction"); // NOI18N
        final Action attachProcessAction = a != null ? a : /* XXX should be impossible */AttachAction.getInstance();

        JPopupMenu dropdownPopup = new JPopupMenu();
        dropdownPopup.add(createDropdownItem(defaultAction));
        dropdownPopup.add(createDropdownItem(attachProjectAction));
        dropdownPopup.addSeparator();
        dropdownPopup.add(createDropdownItem(attachProcessAction));

        JButton button = DropDownButtonFactory.createDropDownButton(new ImageIcon(
                new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB)), dropdownPopup);
        Actions.connect(button, defaultAction);

        toolbarPresenter = button;
    }

    return toolbarPresenter;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProfilerToolbarDropdownAction.java

示例4: createDropdownItem

import org.openide.awt.Actions; //导入依赖的package包/类
private static JMenuItem createDropdownItem(final Action action) {
    String name = (String)action.getValue("menuText"); // NOI18N
    if (name == null || name.trim().isEmpty()) name = (String)action.getValue(NAME);
    final JMenuItem item = new JMenuItem(Actions.cutAmpersand(name)) {
        public void fireActionPerformed(ActionEvent e) {
            action.actionPerformed(e);
        }
    };
    item.setEnabled(action.isEnabled());
    
    // #231371
    action.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            String propName = evt.getPropertyName();
            if ("enabled".equals(propName)) { // NOI18N
                item.setEnabled((Boolean)evt.getNewValue());
            } else if ("menuText".equals(propName)) { // NOI18N
                item.setText(Actions.cutAmpersand((String) evt.getNewValue()));
            }
        }
    });

    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProfilerToolbarDropdownAction.java

示例5: testOpenActionIsAlwaysFirst

import org.openide.awt.Actions; //导入依赖的package包/类
public void testOpenActionIsAlwaysFirst() throws Exception {
    Node n = obj.getNodeDelegate();

    Action openAction = Actions.forID("System", "org.openide.actions.OpenAction");

    assertEquals(
            "Open action is the default one",
            openAction,
            n.getPreferredAction()
            );

    Action[] actions = n.getActions(false);
    assertTrue("There are some actions", actions.length > 1);

    assertEquals(
            "First one is open",
            openAction,
            actions[0]
            );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:DefaultDataObjectHasOpenActionTest.java

示例6: MyProperty

import org.openide.awt.Actions; //导入依赖的package包/类
MyProperty (
    ColumnModel columnModel, TreeModelRoot treeModelRoot
) {
    super (
        columnModel.getID (),
        (columnModel.getType() == null) ? String.class : columnModel.getType (),
        Actions.cutAmpersand(columnModel.getDisplayName ()),
        columnModel.getShortDescription (), 
        true,
        true
    );
    this.nodeColumn = columnModel.getType() == null;
    this.treeModelRoot = treeModelRoot;
    if (columnModel instanceof HyperColumnModel) {
        propertyId = columnModel.getID(); // main column ID
        this.columnModel = ((HyperColumnModel) columnModel).getSpecific();
        id = this.columnModel.getID ();   // specific column ID
    } else {
        id = propertyId = columnModel.getID ();
        this.columnModel = columnModel;
    }
    //System.err.println("new MyProperty("+TreeModelNode.this+", "+id+") = "+this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TreeModelNode.java

示例7: getDisplayName

import org.openide.awt.Actions; //导入依赖的package包/类
/**
 * Returns display name for given node.
 *
 * @throws  UnknownTypeException if this NodeModel implementation is not
 *          able to resolve display name for given node type
 * @return  display name for given node
 */
@Override
public String getDisplayName (Object node) throws UnknownTypeException {
    if (nodeModel instanceof DelegatingNodeModel) {
        NodeModel[] subModels = ((DelegatingNodeModel) nodeModel).getModels();
        if (subModels.length == 0) {
            if (TreeModel.ROOT.equals(node)) {
                ColumnModel[] columns = getColumns();
                for (ColumnModel cm : columns) {
                    if (cm.getType() == null) {
                        return Actions.cutAmpersand(cm.getDisplayName());
                    }
                }
            }
            return ""; // Nothing when there are no models
        }
    }
    String dn = nodeModel.getDisplayName (node);
    //System.err.println("DisplayName for node '"+node+"' is: '"+dn+"'");
    //System.err.println("Model = "+this);
    return dn;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:Models.java

示例8: testCanTCGarbageCollectWhenActionInMap

import org.openide.awt.Actions; //导入依赖的package包/类
public void testCanTCGarbageCollectWhenActionInMap() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:TopComponentTest.java

示例9: testCanTCGarbageCollectWhenActionInMapAndAssignLookup

import org.openide.awt.Actions; //导入依赖的package包/类
public void testCanTCGarbageCollectWhenActionInMapAndAssignLookup() {
    TopComponent tc = new TopComponent();
    class CAA extends AbstractAction implements
            ContextAwareAction {
        public void actionPerformed(ActionEvent arg0) {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public Action createContextAwareInstance(Lookup actionContext) {
            return this;
        }

    }
    tc.associateLookup(Lookups.fixed(tc.getActionMap(), tc));
    ContextAwareAction del = new CAA();
    ContextAwareAction context = Actions.context(Integer.class, true, true, del, null, "DisplayName", null, true);
    Action a = context.createContextAwareInstance(tc.getLookup());
    tc.getActionMap().put("key", a);

    WeakReference<Object> ref = new WeakReference<Object>(tc);
    tc = null;
    a = null;
    del = null;
    context = null;
    assertGC("Can the component GC?", ref);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TopComponentTest.java

示例10: testContextAction

import org.openide.awt.Actions; //导入依赖的package包/类
public void testContextAction() throws Exception {
    Action a = Actions.forID("Tools", "on.int");
    assertTrue("It is context aware action", a instanceof ContextAwareAction);

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = ((ContextAwareAction) a).createContextAwareInstance(lkp);
    NumberLike ten = new NumberLike(10);
    ic.add(ten);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(ten);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ActionProcessorTest.java

示例11: actionPerformed

import org.openide.awt.Actions; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    try {
        Actions.forID("System", "org.netbeans.modules.autoupdate.ui.actions.PluginManagerAction").actionPerformed(new ActionEvent(e.getSource(), 100, initialTab));
    } catch (Exception ex) {
        Exceptions.printStackTrace(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:PluginsPanel.java

示例12: getPopupPresenter

import org.openide.awt.Actions; //导入依赖的package包/类
@Override
public JMenuItem getPopupPresenter() {
    if (project != null) {
        return createMenu(project);
    } else {
        return new Actions.MenuItem(this, false);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:RunTargetsAction.java

示例13: getProcessDisplayName

import org.openide.awt.Actions; //导入依赖的package包/类
private static String getProcessDisplayName(AntProjectCookie pcookie, List<String> targetNames) {
    Element projel = pcookie.getProjectElement();
    String projectName;
    if (projel != null) {
        // remove & if available.
        projectName = Actions.cutAmpersand(projel.getAttribute("name")); // NOI18N
    } else {
        projectName = NbBundle.getMessage(TargetExecutor.class, "LBL_unparseable_proj_name");
    }
    String fileName;
    if (pcookie.getFileObject() != null) {
        fileName = pcookie.getFileObject().getNameExt();
    } else if (pcookie.getFile() != null) {
        fileName = pcookie.getFile().getName();
    } else {
        fileName = ""; // last resort for #84874
    }
    if (projectName.equals("")) { // NOI18N
        // No name="..." given, so try the file name instead.
        projectName = fileName;
    }
    if (targetNames != null) {
        StringBuffer targetList = new StringBuffer();
        Iterator<String> it = targetNames.iterator();
        if (it.hasNext()) {
            targetList.append(it.next());
        }
        while (it.hasNext()) {
            targetList.append(NbBundle.getMessage(TargetExecutor.class, "SEP_output_target"));
            targetList.append(it.next());
        }
        return NbBundle.getMessage(TargetExecutor.class, "TITLE_output_target", projectName, fileName, targetList);
    } else {
        return NbBundle.getMessage(TargetExecutor.class, "TITLE_output_notarget", projectName, fileName);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:TargetExecutor.java

示例14: getSubComponents

import org.openide.awt.Actions; //导入依赖的package包/类
static SubComponent[] getSubComponents( final MultiViewPeer peer ) {
    MultiViewModel model = peer.getModel();
    MultiViewPerspective[] perspectives = model.getPerspectives();
    ArrayList<SubComponent> res = new ArrayList<SubComponent>(perspectives.length);
    for( int i=0; i<perspectives.length; i++ ) {
        final MultiViewPerspective mvp = perspectives[i];
 MultiViewDescription descr = Accessor.DEFAULT.extractDescription(mvp);
        if( descr instanceof ContextAwareDescription ) {
            //don't show split elements unless they're really showing on the screen
            ContextAwareDescription contextDescr = ( ContextAwareDescription ) descr;
            if( contextDescr.isSplitDescription() && !peer.tabs.isShowing( descr ) ) {
                continue;
            }
        }
 Lookup lookup = descr == null ? peer.getLookup() :
  model.getElementForDescription(descr, false) == null ? peer.getLookup() : model.getElementForDescription(descr, false).getLookup();
 boolean showing = peer.tabs.isShowing(descr);
        res.add( new SubComponent( Actions.cutAmpersand(mvp.getDisplayName()), null, new ActionListener() {

            @Override
            public void actionPerformed( ActionEvent e ) {
                peer.getMultiViewHandlerDelegate().requestActive( mvp );
            }
        }, mvp == model.getSelectedPerspective(), lookup, showing ) );
    }
    return res.toArray( new SubComponent[res.size()] );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:MultiViewTopComponent.java

示例15: getPopupPresenter

import org.openide.awt.Actions; //导入依赖的package包/类
@Override
public JMenuItem getPopupPresenter() {
    JMenu menu = new UpdatingMenu();
    String label = NbBundle.getMessage(EditorsAction.class, "CTL_EditorsAction");
    Actions.setMenuText(menu, label, false);
    return menu;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:EditorsAction.java


注:本文中的org.openide.awt.Actions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。