use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method clientShell.
public void clientShell(Object element) {
ServerSettings serverSettings;
if (element instanceof WorkflowProject || element instanceof ServerSettings) {
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
serverSettings = workflowProject.getServerSettings();
MdwPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, workflowProject.getName());
} else {
serverSettings = (ServerSettings) element;
MdwPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
}
ServerConfigurator configurator = ServerConfigurator.Factory.create(serverSettings);
configurator.doClientShell(getShell());
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method rename.
public void rename(WorkflowElement element) {
RenameDialog renameDialog = new RenameDialog(getShell(), element);
renameDialog.setTitle("Rename " + element.getTitle());
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
String lbl = "'" + processVersion.getLabel() + "'";
IEditorPart editor = findOpenEditor(processVersion);
if (editor != null) {
String message = lbl + " is currently open in an editor.\nPlease save and close before renaming.";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
if (processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
String message = lbl + " is currently locked to " + processVersion.getLockingUser() + ", so it cannot be renamed";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
if (asset.getFileEditor() != null) {
IEditorPart assetEditor = findOpenEditor(asset.getFileEditor().getEditorInput());
if (assetEditor != null) {
String message = "'" + asset.getName() + "' is currently open in an editor.\nPlease save and close before renaming.";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
}
} else if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote()) {
if (workflowProject.isCloudProject())
MessageDialog.openWarning(getShell(), "Cloud Project", "Please rename the underlying Java Project in Package Explorer and then refresh the Process Explorer view.");
return;
}
}
int result = renameDialog.open();
if (result == Dialog.OK) {
String newName = renameDialog.getNewName();
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote())
return;
WorkflowProjectManager.renameRemoteProject(workflowProject, newName);
workflowProject.fireElementChangeEvent(ChangeType.RENAME, null);
} else {
WorkflowProject workflowProject = element.getProject();
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
designerProxy.renameProcess(processVersion, newName);
} else if (element instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) element;
designerProxy.renamePackage(packageVersion, newName);
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
designerProxy.renameWorkflowAsset(asset, newName);
}
element.fireElementChangeEvent(ChangeType.RENAME, element.getName());
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method run.
public void run(Object element) {
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
if (MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_WEB_BASED_PROCESS_LAUNCH)) {
// web-based process launch
try {
IViewPart viewPart = getPage().showView("mdw.views.designer.process.launch");
if (viewPart != null) {
ProcessLaunchView launchView = (ProcessLaunchView) viewPart;
launchView.setProcess(processVersion);
}
} catch (PartInitException ex) {
PluginMessages.log(ex);
}
} else {
if (editorPart == null) {
// process must be open
open((WorkflowElement) element);
}
ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.RUN_MODE);
}
} else if (element instanceof Activity) {
Activity activity = (Activity) element;
WorkflowProcess processVersion = activity.getProcess();
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.RUN_MODE);
} else if (element instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) element;
ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.RUN_MODE);
} else if (element instanceof Template) {
Template template = (Template) element;
IEditorPart editorPart = template.getFileEditor();
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Run Template", "Save template '" + template.getName() + "' before running?"))
editorPart.doSave(new NullProgressMonitor());
}
template.openFile(new NullProgressMonitor());
new TemplateRunDialog(getShell(), template).open();
} else if (element instanceof Page) {
Page page = (Page) element;
IEditorPart editorPart = page.getFileEditor();
if (editorPart != null) {
if (editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Run Page", "Save page '" + page.getName() + "' before running?"))
editorPart.doSave(new NullProgressMonitor());
}
}
page.run();
} else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
ServerSettings serverSettings;
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (workflowProject.isRemote())
throw new IllegalArgumentException("Cannot run server for remote projects.");
serverSettings = workflowProject.getServerSettings();
} else {
serverSettings = (ServerSettings) element;
}
if (ServerRunner.isServerRunning()) {
String question = "A server may be running already. Shut down the currently-running server?";
MessageDialog dlg = new MessageDialog(getShell(), "Server Running", null, question, MessageDialog.QUESTION_WITH_CANCEL, new String[] { "Shutdown", "Ignore", "Cancel" }, 0);
int res = dlg.open();
if (res == 0)
new ServerRunner(serverSettings, getShell().getDisplay()).stop();
else if (res == 2)
return;
}
if (serverSettings.getHome() == null && element instanceof WorkflowProject) {
final IProject project = serverSettings.getProject().isCloudProject() ? serverSettings.getProject().getSourceProject() : serverSettings.getProject().getEarProject();
@SuppressWarnings("restriction") org.eclipse.ui.internal.dialogs.PropertyDialog dialog = org.eclipse.ui.internal.dialogs.PropertyDialog.createDialogOn(getShell(), "mdw.workflow.mdwServerConnectionsPropertyPage", project);
if (dialog != null)
dialog.open();
} else {
IPreferenceStore prefStore = MdwPlugin.getDefault().getPreferenceStore();
if (element instanceof WorkflowProject)
prefStore.setValue(PreferenceConstants.PREFS_SERVER_WF_PROJECT, ((WorkflowProject) element).getName());
else
prefStore.setValue(PreferenceConstants.PREFS_RUNNING_SERVER, serverSettings.getServerName());
ServerRunner runner = new ServerRunner(serverSettings, getShell().getDisplay());
if (serverSettings.getProject() != null)
runner.setJavaProject(serverSettings.getProject().getJavaProject());
runner.start();
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method debug.
public void debug(Object element) {
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Process Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
if (editorPart == null) {
// process must be open
open(processVersion);
}
ProcessLaunchShortcut launchShortcut = new ProcessLaunchShortcut();
launchShortcut.launch(new StructuredSelection(processVersion), ILaunchManager.DEBUG_MODE);
} else if (element instanceof Activity) {
Activity activity = (Activity) element;
WorkflowProcess processVersion = activity.getProcess();
IEditorPart editorPart = findOpenEditor(processVersion);
if (editorPart != null && editorPart.isDirty()) {
if (MessageDialog.openQuestion(getShell(), "Activity Launch", "Save process '" + processVersion.getLabel() + "' before launching?"))
editorPart.doSave(new NullProgressMonitor());
}
ActivityLaunchShortcut launchShortcut = new ActivityLaunchShortcut();
launchShortcut.launch(new StructuredSelection(activity), ILaunchManager.DEBUG_MODE);
} else if (element instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) element;
ExternalEventLaunchShortcut launchShortcut = new ExternalEventLaunchShortcut();
launchShortcut.launch(new StructuredSelection(externalEvent), ILaunchManager.DEBUG_MODE);
} else if (element instanceof WorkflowProject || element instanceof ServerSettings) {
ServerSettings serverSettings;
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
serverSettings = workflowProject.getServerSettings();
} else {
serverSettings = (ServerSettings) element;
}
serverSettings.setDebug(true);
if (serverSettings.getDebugPort() == 0)
serverSettings.setDebugPort(8500);
run(serverSettings);
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class CodeGenWizard method init.
public void init(IWorkbench workbench, IStructuredSelection selection, Code codeElement) {
this.workbench = workbench;
this.selection = selection;
this.codeElement = codeElement;
setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
setNeedsProgressMonitor(true);
if (selection != null) {
if (selection.getFirstElement() instanceof WorkflowPackage) {
WorkflowPackage workflowPackage = (WorkflowPackage) selection.getFirstElement();
getCodeElement().setProject(workflowPackage.getProject());
getCodeElement().setPackage(workflowPackage);
} else if (selection.getFirstElement() instanceof WorkflowElement) {
WorkflowElement workflowElement = ((WorkflowElement) selection.getFirstElement());
getCodeElement().setProject(workflowElement.getProject());
getCodeElement().setPackage(workflowElement.getPackage());
} else if (selection.getFirstElement() instanceof IResource) {
IResource resource = (IResource) selection.getFirstElement();
if (resource.getProject() != null) {
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(resource.getProject());
if (workflowProject != null)
getCodeElement().setProject(workflowProject);
}
}
}
if (getCodeElement().getProject() == null) {
// choose any available workflow project
List<WorkflowProject> workflowProjects = WorkflowProjectManager.getInstance().getWorkflowProjects();
if (workflowProjects == null || workflowProjects.size() == 0)
MessageDialog.openError(getShell(), "Error", "No MDW projects found");
else
getCodeElement().setProject(workflowProjects.get(0));
}
}
Aggregations