use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createImportActionGroup.
private ActionGroup createImportActionGroup() {
importMenu = new MenuManager("Import", MdwPlugin.getImageDescriptor("icons/import.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import");
return new ActionGroup() {
@Override
public void fillContextMenu(IMenuManager menu) {
importMenu.removeAll();
IStructuredSelection selection = getSelection();
WorkflowElement element = (WorkflowElement) selection.getFirstElement();
if (!importMenuApplies(selection))
return;
if (importProjectApplies())
importMenu.add(importProjectAction);
if (importPackageApplies(selection))
importMenu.add(importPackageAction);
if (importVcsApplies(selection))
importMenu.add(importVcsAction);
if (importProcessApplies(selection)) {
if (element instanceof WorkflowProcess) {
importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.process.version");
importProcessAction.setText("New Process Version...");
} else {
importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.process");
importProcessAction.setText(PROCESS_DOT);
}
importMenu.add(importProcessAction);
}
if (importWorkflowAssetApplies(selection)) {
if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
// menu item text and icon are dynamic
importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.asset.version");
importWorkflowAssetAction.setText("New " + asset.getTitle() + " Version...");
importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
} else {
importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.asset");
importWorkflowAssetAction.setText("Asset...");
importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICON_DOC_GIF));
}
importMenu.add(importWorkflowAssetAction);
}
if (importAttributesApplies(selection)) {
List<IAction> importAttrsActions = getImportAttributeActions(selection);
if (!importAttrsActions.isEmpty()) {
MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import.attributes");
attributesMenu.removeAll();
for (IAction action : importAttrsActions) attributesMenu.add(action);
importMenu.add(attributesMenu);
}
}
if (importTaskTemplateApplies(selection))
importMenu.add(importTaskTemplateAction);
importMenu.add(new Separator(OTHER));
IWorkbenchAction otherAction = ActionFactory.IMPORT.create(getViewSite().getWorkbenchWindow());
otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.other");
otherAction.setText(OTHER_DOT);
importMenu.add(otherAction);
}
};
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset 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;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDragSource method dragSetData.
@Override
public void dragSetData(DragSourceEvent event) {
if (TextTransfer.getInstance().isSupportedType(event.dataType)) {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
List<?> elements = selection.toList();
StringBuilder data = new StringBuilder();
for (int i = 0; i < elements.size(); i++) {
Object element = elements.get(i);
if (element instanceof WorkflowProcess || element instanceof ExternalEvent || element instanceof ActivityImpl || element instanceof WorkflowAsset) {
data.append(element.toString());
if (i < elements.size() - 1)
data.append("#");
}
}
event.data = data.toString();
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ExportAssetWizard method performImportExport.
void performImportExport(ProgressMonitor progressMonitor) throws IOException, XmlException, DataAccessException, ActionCancelledException {
WorkflowAsset asset = getAsset();
if (!asset.isLoaded())
asset.load();
progressMonitor.progress(20);
byte[] bytes = asset.isBinary() ? asset.getDecodedContent() : asset.getContent().getBytes();
writeFile(getPage().getFilePath(), bytes);
progressMonitor.progress(5);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowAsset in project mdw-designer by CenturyLinkCloud.
the class ImportAssetWizard method postRunUpdates.
@Override
protected void postRunUpdates() {
WorkflowAsset asset = getPage().getAsset();
asset.addElementChangeListener(asset.getProject());
asset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, asset);
if (!asset.isLockedToUser())
asset.fireElementChangeEvent(ChangeType.PROPERTIES_CHANGE, null);
WorkflowAssetFactory.registerAsset(asset);
}
Aggregations