private void initPlugins() { plugins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); plugins.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (plugins.getSelectedIndex() != -1) { PluginLoader loader = getCurrentLoader(); description.setText(loader.getDescription()); description.revalidate(); config.setEnabled(loader.getConfigDialog(SelectionFrame.this) != null); StringBuilder sb = new StringBuilder(); if (stat.isEmpty()) { sb = sb.append(loader.getName()); } else { sb = sb.append(stat).append(" > ").append(loader.getName()); } for (int i = 0; i < InterfaceConfig.SELECTION_FRAME_PROPERTIES.getInt("tabs-count"); i++) { sb = sb.insert(0, " "); } status.setText(sb.toString()); } } }); setLoaders(TaskState.getLoaders()); }
public void setLoaders(final List<PluginLoader> loaders) { this.loaders = loaders; plugins.setModel( new AbstractListModel() { @Override public int getSize() { return loaders.size(); } @Override public Object getElementAt(int i) { return loaders.get(i).getName(); } }); plugins.setSelectedIndex(0); plugins.revalidate(); }
public PluginLoader getCurrentLoader() { return loaders.get(plugins.getSelectedIndex()); }