use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerDropTarget method handleDropWorkflowAsset.
private boolean handleDropWorkflowAsset(String assetInfo, WorkflowPackage targetPackage, int operation) {
if (!targetPackage.getProject().checkRequiredVersion(5, 0)) {
String msg = "Packaging of Definition Documents (such as scripts and pages) is only supported for MDWFramework 5.0 and later.";
MessageDialog.openError(getViewer().getControl().getShell(), "Package Def Doc", msg);
return false;
}
Long assetId = getWorkflowAssetId(assetInfo);
WorkflowProject workflowProject = targetPackage.getProject();
WorkflowPackage sourcePackage = workflowProject.getPackage(getPackageName(assetInfo));
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (operation == DND.DROP_COPY) {
WorkflowAsset existing = workflowProject.getAsset(assetId);
CopyDialog copyDialog = new CopyDialog(getViewer().getControl().getShell(), existing, existing.getName(), String.valueOf(existing.getVersion()), targetPackage);
if (copyDialog.open() == Dialog.OK) {
String newName = copyDialog.getNewName();
if (!existing.isLoaded())
existing.load();
WorkflowAsset newCopy;
try {
// try and use reflection to make it the correct type
Constructor<? extends WorkflowAsset> ctor = existing.getClass().getConstructor(existing.getClass());
newCopy = ctor.newInstance(existing);
} catch (Exception ex) {
PluginMessages.log(ex);
newCopy = new WorkflowAsset(existing);
}
newCopy.setName(newName);
newCopy.setVersion(1);
newCopy.setPackage(targetPackage);
try {
designerProxy.createNewWorkflowAsset(newCopy, true);
} catch (Exception ex) {
PluginMessages.uiError(ex, "Copy " + existing.getTitle(), existing.getProject());
}
newCopy.addElementChangeListener(workflowProject);
newCopy.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, newCopy);
WorkflowAssetFactory.registerAsset(newCopy);
((TreeViewer) getViewer()).refresh(targetPackage, true);
return true;
}
return false;
} else if (operation == DND.DROP_MOVE) {
// don't allow multiple versions of the same asset in a package
if (!targetPackage.isDefaultPackage()) {
WorkflowAsset asset = workflowProject.getAsset(assetId);
if (targetPackage.getAsset(asset.getName()) != null) {
MessageDialog.openError(MdwPlugin.getShell(), "Asset Exists", "Asset '" + asset.getName() + "' already exists in package '" + targetPackage.getName() + "'.");
return false;
}
}
if (targetPackage.isDefaultPackage()) {
designerProxy.removeWorkflowAssetFromPackage(assetId, sourcePackage);
} else {
assetId = designerProxy.moveWorkflowAssetToPackage(assetId, targetPackage);
}
((TreeViewer) getViewer()).refresh(targetPackage.getProject(), true);
WorkflowAssetFactory.registerAsset(workflowProject.getAsset(assetId));
return true;
} else {
return false;
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class TomcatServerBehavior method publishModules.
/**
* Only overridden to set the monitor ticks.
*/
@SuppressWarnings("rawtypes")
@Override
protected void publishModules(int kind, List modules, List deltaKind2, MultiStatus multi, IProgressMonitor monitor) {
if (modules == null)
return;
int size = modules.size();
if (size == 0)
return;
// publish modules
for (int i = 0; i < size; i++) {
if (monitor.isCanceled())
return;
// should skip this publish
IModule[] module = (IModule[]) modules.get(i);
IModule m = module[module.length - 1];
if (shouldIgnorePublishRequest(m))
continue;
int kind2 = kind;
if (getServer().getModulePublishState(module) == IServer.PUBLISH_STATE_UNKNOWN)
kind2 = IServer.PUBLISH_FULL;
// for workflow client apps, download if mdw.war not found
if (getWebProject() == null && module[0].getProject() != null) {
WorkflowProject clientWf = WorkflowProjectManager.getInstance().getWorkflowProject(module[0].getProject());
if (clientWf != null) {
String deployLoc = getServer().getAttribute(ITomcatServer.PROPERTY_INSTANCE_DIR, clientWf.getDeployFolder().getLocation().toPortableString());
File mdwWar = new File(deployLoc + "/webapps/mdw.war");
if (kind == IServer.PUBLISH_CLEAN && mdwWar.exists() && !mdwWar.delete())
showError("Publish Error", "Unable to delete " + mdwWar, clientWf);
if (!mdwWar.exists()) {
ProjectUpdater updater = new ProjectUpdater(getProject(), MdwPlugin.getSettings());
try {
updater.updateFrameworkJars(new SubProgressMonitor(monitor, 1));
} catch (Exception ex) {
showError(ex.getMessage(), "Update Framework Libraries", clientWf);
}
}
}
}
IStatus status;
if (getWebProject() != null && kind == IServer.PUBLISH_CLEAN || ((Integer) deltaKind2.get(i)).intValue() == ServerBehaviourDelegate.REMOVED)
status = publishModule(kind2, module, ((Integer) deltaKind2.get(i)).intValue(), ProgressUtil.getSubMonitorFor(monitor, size * 3000));
else
status = publishModule(kind2, module, ((Integer) deltaKind2.get(i)).intValue(), ProgressUtil.getSubMonitorFor(monitor, 3000));
if (status != null && !status.isOK())
multi.add(status);
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class ArtifactResourceListener method resourceChanged.
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
IResourceDelta rootDelta = event.getDelta();
IResourceDelta artifactDelta = rootDelta.findMember(tempFile.getFullPath());
if (artifactDelta != null && artifactDelta.getKind() == IResourceDelta.CHANGED && (artifactDelta.getFlags() & IResourceDelta.CONTENT) != 0) {
// the file has been changed
final Display display = Display.getCurrent();
if (display != null) {
display.syncExec(new Runnable() {
public void run() {
byte[] newValue = PluginUtil.readFile(tempFile);
String attrVal = valueProvider.isBinary() ? encodeBase64(newValue) : new String(newValue);
if (getElement() instanceof Activity || getElement() instanceof WorkflowProcess) {
WorkflowProcess processVersion = null;
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
activity.setAttribute(valueProvider.getAttributeName(), attrVal);
processVersion = activity.getProcess();
} else {
processVersion = (WorkflowProcess) getElement();
processVersion.setAttribute(valueProvider.getAttributeName(), attrVal);
}
processVersion.fireDirtyStateChanged(true);
ProcessEditor processEditor = findProcessEditor(processVersion);
if (processEditor == null) {
try {
processEditor = openProcessEditor(processVersion);
IEditorPart tempFileEditor = findTempFileEditor(tempFile);
if (tempFileEditor != null)
processEditor.addActiveScriptEditor(tempFileEditor);
} catch (PartInitException ex) {
PluginMessages.uiError(display.getActiveShell(), ex, "Open Process", processVersion.getProject());
return;
}
}
processVersion = processEditor.getProcess();
if (processVersion.isReadOnly()) {
WorkflowProject workflowProject = getElement().getProject();
PluginMessages.uiMessage("Process for '" + getElement().getName() + "' in workflow project '" + workflowProject.getName() + "' is Read Only.", "Not Updated", workflowProject, PluginMessages.INFO_MESSAGE);
return;
}
if (getElement() instanceof Activity) {
Activity activity = (Activity) getElement();
// previously-opened process version
for (Node node : processEditor.getProcessCanvasWrapper().getFlowchartPage().getProcess().nodes) {
if (activity.getLogicalId() != null && activity.getLogicalId().equals(node.getAttribute("LOGICAL_ID"))) {
node.setAttribute(valueProvider.getAttributeName(), attrVal);
ActivityImpl actImpl = processVersion.getProject().getActivityImpl(node.nodet.getImplementorClassName());
element = new Activity(node, processVersion, actImpl);
}
}
activity.fireDirtyStateChanged(true);
}
processEditor.dirtyStateChanged(true);
valueProvider.afterTempFileSaved();
// process editor is open
String message = valueProvider.getArtifactTypeDescription() + " temporary file has been saved locally; however, you must still save the process for the changes to be persisted.";
String toggleMessage = "Don't show me this message again.";
IPreferenceStore prefsStore = MdwPlugin.getDefault().getPreferenceStore();
String prefsKey = "Mdw" + valueProvider.getArtifactTypeDescription() + "SuppressSaveNag";
if (!prefsStore.getBoolean(prefsKey)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(display.getActiveShell(), "Artifact Save", message, toggleMessage, false, null, null);
prefsStore.setValue(prefsKey, dialog.getToggleState());
}
}
}
});
}
}
}
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class TabDescriptorProvider method getPageletTabs.
protected List<PageletTab> getPageletTabs(WorkflowElement element) {
List<PageletTab> tabs = null;
WorkflowProject project = element.getProject();
if (project.checkRequiredVersion(5, 5)) {
String elementType = element.getTitle();
List<PageletTab> allProjTabs = project.getPageletTabs();
if (allProjTabs != null) {
for (PageletTab pageletTab : allProjTabs) {
InputStream inStream = new ByteArrayInputStream(pageletTab.getXml().getBytes());
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
try {
SAXParser parser = parserFactory.newSAXParser();
final List<String> types = new ArrayList<String>();
parser.parse(inStream, new DefaultHandler() {
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
if (qName.equalsIgnoreCase("PAGELET")) {
String appliesTo = attrs.getValue("APPLIES_TO");
if (appliesTo != null) {
for (String type : appliesTo.split(",")) types.add(type);
}
}
}
});
if (types.contains(elementType)) {
if (tabs == null)
tabs = new ArrayList<PageletTab>();
tabs.add(pageletTab);
}
} catch (Exception ex) {
// don't prevent processing
PluginMessages.log(ex);
// other pagelets
}
}
}
}
return tabs;
}
use of com.centurylink.mdw.plugin.project.model.WorkflowProject in project mdw-designer by CenturyLinkCloud.
the class FuseConfigurator method doDeploy.
@SuppressWarnings("restriction")
public void doDeploy(Shell shell) {
org.eclipse.wst.server.core.internal.Server matchingServer = null;
for (IServer server : ServerCore.getServers()) {
if (server.getRuntime() != null && server.getRuntime().getRuntimeType() != null && server.getRuntime().getRuntimeType().getId().startsWith("com.centurylink.server.runtime.jbossfuse")) {
org.eclipse.wst.server.core.internal.Server smixServer = (org.eclipse.wst.server.core.internal.Server) server;
if (smixServer.getAllModules().size() > 0) {
String wfProjectName = smixServer.getAllModules().get(0)[0].getName();
WorkflowProject serverWfp = WorkflowProjectManager.getInstance().getWorkflowProject(wfProjectName);
if (serverWfp != null && serverWfp.equals(getServerSettings().getProject()))
matchingServer = smixServer;
}
}
}
if (matchingServer != null) {
matchingServer.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
} else {
MessageDialog.openError(shell, "Server Deploy", "Could not find a Fues server with a module matching " + getServerSettings().getProject());
}
}
Aggregations