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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations