@Override public void actionPerformed(ActionEvent e) { ContextMenu.this.actionPerformed(getCommandActionEvent(e)); } };
protected void addCheckboxItem(String action, String text, String parent, boolean selected) { if (parent != null) { JMenuItem item = makeCheckboxItem(action, text, selected); getSubmenu(parent).add(item); items.put(action, item); } else { addCheckboxItem(action, text, selected); } }
/** * Set the context menu for when no special context menus (user, link) are * appropriate. * * @param contextMenu */ public void setDefaultContextMenu(ContextMenu contextMenu) { defaultContextMenu = contextMenu; contextMenu.addContextMenuListener(contextMenuListener); }
protected void addRadioItem(String action, String text, String group, String parent) { if (parent != null) { JMenuItem item = makeRadioItem(action, text, group); getSubmenu(parent).add(item); items.put(action, item); } else { addRadioItem(action, text, group); } }
/** * Adds a seperator to the submenu with the given name, or adds a seperator * in the main menu if this submenu doesn't exist yet. * * @param parent */ protected void addSeparator(int pos, String parent) { if (parent != null && isSubmenu(parent)) { if (pos > -1) { getSubmenu(parent).insertSeparator(pos); } else { getSubmenu(parent).addSeparator(); } } else { if (pos > -1) { insert(new Separator(), pos); } else { addSeparator(); } } }
JMenuItem item = makeItem(action, text, icon); if (pos > -1) { getSubmenu(parent).insert(item, pos); } else { getSubmenu(parent).add(item); JMenuItem item = makeItem(action, text, icon); if (pos > -1) { insert(item, pos); } else { add(item);
public JMenuItem addCommandItem(CommandMenuItem item) { if (item.getCommand() == null && item.getLabel() == null) { addSeparator(item.getPos(), item.getParent()); } else if (item.getCommand() == null) { JMenu menu = getSubmenu(item.getLabel(), item.getPos()); addKey(item, menu); } else { commands.put(item.getId(), item.getCommand()); JMenuItem mItem = addItem(item.getId(), item.getLabel(), item.getPos(), item.getParent(), null); addKey(item, mItem); } return null; }
/** * Parses the livestreamer qualities setting and adds the defined qualities * as menu items. * * @param m */ public static void addLivestreamerOptions(ContextMenu m) { if (enableLivestreamer) { String livestreamerMenu = "Livestreamer"; m.setSubMenuIcon(livestreamerMenu, ICON_COMMANDLINE); List<Quality> qualities = parseLivestreamerQualities(livestreamerQualities); for (Quality q : qualities) { if (q == null) { m.addSeparator(livestreamerMenu); } else { m.addItem("livestreamerQ"+q.qualities, q.displayName, livestreamerMenu); } } } }
protected void addCheckboxItem(String action, String text, boolean selected) { items.put(action, add(makeCheckboxItem(action, text, selected))); }
protected void addRadioItem(String action, String text, String group) { items.put(action, add(makeRadioItem(action, text, group))); }
protected JMenuItem addItem(String action, String text, String parent) { return addItem(action, text, -1, parent, null); }
private JMenu getSubmenu(String name) { return getSubmenu(name, -1); }
protected void addSeparator(String parent) { addSeparator(-1, parent); }
public static void addCommands(MenuType type, ContextMenu menu) { List<CommandMenuItem> c = commands.get(type); if (c != null) { for (CommandMenuItem item : c) { menu.addCommandItem(item); } } }
String streamSubmenu = "Twitch Stream"; String miscSubmenu = Language.getString("channelCm.menu.misc"); m.setSubMenuIcon(streamSubmenu, ICON_SPACING); m.addItem("stream", "Normal", streamSubmenu); m.addItem("streamPopout", "Popout", streamSubmenu); m.addSeparator(streamSubmenu); m.addItem("streamsMultitwitchtv", "Multitwitch.tv", streamSubmenu); m.addItem("streamsSpeedruntv", "Speedrun.tv", streamSubmenu); m.addItem("streamsKadgar", "Kadgar.net", streamSubmenu); addLivestreamerOptions(m); if (join) { m.addSeparator(); m.addItem("join", Language.getString("channelCm.join", numStreams)); m.addSeparator(); m.addItem("hostchannel", Language.getString("channelCm.hostChannel"), miscSubmenu); m.addSeparator(miscSubmenu); m.addItem("copy", Language.getString("channelCm.copyStreamname"), miscSubmenu); m.addSeparator(miscSubmenu); m.addItem("follow", Language.getString("channelCm.follow"), miscSubmenu); m.addItem("unfollow", Language.getString("channelCm.unfollow"), miscSubmenu);
protected JMenuItem addItem(String action, String text) { return addItem(action, text, -1, null, null); }
protected void setSubMenuIcon(String name, ImageIcon icon) { getSubmenu(name, -1).setIcon(icon); }
protected JMenuItem addItem(String action, String text, ImageIcon icon) { return addItem(action, text, -1, null, icon); }
/** * Set the listener for all context menus. * * @param listener */ public void setContextMenuListener(ContextMenuListener listener) { contextMenuListener = listener; if (defaultContextMenu != null) { defaultContextMenu.addContextMenuListener(listener); } }