From 5e1e01e8962523048e3e499bf2c7ffefffa8fad9 Mon Sep 17 00:00:00 2001 From: Brendan Robert Date: Mon, 4 Jul 2016 12:38:35 -0500 Subject: [PATCH] Added example interaction to plugin --- .../outlaw/plugin/example/ExamplePlugin.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java b/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java index b27a1dd1..dee8e2f5 100644 --- a/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java +++ b/OutlawEditor/OutlawPluginExample/src/main/java/org/badvision/outlaw/plugin/example/ExamplePlugin.java @@ -9,25 +9,26 @@ 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) @Service(MenuAction.class) public class ExamplePlugin implements MenuAction { - + // Note: Because ApplicationState is already a defined service, this will automatically be bound. // Hence, it is not necessary to worry about passing it it. @Reference ApplicationState app; - + // This is called when our plugin is starting @Activate public void activate() throws Exception { @@ -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()); + } } }