Search in sources :

Example 36 with JPopupMenu

use of javax.swing.JPopupMenu in project jmeter by apache.

the class MenuFactory method getDefaultConfigElementMenu.

public static JPopupMenu getDefaultConfigElementMenu() {
    JPopupMenu pop = new JPopupMenu();
    MenuFactory.addEditMenu(pop, true);
    MenuFactory.addFileMenu(pop);
    return pop;
}
Also used : JPopupMenu(javax.swing.JPopupMenu)

Example 37 with JPopupMenu

use of javax.swing.JPopupMenu in project jmeter by apache.

the class HTTPArgumentsPanel method init.

private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    // register the right click menu
    JTable table = getTable();
    final JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem variabilizeItem = new JMenuItem(JMeterUtils.getResString("transform_into_variable"));
    variabilizeItem.addActionListener(e -> transformNameIntoVariable());
    popupMenu.add(variabilizeItem);
    table.setComponentPopupMenu(popupMenu);
}
Also used : JTable(javax.swing.JTable) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 38 with JPopupMenu

use of javax.swing.JPopupMenu in project jmeter by apache.

the class ProxyControlGui method createTargetPanel.

private JPanel createTargetPanel() {
    targetNodesModel = new DefaultComboBoxModel<>();
    targetNodes = new JComboBox<>(targetNodesModel);
    // $NON-NLS-1$ // Bug 56303 fixed the width of combo list
    targetNodes.setPrototypeDisplayValue("");
    // get popup element
    JPopupMenu popup = (JPopupMenu) targetNodes.getUI().getAccessibleChild(targetNodes, 0);
    JScrollPane scrollPane = findScrollPane(popup);
    if (scrollPane != null) {
        // add scroll pane if label element is too long
        scrollPane.setHorizontalScrollBar(new JScrollBar(JScrollBar.HORIZONTAL));
        scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    }
    targetNodes.setActionCommand(CHANGE_TARGET);
    // Action listener will be added later
    // $NON-NLS-1$
    JLabel label = new JLabel(JMeterUtils.getResString("proxy_target"));
    label.setLabelFor(targetNodes);
    HorizontalPanel panel = new HorizontalPanel();
    panel.add(label);
    panel.add(targetNodes);
    return panel;
}
Also used : JScrollPane(javax.swing.JScrollPane) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel) JLabel(javax.swing.JLabel) JPopupMenu(javax.swing.JPopupMenu) JScrollBar(javax.swing.JScrollBar)

Example 39 with JPopupMenu

use of javax.swing.JPopupMenu in project jadx by skylot.

the class TabbedPane method createTabPopupMenu.

private JPopupMenu createTabPopupMenu(final ContentPanel contentPanel) {
    JPopupMenu menu = new JPopupMenu();
    JMenuItem closeTab = new JMenuItem(NLS.str("tabs.close"));
    closeTab.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeCodePanel(contentPanel);
        }
    });
    menu.add(closeTab);
    if (openTabs.size() > 1) {
        JMenuItem closeOther = new JMenuItem(NLS.str("tabs.closeOthers"));
        closeOther.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                List<ContentPanel> contentPanels = new ArrayList<ContentPanel>(openTabs.values());
                for (ContentPanel panel : contentPanels) {
                    if (panel != contentPanel) {
                        closeCodePanel(panel);
                    }
                }
            }
        });
        menu.add(closeOther);
        JMenuItem closeAll = new JMenuItem(NLS.str("tabs.closeAll"));
        closeAll.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                closeAllTabs();
            }
        });
        menu.add(closeAll);
        menu.addSeparator();
        ContentPanel selectedContentPanel = getSelectedCodePanel();
        for (final Map.Entry<JNode, ContentPanel> entry : openTabs.entrySet()) {
            final ContentPanel cp = entry.getValue();
            if (cp == selectedContentPanel) {
                continue;
            }
            JNode node = entry.getKey();
            final String clsName = node.makeLongString();
            JMenuItem item = new JMenuItem(clsName);
            item.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    setSelectedComponent(cp);
                }
            });
            item.setIcon(node.getIcon());
            menu.add(item);
        }
    }
    return menu;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) List(java.util.List) JNode(jadx.gui.treemodel.JNode) JMenuItem(javax.swing.JMenuItem) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JPopupMenu(javax.swing.JPopupMenu)

Example 40 with JPopupMenu

use of javax.swing.JPopupMenu in project jadx by skylot.

the class TabbedPane method makeTabComponent.

private Component makeTabComponent(final ContentPanel contentPanel) {
    JNode node = contentPanel.getNode();
    String name = node.makeLongString();
    final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
    panel.setOpaque(false);
    final JLabel label = new JLabel(name);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    label.setIcon(node.getIcon());
    final JButton button = new JButton();
    button.setIcon(ICON_CLOSE_INACTIVE);
    button.setRolloverIcon(ICON_CLOSE);
    button.setRolloverEnabled(true);
    button.setOpaque(false);
    button.setUI(new BasicButtonUI());
    button.setContentAreaFilled(false);
    button.setFocusable(false);
    button.setBorder(null);
    button.setBorderPainted(false);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeCodePanel(contentPanel);
        }
    });
    panel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                closeCodePanel(contentPanel);
            } else if (SwingUtilities.isRightMouseButton(e)) {
                JPopupMenu menu = createTabPopupMenu(contentPanel);
                menu.show(panel, e.getX(), e.getY());
            } else {
                // TODO: make correct event delegation to tabbed pane
                setSelectedComponent(contentPanel);
            }
        }
    });
    panel.add(label);
    panel.add(button);
    panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) JNode(jadx.gui.treemodel.JNode)

Aggregations

JPopupMenu (javax.swing.JPopupMenu)203 JMenuItem (javax.swing.JMenuItem)105 ActionEvent (java.awt.event.ActionEvent)61 ActionListener (java.awt.event.ActionListener)46 JMenu (javax.swing.JMenu)28 Point (java.awt.Point)24 Component (java.awt.Component)20 JLabel (javax.swing.JLabel)20 JSeparator (javax.swing.JSeparator)19 JScrollPane (javax.swing.JScrollPane)18 MouseEvent (java.awt.event.MouseEvent)17 JButton (javax.swing.JButton)16 AbstractAction (javax.swing.AbstractAction)15 BorderLayout (java.awt.BorderLayout)13 JPanel (javax.swing.JPanel)13 JTable (javax.swing.JTable)13 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)12 MouseAdapter (java.awt.event.MouseAdapter)11 ArrayList (java.util.ArrayList)11 Icon (javax.swing.Icon)11