void update(String group) { myTitleLabel.setText( "<html><body><h2 style=\"text-align:left;\">" + group + "</h2></body></html>"); myContentPanel.removeAll(); List<IdSet> idSets = PluginGroups.getInstance().getSets(group); for (final IdSet set : idSets) { final JCheckBox checkBox = new JCheckBox(set.getTitle(), PluginGroups.getInstance().isIdSetAllEnabled(set)); checkBox.setModel( new JToggleButton.ToggleButtonModel() { @Override public boolean isSelected() { return PluginGroups.getInstance().isIdSetAllEnabled(set); } }); checkBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PluginGroups.getInstance().setIdSetEnabled(set, !checkBox.isSelected()); CustomizePluginsStepPanel.this.repaint(); } }); myContentPanel.add(checkBox); } }
private boolean isGroupEnabled(String group) { List<IdSet> sets = PluginGroups.getInstance().getSets(group); for (IdSet idSet : sets) { String[] ids = idSet.getIds(); for (String id : ids) { if (PluginGroups.getInstance().isPluginEnabled(id)) return true; } } return false; }
@Override public void linkSelected(LinkLabel linkLabel, String command) { if (command == null || !command.contains(":")) return; int semicolonPosition = command.indexOf(":"); String group = command.substring(semicolonPosition + 1); command = command.substring(0, semicolonPosition); if (SWITCH_COMMAND.equals(command)) { boolean enabled = isGroupEnabled(group); List<IdSet> sets = PluginGroups.getInstance().getSets(group); for (IdSet idSet : sets) { String[] ids = idSet.getIds(); for (String id : ids) { PluginGroups.getInstance().setPluginEnabledWithDependencies(id, !enabled); } } repaint(); return; } if (CUSTOMIZE_COMMAND.equals(command)) { myCustomizePanel.update(group); myCardLayout.show(this, CUSTOMIZE); } }