List of usage examples for org.eclipse.jface.dialogs MessageDialog openConfirm
public static boolean openConfirm(Shell parent, String title, String message)
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
public void update(WorkflowElement element) { if (element instanceof WorkflowPackage) { WorkflowPackage packageVersion = (WorkflowPackage) element; if (MessageDialog.openConfirm(getShell(), "Update Package", "Bring latest versions of Processes and Workflow Assets into package '" + packageVersion.getLabel() + "'?")) { packageVersion.getProject().getDesignerProxy().updateProcessesAndAssetsToLatest(packageVersion); packageVersion.fireElementChangeEvent(packageVersion, ChangeType.SETTINGS_CHANGE, null); }//from w w w . j ava 2 s . c o m } }
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
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); }//from w ww . j av a2 s . co m } 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); } } } }
From source file:com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler.java
License:Apache License
public void remoteImportVcs(final WorkflowProject workflowProject) { VcsRepository repo = workflowProject.getMdwVcsRepository(); String msg = "Pull latest assets into " + workflowProject.getName() + " from Git branch: " + repo.getBranch() + "?"; boolean proceed = MessageDialog.openConfirm(getShell(), "Import from VCS", msg); if (proceed) { ProgressMonitorDialog pmDialog = new MdwProgressMonitorDialog(getShell()); try {/* ww w. ja va 2 s .c o m*/ pmDialog.run(true, false, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask("Importing remote project from Git...", IProgressMonitor.UNKNOWN); monitor.worked(20); try { workflowProject.getDesignerProxy().remoteImportVcs(); } catch (Exception ex) { PluginMessages.log(ex); throw new InvocationTargetException(ex); } } }); } catch (Exception ex) { PluginMessages.uiError(getShell(), ex, "Import From VCS", workflowProject); } } }
From source file:com.centurylink.mdw.plugin.designer.DesignerProxy.java
License:Apache License
public void renameProcess(final WorkflowProcess processVersion, final String newName) { if (dataAccess.processNameExists(processVersion.getPackage().getPackageVO(), newName)) { Shell shell = MdwPlugin.getActiveWorkbenchWindow().getShell(); MessageDialog.openError(shell, "Can't Rename", "Process name already exists: '" + newName + "'"); return;/*from w ww. j a v a 2 s . c o m*/ } String version = "v" + processVersion.getVersionString(); String progressMsg = "Renaming to '" + newName + "' " + version; String errorMsg = "Rename Process"; designerRunner = new DesignerRunner(progressMsg, errorMsg, project) { public void perform() throws ValidationException, DataAccessException, RemoteException, XmlException { try { if (dataAccess.getDesignerDataAccess().hasProcessInstances(processVersion.getId())) throw new DataAccessException("Process " + processVersion.getLabel() + " has instances and cannot be renamed.\nPlease save as a new version."); } catch (DataAccessOfflineException ex) { final StringBuffer confirm = new StringBuffer(); MdwPlugin.getDisplay().syncExec(new Runnable() { public void run() { String msg = "Cannot connect to server to check for instances. Are you sure you want to rename?"; confirm.append(MessageDialog.openConfirm(MdwPlugin.getShell(), "Rename Process", msg)); } }); if (!Boolean.valueOf(confirm.toString())) return; } dataAccess.removeProcess(processVersion.getProcessVO()); if (processVersion.isInRuleSet() && !project.isFilePersist()) { ProcessVO procVO = dataAccess.getDesignerDataAccess() .getProcessDefinition(processVersion.getName(), processVersion.getVersion()); procVO = dataAccess.getDesignerDataAccess().getProcess(procVO.getProcessId(), procVO); procVO.setName(newName); procVO.setVersion(1); new ProcessWorker().convert_to_designer(procVO); dataAccess.getDesignerDataAccess().updateProcess(procVO, 0, false); processVersion.setProcessVO(procVO); } else { processVersion.setName(newName); processVersion.getProcessVO().setVersion(1); processVersion.getProcessVO().setId( dataAccess.getDesignerDataAccess().renameProcess(processVersion.getId(), newName, 1)); } dataAccess.getDesignerDataModel().addProcess(processVersion.getProcessVO()); } }; designerRunner.run(); }
From source file:com.centurylink.mdw.plugin.designer.DesignerProxy.java
License:Apache License
public void deleteProcess(final WorkflowProcess processVersion, final boolean includeInstances) { String version = "v" + processVersion.getVersionString(); String progressMsg = "Deleting '" + processVersion.getName() + "' " + version; String errorMsg = "Delete Process"; designerRunner = new DesignerRunner(progressMsg, errorMsg, project) { public void perform() throws DataAccessException, RemoteException, ValidationException { if (!includeInstances) { try { if (dataAccess.getDesignerDataAccess().hasProcessInstances(processVersion.getId())) throw new DataAccessException("Process " + processVersion.getLabel() + " has instances which also must be deleted."); } catch (DataAccessOfflineException ex) { final StringBuffer confirm = new StringBuffer(); MdwPlugin.getDisplay().syncExec(new Runnable() { public void run() { String msg = "Cannot connect to server to check for instances. Are you sure you want to delete?"; confirm.append( MessageDialog.openConfirm(MdwPlugin.getShell(), "Delete Process", msg)); }//from www .j ava 2 s . c om }); if (!Boolean.valueOf(confirm.toString())) return; } } dataAccess.getDesignerDataAccess().removeProcess(processVersion.getProcessVO(), includeInstances); dataAccess.removeProcess(processVersion.getProcessVO()); if (processVersion.isInDefaultPackage()) { processVersion.getProject().getDefaultPackage().removeProcess(processVersion); } else { processVersion.getPackage().removeProcess(processVersion); if (!project.isFilePersist()) savePackage(processVersion.getPackage()); } } }; designerRunner.run(); }
From source file:com.centurylink.mdw.plugin.designer.dialogs.SwtDialogProvider.java
License:Apache License
public boolean confirm(Component parent, final String message, final boolean yes_no) { display.syncExec(new Runnable() { public void run() { dispensation = MessageDialog.openConfirm(getShell(), "MDW Confirm", message); }/*from ww w . j a va 2 s.c o m*/ }); return dispensation; }
From source file:com.centurylink.mdw.plugin.designer.editors.ProcessEditor.java
License:Apache License
public void commitChanges() { if (MessageDialog.openConfirm(getSite().getShell(), "Commit Changes", "Commit recorded changes?")) processCanvasWrapper.commitChanges(); }
From source file:com.centurylink.mdw.plugin.designer.Importer.java
License:Apache License
public WorkflowPackage importPackage(final WorkflowProject project, final String content, final ProgressMonitor progressMonitor) throws DataAccessException, RemoteException, ActionCancelledException, JSONException, XmlException { CodeTimer timer = new CodeTimer("importPackage()"); int preexistingVersion = -1; importedPackageVO = null;/*from w w w . j a va2s. c om*/ progressMonitor.start("Importing Package into: '" + project.getLabel() + "'"); progressMonitor.progress(5); progressMonitor.subTask("Parsing XML"); boolean isJson = content.trim().startsWith("{"); importedPackageVO = parsePackageContent(content); progressMonitor.subTask("Importing " + importedPackageVO.getLabel()); progressMonitor.progress(10); final WorkflowPackage existing = project.getPackage(importedPackageVO.getPackageName()); if (existing != null) { if (existing.getVersion() == importedPackageVO.getVersion()) { final String msg = project.getName() + " already contains Package '" + importedPackageVO.getPackageName() + "' v" + importedPackageVO.getVersionString(); if (shell != null) { shell.getDisplay().syncExec(new Runnable() { public void run() { if (!MessageDialog.openConfirm(shell, "Import Package", msg + ".\nImport this package?")) importedPackageVO = null; } }); } else { PluginMessages.log(msg); } if (importedPackageVO != null) { // overwrite existing importedPackageVO.setPackageId(existing.getId()); if (!isLocal()) importedPackageVO.setVersion(0); preexistingVersion = existing.getVersion(); } } else if (existing.getVersion() > importedPackageVO.getVersion()) { final String msg = project.getName() + " already contains Package '" + importedPackageVO.getPackageName() + "' v" + existing.getVersionString() + ", whose version is greater than that of the imported package. Cannot continue."; if (shell != null) { shell.getDisplay().syncExec(new Runnable() { public void run() { MessageDialog.openError(shell, "Import Package", msg); importedPackageVO = null; } }); } else { PluginMessages.log(msg); } } if (importedPackageVO == null) return null; } if (shell != null && progressMonitor.isCanceled()) throw new ActionCancelledException(); progressMonitor.progress(10); progressMonitor.subTask("Checking elements"); final List<WorkflowElement> conflicts = new ArrayList<WorkflowElement>(); final List<WorkflowElement> conflictsWithDifferences = new ArrayList<WorkflowElement>(); final List<ProcessVO> existingProcessVOs = new ArrayList<ProcessVO>(); List<ProcessVO> processVOsToBeImported = new ArrayList<ProcessVO>(); ProcessExporter exporter = null; for (ProcessVO importedProcessVO : importedPackageVO.getProcesses()) { WorkflowProcess existingProcess = project.getProcess(importedProcessVO.getProcessName(), importedProcessVO.getVersionString()); if (existingProcess != null) { conflicts.add(existingProcess); if (project.getDataAccess().getSupportedSchemaVersion() >= DataAccess.schemaVersion52 && MdwPlugin.getSettings().isCompareConflictingAssetsDuringImport()) { progressMonitor.subTask("Comparing processes (can be disabled in prefs)"); // content comparison if (exporter == null) exporter = DataAccess.getProcessExporter(project.getDataAccess().getSchemaVersion(), project.isOldNamespaces() ? DesignerCompatibility.getInstance() : null); String existingProcessXml = project.getDataAccess().loadRuleSet(existingProcess.getId()) .getRuleSet(); String importedProcessXml = isJson ? importedProcessVO.getJson().toString(2) : exporter.exportProcess(importedProcessVO, project.getDataAccess().getSchemaVersion(), null); if (project.getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion55) { // may need to replace old namespace prefix in existing // to avoid false positives in 5.2 String oldNamespaceDecl = "xmlns:xs=\"http://mdw.qwest.com/XMLSchema\""; int oldNsIdx = existingProcessXml.indexOf(oldNamespaceDecl); if (oldNsIdx > 0) { String newNamespaceDecl = "xmlns:bpm=\"http://mdw.qwest.com/XMLSchema\""; existingProcessXml = existingProcessXml.substring(0, oldNsIdx) + newNamespaceDecl + importedProcessXml.substring(oldNsIdx + oldNamespaceDecl.length() + 2); existingProcessXml = existingProcessXml.replaceAll("<xs:", "<bpm:"); existingProcessXml = existingProcessXml.replaceAll("</xs:", "</bpm:"); } } // avoid false positives existingProcessXml = existingProcessXml .replaceAll("\\s*<bpm:Attribute Name=\"REFERENCED_ACTIVITIES\".*/>", ""); existingProcessXml = existingProcessXml .replaceAll("\\s*<bpm:Attribute Name=\"REFERENCED_PROCESSES\".*/>", ""); existingProcessXml = existingProcessXml.replaceFirst(" packageVersion=\"0.0\"", ""); existingProcessXml = existingProcessXml.replaceAll("\\s*<bpm:Attribute Name=\"processid\".*/>", ""); if (!existingProcessXml.equals(importedProcessXml)) conflictsWithDifferences.add(existingProcess); } if (isLocal()) processVOsToBeImported.add(importedProcessVO); else existingProcessVOs.add(existingProcess.getProcessVO()); } else { if (project.getDataAccess().getSupportedSchemaVersion() >= DataAccess.schemaVersion52) importedProcessVO.setInRuleSet(true); // not optional processVOsToBeImported.add(importedProcessVO); } for (ProcessVO subProcVO : importedProcessVO.getSubProcesses()) { WorkflowProcess existingSubProc = project.getProcess(subProcVO.getProcessName(), subProcVO.getVersionString()); if (existingSubProc != null) { conflicts.add(existingSubProc); existingProcessVOs.add(existingSubProc.getProcessVO()); if (!isLocal()) existingProcessVOs.add(existingSubProc.getProcessVO()); } } } if (shell != null && progressMonitor.isCanceled()) throw new ActionCancelledException(); progressMonitor.progress(10); final List<RuleSetVO> existingRuleSets = new ArrayList<RuleSetVO>(); List<RuleSetVO> ruleSetsToBeImported = new ArrayList<RuleSetVO>(); final List<RuleSetVO> emptyRuleSets = new ArrayList<RuleSetVO>(); if (importedPackageVO.getRuleSets() != null) { for (RuleSetVO importedRuleSet : importedPackageVO.getRuleSets()) { WorkflowAsset existingAsset = null; if (dataAccess.getSupportedSchemaVersion() >= DataAccess.schemaVersion55) existingAsset = project.getAsset(importedPackageVO.getName(), importedRuleSet.getName(), importedRuleSet.getLanguage(), importedRuleSet.getVersion()); else existingAsset = project.getAsset(importedRuleSet.getName(), importedRuleSet.getLanguage(), importedRuleSet.getVersion()); if (existingAsset != null) { conflicts.add(existingAsset); if (project.getDataAccess().getSupportedSchemaVersion() >= DataAccess.schemaVersion52 && MdwPlugin.getSettings().isCompareConflictingAssetsDuringImport() && !existingAsset.isBinary()) { progressMonitor.subTask("Comparing assets (can be disabled in prefs)"); // content comparison existingAsset = project.getDesignerProxy().loadWorkflowAsset(existingAsset); String existingAssetStr = existingAsset.getRuleSetVO().getRuleSet().trim(); String importedAssetStr = importedRuleSet.getRuleSet().trim(); if (!existingAsset.isBinary()) { existingAssetStr = existingAssetStr.replaceAll("\r", ""); importedAssetStr = importedAssetStr.replaceAll("\r", ""); } if (!existingAssetStr.equals(importedAssetStr)) conflictsWithDifferences.add(existingAsset); } if (isLocal()) ruleSetsToBeImported.add(importedRuleSet); else existingRuleSets.add(existingAsset.getRuleSetVO()); } else if (importedRuleSet.getRuleSet().trim().isEmpty()) { emptyRuleSets.add(importedRuleSet); } else { ruleSetsToBeImported.add(importedRuleSet); } } } if (MdwPlugin.getSettings().isCompareConflictingAssetsDuringImport() && existing != null && importedPackageVO.getTaskTemplates() != null && existing.getTaskTemplates() != null) { for (TaskVO importedTask : importedPackageVO.getTaskTemplates()) { for (TaskTemplate taskTemplate : existing.getTaskTemplates()) { if (taskTemplate.getName().equals(importedTask.getName()) && taskTemplate.getVersion() == importedTask.getVersion()) { conflicts.add(taskTemplate); String existingTemplStr = taskTemplate.getTaskVO().toTemplate().xmlText(); String importedTemplStr = importedTask.toTemplate().xmlText(); if (!existingTemplStr.equals(importedTemplStr)) conflictsWithDifferences.add(taskTemplate); } } } } if (progressMonitor.isCanceled()) throw new ActionCancelledException(); progressMonitor.progress(10); if (conflicts.size() > 0) { Collections.sort(conflicts, new Comparator<WorkflowElement>() { public int compare(WorkflowElement we1, WorkflowElement we2) { return we1.getLabel().compareToIgnoreCase(we2.getLabel()); } }); final String msg; if (isLocal()) msg = "The following versions exist locally in '" + importedPackageVO.getPackageName() + "'.\nThese files in project '" + project.getName() + "' will be overwritten.\n"; else msg = "The following versions from package '" + importedPackageVO.getPackageName() + "' will not be imported.\nThe same versions already exist in the '" + project.getName() + "' project.\n"; if (shell != null) { shell.getDisplay().syncExec(new Runnable() { public void run() { String msg2 = msg; if (project.checkRequiredVersion(5, 2) && MdwPlugin.getSettings().isCompareConflictingAssetsDuringImport()) msg2 += "(Asterisk * indicates content differs.)\n"; int res = PluginMessages.uiList(shell, msg2, "Package Import", conflicts, conflictsWithDifferences); if (res == Dialog.CANCEL) importedPackageVO = null; } }); } else { String msg2 = msg + " ("; if (project.checkRequiredVersion(5, 2)) msg2 += " -- * indicates content differs"; msg2 += ").\n"; for (WorkflowElement we : conflicts) { String flag = conflictsWithDifferences.contains(we) ? " *" : ""; msg2 += " " + we.getLabel() + flag + "\n"; } PluginMessages.log(msg2); } if (importedPackageVO == null) return null; } if (emptyRuleSets.size() > 0) { final String msg = "The following assets from package '" + importedPackageVO.getPackageName() + "' will not be imported because they're empty.\n"; if (shell != null) { shell.getDisplay().syncExec(new Runnable() { public void run() { int res = PluginMessages.uiList(shell, msg, "Package Import", emptyRuleSets); if (res == Dialog.CANCEL) importedPackageVO = null; } }); } else { String msg2 = msg; for (RuleSetVO rs : emptyRuleSets) msg2 += " " + rs.getLabel() + "\n"; PluginMessages.log(msg2); } if (importedPackageVO == null) return null; } importedPackageVO.setProcesses(processVOsToBeImported); importedPackageVO.setRuleSets(ruleSetsToBeImported); // designer fix for backward compatibility ProcessWorker worker = new ProcessWorker(); if (importedPackageVO.getProcesses() != null) { NodeMetaInfo syncedNodeMetaInfo = syncNodeMetaInfo(dataAccess.getDesignerDataModel().getNodeMetaInfo(), importedPackageVO); for (ProcessVO p : importedPackageVO.getProcesses()) { worker.convert_to_designer(p); worker.convert_from_designer(p, syncedNodeMetaInfo); } } if (shell != null && progressMonitor.isCanceled()) throw new ActionCancelledException(); progressMonitor.progress(10); progressMonitor.subTask("Saving package"); ProcessPersister.PersistType persistType = ProcessPersister.PersistType.IMPORT; if (isJson) persistType = ProcessPersister.PersistType.IMPORT_JSON; Long packageId = dataAccess.getDesignerDataAccess().savePackage(importedPackageVO, persistType); if (preexistingVersion > 0) importedPackageVO.setVersion(preexistingVersion); // reset version // for overwrite progressMonitor.progress(10); progressMonitor.subTask("Reloading processes"); if (importedPackageVO.getProcesses() != null) { for (ProcessVO importedProcessVO : importedPackageVO.getProcesses()) { ProcessVO reloaded = dataAccess.getDesignerDataAccess() .getProcessDefinition(importedProcessVO.getProcessName(), importedProcessVO.getVersion()); importedProcessVO.setProcessId(reloaded.getProcessId()); } if (project.getDataAccess().getSupportedSchemaVersion() < DataAccess.schemaVersion52) { for (ProcessVO importedProcessVO : importedPackageVO.getProcesses()) updateSubProcessIdAttributes(importedProcessVO); } } if (existingProcessVOs.size() > 0) { // add back existing processes importedPackageVO.getProcesses().addAll(existingProcessVOs); dataAccess.getDesignerDataAccess().savePackage(importedPackageVO); } progressMonitor.progress(10); progressMonitor.subTask("Reloading workflow assets"); if (importedPackageVO.getRuleSets() != null) { for (RuleSetVO importedRuleSet : importedPackageVO.getRuleSets()) { RuleSetVO reloaded; if (dataAccess.getSupportedSchemaVersion() >= DataAccess.schemaVersion55) { reloaded = dataAccess.getDesignerDataAccess().getRuleSet(importedPackageVO.getId(), importedRuleSet.getName()); if (reloaded == null) // TODO: verify whether the above is // even needed reloaded = dataAccess.getDesignerDataAccess().getRuleSet(importedRuleSet.getId()); } else { reloaded = dataAccess.getDesignerDataAccess().getRuleSet(importedRuleSet.getName(), importedRuleSet.getLanguage(), importedRuleSet.getVersion()); } importedRuleSet.setId(reloaded.getId()); } } if (existingRuleSets.size() > 0) { importedPackageVO.getRuleSets().addAll(existingRuleSets); progressMonitor.subTask("Saving Package"); dataAccess.getDesignerDataAccess().savePackage(importedPackageVO); } if (preexistingVersion > 0 && existingProcessVOs.size() == 0 && existingRuleSets.size() == 0) { progressMonitor.subTask("Saving Package"); dataAccess.getDesignerDataAccess().savePackage(importedPackageVO); // force // associate // processes } progressMonitor.progress(10); progressMonitor.subTask("Loading package"); PackageVO newPackageVO = dataAccess.getDesignerDataAccess().loadPackage(packageId, false); WorkflowPackage importedPackage = new WorkflowPackage(project, newPackageVO); List<WorkflowProcess> processVersions = new ArrayList<WorkflowProcess>(); for (ProcessVO processVO : newPackageVO.getProcesses()) { WorkflowProcess processVersion = new WorkflowProcess(project, processVO); processVersion.setPackage(importedPackage); processVersions.add(processVersion); } Collections.sort(processVersions); importedPackage.setProcesses(processVersions); List<ExternalEvent> externalEvents = new ArrayList<ExternalEvent>(); for (ExternalEventVO externalEventVO : newPackageVO.getExternalEvents()) { ExternalEvent externalEvent = new ExternalEvent(externalEventVO, importedPackage); externalEvents.add(externalEvent); } Collections.sort(externalEvents); importedPackage.setExternalEvents(externalEvents); List<TaskTemplate> taskTemplates = new ArrayList<TaskTemplate>(); if (newPackageVO.getTaskTemplates() != null) { for (TaskVO taskVO : newPackageVO.getTaskTemplates()) { TaskTemplate taskTemplate = new TaskTemplate(taskVO, importedPackage); taskTemplates.add(taskTemplate); } Collections.sort(taskTemplates); importedPackage.setTaskTemplates(taskTemplates); } List<ActivityImpl> activityImpls = new ArrayList<ActivityImpl>(); if (newPackageVO.getImplementors() != null) { for (ActivityImplementorVO activityImplVO : newPackageVO.getImplementors()) { if (importedPackageVO.getImplementors() != null) { // attrs not included in reload -- take from original XML ActivityImplementorVO xmlImplVO = null; for (ActivityImplementorVO implVO : importedPackageVO.getImplementors()) { if (activityImplVO.getImplementorClassName().equals(implVO.getImplementorClassName())) xmlImplVO = implVO; } if (xmlImplVO != null) { activityImplVO.setBaseClassName(xmlImplVO.getBaseClassName()); activityImplVO.setIconName(xmlImplVO.getIconName()); activityImplVO.setShowInToolbox(xmlImplVO.isShowInToolbox()); activityImplVO.setLabel(xmlImplVO.getLabel()); activityImplVO.setAttributeDescription(xmlImplVO.getAttributeDescription()); } } ActivityImpl activityImpl = new ActivityImpl(activityImplVO, importedPackage); activityImpls.add(activityImpl); } Collections.sort(activityImpls); importedPackage.setActivityImpls(activityImpls); } if (newPackageVO.getRuleSets() != null) { List<WorkflowAsset> assets = new ArrayList<WorkflowAsset>(); for (RuleSetVO ruleSet : newPackageVO.getRuleSets()) { WorkflowAsset asset = WorkflowAssetFactory.createAsset(ruleSet, importedPackage); assets.add(asset); } Collections.sort(assets); importedPackage.setAssets(assets); } if (existing != null) { // deregister old assets if (existing.getAssets() != null) { for (WorkflowAsset oldAsset : existing.getAssets()) WorkflowAssetFactory.deRegisterAsset(oldAsset); } project.removePackage(existing); } // register new assets if (importedPackage.getAssets() != null) { for (WorkflowAsset newAsset : importedPackage.getAssets()) WorkflowAssetFactory.registerAsset(newAsset); } project.addPackage(importedPackage); progressMonitor.progress(10); dataAccess.auditLog(Action.Import, importedPackage); dataAccess.getPackages(true); dataAccess.getProcesses(true); dataAccess.getRuleSets(true); dataAccess.getActivityImplementors(true); project.findActivityImplementors(importedPackage); progressMonitor.progress(5); timer.stopAndLog(); return importedPackage; }
From source file:com.centurylink.mdw.plugin.designer.properties.DocumentationSection.java
License:Apache License
public void setSelection(WorkflowElement selection) { element = selection;//from w w w. j a v a 2s. c o m String attrVal = element.getAttribute(ATTR); if (attrVal != null && !attrVal.isEmpty()) { if (attrVal.length() >= 8) { byte[] first4 = RuleSetVO.decode(attrVal.substring(0, 8)); if (first4[0] == 68 && first4[1] == 35 && first4[2] == 17 && first4[3] == 0) language = DocumentationEditorValueProvider.MS_WORD; } } if (artifactEditor != null) { artifactEditor.dispose(); artifactEditor = null; } if (referenceIdEditor != null) { referenceIdEditor.dispose(); referenceIdEditor = null; } if (sequenceIdEditor != null) { sequenceIdEditor.dispose(); sequenceIdEditor = null; } if (webEditor != null) { webEditor.dispose(); webEditor = null; } // artifact editor ArtifactEditorValueProvider valueProvider = new DocumentationEditorValueProvider(selection) { @Override public void languageChanged(String newLanguage) { super.languageChanged(newLanguage); boolean proceed = true; String attrVal = element.getAttribute(ATTR); if (attrVal != null && !attrVal.isEmpty() && !language.equals(newLanguage)) proceed = MessageDialog.openConfirm(getShell(), "Confirm Format", "Proceed with switch to " + newLanguage + " format? (" + language + " formatted content will be lost.)"); if (proceed) { language = newLanguage; element.setAttribute(getAttributeName(), " "); setSelection(element); } else { artifactEditor.setLanguage(language); } } @Override public String getLanguage() { return language; } }; artifactEditor = new ArtifactEditor(selection, valueProvider, "Format"); artifactEditor.render(composite); artifactEditor.setElement(selection); artifactEditor.setEditable(!selection.isReadOnly()); artifactEditor.setLanguage(language); if (element instanceof Activity || element instanceof EmbeddedSubProcess) { // reference ID text field sequenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT); sequenceIdEditor.setLabel("Sequence Number"); sequenceIdEditor.setWidth(100); sequenceIdEditor.setVerticalIndent(5); sequenceIdEditor.render(composite); sequenceIdEditor.setElement(selection); sequenceIdEditor .setValue(element instanceof EmbeddedSubProcess ? ((EmbeddedSubProcess) element).getSequenceId() : ((Activity) element).getSequenceId()); sequenceIdEditor.setEditable(false); // reference ID text field referenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT); referenceIdEditor.setLabel("Reference ID"); referenceIdEditor.setWidth(100); referenceIdEditor.setComment("Optional (select Reference ID element order when exporting)"); referenceIdEditor.addValueChangeListener(new ValueChangeListener() { public void propertyValueChanged(Object newValue) { element.setAttribute(WorkAttributeConstant.REFERENCE_ID, (String) newValue); } }); referenceIdEditor.render(composite); referenceIdEditor.setElement(selection); referenceIdEditor.setEditable(!selection.isReadOnly()); referenceIdEditor.setValue(element.getAttribute(WorkAttributeConstant.REFERENCE_ID)); } if (DocumentationEditorValueProvider.MARKDOWN.equals(language) && element.getProject().checkRequiredVersion(6, 0)) { webEditor = new PropertyEditor(element, PropertyEditor.TYPE_WEB); webEditor.render(composite); webEditor.setElement(element); MarkdownRenderer renderer = new MarkdownRenderer(attrVal); webEditor.setValue(renderer.renderHtml()); webEditor.addValueChangeListener(new ValueChangeListener() { public void propertyValueChanged(Object newValue) { MarkdownRenderer renderer = new MarkdownRenderer(newValue == null ? null : newValue.toString()); String html = renderer.renderHtml(); webEditor.setValue(html); } }); } composite.layout(true); }
From source file:com.centurylink.mdw.plugin.designer.views.ProcessInstanceListView.java
License:Apache License
private Menu createContextMenu(Shell shell) { Menu menu = new Menu(shell, SWT.POP_UP); final StructuredSelection selection = (StructuredSelection) getTableViewer().getSelection(); if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) { final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement(); // open instance MenuItem openItem = new MenuItem(menu, SWT.PUSH); openItem.setText("Open"); ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif"); openItem.setImage(openImageDesc.createImage()); openItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handleOpen(processInstanceInfo); }/*from w w w . ja va2 s.c o m*/ }); // owning document if (OwnerType.DOCUMENT.equals(processInstanceInfo.getOwner()) || OwnerType.TESTER.equals(processInstanceInfo.getOwner())) { MenuItem docItem = new MenuItem(menu, SWT.PUSH); docItem.setText("View Owning Document"); ImageDescriptor docImageDesc = MdwPlugin.getImageDescriptor("icons/doc.gif"); docItem.setImage(docImageDesc.createImage()); docItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { IStorage storage = new DocumentStorage(workflowProject, new DocumentReference(processInstanceInfo.getOwnerId(), null)); final IStorageEditorInput input = new StorageEditorInput(storage); final IWorkbenchPage page = MdwPlugin.getActivePage(); if (page != null) { BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { public void run() { try { page.openEditor(input, "org.eclipse.ui.DefaultTextEditor"); } catch (PartInitException ex) { PluginMessages.uiError(ex, "View Document", workflowProject); } } }); } } }); } // instance hierarchy MenuItem hierarchyItem = new MenuItem(menu, SWT.PUSH); hierarchyItem.setText("Instance Hierarchy"); ImageDescriptor hierarchyImageDesc = MdwPlugin.getImageDescriptor("icons/hierarchy.gif"); hierarchyItem.setImage(hierarchyImageDesc.createImage()); hierarchyItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { WorkflowProcess pv = new WorkflowProcess(processVersion); pv.setProcessVO(processVersion.getProcessVO()); pv.setProcessInstance(processInstanceInfo); new WorkflowElementActionHandler().showHierarchy(pv); } }); } // delete if (!selection.isEmpty() && !processVersion.getProject().isProduction() && processVersion.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION)) { MenuItem deleteItem = new MenuItem(menu, SWT.PUSH); deleteItem.setText("Delete..."); ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif"); deleteItem.setImage(deleteImageDesc.createImage()); deleteItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) { ProcessInstanceVO pii = (ProcessInstanceVO) selection.getFirstElement(); if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete process instance ID: " + pii.getId() + " for workflow project '" + processVersion.getProject().getName() + "'?")) { List<ProcessInstanceVO> instances = new ArrayList<ProcessInstanceVO>(); instances.add((ProcessInstanceVO) selection.getFirstElement()); handleDelete(instances); } } else { if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete selected process instances for workflow project '" + processVersion.getProject().getName() + "'?")) { List<ProcessInstanceVO> instances = new ArrayList<ProcessInstanceVO>(); for (Object instance : selection.toArray()) { if (instance instanceof ProcessInstanceVO) instances.add((ProcessInstanceVO) instance); } handleDelete(instances); } } } }); } return menu; }