/** * Adds and configures a toggle button. * @param a an abstraction of a toggle action. * @param group the group to add the toggle button or null */ private JToggleButton createToggleButton(AbstractActionExt a, ButtonGroup group) { JToggleButton button = new JToggleButton(); configureButton(button, a, group); return button; }
/** * Creates a menu item based on the attributes of the action element. * Will return a JMenuItem, JRadioButtonMenuItem or a JCheckBoxMenuItem * depending on the context of the Action. * * @return a JMenuItem or subclass depending on type. */ private JMenuItem createMenuItem(Object id, JComponent container) { return createMenuItem(getAction(id), container); }
/** * @return current <code>ActionContainerFactory</code>. * Will lazily create new factory if it does not exist */ protected ActionContainerFactory getActionContainerFactory() { if (actionFactory == null) { actionFactory = new ActionContainerFactory(null); } return actionFactory; }
/** * * @param button * @param a * @param group */ public void configureButton(JToggleButton button, AbstractActionExt a, ButtonGroup group) { configureSelectableButton(button, a, group); configureButtonFromExtActionProperties(button, a); }
/** * Creates, configures and returns an AbstractButton. * * The attributes of the action element * registered with the ActionManger by the given id. * Will return a JButton or a JToggleButton. * * @param id the identifier * @param container the JComponent which parents the group, if any. * @return an AbstractButton based on the */ public AbstractButton createButton(Object id, JComponent container) { return createButton(getAction(id), container); }
menuItem = createRadioButtonMenuItem(getGroup(groupid, container), (AbstractActionExt)action); } else { menuItem = createCheckBoxMenuItem((AbstractActionExt)action); configureMenuItemFromExtActionProperties(menuItem, action);
/** * Constructs a menu tree from a list of actions or lists of lists or actions. * * @param list a list which represents the root item. * @return a menu bar which represents the menu bar tree */ public JMenuBar createMenuBar(List<?> list) { final JMenuBar menubar = new JMenuBar(); for (Object element : list) { if (element == null) { continue; } JMenuItem menu; if (element instanceof Object[]) { menu = createMenu((Object[]) element); } else if (element instanceof List<?>) { menu = createMenu((List<?>) element); } else { menu = createMenuItem(element, menubar); } if (menu != null) { menubar.add(menu); } } return menubar; }
Action action = getAction(list.get(0)); newMenu = createMenu((Object[]) element); } else if (element instanceof List<?>) { newMenu = createMenu((List<?>) element); } else { newMenu = createMenuItem(element, menu);
/** * Here: creates and adds a menuItem to the popup for every * Action in the list. Does nothing if * if the list is empty. * * PRE: actions != null. * * @param actions a list containing the actions to add to the popup. * Must not be null. * */ protected void addItems(List<? extends Action> actions) { ActionContainerFactory factory = new ActionContainerFactory(null); for (Action action : actions) { addItem(factory.createMenuItem(action)); } }
button = createToggleButton(ta); } else { button = createToggleButton(ta, getGroup(groupid, container)); configureButtonFromExtActionProperties(button, action);
/** * Helper method to add a checkbox menu item. */ private JCheckBoxMenuItem createCheckBoxMenuItem(AbstractActionExt a) { JCheckBoxMenuItem mi = new JCheckBoxMenuItem(); configureSelectableButton(mi, a, null); configureMenuItemFromExtActionProperties(mi, a); return mi; }
/** * Creates a menu item based on the attributes of the action. * Will return a JMenuItem, JRadioButtonMenuItem or a JCheckBoxMenuItem * depending on the context of the Action. * * @param action an action used to create the menu item * @return a JMenuItem or subclass depending on type. */ public JMenuItem createMenuItem(Action action) { return createMenuItem(action, null); }
/** * Creates a button based on the attributes of the action. * * @param action an action used to create the button * @return will return a JButton or a JToggleButton. */ public AbstractButton createButton(Action action) { return createButton(action, null); }
/** * Constructs a menu tree from a list of actions or lists of lists or actions. * * @param actionIds an array which represents the root item. * @return a menu bar which represents the menu bar tree */ public JMenuBar createMenuBar(Object[] actionIds) { return createMenuBar(Arrays.asList(actionIds)); }
/** * Creates and returns a menu from a List which represents actions, separators * and sub-menus. The menu * constructed will have the attributes from the first action in the List. * Subsequent actions in the list represent menu items. * * @param actionIds an array of action ids used to construct the menu and menu items. * the first element represents the action used for the menu, * @return the constructed JMenu or null */ public JMenu createMenu(Object[] actionIds) { return createMenu(Arrays.asList(actionIds)); }
menuItem = createRadioButtonMenuItem(getGroup(groupid, container), (AbstractActionExt)action); } else { menuItem = createCheckBoxMenuItem((AbstractActionExt)action); configureMenuItemFromExtActionProperties(menuItem, action);
/** * Constructs a menu tree from a list of actions or lists of lists or actions. * * @param list a list which represents the root item. * @return a menu bar which represents the menu bar tree */ public JMenuBar createMenuBar(List<?> list) { final JMenuBar menubar = new JMenuBar(); for (Object element : list) { if (element == null) { continue; } JMenuItem menu; if (element instanceof Object[]) { menu = createMenu((Object[]) element); } else if (element instanceof List<?>) { menu = createMenu((List<?>) element); } else { menu = createMenuItem(element, menubar); } if (menu != null) { menubar.add(menu); } } return menubar; }
Action action = getAction(list.get(0)); newMenu = createMenu((Object[]) element); } else if (element instanceof List<?>) { newMenu = createMenu((List<?>) element); } else { newMenu = createMenuItem(element, menu);
/** * Here: creates and adds a menuItem to the popup for every * Action in the list. Does nothing if * if the list is empty. * * PRE: actions != null. * * @param actions a list containing the actions to add to the popup. * Must not be null. * */ protected void addItems(List<? extends Action> actions) { ActionContainerFactory factory = new ActionContainerFactory(null); for (Action action : actions) { addItem(factory.createMenuItem(action)); } }
button = createToggleButton(ta); } else { button = createToggleButton(ta, getGroup(groupid, container)); configureButtonFromExtActionProperties(button, action);