use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerView method createPartControl.
@Override
public void createPartControl(Composite parent) {
treeViewer = new TreeViewer(parent) {
protected void handleTreeExpand(TreeEvent event) {
if (event.item.getData() instanceof WorkflowProject) {
final WorkflowProject project = (WorkflowProject) event.item.getData();
if (project.isFilePersist() && !project.isRemote()) {
// authentication not needed
project.setUser(new User(System.getProperty("user.name")));
} else {
// user authentication
Boolean authenticated = project.isAuthenticated();
if (authenticated == null) {
// has to be in a separate
// thread to take effect
event.item.getDisplay().asyncExec(new Runnable() {
public void run() {
treeViewer.collapseToLevel(project, TreeViewer.ALL_LEVELS);
}
});
return;
}
if (!authenticated) {
LoginDialog loginDialog = new LoginDialog(MdwPlugin.getShell(), project);
int res = loginDialog.open();
if (res == Dialog.CANCEL || !project.isAuthenticated()) {
// has
// to
// be
// in
// a
// separate
// thread
// to
// take
// effect
event.item.getDisplay().asyncExec(new Runnable() {
public void run() {
treeViewer.collapseToLevel(project, TreeViewer.ALL_LEVELS);
}
});
return;
}
}
super.handleTreeExpand(event);
return;
}
}
super.handleTreeExpand(event);
}
};
ProcessExplorerContentProvider contentProvider = new ProcessExplorerContentProvider();
// for
WorkflowProjectManager.getInstance().addElementChangeListener(contentProvider);
// project
// adds/deletes
treeViewer.setContentProvider(contentProvider);
treeViewer.setLabelProvider(new ProcessExplorerLabelProvider());
treeViewer.setInput(WorkflowProjectManager.getInstance().getWorkflowProjects());
treeViewer.collapseAll();
clipboard = new Clipboard(parent.getDisplay());
// action group
actionGroup = new ProcessExplorerActionGroup(this);
actionGroup.fillActionBars(getViewSite().getActionBars());
// context menu
MenuManager menuMgr = new MdwMenuManager("Process Explorer");
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(this);
contextMenu = menuMgr.createContextMenu(treeViewer.getTree());
treeViewer.getTree().setMenu(contextMenu);
getSite().registerContextMenu(menuMgr, treeViewer);
treeViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
for (Object item : getSelection().toList()) {
if (!actionGroup.getActionHandler().open((WorkflowElement) item))
expand(item);
}
}
});
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
handleSelectionChanged((IStructuredSelection) event.getSelection());
}
});
// drag and drop support
Transfer[] transfers = new Transfer[] { TextTransfer.getInstance() };
dragSource = new ProcessExplorerDragSource(treeViewer);
treeViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, dragSource);
dropTarget = new ProcessExplorerDropTarget(treeViewer);
treeViewer.addDropSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, dropTarget);
contextListener = new ProcessExplorerContextListener();
getSite().getPage().addPartListener(contextListener);
MdwPlugin.getPluginWorkbench().getHelpSystem().setHelp(parent, MdwPlugin.getPluginId() + ".process_explorer_help");
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ServiceMixServerBehavior method getServerSettings.
ServerSettings getServerSettings() {
serverSettings = null;
String serverLoc = getServer().getAttribute(ServiceMixServer.LOCATION, "");
ServiceMixRuntime runtime = (ServiceMixRuntime) getServer().getRuntime().loadAdapter(RuntimeDelegate.class, null);
if (!serverLoc.isEmpty() && runtime != null && runtime.getLocation() != null && !runtime.getLocation().isEmpty()) {
serverSettings = new ServerSettings(getProject());
serverSettings.setContainerType(ContainerType.ServiceMix);
serverSettings.setHome(runtime.getLocation().toString());
serverSettings.setJdkHome(runtime.getJavaHome());
serverSettings.setServerName(getServer().getName());
serverSettings.setServerLoc(serverLoc);
serverSettings.setHost(getServer().getHost());
serverSettings.setPort(getServer().getAttribute(ServiceMixServer.SERVER_PORT, 0));
serverSettings.setCommandPort(getServer().getAttribute(ServiceMixServer.SSH_PORT, 0));
serverSettings.setUser(getServer().getAttribute(ServiceMixServer.USER, ""));
serverSettings.setPassword(getServer().getAttribute(ServiceMixServer.PASSWORD, ""));
serverSettings.setJavaOptions(getServer().getAttribute(JAVA_OPTIONS, DEFAULT_JAVA_OPTS));
serverSettings.setDebug(getServer().getAttribute(DEBUG_MODE, DEFAULT_DEBUG_MODE));
serverSettings.setDebugPort(getServer().getAttribute(DEBUG_PORT, DEFAULT_DEBUG_PORT));
serverSettings.setSuspend(getServer().getAttribute(DEBUG_SUSPEND, DEFAULT_DEBUG_SUSPEND));
}
if (serverSettings == null) {
// compatibility for old servers
WorkflowProject workflowProject = getProject();
if (workflowProject == null)
return null;
serverSettings = workflowProject.getServerSettings();
serverSettings.setServerName(getServer().getName());
}
return serverSettings;
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class SearchPage method determineScope.
protected void determineScope() {
if (searchPattern == null)
searchPattern = "";
if (scopedProjects == null) {
// determine scoped projects from selection
scopedProjects = new ArrayList<WorkflowProject>();
if (searchPageContainer.getSelectedScope() == ISearchPageContainer.SELECTED_PROJECTS_SCOPE) {
for (String projectName : searchPageContainer.getSelectedProjectNames()) {
IProject project = MdwPlugin.getWorkspaceRoot().getProject(projectName);
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
if (workflowProject != null && !scopedProjects.contains(workflowProject))
scopedProjects.add(workflowProject);
}
} else if (searchPageContainer.getSelectedScope() == ISearchPageContainer.SELECTION_SCOPE) {
if (searchPageContainer.getSelection() instanceof WorkflowProject)
scopedProjects.add((WorkflowProject) searchPageContainer.getSelection());
if (searchPageContainer.getSelection() instanceof WorkflowPackage)
selectedPackage = (WorkflowPackage) searchPageContainer.getSelection();
} else if (searchPageContainer.getSelectedScope() == ISearchPageContainer.WORKING_SET_SCOPE) {
for (IWorkingSet workingSet : searchPageContainer.getSelectedWorkingSets()) {
for (IAdaptable element : workingSet.getElements()) {
if (element instanceof IProject || element instanceof IJavaProject) {
IProject project = element instanceof IJavaProject ? ((IJavaProject) element).getProject() : (IProject) element;
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(project);
if (workflowProject != null && !scopedProjects.contains(workflowProject))
scopedProjects.add(workflowProject);
}
}
}
} else {
scopedProjects.addAll(WorkflowProjectManager.getInstance().getWorkflowProjects());
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method delete.
public void delete(WorkflowElement[] elements) {
boolean globalConf = false;
boolean includeInstances = false;
if (elements.length > 1) {
boolean globalConfAllowed = true;
List<WorkflowElement> lockedElems = new ArrayList<WorkflowElement>();
for (WorkflowElement element : elements) {
if ((element instanceof WorkflowProject) || (element instanceof WorkflowPackage)) {
globalConfAllowed = false;
break;
} else if (element instanceof WorkflowProcess) {
WorkflowProcess pv = (WorkflowProcess) element;
if (pv.getLockingUser() != null && !pv.isLockedToUser())
lockedElems.add(pv);
} else if (element instanceof WorkflowAsset) {
WorkflowAsset dd = (WorkflowAsset) element;
if (dd.getLockingUser() != null && !dd.isLockedToUser())
lockedElems.add(dd);
}
}
if (!lockedElems.isEmpty()) {
PluginMessages.uiList(getShell(), "Error: The following elements are locked to other users.\nPlease exclude them from your selection or have them unlocked before proceeding.", "Delete Elements", lockedElems);
return;
}
if (globalConfAllowed) {
WorkflowElementDeleteDialog multipleDeleteDialog = new WorkflowElementDeleteDialog(getShell(), Arrays.asList(elements));
int res = multipleDeleteDialog.open();
if (res == Dialog.CANCEL)
return;
else if (res == Dialog.OK) {
globalConf = true;
includeInstances = multipleDeleteDialog.isIncludeInstances();
}
}
}
for (WorkflowElement element : elements) {
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote()) {
MessageDialog.openWarning(getShell(), "Delete Project", "Please delete the underlying Java Project in Package Explorer view.");
return;
}
boolean confirmed = MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete workflow project: " + workflowProject.getName() + "?");
if (confirmed) {
WorkflowProjectManager.getInstance().deleteProject(workflowProject);
workflowProject.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
} else {
return;
}
} else if (element instanceof AutomatedTestCase && ((AutomatedTestCase) element).isLegacy()) {
// still allow deletion of legacy test stuff
final AutomatedTestCase testCase = (AutomatedTestCase) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Test Case", "Delete " + testCase.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
File tcDir = testCase.getTestCaseDirectory();
try {
PluginUtil.deleteDirectory(tcDir);
testCase.getTestSuite().getTestCases().remove(testCase);
try {
IFolder folder = testCase.getProject().getOldTestCasesFolder();
if (folder.exists())
folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Delete Legacy Test Case", testCase.getProject());
}
testCase.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
testCase.removeElementChangeListener(testCase.getProject());
} catch (IOException ex) {
PluginMessages.uiError(ex, "Delete Test Case", testCase.getProject());
}
}
});
}
} else if (element instanceof LegacyExpectedResults) {
final LegacyExpectedResults expectedResult = (LegacyExpectedResults) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Expected Result", "Delete " + expectedResult.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
File file = expectedResult.getExpectedResultFile();
if (file.delete()) {
expectedResult.getTestCase().getLegacyExpectedResults().remove(expectedResult);
try {
IFolder folder = expectedResult.getProject().getOldTestCasesFolder();
if (folder.exists())
folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Delete Legacy Expected Result", expectedResult.getProject());
}
expectedResult.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
expectedResult.removeElementChangeListener(expectedResult.getProject());
} else {
PluginMessages.uiError("Cannot delete expected result " + expectedResult.getName(), "Delete Result", expectedResult.getProject());
}
}
});
}
} else if (element instanceof com.centurylink.mdw.plugin.designer.model.File) {
final com.centurylink.mdw.plugin.designer.model.File file = (com.centurylink.mdw.plugin.designer.model.File) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete File", "Delete " + file.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
IFile workspaceFile = file.getWorkspaceFile();
try {
workspaceFile.delete(true, null);
WorkflowElement parent = file.getParent();
if (parent instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) parent;
testCase.getFiles().remove(file);
}
file.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
file.removeElementChangeListener(file.getProject());
refresh(file.getProject().getLegacyTestSuite());
} catch (Exception ex) {
PluginMessages.uiError("Cannot delete file " + file.getName(), "Delete File", file.getProject());
}
}
});
}
} else {
WorkflowProject workflowProject = element.getProject();
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (element instanceof WorkflowPackage) {
WorkflowPackage packageToDelete = (WorkflowPackage) element;
PackageDeleteDialog packageDeleteDialog = new PackageDeleteDialog(getShell(), packageToDelete);
if (packageDeleteDialog.open() == Dialog.OK) {
designerProxy.deletePackage(packageToDelete);
} else {
return;
}
} else if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
if (!processVersion.getProject().isFilePersist() && processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
MessageDialog.openError(getShell(), "Cannot Delete", "Process '" + processVersion.getLabel() + "' is locked to user '" + processVersion.getLockingUser() + "'.\nPlease have it unlocked before deleting.");
return;
}
ProcessDeleteDialog deleteDialog = new ProcessDeleteDialog(getShell(), processVersion);
if (globalConf || deleteDialog.open() == Dialog.OK) {
closeOpenEditor(processVersion, false);
includeInstances = includeInstances || deleteDialog.isIncludeInstances();
designerProxy.deleteProcess(processVersion, includeInstances);
} else {
return;
}
} else if (element instanceof TaskTemplate) {
TaskTemplate taskTemplate = (TaskTemplate) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + taskTemplate.getTitle() + " '" + taskTemplate.getLabel() + "'?")) {
designerProxy.deleteTaskTemplate(taskTemplate);
} else {
return;
}
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
if (!asset.getProject().isFilePersist() && asset.getLockingUser() != null && !asset.isLockedToUser()) {
MessageDialog.openError(getShell(), "Cannot Delete", asset.getTitle() + " '" + asset.getLabel() + "' is locked to user '" + asset.getLockingUser() + "'.\nPlease have it unlocked before deleting");
return;
}
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + asset.getTitle() + " '" + asset.getLabel() + "'?")) {
if (asset.getFileEditor() != null) {
IEditorInput editorInput = asset.getFileEditor().getEditorInput();
if (editorInput != null)
closeOpenEditor(editorInput, false);
}
WorkflowAssetFactory.deRegisterAsset(asset);
designerProxy.deleteWorkflowAsset(asset);
} else {
return;
}
} else if (element instanceof ActivityImpl) {
ActivityImpl activityImpl = (ActivityImpl) element;
ActivityImplDeleteDialog deleteDialog = new ActivityImplDeleteDialog(getShell(), activityImpl);
if (globalConf || deleteDialog.open() == Dialog.OK) {
designerProxy.deleteActivityImpl(activityImpl, deleteDialog.isIncludeActivities());
} else {
return;
}
} else if (element instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete Event Handler: " + externalEvent.getLabel() + "?")) {
designerProxy.deleteExternalEvent(externalEvent);
} else {
return;
}
} else if (element instanceof TaskTemplate) {
MessageDialog.openWarning(getShell(), "TODO", "Delete task template not yet implemented");
}
if (RunnerStatus.SUCCESS.equals(designerProxy.getRunnerStatus())) {
// notify listeners
element.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
element.removeElementChangeListener(workflowProject);
}
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method syncOpenEditors.
public void syncOpenEditors(final WorkflowProject project) {
final WorkflowProjectManager projectMgr = WorkflowProjectManager.getInstance();
final List<ProcessEditor> processEditors = getOpenProcessEditors(project);
final List<IEditorPart> assetEditors = getOpenAssetEditors(project);
if (!processEditors.isEmpty() || !assetEditors.isEmpty()) {
// sync open editors
IRunnableWithProgress loader = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("Loading " + project.getLabel(), 100);
monitor.worked(25);
// sync process editors
for (ProcessEditor ed : processEditors) {
WorkflowProcess pv = ed.getProcess();
pv.setProject(projectMgr.getWorkflowProject(pv.getProject().getName()));
if (pv.getPackage() != null && !pv.getPackage().isDefaultPackage()) {
WorkflowPackage pkg = pv.getProject().getPackage(pv.getPackage().getName());
WorkflowProcess oldPv = pkg.getProcess(pv.getName());
if (oldPv != null)
pkg.removeProcess(oldPv);
pkg.addProcess(pv);
pv.setPackage(pkg);
}
}
monitor.worked(50);
// sync asset editors
Map<IFile, AssetWorkbenchListener> assetListeners = WorkflowAssetFactory.getWorkbenchListeners();
for (IEditorPart assetEd : assetEditors) {
FileEditorInput fileInput = (FileEditorInput) assetEd.getEditorInput();
AssetWorkbenchListener wbListener = assetListeners.get(fileInput.getFile());
if (wbListener != null) {
WorkflowAsset asset = wbListener.getAsset();
WorkflowProject wfProj = projectMgr.getWorkflowProject(asset.getProject().getName());
WorkflowAsset oldAsset = wfProj.getAsset(asset.getName(), asset.getLanguage(), asset.getVersion());
if (asset.getPackage() != null && !asset.getPackage().isDefaultPackage()) {
WorkflowPackage pkg = wfProj.getPackage(asset.getPackage().getName());
if (pkg != null) {
pkg.removeAsset(oldAsset);
pkg.addAsset(asset);
asset.setPackage(pkg);
} else {
asset.setPackage(wfProj.getDefaultPackage());
}
} else {
asset.setPackage(wfProj.getDefaultPackage());
}
asset.addElementChangeListener(wfProj);
if (oldAsset != null)
WorkflowAssetFactory.deRegisterAsset(oldAsset);
WorkflowAssetFactory.registerAsset(asset);
assetEd.addPropertyListener(asset.new AssetEditorPropertyListener(assetEd));
WorkflowAssetFactory.registerWorkbenchListener(fileInput.getFile(), wbListener);
}
}
monitor.worked(25);
monitor.done();
}
};
ProgressMonitorDialog progMonDlg = new MdwProgressMonitorDialog(Display.getCurrent().getActiveShell());
try {
progMonDlg.run(true, false, loader);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Sync Open Editors", project);
}
}
}
Aggregations