"This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched. Is that ok?",
"Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
new Thread(
new Runnable() {
public void run() {
PluginRegistry pluginRegistry = LogManager.getLoggerRepository().getPluginRegistry();
List list = pluginRegistry.getPlugins(Generator.class);
for (Iterator iter = list.iterator(); iter.hasNext();) {
Plugin plugin = (Plugin) iter.next();
pluginRegistry.stopPlugin(plugin.getName());
}
}
}).start();
setEnabled(false);
startTutorial.putValue("TutorialStarted", Boolean.FALSE);
}
}
};
stopTutorial.putValue(
Action.SHORT_DESCRIPTION,
"Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched");
startTutorial.putValue(
Action.SHORT_DESCRIPTION,
"Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action");
stopTutorial.setEnabled(false);
final SmallToggleButton startButton = new SmallToggleButton(startTutorial);
PropertyChangeListener pcl =
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
stopTutorial.setEnabled(
((Boolean) startTutorial.getValue("TutorialStarted")).equals(
Boolean.TRUE));
startButton.setSelected(stopTutorial.isEnabled());
}
};
startTutorial.addPropertyChangeListener(pcl);
stopTutorial.addPropertyChangeListener(pcl);
pluginRegistry.addPluginListener(
new PluginListener() {
public void pluginStarted(PluginEvent e) {
}
public void pluginStopped(PluginEvent e) {
List list = pluginRegistry.getPlugins(Generator.class);
if (list.size() == 0) {
startTutorial.putValue("TutorialStarted", Boolean.FALSE);
}
}