Added example interaction to plugin

This commit is contained in:
Brendan Robert 2016-07-04 12:38:35 -05:00
parent a521b66045
commit 5e1e01e896

View File

@ -9,14 +9,15 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.badvision.outlaweditor.api.ApplicationState;
import org.badvision.outlaweditor.api.MenuAction;
import org.badvision.outlaweditor.ui.UIAction;
import org.osgi.framework.BundleContext;
/**
* This registers a simple plugin that does nothing more than print a message
* to the console when executed. However, this plugin also demonstrates how
* to inject dependencies to more useful features, specifically the ApplicationState
* which in turn provides all game data, etc.
* This registers a simple plugin that does nothing more than print a message to
* the console when executed. However, this plugin also demonstrates how to
* inject dependencies to more useful features, specifically the
* ApplicationState which in turn provides all game data, etc.
*
* @author blurry
*/
@Component(immediate = true)
@ -53,18 +54,19 @@ public class ExamplePlugin implements MenuAction {
System.out.println("Clicked!");
JAXB.marshal(ApplicationState.getInstance().getGameData(), System.out);
checkReferences();
UIAction.confirm("Did you mean to click that?",
() -> UIAction.alert("Well isn't that special?"),
() -> UIAction.alert("You should be more careful next time then."));
}
private void checkReferences() {
// app = ApplicationState.getInstance();
if (app == null) {
System.out.println("App is null?!?!");
} else if (app.getCurrentPlatform() == null) {
System.out.println("Current platform is null?");
} else {
if (app.getCurrentPlatform() == null) {
System.out.println("Current platform is null?");
} else {
System.out.println("Current platform is "+app.getCurrentPlatform());
}
System.out.println("Current platform is " + app.getCurrentPlatform());
}
}
}