Search in sources :

Example 1 with WorkspaceModifyDelegatingOperation

use of org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation in project mechanoid by robotoworks.

the class NewMechanoidElementWizard method performFinish.

@Override
public boolean performFinish() {
    final IPath newFilePath = createNewResourceFilePath();
    onBeforeCreateElementResource();
    WorkspaceModifyDelegatingOperation op = new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException {
            try {
                mNewResource = createElementResource(monitor, newFilePath);
            } catch (Exception e) {
                throw new InvocationTargetException(e);
            } finally {
                monitor.done();
            }
        }
    });
    try {
        getContainer().run(true, true, op);
        selectAndReveal(mNewResource);
        openResource(mNewResource);
    } catch (InvocationTargetException e) {
        Throwable realException = e.getTargetException();
        MessageDialog.openError(getShell(), Messages.NewMechanoidElementWizard_Dialog_CreateResourceError_Title, realException.getMessage());
        return false;
    } catch (InterruptedException e) {
        return false;
    }
    return true;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IPath(org.eclipse.core.runtime.IPath) WorkspaceModifyDelegatingOperation(org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PartInitException(org.eclipse.ui.PartInitException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 PartInitException (org.eclipse.ui.PartInitException)1 WorkspaceModifyDelegatingOperation (org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation)1