Search in sources :

Example 1 with UploadWorkflowFileJob

use of com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob in project liferay-ide by liferay.

the class WorkflowDropAdapterAssistant method handleDrop.

@Override
public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object aTarget) {
    if (aTarget instanceof WorkflowDefinitionsFolder) {
        WorkflowDefinitionsFolder folder = (WorkflowDefinitionsFolder) aTarget;
        IKaleoConnection kaleoConnection = KaleoCore.getKaleoConnection(folder.getParent());
        TransferData transferData = aDropTargetEvent.currentDataType;
        if (LocalSelectionTransfer.getTransfer().isSupportedType(transferData)) {
            Object dropData = LocalSelectionTransfer.getTransfer().getSelection();
            if (dropData instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) dropData;
                Object element = selection.getFirstElement();
                if (element instanceof IFile) {
                    IFile file = (IFile) element;
                    Runnable runnable = new Runnable() {

                        public void run() {
                            folder.clearCache();
                            Runnable runnable = new Runnable() {

                                public void run() {
                                    IViewPart serversView = UIUtil.showView("org.eclipse.wst.server.ui.ServersView");
                                    CommonViewer viewer = (CommonViewer) serversView.getAdapter(CommonViewer.class);
                                    viewer.refresh(true);
                                }
                            };
                            Display.getDefault().asyncExec(runnable);
                        }
                    };
                    new UploadWorkflowFileJob(kaleoConnection, file, runnable).schedule();
                }
            }
        }
    }
    return Status.OK_STATUS;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IKaleoConnection(com.liferay.ide.kaleo.core.IKaleoConnection) IFile(org.eclipse.core.resources.IFile) TransferData(org.eclipse.swt.dnd.TransferData) CommonViewer(org.eclipse.ui.navigator.CommonViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) UploadWorkflowFileJob(com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob)

Example 2 with UploadWorkflowFileJob

use of com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob 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

IKaleoConnection (com.liferay.ide.kaleo.core.IKaleoConnection)2 UploadWorkflowFileJob (com.liferay.ide.kaleo.ui.util.UploadWorkflowFileJob)2 IFile (org.eclipse.core.resources.IFile)2 CommonViewer (org.eclipse.ui.navigator.CommonViewer)2 WorkflowDefinitionsFolder (com.liferay.ide.kaleo.ui.navigator.WorkflowDefinitionsFolder)1 Job (org.eclipse.core.runtime.jobs.Job)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TransferData (org.eclipse.swt.dnd.TransferData)1 IViewPart (org.eclipse.ui.IViewPart)1