Search in sources :

Example 1 with WorkflowDefinitionsFolder

use of com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder in project liferay-ide by liferay.

the class AbstractWorkflowDefinitionAction method selectionChanged.

@SuppressWarnings("rawtypes")
public void selectionChanged(IStructuredSelection sel) {
    if (sel.isEmpty()) {
        setEnabled(false);
        return;
    }
    boolean enabled = false;
    Iterator iterator = sel.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof WorkflowDefinitionEntry) {
            WorkflowDefinitionEntry node = (WorkflowDefinitionEntry) obj;
            if (accept(node)) {
                enabled = true;
            }
        } else if (obj instanceof WorkflowDefinitionsFolder) {
            WorkflowDefinitionsFolder node = (WorkflowDefinitionsFolder) obj;
            if (accept(node)) {
                enabled = true;
            }
        } else {
            setEnabled(false);
            return;
        }
    }
    setEnabled(enabled);
}
Also used : WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) Iterator(java.util.Iterator) WorkflowDefinitionsFolder(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)

Example 2 with WorkflowDefinitionsFolder

use of com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder in project liferay-ide by liferay.

the class PublishWorkflowDefinitionAction method perform.

@Override
public void perform(Object node) {
    if (getSelectionProvider() instanceof CommonViewer && node instanceof WorkflowDefinitionEntry) {
        WorkflowDefinitionEntry definitionNode = (WorkflowDefinitionEntry) node;
        Job publishJob = new Job("Publishing workflow draft definition") {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
                IKaleoConnection kaleoConnection = KaleoCore.getKaleoConnection(definitionNode.getParent().getParent());
                try {
                    kaleoConnection.publishKaleoDraftDefinition(definitionNode.getName(), definitionNode.getTitleMap(), definitionNode.getContent(), definitionNode.getCompanyId() + "", definitionNode.getUserId() + "", definitionNode.getGroupId() + "");
                } catch (KaleoAPIException kapie) {
                    kapie.printStackTrace();
                }
                WorkflowDefinitionsFolder definitionsFolder = (WorkflowDefinitionsFolder) definitionNode.getParent();
                CommonViewer viewer = (CommonViewer) getSelectionProvider();
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        definitionsFolder.clearCache();
                        viewer.refresh(true);
                    }
                });
                return Status.OK_STATUS;
            }
        };
        publishJob.schedule();
    }
}
Also used : WorkflowDefinitionEntry(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IKaleoConnection(com.liferay.ide.kaleo.core.IKaleoConnection) CommonViewer(org.eclipse.ui.navigator.CommonViewer) KaleoAPIException(com.liferay.ide.kaleo.core.KaleoAPIException) Job(org.eclipse.core.runtime.jobs.Job) WorkflowDefinitionsFolder(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)

Example 3 with WorkflowDefinitionsFolder

use of com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder in project liferay-ide by liferay.

the class RefreshWorkflowDefinitionsAction method perform.

@Override
public void perform(Object node) {
    if (getSelectionProvider() instanceof CommonViewer) {
        if (node instanceof WorkflowDefinitionsFolder) {
            ((WorkflowDefinitionsFolder) node).clearCache();
        }
        CommonViewer viewer = (CommonViewer) getSelectionProvider();
        Display.getDefault().asyncExec(new Runnable() {

            public void run() {
                viewer.refresh(true);
            }
        });
    }
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) WorkflowDefinitionsFolder(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)

Example 4 with WorkflowDefinitionsFolder

use of com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder in project liferay-ide by liferay.

the class UploadNewWorkflowDefinitionAction method perform.

@Override
public void perform(Object node) {
    if (getSelectionProvider() instanceof CommonViewer && node instanceof WorkflowDefinitionsFolder) {
        IFile workspaceFile = promptForWorkspaceFile();
        if ((workspaceFile == null) || !FileUtil.exists(workspaceFile)) {
            return;
        }
        String errorMsgs = KaleoUtil.checkWorkflowDefinitionForErrors(workspaceFile);
        if (!CoreUtil.empty(errorMsgs)) {
            MessageDialog.openError(Display.getDefault().getActiveShell(), "Upload Kaleo Workflow", "Unable to upload kaleo workflow:\n\n" + errorMsgs);
            return;
        }
        WorkflowDefinitionsFolder definitionsFolder = (WorkflowDefinitionsFolder) node;
        IKaleoConnection kaleoConnection = KaleoCore.getKaleoConnection(definitionsFolder.getParent());
        Runnable runnable = new Runnable() {

            public void run() {
                CommonViewer viewer = (CommonViewer) getSelectionProvider();
                Runnable runnable = new Runnable() {

                    public void run() {
                        definitionsFolder.clearCache();
                        viewer.refresh(true);
                    }
                };
                Display.getDefault().asyncExec(runnable);
            }
        };
        Job upload = new UploadWorkflowFileJob(kaleoConnection, workspaceFile, runnable);
        upload.schedule();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IKaleoConnection(com.liferay.ide.kaleo.core.IKaleoConnection) CommonViewer(org.eclipse.ui.navigator.CommonViewer) UploadWorkflowFileJob(com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob) Job(org.eclipse.core.runtime.jobs.Job) UploadWorkflowFileJob(com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob) WorkflowDefinitionsFolder(com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)

Aggregations

WorkflowDefinitionsFolder (com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)4 CommonViewer (org.eclipse.ui.navigator.CommonViewer)3 IKaleoConnection (com.liferay.ide.kaleo.core.IKaleoConnection)2 WorkflowDefinitionEntry (com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionEntry)2 Job (org.eclipse.core.runtime.jobs.Job)2 KaleoAPIException (com.liferay.ide.kaleo.core.KaleoAPIException)1 UploadWorkflowFileJob (com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob)1 Iterator (java.util.Iterator)1 IFile (org.eclipse.core.resources.IFile)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1