|
@@ -1,15 +1,14 @@
|
|
|
-package uraxis.impl;
|
|
|
+package uraxis;
|
|
|
|
|
|
import com.ur.urcap.api.contribution.DaemonContribution;
|
|
|
import com.ur.urcap.api.contribution.InstallationNodeContribution;
|
|
|
import com.ur.urcap.api.domain.data.DataModel;
|
|
|
import com.ur.urcap.api.domain.script.ScriptWriter;
|
|
|
+import com.ur.urcap.api.ui.annotation.Div;
|
|
|
import com.ur.urcap.api.ui.annotation.Input;
|
|
|
import com.ur.urcap.api.ui.annotation.Label;
|
|
|
-import com.ur.urcap.api.ui.component.InputButton;
|
|
|
-import com.ur.urcap.api.ui.component.InputEvent;
|
|
|
-import com.ur.urcap.api.ui.component.InputTextField;
|
|
|
-import com.ur.urcap.api.ui.component.LabelComponent;
|
|
|
+import com.ur.urcap.api.ui.component.*;
|
|
|
+import org.apache.xmlrpc.XmlRpcException;
|
|
|
|
|
|
import java.awt.EventQueue;
|
|
|
import java.util.Timer;
|
|
@@ -23,17 +22,18 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
private static final String DEFAULT_VALUE = "HelloWorld";
|
|
|
|
|
|
private DataModel model;
|
|
|
- private final MyDaemonDaemonService daemonService;
|
|
|
- // private XmlRpcMyDaemonInterface xmlRpcDaemonInterface;
|
|
|
+ // private final MyDaemonDaemonService daemonService;
|
|
|
private MyDaemonInterface daemonInterface;
|
|
|
|
|
|
private Timer uiTimer;
|
|
|
+ private Timer statusTimer;
|
|
|
+
|
|
|
|
|
|
public MyDaemonInstallationNodeContribution(MyDaemonDaemonService daemonService, DataModel model) {
|
|
|
- this.daemonService = daemonService;
|
|
|
+ // this.daemonService = daemonService;
|
|
|
this.model = model;
|
|
|
- daemonInterface = new MyDaemonInterface("127.0.0.1", 40404);
|
|
|
- applyDesiredDaemonStatus();
|
|
|
+ daemonInterface = new MyDaemonInterface("10.0.31.42", 8082);
|
|
|
+ // applyDesiredDaemonStatus();
|
|
|
}
|
|
|
|
|
|
@Input(id = POPUPTITLE_KEY)
|
|
@@ -42,6 +42,18 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
@Input(id = "btnEnableDaemon")
|
|
|
private InputButton enableDaemonButton;
|
|
|
|
|
|
+ @Input(id = "btnRef")
|
|
|
+ private InputButton refButton;
|
|
|
+
|
|
|
+ @Input(id = "textIP")
|
|
|
+ private InputTextField refTextIP;
|
|
|
+
|
|
|
+ @Input(id = "textPort")
|
|
|
+ private InputTextField refTextPort;
|
|
|
+
|
|
|
+ @Label(id = "lblStatus")
|
|
|
+ private LabelComponent refLblStatus;
|
|
|
+
|
|
|
@Input(id = "btnDisableDaemon")
|
|
|
private InputButton disableDaemonButton;
|
|
|
|
|
@@ -54,12 +66,23 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
setPopupTitle(popupTitleField.getText());
|
|
|
}
|
|
|
}
|
|
|
+ @Input(id = "btnRef")
|
|
|
+ public void onBtnRef(InputEvent event) {
|
|
|
+ if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
|
|
|
+ try {
|
|
|
+ getDaemonInterface().client.execute("ref", new String[]{"foo", "bar"});
|
|
|
+ } catch (XmlRpcException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Input(id = "btnEnableDaemon")
|
|
|
public void onStartClick(InputEvent event) {
|
|
|
if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
|
|
|
setDaemonEnabled(true);
|
|
|
- applyDesiredDaemonStatus();
|
|
|
+ // applyDesiredDaemonStatus();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -67,7 +90,7 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
public void onStopClick(InputEvent event) {
|
|
|
if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
|
|
|
setDaemonEnabled(false);
|
|
|
- applyDesiredDaemonStatus();
|
|
|
+ // applyDesiredDaemonStatus();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -90,6 +113,24 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
});
|
|
|
}
|
|
|
}, 0, 1000);
|
|
|
+
|
|
|
+ statusTimer = new Timer(true);
|
|
|
+ statusTimer.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ EventQueue.invokeLater(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ Object res = getDaemonInterface().client.execute("status", new String[]{});
|
|
|
+ refLblStatus.setText(res.toString());
|
|
|
+ System.out.println(res);
|
|
|
+ } catch (XmlRpcException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }},0,1000);
|
|
|
}
|
|
|
|
|
|
private void updateUI() {
|
|
@@ -125,13 +166,9 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public boolean isDefined() {
|
|
|
- return !getPopupTitle().isEmpty() && getDaemonState() == DaemonContribution.State.RUNNING;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public void generateScript(ScriptWriter writer) {
|
|
|
- writer.globalVariable(XMLRPC_VARIABLE, "rpc_factory(\"xmlrpc\", \"http://127.0.0.1:40404/RPC2\")");
|
|
|
+ writer.globalVariable(XMLRPC_VARIABLE, "rpc_factory(\"xmlrpc\", \"http://192.168.20.111:8081/\")");
|
|
|
// Apply the settings to the daemon on program start in the Installation pre-amble
|
|
|
writer.appendLine(XMLRPC_VARIABLE + ".set_title(\"" + getPopupTitle() + "\")");
|
|
|
}
|
|
@@ -168,35 +205,36 @@ public class MyDaemonInstallationNodeContribution implements InstallationNodeCon
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void applyDesiredDaemonStatus() {
|
|
|
- new Thread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (isDaemonEnabled()) {
|
|
|
- // Download the daemon settings to the daemon process on initial start for real-time preview purposes
|
|
|
- try {
|
|
|
- awaitDaemonRunning(5000);
|
|
|
- daemonInterface.setTitle(getPopupTitle());
|
|
|
- } catch (Exception e) {
|
|
|
- System.err.println("Could not set the title in the daemon process.");
|
|
|
- }
|
|
|
- } else {
|
|
|
- daemonService.getDaemon().stop();
|
|
|
- }
|
|
|
- }
|
|
|
- }).start();
|
|
|
- }
|
|
|
-
|
|
|
- private void awaitDaemonRunning(long timeOutMilliSeconds) throws InterruptedException {
|
|
|
- daemonService.getDaemon().start();
|
|
|
- long endTime = System.nanoTime() + timeOutMilliSeconds * 1000L * 1000L;
|
|
|
- while(System.nanoTime() < endTime && (daemonService.getDaemon().getState() != DaemonContribution.State.RUNNING || !daemonInterface.isReachable())) {
|
|
|
- Thread.sleep(100);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+// private void applyDesiredDaemonStatus() {
|
|
|
+// new Thread(new Runnable() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// if (isDaemonEnabled()) {
|
|
|
+// // Download the daemon settings to the daemon process on initial start for real-time preview purposes
|
|
|
+// try {
|
|
|
+// awaitDaemonRunning(5000);
|
|
|
+// daemonInterface.setTitle(getPopupTitle());
|
|
|
+// } catch (Exception e) {
|
|
|
+// System.err.println("Could not set the title in the daemon process.");
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// daemonService.getDaemon().stop();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }).start();
|
|
|
+// }
|
|
|
+
|
|
|
+// private void awaitDaemonRunning(long timeOutMilliSeconds) throws InterruptedException {
|
|
|
+// daemonService.getDaemon().start();
|
|
|
+// long endTime = System.nanoTime() + timeOutMilliSeconds * 1000L * 1000L;
|
|
|
+// while(System.nanoTime() < endTime && (daemonService.getDaemon().getState() != DaemonContribution.State.RUNNING || !daemonInterface.isReachable())) {
|
|
|
+// Thread.sleep(100);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
private DaemonContribution.State getDaemonState(){
|
|
|
- return daemonService.getDaemon().getState();
|
|
|
+ return DaemonContribution.State.RUNNING;
|
|
|
+ // return daemonService.getDaemon().getState();
|
|
|
}
|
|
|
|
|
|
private Boolean isDaemonEnabled() {
|