• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Presenter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: acceptCookie

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/**
           * Accepts only cookies that can provide <code>Menu</code>.
           * @param cookie an <code>InstanceCookie</code> to test
           * @return true if the cookie can provide accepted instances
           */
  	    protected @Override InstanceCookie acceptCookie(InstanceCookie cookie)
  	    throws IOException, ClassNotFoundException {
// [pnejedly] Don't try to optimize this by InstanceCookie.Of
// It will load the classes few ms later from instanceCreate
// anyway and more instanceOf calls take longer
          	Class c = cookie.instanceClass();
              boolean action = Action.class.isAssignableFrom (c);
              if (action) {
                  cookie.instanceCreate();
              }
          	boolean is =
              	Presenter.Menu.class.isAssignableFrom (c) ||
              	JMenuItem.class.isAssignableFrom (c) ||
              	JSeparator.class.isAssignableFrom (c) ||
                  action;
          	return is ? cookie : null;
  	    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:MenuBar.java


示例2: acceptCookie

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/**
 * Accepts only cookies that can provide <code>Toolbar</code>.
 * @param cookie an <code>InstanceCookie</code> to test
 * @return true if the cookie can provide accepted instances
 */
@Override
protected InstanceCookie acceptCookie (InstanceCookie cookie)
    throws IOException, ClassNotFoundException {
    boolean is;
    boolean action;
    
    if (cookie instanceof InstanceCookie.Of) {
        InstanceCookie.Of of = (InstanceCookie.Of)cookie;
        action = of.instanceOf (Action.class);
        is = of.instanceOf (Component.class) ||
             of.instanceOf (Presenter.Toolbar.class) ||
             action;
    } else {
        Class c = cookie.instanceClass();
        action = Action.class.isAssignableFrom (c);
        is = Component.class.isAssignableFrom(c) ||
             Presenter.Toolbar.class.isAssignableFrom(c) ||
             action;
    }
    if (action) {
        cookie.instanceCreate();
    }
    
    return is ? cookie : null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:Toolbar.java


示例3: testManualRefreshPreference

import org.openide.util.actions.Presenter; //导入依赖的package包/类
public void testManualRefreshPreference() throws IOException {
    Preferences pref = NbPreferences.root().node("org/openide/actions/FileSystemRefreshAction");
    assertFalse("Not set", pref.getBoolean("manual", false));

    FileObject fo = FileUtil.toFileObject(getWorkDir());
    Lookup lkp = Lookups.singleton(DataFolder.findFolder(fo).getNodeDelegate());

    FileSystemAction fsa = FileSystemAction.get(FileSystemAction.class);
    Action a = fsa.createContextAwareInstance(lkp);

    assertEquals("Menu presenter ", true, a instanceof Presenter.Menu);

    Presenter.Menu pm = (Presenter.Menu)a;
    DynamicMenuContent submenu = (DynamicMenuContent)pm.getMenuPresenter();
    assertEquals("No submenu", 0, submenu.getMenuPresenters().length);

    pref.putBoolean("manual", true);

    DynamicMenuContent submenu2 = (DynamicMenuContent)pm.getMenuPresenter();
    assertEquals("One action", 1, submenu2.getMenuPresenters().length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FileSystemActionTest.java


示例4: setShowEditorToolbar

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private static boolean setShowEditorToolbar( boolean show ) {
    boolean res = true;
    Action toggleEditorToolbar = FileUtil.getConfigObject( "Editors/Actions/toggle-toolbar.instance", Action.class ); //NOI18N
    if( null != toggleEditorToolbar ) {
        if( toggleEditorToolbar instanceof Presenter.Menu ) {
            JMenuItem menuItem = ((Presenter.Menu)toggleEditorToolbar).getMenuPresenter();
            if( menuItem instanceof JCheckBoxMenuItem ) {
                JCheckBoxMenuItem checkBoxMenu = ( JCheckBoxMenuItem ) menuItem;
                res = checkBoxMenu.isSelected();
                if( checkBoxMenu.isSelected() != show ) {
                    try {
                        toggleEditorToolbar.actionPerformed( new ActionEvent( menuItem, 0, "")); //NOII18N
                    } catch( Exception ex ) {
                        //don't worry too much if it isn't working, we're just trying to be helpful here
                        Logger.getLogger( EditorOnlyDisplayer.class.getName()).log( Level.FINE, null, ex );
                    }
                }
            }
        }
    }

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


示例5: testActionPerformed

import org.openide.util.actions.Presenter; //导入依赖的package包/类
public void testActionPerformed() {
    instanceContent.add(sqlExecution);
    Component tp = ((Presenter.Toolbar)action).getToolbarPresenter();
    assertTrue("The toolbar presenter should be a JButton", tp instanceof JButton);

    JButton button = (JButton)tp;
    button.doClick();
    assertTrue("Should perform the action when SQLExecution in the context", baseAction.actionPeformedCount == 1);

    instanceContent.remove(sqlExecution);
    button.doClick();
    assertTrue("Should not perform the action when no SQLExecution in the context", baseAction.actionPeformedCount == 1);

    instanceContent.add(sqlExecution);
    button.doClick();
    assertTrue("Should perform the action when SQLExecution in the context", baseAction.actionPeformedCount == 2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SQLExecutionBaseActionTest.java


示例6: testIsPopupVisible

import org.openide.util.actions.Presenter; //导入依赖的package包/类
public void testIsPopupVisible() throws Exception {
    ToolsAction ta = ToolsAction.get(ToolsAction.class);

    Lookup lkp = Lookups.singleton(this);
    FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions");
    assertNotNull("ToolActions folder found", fo);

    fo.createFolder("Cat1").createData("org-openide-actions-SaveAction.instance").setAttribute("position", 100);

    Action a = ta.createContextAwareInstance(lkp);
    assertTrue("It is menu presenter", a instanceof Presenter.Popup);
    Presenter.Popup pp = (Presenter.Popup)a;
    JMenuItem item = pp.getPopupPresenter();

    assertTrue("Item is enabled", item.isEnabled());
    DynamicMenuContent dmc = (DynamicMenuContent)item;
    assertEquals("One presenter to delegte to", 1, dmc.getMenuPresenters().length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ToolsActionTest.java


示例7: testInlineIsNotBlocked

import org.openide.util.actions.Presenter; //导入依赖的package包/类
public void testInlineIsNotBlocked() throws Exception {
    ToolsAction ta = ToolsAction.get(ToolsAction.class);

    Lookup lkp = Lookups.singleton(this);
    FileObject fo = FileUtil.createFolder(FileUtil.getConfigRoot(), "UI/ToolActions");
    assertNotNull("ToolActions folder found", fo);

    fo.createFolder("Cat3").createData(BlockingAction.class.getName().replace('.', '-') + ".instance").setAttribute("position", 100);

    Action a = ta.createContextAwareInstance(lkp);
    assertTrue("It is menu presenter", a instanceof Presenter.Menu);
    Presenter.Menu mp = (Presenter.Menu)a;
    JMenuItem item = mp.getMenuPresenter();

    assertTrue("Item is enabled", item.isEnabled());
    DynamicMenuContent dmc = (DynamicMenuContent)item;
    final JComponent[] arr = dmc.getMenuPresenters();
    assertEquals("One presenter to delegte to", 1, arr.length);
    assertFalse("Disabled", arr[0].isEnabled());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ToolsActionSlowTest.java


示例8: createInstance

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/** Updates the <code>MenuBar</code> represented by this folder.
    *
    * @param cookies array of instance cookies for the folder
    * @return the updated <code>MenuBar</code> representee
    */
   protected Object createInstance (InstanceCookie[] cookies)
   throws IOException, ClassNotFoundException {
       final LinkedList ll = new LinkedList ();
       allInstances (cookies, ll);

final MenuBar mb = MenuBar.this;

       cleanUp(); //remove the stuff we've added last time

       // fill with new content
       Iterator it = ll.iterator ();
       while (it.hasNext()) {
           Object obj = it.next ();
           if (obj instanceof Presenter.Toolbar) {
               obj = ((Presenter.Toolbar)obj).getToolbarPresenter();
               if (obj instanceof JButton) { // tune the presenter a bit
                   ((JButton)obj).setBorderPainted(false);
               }
           }
           if (obj instanceof Component) addComponent((Component) obj);
       }
       mb.validate();
       mb.repaint();
       return mb;
   }
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:31,代码来源:MenuBar.java


示例9: acceptCookie

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/**
 * Accepts only cookies that can provide <code>Toolbar</code>.
 * @param cookie an <code>InstanceCookie</code> to test
 * @return true if the cookie can provide accepted instances
 */
protected InstanceCookie acceptCookie (InstanceCookie cookie)
throws java.io.IOException, ClassNotFoundException {
    boolean is;
    
    if (cookie instanceof InstanceCookie.Of) {
        InstanceCookie.Of of = (InstanceCookie.Of)cookie;
        is = of.instanceOf (Component.class) ||
             of.instanceOf (Presenter.Toolbar.class) ||
             of.instanceOf (Action.class);
    } else {
        Class c = cookie.instanceClass();
        is = Component.class.isAssignableFrom(c) ||
             Presenter.Toolbar.class.isAssignableFrom(c) ||
             Action.class.isAssignableFrom (c);
    }
    return is ? cookie : null;
}
 
开发者ID:CharlesSkelton,项目名称:studio,代码行数:23,代码来源:Toolbar.java


示例10: createToolbar

import org.openide.util.actions.Presenter; //导入依赖的package包/类
protected JToolBar createToolbar() {
    JToolBar toolbar = new Toolbar(getShortName());
    String toolbarActionsPath = "Office/" + getShortName() + "/Toolbar";
    List<? extends Action> toolbarActions = Utilities.actionsForPath(toolbarActionsPath);
    for (Action action : toolbarActions) {
        if (action == null) {
            toolbar.addSeparator();
        } else if (action instanceof Presenter.Toolbar) {
            Component actionComponent = ((Presenter.Toolbar) action).getToolbarPresenter();
            toolbar.add(actionComponent);
        } else {
            JButton newButton = toolbar.add(action);
            if (newButton.getToolTipText() == null) {
                String label = (String) action.getValue("displayName");
                newButton.setToolTipText(label);
            }
        }
    }
    return toolbar;
}
 
开发者ID:foxerfly,项目名称:Joeffice,代码行数:21,代码来源:OfficeTopComponent.java


示例11: createPopupMenu

import org.openide.util.actions.Presenter; //导入依赖的package包/类
public static JPopupMenu createPopupMenu(String path) {
    JPopupMenu popUp = new JPopupMenu();
    
    List<? extends Action> actions = Utilities.actionsForPath(path);
    if(actions.isEmpty())
        return null;
    
    for(Action action : actions) {
        if(action instanceof Presenter.Popup) {
            popUp.add(((Presenter.Popup)action).getPopupPresenter());
        } else if (action == null) {
            popUp.addSeparator();
        } else {
            popUp.add(createActionPopUpItem(action));
        }
    }
    
    return popUp;
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:20,代码来源:WidgetUtils.java


示例12: getPopupMenuItem

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private static JMenuItem getPopupMenuItem(Action action) {
    JMenuItem popupItem = null;
    if (action instanceof BaseAction) {
        popupItem = ((BaseAction) action).getPopupMenuItem(null);
    }
    if (popupItem == null) {
        if (action instanceof Presenter.Popup) {
            popupItem = ((Presenter.Popup) action).getPopupPresenter();
        }
    }
    return popupItem;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Annotations.java


示例13: fillToolBar

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private void fillToolBar() {
    actionsBar.removeAll();

    for (Action action : getToolbarActions()) {
        if (action instanceof Presenter.Toolbar) {
            actionsBar.add(((Presenter.Toolbar) action).getToolbarPresenter());
        }
    }

    actionsBar.revalidate();
    actionsBar.repaint();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:TerminalContainerTopComponent.java


示例14: resolveInstance

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private static void resolveInstance(Object instance, List<JComponent> result) throws IOException {
   if (instance instanceof Presenter.Popup) {
       JMenuItem temp = ((Presenter.Popup) instance).getPopupPresenter();
       result.add(temp);
   } else if (instance instanceof JSeparator) {
       result.add(null);
   } else if (instance instanceof JComponent) {
       result.add((JComponent) instance);
   } else if (instance instanceof Action) {
       Actions.MenuItem mi = new Actions.MenuItem((Action) instance, true);
       result.add(mi);
   } else {
       throw new IOException(String.format("Unsupported instance: %s, class: %s", instance, instance.getClass())); // NOI18N
   }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:RefactoringContextActionsProvider.java


示例15: item

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private JMenuItem item(Action a, boolean menu) {
    if (menu) {
        if (a instanceof Presenter.Menu) {
            return ((Presenter.Menu) a).getMenuPresenter();
        } else {
            return new JMenuItem(a);
        }
    } else {
        if (a instanceof Presenter.Popup) {
            return ((Presenter.Popup)a).getPopupPresenter();        
        } else {
            return new JMenuItem(a);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:LookupSensitiveActionBase.java


示例16: toMenuItem

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/**
 * Creates a menu item from an action.
 *
 * @param action an action
 * @return JMenuItem
 */
public static JMenuItem toMenuItem(Action action) {
    JMenuItem item;
    if (action instanceof Presenter.Menu) {
        item = ((Presenter.Menu) action).getMenuPresenter();
    } else {
        item = new JMenuItem();
        Actions.connect(item, action, false);
    }
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:Utils.java


示例17: createmenuItem

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private JMenuItem createmenuItem(Action action) {
    JMenuItem item;
    if (action instanceof Presenter.Menu) {
        item = ((Presenter.Menu) action).getMenuPresenter();
    } else if (action instanceof Presenter.Popup) {
        item = ((Presenter.Popup) action).getPopupPresenter();
    } else {
        item = new JMenuItem();
        Actions.connect(item, action, true);
    }
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ProjectMenuItem.java


示例18: toMenuItem

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/**
 * Creates a menu item from an action.
 * 
 * @param action an action
 * @return JMenuItem
 */
public static JMenuItem toMenuItem(Action action) {
    JMenuItem item;
    if (action instanceof Presenter.Menu) {
        item = ((Presenter.Menu) action).getMenuPresenter();
    } else if (action instanceof Presenter.Popup) {
        item = ((Presenter.Popup) action).getPopupPresenter();
    } else {
        item = new JMenuItem();
        Actions.connect(item, action, false);
    }
    return item;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Utils.java


示例19: createMenu

import org.openide.util.actions.Presenter; //导入依赖的package包/类
private JMenuItem[] createMenu (Collection coll) {
    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
        "\n--> CollectSystemAction.createMenu: ( " + coll + " )");

    ArrayList items = new ArrayList ();

    Iterator it = coll.iterator();
    while (it.hasNext ()) {
        SystemAction a = (SystemAction) it.next();
        
        if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (
            "-*- CollectSystemAction.createMenu: next action " + a +
                         " -- " + ( a.isEnabled() ? "<enabled>" : "[disabled]" ) );
        
        if ( a.isEnabled() ) {
            JMenuItem item = null;
            if (a instanceof Presenter.Popup) {
                item = ((Presenter.Popup)a).getPopupPresenter ();
            }

            if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
                ("-*- CollectSystemAction.createMenu: menu item = " + item);

            // test if we obtained the item
            if (item != null) {
                items.add (item);
            }
        }
    }

    if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug
        ("<-- CollectSystemAction.createMenu: all items = " + items + "\n");

    JMenuItem[] array = new JMenuItem [items.size ()];
    items.toArray (array);
    return array;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:CollectSystemAction.java


示例20: warmUpToolsPopupMenuItem

import org.openide.util.actions.Presenter; //导入依赖的package包/类
/** Warms up tools action popup menu item. */
private static void warmUpToolsPopupMenuItem() {
    SystemAction toolsAction = SystemAction.get(ToolsAction.class);
    if(toolsAction instanceof ContextAwareAction) {
        // Here is important to create proper lookup
        // to warm up Tools sub actions.
        Lookup lookup = new org.openide.util.lookup.ProxyLookup(
            new Lookup[] {
                // This part of lookup causes warm up of Node (cookie) actions.
                new AbstractNode(Children.LEAF).getLookup(),
                // This part of lookup causes warm up of Callback actions.
                new TopComponent().getLookup()
            }
        );
        
        Action action = ((ContextAwareAction)toolsAction)
                            .createContextAwareInstance(lookup);
        if(action instanceof Presenter.Popup) {
            JMenuItem toolsMenuItem = ((Presenter.Popup)action)
                                            .getPopupPresenter();
            if(toolsMenuItem instanceof Runnable) {
                // This actually makes the warm up.
                // See ToolsAction.Popup impl.
                ((Runnable)toolsMenuItem).run();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ContextMenuWarmUpTask.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Workspace类代码示例发布时间:2022-05-21
下一篇:
Java CompatibleFieldSerializer类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap