Search in sources :

Example 1 with FormDataDocument

use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.

the class FormPanel method setData.

/**
 * this is invoked when coming from script list page or package tree
 */
public void setData(String formname, String data) throws Exception {
    try {
        formdoc = loadForm(formname);
        datadoc = new FormDataDocument();
        if (data != null && data.length() > 0)
            datadoc.load(data);
        canvas = new FormDesignCanvas(frame, this, dao);
        canvas.setFormXml(formdoc, datadoc);
        JScrollPane canvasScrollpane = new JScrollPane(canvas);
        MbengNode rootnode = canvas.getFormXml().getRootNode();
        String av = rootnode.getAttribute(FormConstants.FORMATTR_VW);
        int w = (av == null) ? 800 : Integer.parseInt(av);
        av = rootnode.getAttribute(FormConstants.FORMATTR_VH);
        int h = (av == null) ? 600 : Integer.parseInt(av);
        this.add(canvasScrollpane, BorderLayout.CENTER);
        Container content_pane;
        if (frame instanceof JDialog) {
            content_pane = ((JDialog) frame).getContentPane();
        } else {
            content_pane = ((JFrame) frame).getContentPane();
        }
        content_pane.add(this);
        frame.setSize(w + 10, h + 30);
    } catch (Exception e) {
        e.printStackTrace();
        show_error("failed to set data for canvas: " + e.getMessage());
        throw e;
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) Container(java.awt.Container) MbengNode(com.qwest.mbeng.MbengNode) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) JDialog(javax.swing.JDialog) MbengException(com.qwest.mbeng.MbengException)

Example 2 with FormDataDocument

use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.

the class WorkflowElementActionHandler method launchSwing.

public void launchSwing(final WorkflowProject project, final String title, final String formName, String dataInit) {
    try {
        if (title.equals("Java VisualVM")) {
            String javaVersion = System.getProperty("java.version");
            String badVersionMsg = "Cannot launch Java VisualVM.\nRequires Java version >= 1.6.0_07.\nRunning version: " + javaVersion + ".";
            if (!javaVersion.startsWith("1.6") && !javaVersion.startsWith("1.7") && !javaVersion.startsWith("1.8")) {
                MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
                return;
            } else if (javaVersion.startsWith("1.6")) {
                // check minor version
                String minorVer = javaVersion.substring(javaVersion.indexOf('_') + 1);
                if (Integer.parseInt(minorVer) < 7) {
                    MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
                    return;
                }
            }
            String jdkBin = PluginUtil.getJdkBin();
            File exe = new File(jdkBin + File.separator + "jvisualvm.exe");
            if (!exe.exists()) {
                MessageDialog.openError(getShell(), "Launch Java VisualVM", "Executable not found: '" + exe + "'");
                return;
            }
            String[] cmdArr = new String[] { exe.getAbsolutePath() };
            if (project.isRemote()) {
                cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openjmx", project.getServerSettings().getHost() + ":" + project.getJmxPort() });
            } else {
                cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openid", String.valueOf(project.getVisualVmId()) });
            }
            new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
        } else if (title.equals("JConsole")) {
            String jdkBin = PluginUtil.getJdkBin();
            File exe = new File(jdkBin + File.separator + "jconsole.exe");
            if (!exe.exists()) {
                MessageDialog.openError(getShell(), "Launch JConsole", "Executable not found: '" + exe + "'");
                return;
            }
            String[] cmdArr = new String[] { exe.getAbsolutePath() };
            if (project.isRemote())
                cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { project.getServerSettings().getHost() + ":" + project.getJmxPort() });
            else {
                String serverProcId = project.getServerSettings().getServerProcessId();
                if (serverProcId != null)
                    cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { serverProcId });
            }
            new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
        } else {
            String request = null;
            if (dataInit != null) {
                FormDataDocument datadoc = new FormDataDocument();
                datadoc.setAttribute(FormDataDocument.ATTR_ACTION, dataInit);
                request = datadoc.format();
            }
            final String response = dataInit == null ? null : project.getDesignerProxy().getDesignerDataAccess().engineCall(request);
            EventQueue.invokeLater(new Runnable() {

                public void run() {
                    try {
                        DesignerProxy designerProxy = project.getDesignerProxy();
                        JFrame propmgr_frame = new JFrame(title);
                        FormPanel mainform = new FormPanel(propmgr_frame, designerProxy.getDesignerDataAccess(), designerProxy.getPluginDataAccess().getPrivileges());
                        mainform.setData(formName, response);
                        propmgr_frame.setVisible(true);
                    } catch (final Exception ex) {
                        if (getShell() == null) {
                            PluginMessages.log(ex);
                        } else {
                            getShell().getDisplay().asyncExec(new Runnable() {

                                public void run() {
                                    if (ex.getCause() instanceof ConnectException)
                                        MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
                                    else
                                        PluginMessages.uiError(ex, "Launch " + title, project);
                                }
                            });
                        }
                    }
                }
            });
        }
    } catch (Exception ex) {
        if (ex.getCause() instanceof ConnectException)
            MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
        else
            PluginMessages.uiError(ex, "Launch " + title, project);
    }
}
Also used : ProcessConsoleRunner(com.centurylink.mdw.plugin.ProcessConsoleRunner) FormPanel(com.centurylink.mdw.designer.pages.FormPanel) JFrame(javax.swing.JFrame) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) IFile(org.eclipse.core.resources.IFile) File(java.io.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) PartInitException(org.eclipse.ui.PartInitException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ConnectException(java.net.ConnectException) IOException(java.io.IOException) ConnectException(java.net.ConnectException)

Example 3 with FormDataDocument

use of com.centurylink.mdw.model.FormDataDocument in project mdw-designer by CenturyLinkCloud.

the class DesignerDataAccess method getTaskInstances.

private List<TaskInstanceVO> getTaskInstances(ProcessVO process, ProcessInstanceVO processInstance, Long activityId, List<TaskInstanceVO> allTaskInstances) throws DataAccessException {
    List<TaskInstanceVO> taskInstances = new ArrayList<>();
    for (TaskInstanceVO taskInstance : allTaskInstances) {
        String secondaryOwner = taskInstance.getSecondaryOwnerType();
        if (OwnerType.DOCUMENT.equals(secondaryOwner) || "EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner)) {
            String formDataString = null;
            if (OwnerType.DOCUMENT.equals(secondaryOwner))
                formDataString = rtinfo.getDocument(taskInstance.getSecondaryOwnerId()).getContent();
            else if ("EXTERNAL_EVENT_INSTANCE".equals(secondaryOwner))
                formDataString = rtinfo.getExternalEventDetails(taskInstance.getSecondaryOwnerId());
            FormDataDocument formDataDoc = new FormDataDocument();
            try {
                formDataDoc.load(formDataString);
                for (ActivityInstanceVO activityInstance : processInstance.getActivityInstances(activityId)) {
                    if (activityInstance.getId().equals(formDataDoc.getActivityInstanceId()))
                        taskInstances.add(taskInstance);
                }
            } catch (MbengException ex) {
                throw new DataAccessException(-1, ex.getMessage(), ex);
            }
        } else {
            // task instance secondary owner is work transition instance
            Long workTransInstId = taskInstance.getSecondaryOwnerId();
            for (WorkTransitionInstanceVO transitionInstance : processInstance.getTransitions()) {
                if (transitionInstance.getTransitionInstanceID().equals(workTransInstId)) {
                    Long transitionId = transitionInstance.getTransitionID();
                    WorkTransitionVO workTrans = process.getWorkTransition(transitionId);
                    if (workTrans == null && process.getSubProcesses() != null) {
                        for (ProcessVO subproc : process.getSubProcesses()) {
                            workTrans = subproc.getWorkTransition(transitionId);
                            if (workTrans != null)
                                break;
                        }
                    }
                    if (workTrans != null && workTrans.getToWorkId().equals(activityId))
                        taskInstances.add(taskInstance);
                }
            }
        }
    }
    return taskInstances;
}
Also used : MbengException(com.qwest.mbeng.MbengException) WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) WorkTransitionVO(com.centurylink.mdw.model.value.work.WorkTransitionVO) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) TaskInstanceVO(com.centurylink.mdw.model.value.task.TaskInstanceVO) ArrayList(java.util.ArrayList) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) FormDataDocument(com.centurylink.mdw.model.FormDataDocument) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException)

Aggregations

FormDataDocument (com.centurylink.mdw.model.FormDataDocument)3 MbengException (com.qwest.mbeng.MbengException)2 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 FormPanel (com.centurylink.mdw.designer.pages.FormPanel)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 TaskInstanceVO (com.centurylink.mdw.model.value.task.TaskInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)1 WorkTransitionVO (com.centurylink.mdw.model.value.work.WorkTransitionVO)1 ProcessConsoleRunner (com.centurylink.mdw.plugin.ProcessConsoleRunner)1 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 JarFile (com.centurylink.mdw.plugin.designer.model.JarFile)1 MbengNode (com.qwest.mbeng.MbengNode)1 Container (java.awt.Container)1 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ConnectException (java.net.ConnectException)1 ArrayList (java.util.ArrayList)1 JDialog (javax.swing.JDialog)1