use of com.centurylink.mdw.plugin.designer.model.ExternalEvent 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.designer.model.ExternalEvent 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.designer.model.ExternalEvent in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method runApplies.
// top-level run action
public boolean runApplies(IStructuredSelection selection) {
if (selection.size() > 1) {
Boolean legacy = null;
WorkflowPackage testPkg = null;
for (Object o : selection.toArray()) {
if (!(o instanceof AutomatedTestCase))
return false;
// make sure they're all in the same package or legacy suite
AutomatedTestCase testCase = (AutomatedTestCase) o;
if (legacy == null)
legacy = testCase.isLegacy();
if (legacy.booleanValue() != testCase.isLegacy())
return false;
if (!testCase.isLegacy()) {
if (testPkg == null)
testPkg = testCase.getPackage();
if (!testPkg.equals(testCase.getPackage()))
return false;
}
}
WorkflowProject workflowProject = ((AutomatedTestCase) selection.getFirstElement()).getProject();
if (!workflowProject.isRemote())
return true;
return workflowProject.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION);
}
if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
return false;
WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
if (workflowElement instanceof Report)
return true;
if (workflowElement instanceof Page)
return true;
if (workflowElement instanceof Template && ((Template) workflowElement).getLanguage().equals(RuleSetVO.VELOCITY))
return true;
if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent) {
if (!workflowElement.getProject().isRemote())
return true;
return workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
}
if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
if (workflowElement.getProject() == null)
return false;
if (workflowElement.getProject().isRemote()) {
if (!workflowElement.getProject().isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
return false;
WorkflowPackage pkg = workflowElement.getPackage();
if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
return false;
}
try {
AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
return !testView.isLocked();
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
}
}
return false;
}
use of com.centurylink.mdw.plugin.designer.model.ExternalEvent in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method debugApplies.
public boolean debugApplies(IStructuredSelection selection) {
if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
return false;
WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
WorkflowProject prj = workflowElement.getProject();
if (prj == null || !prj.checkRequiredVersion(6, 0) || !prj.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
return false;
WorkflowPackage pkg = workflowElement.getPackage();
if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
return false;
try {
AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
return !testView.isLocked();
} catch (PartInitException ex) {
PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
}
}
if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent)
return !MdwPlugin.isRcp() && workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
else
return false;
}
use of com.centurylink.mdw.plugin.designer.model.ExternalEvent in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDragSource method isDragAllowed.
private boolean isDragAllowed(Object selectedElement) {
boolean dragArchived = MdwPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREFS_ALLOW_DELETE_ARCHIVED_PROCESSES);
if (selectedElement instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) selectedElement;
IEditorPart editor = findOpenEditor(processVersion);
if (editor != null) {
String message = "'" + processVersion.getLabel() + "' is currently open in an editor.\nPlease save and close before dragging.";
MessageDialog.openError(MdwPlugin.getShell(), "Process Explorer", message);
return false;
}
return dragArchived || !processVersion.isArchived();
} else if (selectedElement instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) selectedElement;
return dragArchived || !externalEvent.isArchived();
} else if (selectedElement instanceof ActivityImpl) {
ActivityImpl activityImpl = (ActivityImpl) selectedElement;
return dragArchived || !activityImpl.isArchived();
} else if (selectedElement instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) selectedElement;
IEditorPart tempFileEditor = asset.getFileEditor();
if (tempFileEditor != null && findOpenEditor(tempFileEditor.getEditorInput()) != null) {
String message = "'" + asset.getLabel() + "' is currently open in an editor.\nPlease save and close before dragging.";
MessageDialog.openError(MdwPlugin.getShell(), "Process Explorer", message);
return false;
}
return dragArchived || !asset.isArchived();
}
return false;
}
Aggregations