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


Java Utilities.actionsToPopup方法代碼示例

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


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

示例1: showPopupMenuAt

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Show popup menu from actions provided by node at given index (if any).
 *
 * @param rowIndex
 * @param location
 */
void showPopupMenuAt(int rowIndex, Point location) {
    TreeListNode node = (TreeListNode) getModel().getElementAt(rowIndex);
    boolean popupForSelected = false;
    if (getSelectionMode() != ListSelectionModel.SINGLE_SELECTION) {
        popupForSelected = isPopupForSelected(node);
    }
    if (!popupForSelected) {
        setSelectedIndex(rowIndex);
    }
    Action[] actions = node.getPopupActions();

    if (null == actions || actions.length == 0) {
        return;
    }
    JPopupMenu popup = Utilities.actionsToPopup(actions, this);
    popup.show(this, location.x, location.y);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:TreeList.java

示例2: createExtendedPopup

import org.openide.util.Utilities; //導入方法依賴的package包/類
void createExtendedPopup(int xpos, int ypos, JMenu newMenu) {
    Node[] ns = manager.getSelectedNodes();
    JPopupMenu popup = null;

    if (ns.length > 0) {
        // if any nodes are selected --> find theirs actions
        Action[] actions = NodeOp.findActions(ns);
        popup = Utilities.actionsToPopup(actions, this);
    } else {
        // if none node is selected --> get context actions from view's root
        if (manager.getRootContext() != null) {
            popup = manager.getRootContext().getContextMenu();
        }
    }

    int cnt = 0;

    if (popup == null) {
        popup = SystemAction.createPopupMenu(new SystemAction[] {  });
    }

    popup.add(newMenu);

    createPopup(xpos, ypos, popup);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:TreeView.java

示例3: createPopupMenu

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Creates a popup menu with entries from the selected nodes
 * related to the given component (usually a ETable subclass). The popup
 * is created for the table element in given column and row (column
 *  and row are in the view's coordinates (not the model's)).
 */
public JPopupMenu createPopupMenu(int row, int column, Node[] selectedNodes,
        Component component) {
    
    Action[] actions = NodeOp.findActions (selectedNodes);
    JPopupMenu res = Utilities.actionsToPopup(actions, component);
    if (showQuickFilter) {
        if ((component instanceof ETable) && (column >= 0)) {
            ETable et = (ETable)component;
            if (row >= 0) {
                Object val = et.getValueAt(row, column);
                val = et.transformValue(val);
                String s = NbBundle.getMessage(NodePopupFactory.class, "LBL_QuickFilter");
                res.add(et.getQuickFilterPopup(column, val, s));
            } else if (et.getQuickFilterColumn() == column) {
                addNoFilterItem(et, res);
            }
        }
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:NodePopupFactory.java

示例4: createMouseListener

import org.openide.util.Utilities; //導入方法依賴的package包/類
private MouseListener createMouseListener() {
    return new MouseAdapter() {
        public void mouseClicked(MouseEvent event) {
            if (SwingUtilities.isRightMouseButton(event)) {
                JComponent comp = (JComponent)event.getSource();
                Item item = null;
                if (comp instanceof JList) {
                    JList list = (JList)comp;
                    Point p = event.getPoint();
                    int index = list.locationToIndex(p);
                    if (index >= 0 && !list.getCellBounds(index, index).contains(p)) {
                        index = -1;
                    }
                    if (index >= 0) {
                        item = (Item)list.getModel().getElementAt(index);
                    }
                }
                Action[] actions = null == item ? category.getActions() : item.getActions();
                JPopupMenu popup = Utilities.actionsToPopup( actions, getComponent() );
                Utils.addCustomizationMenuItems( popup, getPalettePanel().getController(), getPalettePanel().getSettings() );
                popup.show(comp, event.getX(), event.getY());
            }
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:CategoryDescriptor.java

示例5: mousePressed

import org.openide.util.Utilities; //導入方法依賴的package包/類
public void mousePressed(MouseEvent ev) {
    if (ev.isPopupTrigger()) {
        int x = ev.getX();
        int y = ev.getY();
        TreePath path = view.getClosestPathForLocation(x, y);
        if (path != null) {
            LookTreeNode n = (LookTreeNode)path.getLastPathComponent();
            clicked = new WeakReference<LookTreeNode>(n);
            @SuppressWarnings("unchecked")
            Action[] actions = n.getLook().getActions(n.getData(), n.getLookup() );
            // XXX handle multiselects...
            Node selection = makeNode( n );
            Lookup context = Lookups.fixed(new Object[] {selection, actionMap});
            JPopupMenu menu = Utilities.actionsToPopup(actions, context);
            menu.show(view, x, y);
            // XXX selection does not appear to be collected... do we need to
            // also destroy the popup menu?
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:PopupHandler.java

示例6: showPopup

import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
protected void showPopup(MouseEvent e) {
    Terminal selected = (Terminal) getSelected();
    
    Action close = ActionFactory.forID(ActionFactory.CLOSE_ACTION_ID);
    Action setTitle = ActionFactory.forID(ActionFactory.SET_TITLE_ACTION_ID);
    Action pin = ActionFactory.forID(ActionFactory.PIN_TAB_ACTION_ID);
    pin.putValue("Name", PinTabAction.getMessage(selected.isPinned())); //NOI18N
    Action closeAll = new CloseAll();
    Action closeAllBut = new CloseAllButCurrent();
	    
    JPopupMenu menu = Utilities.actionsToPopup(
	    new Action[]{
		close,
		closeAll,
		closeAllBut,
		null,
		setTitle,
		pin
	    }, Lookups.fixed(getSelected())
    );
    menu.show(TerminalContainerTabbed.this, e.getX(), e.getY());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:TerminalContainerTabbed.java

示例7: testContextAware

import org.openide.util.Utilities; //導入方法依賴的package包/類
public void testContextAware () {
    NewTemplateAction global = NewTemplateAction.get(NewTemplateAction.class);
    
    CookieNode node = new CookieNode ();
    JPopupMenu popup = Utilities.actionsToPopup (new Action[] {
        global
    }, node.getLookup ());
    
    assertTrue ("NewTemplateAction's cookie must be called.", node.counter > 0);
    
    global.getPopupPresenter ();
    
    assertTrue ("When calling wizard on global action, the CookieNode's cookie is not " +
        "as it is not selected", node.counter > 0
    );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:NewTemplateActionTest.java

示例8: actionPerformed

import org.openide.util.Utilities; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent ae) {
    TreeListNode node = getSelectedTreeListNode();
    TreeList tl = (TreeList) ae.getSource();
    JPopupMenu menu = Utilities.actionsToPopup(node.getPopupActions(), tl);
    Point p = tl.getUI().indexToLocation(tl, tl.getSelectedIndex());
    menu.show(tl, p.x + 22, p.y);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:TreeList.java

示例9: showPopupMenuAt

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Show popup menu from actions provided by node at given index (if any).
 *
 * @param rowIndex
 * @param location
 */
private void showPopupMenuAt(int rowIndex, Point location) {
    ListNode node = getModel().getElementAt(rowIndex);
    Action[] actions = node.getPopupActions();

    if (null == actions || actions.length == 0) {
        return;
    }
    JPopupMenu popup = Utilities.actionsToPopup(actions, this);
    popup.show(this, location.x, location.y);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:SelectionList.java

示例10: showPopupMenu

import org.openide.util.Utilities; //導入方法依賴的package包/類
private void showPopupMenu(int x, int y) {
    Node[] activatedNodes = getActivatedNodes();
    if (activatedNodes.length == 1) {
        Action[] actions = activatedNodes[0].getActions(true);
        JPopupMenu contextMenu = Utilities.actionsToPopup(actions, ScreenshotComponent.this);
        contextMenu.show(ScreenshotComponent.this.canvas, x, y);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ScreenshotComponent.java

示例11: actionPerformed

import org.openide.util.Utilities; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    int posX = 0;
    int posY = 0;
    Item item = getItemAt( getSelectedIndex() );
    if( null != item ) {
        Rectangle rect = getCellBounds( getSelectedIndex(), getSelectedIndex() );
        posX = rect.x;
        posY = rect.y + rect.height;
    }
    Action[] actions = null == item ? category.getActions() : item.getActions();
    JPopupMenu popup = Utilities.actionsToPopup( actions, CategoryList.this );
    Utils.addCustomizationMenuItems( popup, palettePanel.getController(), palettePanel.getSettings() );
    popup.show( getParent(), posX, posY );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:CategoryList.java

示例12: testAddingSeparators

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * This test checks whether the JSeparator added from the configuration
 * file is reflected in the resulting popup.
 * The tests performs following steps:
 * <OL><LI> Create an instance of ExtensibleNode with folder set to "test"
 *     <LI> No actions should be returned by getActions since the "test" folder
 *          is not there
 *     <LI> Create two actions in the testing folder separated by JSeparator
 *     <LI> getActions should return 3 elements - null element for the separator
 *     <LI> Popup is created from the actions array - the null element
 *              should be replaced by a JSeparator again
 * </OL>
 */
public void testAddingSeparators() throws Exception {
    Node en1 = node;
    assertEquals("No actions at the start", 0, en1.getActions(false).length);
    FileObject test = root;
    FileObject a1 = test.createData("1[org-openide-actions-PropertiesAction].instance");
    FileObject sep = test.createData("2[javax-swing-JSeparator].instance");
    FileObject a2 = test.createData("3[org-openide-actions-CutAction].instance");
    Action[] actions = en1.getActions(false);
    assertEquals("Actions array should contain 3 elements: "+Arrays.asList(actions), 3, actions.length);
    assertNull("separator should create null element in the array", actions[1]);
    javax.swing.JPopupMenu jp = Utilities.actionsToPopup(actions, Lookups.singleton(en1));
    assertEquals("Popup should contain 3 components", 3, jp.getComponentCount());
    assertTrue("Separator should be second", jp.getComponent(1) instanceof JSeparator);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:DataLoaderGetActionsTest.java

示例13: findContextMenu

import org.openide.util.Utilities; //導入方法依賴的package包/類
/**
 * Computes a common popup menu for the specified nodes.
 * Provides only those actions supplied by all nodes in the list.
 * <p>Component action maps are not taken into consideration.
 * {@link Utilities#actionsToPopup(Action[], Component)} is a better choice
 * if you want to use actions such as "Paste" which look at action maps.
* @param nodes the nodes
* @return the menu for all nodes
*/
public static JPopupMenu findContextMenu(Node[] nodes) {
    Action[] arr = findActions(nodes);

    // prepare lookup representing all the selected nodes
    List<Lookup> allLookups = new ArrayList<Lookup>();

    for (Node n : nodes) {
        allLookups.add(n.getLookup());
    }

    Lookup lookup = new ProxyLookup(allLookups.toArray(new Lookup[allLookups.size()]));

    return Utilities.actionsToPopup(arr, lookup);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:NodeOp.java

示例14: testDynamicMenuContent

import org.openide.util.Utilities; //導入方法依賴的package包/類
public void testDynamicMenuContent() {
    Action[] acts = new Action[] {
        new Act1(),
        new Act2()
        
    };
    JPopupMenu popup = Utilities.actionsToPopup(acts, Lookup.EMPTY);
    Component[] comp = popup.getComponents();
    boolean onepresent = false;
    boolean twopresent = false;
    boolean threepresent = false;
    boolean fourpresent = false;
    boolean zeropresent = false;
    for (int i = 0; i < comp.length; i++) {
        if ("0".equals(((JMenuItem)comp[i]).getText())) {
            zeropresent = true;
        }
        if ("2".equals(((JMenuItem)comp[i]).getText())) {
            twopresent = true;
        }
        if ("4".equals(((JMenuItem)comp[i]).getText())) {
            fourpresent = true;
        }
        if ("3".equals(((JMenuItem)comp[i]).getText())) {
            threepresent = true;
        }
        if ("1".equals(((JMenuItem)comp[i]).getText())) {
            onepresent = true;
        }
    }
    assertTrue(threepresent);
    assertTrue(fourpresent);
    assertTrue(onepresent);
    assertTrue(twopresent);
    assertTrue(zeropresent);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:UtilitiesActionsTest.java

示例15: createPopup

import org.openide.util.Utilities; //導入方法依賴的package包/類
void createPopup(int xpos, int ypos, boolean contextMenu) {
    if (manager == null) {
        return;
    }

    if (!popupAllowed) {
        return;
    }
    
    if (!isShowing()) {
        return;
    }

    JPopupMenu popup;

    if (contextMenu) {
        popup = Utilities.actionsToPopup(manager.getExploredContext().getActions(true), this);
    } else {
        Action[] actions = NodeOp.findActions(manager.getSelectedNodes());
        popup = Utilities.actionsToPopup(actions, this);
    }

    if ((popup != null) && (popup.getSubElements().length > 0)) {
        Point p = getViewport().getViewPosition();
        p.x = xpos - p.x;
        p.y = ypos - p.y;

        SwingUtilities.convertPointToScreen(p, ListView.this);

        Dimension popupSize = popup.getPreferredSize();
        Rectangle screenBounds = Utilities.getUsableScreenBounds(getGraphicsConfiguration());

        if ((p.x + popupSize.width) > (screenBounds.x + screenBounds.width)) {
            p.x = (screenBounds.x + screenBounds.width) - popupSize.width;
        }

        if ((p.y + popupSize.height) > (screenBounds.y + screenBounds.height)) {
            p.y = (screenBounds.y + screenBounds.height) - popupSize.height;
        }

        SwingUtilities.convertPointFromScreen(p, ListView.this);
        popup.show(this, p.x, p.y);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:45,代碼來源:ListView.java


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