use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method findCallers.
public void findCallers(WorkflowElement element) {
WorkflowProcess processVersion = (WorkflowProcess) element;
List<WorkflowProject> projects = new ArrayList<WorkflowProject>();
projects.add(processVersion.getProject());
Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
ProcessSearchQuery searchQuery = new ProcessSearchQuery(projects, SearchQuery.SearchType.INVOKING_ENTITY, "*", true, shell);
searchQuery.setInvokedEntityId(processVersion.getId());
try {
ProgressMonitorDialog context = new MdwProgressMonitorDialog(shell);
NewSearchUI.runQueryInForeground(context, searchQuery);
// this shouldn't be necessary according to the Eclipse API docs
NewSearchUI.activateSearchResultView();
ISearchResultViewPart part = NewSearchUI.getSearchResultView();
part.updateLabel();
SearchResultsPage page = (SearchResultsPage) part.getActivePage();
page.setSearchQuery(searchQuery);
page.setInput(searchQuery.getSearchResult(), null);
} catch (OperationCanceledException ex) {
MessageDialog.openInformation(shell, "Search Cancelled", "Search for callers cancelled.");
} catch (Exception ex) {
PluginMessages.uiError(shell, ex, "Search for Callers", processVersion.getProject());
}
}
use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.
the class Template method runWith.
public void runWith(final String inputPath, final String outputLocation, final String velocityPropFile, final String velocityToolboxFile) {
try {
VelocityEngine engine = new VelocityEngine();
Properties vProps = new Properties();
if (velocityPropFile != null && velocityPropFile.length() > 0)
vProps.load(new FileInputStream(velocityPropFile));
String loadPath = vProps.getProperty("file.resource.loader.path");
String tempFolder = getTempFolder().getLocation().toString();
if (loadPath == null)
loadPath = tempFolder;
else
loadPath += "," + tempFolder;
vProps.setProperty("file.resource.loader.path", loadPath);
engine.init(vProps);
final VelocityContext velocityContext = getVelocityContext(velocityToolboxFile);
final org.apache.velocity.Template velocityTemplate = engine.getTemplate(getTempFileName());
final java.io.File input = new java.io.File(inputPath);
if (input.isDirectory()) {
ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(MdwPlugin.getActiveWorkbenchWindow().getShell());
pmDialog.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
java.io.File[] inputFiles = input.listFiles();
monitor.beginTask("Creating output files", inputFiles.length);
for (java.io.File inputFile : inputFiles) {
if (!inputFile.isDirectory()) {
String outputFile = outputLocation + "/" + getOutputFileName(inputFile.getName());
monitor.subTask(inputFile.getName());
InputStream inputStream = null;
try {
inputStream = new FileInputStream(inputFile);
processInput(inputStream, outputLocation, outputFile, velocityContext, velocityTemplate);
} catch (Exception ex) {
throw new InvocationTargetException(ex, "Problem applying input:\n'" + inputFile.getName() + "'");
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (Exception ex) {
}
}
}
}
monitor.worked(1);
}
}
});
} else {
int sepIdx = inputPath.lastIndexOf(System.getProperty("file.separator"));
String inputFileName = sepIdx == -1 ? inputPath : inputPath.substring(sepIdx + 1);
String outputFile = outputLocation + "/" + getOutputFileName(inputFileName);
processInput(new FileInputStream(inputPath), outputLocation, outputFile, velocityContext, velocityTemplate);
final IWorkbenchPage page = MdwPlugin.getActivePage();
if (page != null) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(outputFile));
IDE.openEditorOnFileStore(page, fileStore);
}
}
} catch (InvocationTargetException ex) {
PluginMessages.log(ex);
String message = ex.getMessage() + ":\n\nCause:\n---------\n" + PluginMessages.getRootCause(ex);
PluginMessages.uiError(message, "Run Template", getProject());
} catch (Exception ex) {
PluginMessages.uiError(ex, "Run Template", getProject());
}
}
use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.
the class DesignerRunner method run.
public RunnerResult run(boolean forked) {
result = new RunnerResult();
Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell();
ProgressMonitorDialog progressMonitorDialog = new MdwProgressMonitorDialog(shell);
try {
// this is absolutely needed
shell.setFocus();
progressMonitorDialog.run(forked, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(progressMessage, IProgressMonitor.UNKNOWN);
try {
perform();
result.setStatus(RunnerStatus.SUCCESS);
} catch (Exception ex) {
result.setStatus(RunnerStatus.FAILURE);
throw new InvocationTargetException(ex);
}
}
});
return result;
} catch (Exception ex) {
int messageLevel = PluginMessages.isDataIntegrityException(ex) ? PluginMessages.DATA_INTEGRITY_MESSAGE : PluginMessages.ERROR_MESSAGE;
PluginMessages.uiMessage(shell, ex, errorMessage, workflowProject, messageLevel);
if (ex.getCause() instanceof ValidationException) {
if (DesignerProxy.INCOMPATIBLE_INSTANCES.equals(ex.getCause().getMessage()) || (ex.getCause().getMessage() != null && ex.getCause().getMessage().contains(DesignerProxy.ALREADY_EXISTS)))
result.setStatus(RunnerStatus.DISALLOW);
else
result.setStatus(RunnerStatus.INVALID);
}
return result;
}
}
use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.
the class WebUpdateAction method run.
/**
* @see IActionDelegate#run(IAction)
*/
public void run(final IAction action) {
IProject webProject = null;
WorkflowProject workflowProject = null;
try {
if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() instanceof IProject) {
webProject = (IProject) ((IStructuredSelection) selection).getFirstElement();
workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(webProject);
}
if (workflowProject == null) {
MessageDialog.openError(shell, "MDW Update", "Selection must be a Workflow Web project.\n(Try refreshing Process Explorer view.)");
return;
}
ProjectUpdater updater = new ProjectUpdater(workflowProject, MdwPlugin.getSettings());
if (action.getId().equals("mdw.workflow.updateFrameworkWebJars")) {
updater.updateWebProjectJars(null);
} else if (action.getId().equals("mdw.workflow.associateWebAppSourceCode")) {
ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(shell);
final WorkflowProject wfProject = workflowProject;
pmDialog.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Setting Java source attachment locations", 100);
monitor.worked(20);
ProjectConfigurator configurator = new ProjectConfigurator(wfProject, MdwPlugin.getSettings());
try {
configurator.createWebProjectSourceCodeAssociations(shell, monitor);
} catch (CoreException ex) {
PluginMessages.log(ex);
}
}
});
}
} catch (Exception ex) {
PluginMessages.log(ex);
}
}
use of com.centurylink.mdw.plugin.designer.dialogs.MdwProgressMonitorDialog in project mdw-designer by CenturyLinkCloud.
the class ToolboxWrapper method refresh.
/**
* Reloads from the database.
*/
public void refresh() {
try {
IRunnableWithProgress loader = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ProgressMonitor progressMonitor = new SwtProgressMonitor(monitor);
progressMonitor.start("Loading Activity Implementors for " + getProject().getLabel());
progressMonitor.progress(25);
getProject().reloadActivityImplementors();
progressMonitor.done();
}
};
ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(Display.getCurrent().getActiveShell());
progMonDlg.run(true, false, loader);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Refresh Implementors", getProject());
}
update();
clearDirty();
}
Aggregations