Search in sources :

Example 56 with WorkflowProject

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;
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CopyDialog(com.centurylink.mdw.plugin.designer.dialogs.CopyDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) SWTException(org.eclipse.swt.SWTException)

Example 57 with WorkflowProject

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);
    }
}
Also used : IModule(org.eclipse.wst.server.core.IModule) IStatus(org.eclipse.core.runtime.IStatus) ProjectUpdater(com.centurylink.mdw.plugin.project.assembly.ProjectUpdater) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) JarFile(java.util.jar.JarFile) OsgiBuildFile(com.centurylink.mdw.plugin.project.model.OsgiBuildFile) MavenBuildFile(com.centurylink.mdw.plugin.project.model.MavenBuildFile) GradleBuildFile(com.centurylink.mdw.plugin.project.model.GradleBuildFile) File(java.io.File) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException)

Example 58 with WorkflowProject

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());
                            }
                        }
                    }
                });
            }
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) PartInitException(org.eclipse.ui.PartInitException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessEditor(com.centurylink.mdw.plugin.designer.editors.ProcessEditor) IResourceDelta(org.eclipse.core.resources.IResourceDelta) Display(org.eclipse.swt.widgets.Display)

Example 59 with WorkflowProject

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;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) Attributes(org.xml.sax.Attributes) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) SAXException(org.xml.sax.SAXException) DefaultHandler(org.xml.sax.helpers.DefaultHandler) SAXException(org.xml.sax.SAXException) ByteArrayInputStream(java.io.ByteArrayInputStream) SAXParser(javax.xml.parsers.SAXParser) SAXParserFactory(javax.xml.parsers.SAXParserFactory)

Example 60 with WorkflowProject

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());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IServer(org.eclipse.wst.server.core.IServer) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Aggregations

WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)128 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)31 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)22 ArrayList (java.util.ArrayList)22 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 CoreException (org.eclipse.core.runtime.CoreException)19 Action (org.eclipse.jface.action.Action)19 IAction (org.eclipse.jface.action.IAction)18 IProject (org.eclipse.core.resources.IProject)17 IFile (org.eclipse.core.resources.IFile)16 PartInitException (org.eclipse.ui.PartInitException)16 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)12 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 IOException (java.io.IOException)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)9