use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ConvertApplicationProperties method run.
public void run(IAction action) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (structuredSelection.getFirstElement() instanceof IFile) {
final IFile inputFile = (IFile) structuredSelection.getFirstElement();
final WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(inputFile.getProject().getName());
String ext = project == null || project.isOsgi() ? "cfg" : "properties";
FileSaveDialog saveDialog = new FileSaveDialog(MdwPlugin.getActiveWorkbenchWindow().getShell());
saveDialog.setFilterPath(inputFile.getParent().getRawLocation().makeAbsolute().toFile().getAbsolutePath());
saveDialog.setFilterExtensions(new String[] { "*" + ext });
final String filePath = saveDialog.open();
if (filePath != null) {
BusyIndicator.showWhile(MdwPlugin.getActiveWorkbenchWindow().getShell().getDisplay(), new Runnable() {
public void run() {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(inputFile.getContents());
doc.getDocumentElement().normalize();
StringBuffer sb = new StringBuffer();
NodeList nList = doc.getElementsByTagName("PropertyGroup");
// for every property group
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
String propertyGroupName = eElement.getAttribute("Name");
// create PropertyGroup comment
sb.append("\n");
sb.append("#");
sb.append(propertyGroupName);
sb.append("\n");
NodeList propertyList = eElement.getElementsByTagName("Property");
// group
for (int temp2 = 0; temp2 < propertyList.getLength(); temp2++) {
Node nNode2 = propertyList.item(temp2);
if (nNode2.getNodeType() == Node.ELEMENT_NODE) {
Element eElement2 = (Element) nNode2;
// format to:
// propertyGroup-propertyName=elementValue
sb.append(propertyGroupName);
if (project == null || project.isOsgi())
sb.append("-");
else
sb.append("/");
sb.append(eElement2.getAttribute("Name"));
sb.append("=");
sb.append(nNode2.getTextContent());
sb.append("\n");
}
}
}
}
PluginUtil.writeFile(new File(filePath), sb.toString().getBytes());
inputFile.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
} catch (Exception ex) {
PluginMessages.uiError(shell, ex, "Convert Application Properties", project);
}
}
});
}
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ConvertPropertiesToYaml method run.
@SuppressWarnings("restriction")
public void run(IAction action) {
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
if (structuredSelection.getFirstElement() instanceof IFile) {
final IFile inputFile = (IFile) structuredSelection.getFirstElement();
final WorkflowProject project = WorkflowProjectManager.getInstance().getWorkflowProject(inputFile.getProject().getName());
BusyIndicator.showWhile(MdwPlugin.getActiveWorkbenchWindow().getShell().getDisplay(), new Runnable() {
public void run() {
try {
Convert convert = new Convert(inputFile.getRawLocation().makeAbsolute().toFile());
convert.setConfigLoc(inputFile.getParent().getRawLocation().makeAbsolute().toFile().getAbsolutePath());
convert.run();
inputFile.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
} catch (Exception ex) {
PluginMessages.uiError(shell, ex, "Convert Application Properties", project);
}
}
});
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class MdwWorkbenchWindowAdvisor method getWorkflowProject.
private WorkflowProject getWorkflowProject(String host, String port, String contextRoot) throws DiscoveryException {
BigInteger portInt = new BigInteger(port);
WorkflowApplication matchingWorkflowApp = null;
WorkflowEnvironment matchingWorkflowEnv = null;
boolean isLocalhost = "localhost".equals(host);
List<WorkflowApplication> workflowApps = WorkflowProjectManager.getInstance().discoverWorkflowApps();
for (WorkflowApplication workflowApp : workflowApps) {
if (isLocalhost) {
// right info except host and port
if (workflowApp.getWebContextRoot().equals(contextRoot) || (workflowApp.getServicesContextRoot() != null && workflowApp.getServicesContextRoot().equals(contextRoot))) {
matchingWorkflowApp = workflowApp;
matchingWorkflowEnv = workflowApp.getEnvironmentList().get(0);
ManagedNode server = matchingWorkflowEnv.getManagedServerList().get(0);
server.setHost(host);
server.setPort(new BigInteger(port));
break;
}
} else {
for (WorkflowEnvironment workflowEnv : workflowApp.getEnvironmentList()) {
for (ManagedNode server : workflowEnv.getManagedServerList()) {
if (server.getHost().equals(host) && server.getPort().equals(portInt)) {
if (matchingWorkflowEnv == null) {
matchingWorkflowEnv = workflowEnv;
matchingWorkflowApp = workflowApp;
} else {
// context root is only used to break a tie
if (workflowApp.getWebContextRoot().equals(contextRoot) || (workflowApp.getServicesContextRoot() != null && workflowApp.getServicesContextRoot().equals(contextRoot))) {
matchingWorkflowEnv = workflowEnv;
matchingWorkflowApp = workflowApp;
}
}
}
}
}
}
}
if (matchingWorkflowApp == null)
return null;
return new WorkflowProject(matchingWorkflowApp, matchingWorkflowEnv);
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class MdwWorkbenchWindowAdvisor method postWindowOpen.
public void postWindowOpen() {
IWorkbenchPage activePage = Activator.getActivePage();
// check for updates
// IHandlerService handlerService = (IHandlerService)
// activePage.getWorkbenchWindow().getService(IHandlerService.class);
// try
// {
// Object result =
// handlerService.executeCommand("org.eclipse.equinox.p2.ui.sdk.update", null);
// System.out.println("result: " + result);
// if (result != null)
// System.out.println("result class: " + result.getClass().getName());
// }
// catch (Exception ex)
// {
// ex.printStackTrace();
// }
PluginMessages.log("MDW workbench startup...");
if (activePage != null) {
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.tools");
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.dev");
activePage.hideActionSet("com.centurylink.mdw.plugin.actionset.designerClassic");
activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.navigation");
activePage.hideActionSet("org.eclipse.ui.edit.text.actionSet.annotationNavigation");
activePage.hideActionSet("org.eclipse.ui.externaltools.ExternalToolsSet");
activePage.showActionSet("org.eclipse.search.menu");
// make sure the process explorer view is visible
try {
ProcessExplorerView processExplorerView = (ProcessExplorerView) activePage.showView("mdw.views.designer.processes");
if (mdwHost != null && mdwPort != null) {
final Shell shell = activePage.getActivePart().getSite().getShell();
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
try {
discoveryException = null;
projectToImport = getWorkflowProject(mdwHost, mdwPort, mdwContextRoot);
if (projectToImport == null)
throw new DiscoveryException("Unable to discover workflow app at: " + mdwHost + ":" + mdwPort);
} catch (DiscoveryException ex) {
discoveryException = ex;
}
}
});
if (discoveryException != null)
throw discoveryException;
WorkflowProject existing = WorkflowProjectManager.getInstance().getRemoteWorkflowProject(projectToImport.getName());
if (existing != null)
WorkflowProjectManager.getInstance().deleteProject(existing);
ProgressMonitorDialog progMonDlg = new ProgressMonitorDialog(shell);
ProjectInflator projectInflator = new ProjectInflator(projectToImport, null);
projectInflator.inflateRemoteProject(progMonDlg);
ProjectImporter projectImporter = new ProjectImporter(projectToImport);
projectImporter.doImport();
processExplorerView.handleRefresh();
// handle preselected entity
if (preselectType != null && preselectType.trim().length() > 0 && preselectId != null && preselectId.trim().length() > 0) {
if (!preselectType.equals(PRESELECT_PROCESS_INSTANCE))
throw new UnsupportedOperationException("Unsupported preselect type: " + preselectType);
BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
public void run() {
// open the process instance
IWorkbenchPage page = MdwPlugin.getActivePage();
try {
WorkflowProcess instance = getProcessInstance(new Long(preselectId));
page.openEditor(instance, "mdw.editors.process");
page.showView("org.eclipse.ui.views.PropertySheet");
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "Open Process Instance", projectToImport);
}
}
});
}
}
} catch (Exception ex) {
PluginMessages.uiError(ex, "Initialize Workspace");
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class MdwPlugin method stop.
/**
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
try {
for (WorkflowProject project : WorkflowProjectManager.getInstance().getWorkflowProjects()) project.clear();
LogWatcher logWatcher = LogWatcher.instance;
if (logWatcher != null && logWatcher.isRunning())
logWatcher.shutdown();
plugin = null;
} finally {
super.stop(context);
}
}
Aggregations