use of com.centurylink.mdw.plugin.ProcessConsoleRunner in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method launchSwing.
public void launchSwing(final WorkflowProject project, final String title, final String formName, String dataInit) {
try {
if (title.equals("Java VisualVM")) {
String javaVersion = System.getProperty("java.version");
String badVersionMsg = "Cannot launch Java VisualVM.\nRequires Java version >= 1.6.0_07.\nRunning version: " + javaVersion + ".";
if (!javaVersion.startsWith("1.6") && !javaVersion.startsWith("1.7") && !javaVersion.startsWith("1.8")) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
} else if (javaVersion.startsWith("1.6")) {
// check minor version
String minorVer = javaVersion.substring(javaVersion.indexOf('_') + 1);
if (Integer.parseInt(minorVer) < 7) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
}
}
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jvisualvm.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote()) {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openjmx", project.getServerSettings().getHost() + ":" + project.getJmxPort() });
} else {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openid", String.valueOf(project.getVisualVmId()) });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else if (title.equals("JConsole")) {
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jconsole.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch JConsole", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote())
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { project.getServerSettings().getHost() + ":" + project.getJmxPort() });
else {
String serverProcId = project.getServerSettings().getServerProcessId();
if (serverProcId != null)
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { serverProcId });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else {
String request = null;
if (dataInit != null) {
FormDataDocument datadoc = new FormDataDocument();
datadoc.setAttribute(FormDataDocument.ATTR_ACTION, dataInit);
request = datadoc.format();
}
final String response = dataInit == null ? null : project.getDesignerProxy().getDesignerDataAccess().engineCall(request);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DesignerProxy designerProxy = project.getDesignerProxy();
JFrame propmgr_frame = new JFrame(title);
FormPanel mainform = new FormPanel(propmgr_frame, designerProxy.getDesignerDataAccess(), designerProxy.getPluginDataAccess().getPrivileges());
mainform.setData(formName, response);
propmgr_frame.setVisible(true);
} catch (final Exception ex) {
if (getShell() == null) {
PluginMessages.log(ex);
} else {
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
});
}
}
}
});
}
} catch (Exception ex) {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
}
Aggregations