use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class MdwListInputDialog method initialize.
protected void initialize() {
setAddCancelButton(true);
setContentProvider(new ArrayContentProvider());
int width = 0;
// calculate dialog width
for (WorkflowElement element : elements) {
if (element.getLabel().length() > width)
width = element.getLabel().length();
}
if (width != 0)
setWidthInChars(width + 2);
setLabelProvider(new LabelProvider() {
public Image getImage(Object element) {
return ((WorkflowElement) element).getIconImage();
}
public String getText(Object element) {
return ((WorkflowElement) element).getLabel();
}
});
setInput(elements);
setTitle(title);
setMessage(message);
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class PluginMessages method uiList.
public static int uiList(Shell shell, String message, String title, List<?> items, final List<?> flaggedItems) {
ListDialog listDialog = new ListDialog(shell);
listDialog.setAddCancelButton(true);
listDialog.setContentProvider(new ArrayContentProvider());
int width = 0;
if (!items.isEmpty() && items.get(0) instanceof WorkflowElement) {
// calculate dialog width
for (Object item : items) {
WorkflowElement element = (WorkflowElement) item;
String label = (element instanceof WorkflowAsset && element.getProject().checkRequiredVersion(5, 5) && flaggedItems == null) ? element.getLabelWithPackage() : element.getLabel();
if (flaggedItems != null && flaggedItems.contains(item))
label += " *";
if (label.length() > width)
width = label.length();
}
listDialog.setLabelProvider(new LabelProvider() {
@Override
public Image getImage(Object element) {
return ((WorkflowElement) element).getIconImage();
}
@Override
public String getText(Object element) {
String flag = flaggedItems != null && flaggedItems.contains(element) ? " *" : "";
if (element instanceof WorkflowAsset && ((WorkflowAsset) element).getProject().checkRequiredVersion(5, 5) && flaggedItems == null)
return ((WorkflowAsset) element).getLabelWithPackage() + flag;
else
return ((WorkflowElement) element).getLabel() + flag;
}
});
} else {
for (Object item : items) {
if (item.toString().length() > width)
width = item.toString().length();
}
listDialog.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
return element.toString();
}
});
}
listDialog.setInput(items);
listDialog.setTitle(title);
listDialog.setMessage(message);
if (width != 0)
listDialog.setWidthInChars(width + 2);
return listDialog.open();
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class ImportPackagePage method removeGitVersionedPackages.
/**
* Not foolproof since it relies on asset XML naming convention. returns
* emptyFolders to be pruned.
*/
private List<Folder> removeGitVersionedPackages(Folder folder) {
List<Folder> emptyFolders = new ArrayList<>();
Map<File, Folder> toRemove = new HashMap<>();
for (WorkflowElement child : folder.getChildren()) {
if (child instanceof Folder) {
for (Folder emptyFolder : removeGitVersionedPackages((Folder) child)) {
if (!emptyFolders.contains(emptyFolder))
emptyFolders.add(emptyFolder);
}
} else if (child instanceof File) {
File file = (File) child;
String pkgName = file.getName();
if (file.getParent() instanceof Folder && pkgName.endsWith(".xml")) {
pkgName = pkgName.substring(0, pkgName.length() - 3);
int lastDash = pkgName.lastIndexOf('-');
if (lastDash > 0) {
pkgName = pkgName.substring(0, lastDash);
for (WorkflowPackage gitPackage : getProject().getTopLevelPackages()) {
if (pkgName.equals(gitPackage.getName())) {
PluginMessages.log("Import excludes VCS package: " + pkgName);
toRemove.put(file, (Folder) file.getParent());
}
}
}
}
}
}
if (!toRemove.isEmpty()) {
getImportPackageWizard().getImportPackageSelectPage().setInfo("Some packages are not displayed since they exist in version control.");
for (Map.Entry<File, Folder> file : toRemove.entrySet()) {
Folder removeFrom = file.getValue();
removeFrom.getChildren().remove(file.getKey());
if (removeFrom.getChildren().isEmpty())
emptyFolders.add(removeFrom);
}
}
return emptyFolders;
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class NewPackageWizard method init.
public void init(IWorkbench workbench, IStructuredSelection selection) {
setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
setNeedsProgressMonitor(true);
newPackagePage = new NewPackagePage();
newPackage = new WorkflowPackage();
if (selection != null && selection.getFirstElement() instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) selection.getFirstElement();
newPackage.setProject(workflowProject);
} else if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
WorkflowProject workflowProject = ((WorkflowElement) selection.getFirstElement()).getProject();
newPackage.setProject(workflowProject);
} else {
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().findWorkflowProject(selection);
if (workflowProject != null)
newPackage.setProject(workflowProject);
}
}
use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.
the class WorkflowAssetWizard method init.
public void init(IWorkbench workbench, IStructuredSelection selection, WorkflowAsset asset) {
setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
setNeedsProgressMonitor(true);
this.workflowAsset = asset;
if (selection != null && selection.getFirstElement() instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) selection.getFirstElement();
workflowAsset.setPackage(packageVersion);
} else if (selection != null && selection.getFirstElement() instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) selection.getFirstElement();
if (workflowProject.isShowDefaultPackage())
workflowAsset.setPackage(workflowProject.getDefaultPackage());
} else if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
WorkflowElement element = (WorkflowElement) selection.getFirstElement();
workflowAsset.setPackage(element.getPackage());
} else {
WorkflowProject workflowProject = WorkflowProjectManager.getInstance().findWorkflowProject(selection);
if (workflowProject != null)
workflowAsset.setProject(workflowProject);
}
workflowAssetPage = new WorkflowAssetPage(workflowAsset);
}
Aggregations