Search in sources :

Example 26 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project bndtools by bndtools.

the class OpenMainConfigHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        IFile buildFile = Central.getWorkspaceBuildFile();
        if (buildFile == null)
            return null;
        FileEditorInput input = new FileEditorInput(buildFile);
        IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindowChecked(event).getActivePage();
        page.openEditor(input, "bndtools.bndWorkspaceConfigEditor", true);
    } catch (PartInitException e) {
        ErrorDialog.openError(HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(), "Error", "Unable to open editor", e.getStatus());
    } catch (Exception e) {
        logger.logError("Error retrieving bnd configuration file", e);
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 27 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project bndtools by bndtools.

the class ReleaseWorkspaceHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
        if (ReleaseHelper.getReleaseRepositories().length == 0) {
            Activator.message(Messages.noReleaseRepos);
            return null;
        }
        if (!PlatformUI.getWorkbench().saveAllEditors(true)) {
            return null;
        }
        WorkspaceAnalyserJob job = new WorkspaceAnalyserJob(null);
        job.setRule(ResourcesPlugin.getWorkspace().getRoot());
        job.schedule();
    } catch (Exception e) {
        throw new ExecutionException(e.getMessage(), e);
    }
    return null;
}
Also used : ExecutionException(org.eclipse.core.commands.ExecutionException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 28 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project che by eclipse.

the class UndoableOperation2ChangeAdapter method undo.

public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    if (monitor == null)
        monitor = new NullProgressMonitor();
    try {
        ExecuteResult result = executeChange(getQuery(info, RefactoringCoreMessages.Refactoring_undo_label), monitor);
        if (!result.changeExecuted) {
            fUndoChange = null;
            fRedoChange = null;
            clearActiveChange();
            return createStatus(result);
        }
        fRedoChange = result.reverseChange;
        fActiveChange = fRedoChange;
        fUndoChange = null;
        return Status.OK_STATUS;
    } catch (CoreException e) {
        throw new ExecutionException(e.getStatus().getMessage(), e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 29 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project che by eclipse.

the class UndoableOperation2ChangeAdapter method computeUndoableStatus.

public IStatus computeUndoableStatus(IProgressMonitor monitor) throws ExecutionException {
    if (fUndoChange == null)
        return new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoableOperation2ChangeAdapter_no_undo_available, null);
    try {
        if (monitor == null)
            monitor = new NullProgressMonitor();
        RefactoringStatus status = fUndoChange.isValid(monitor);
        if (status.hasFatalError()) {
            // The operation can no longer be undo.
            fUndoChange = null;
            clearActiveChange();
            return asStatus(status);
        } else {
            // own dialog again inside the runnable.
            return Status.OK_STATUS;
        }
    } catch (CoreException e) {
        throw new ExecutionException(e.getStatus().getMessage(), e);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 30 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project che by eclipse.

the class UndoableOperation2ChangeAdapter method redo.

public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    if (monitor == null)
        monitor = new NullProgressMonitor();
    try {
        ExecuteResult result = executeChange(getQuery(info, RefactoringCoreMessages.Refactoring_redo_label), monitor);
        if (!result.changeExecuted) {
            fUndoChange = null;
            fRedoChange = null;
            clearActiveChange();
            return createStatus(result);
        }
        fUndoChange = result.reverseChange;
        fActiveChange = fUndoChange;
        fRedoChange = null;
        return Status.OK_STATUS;
    } catch (CoreException e) {
        throw new ExecutionException(e.getStatus().getMessage(), e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)47 CoreException (org.eclipse.core.runtime.CoreException)18 IFile (org.eclipse.core.resources.IFile)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)12 ArrayList (java.util.ArrayList)11 IEditorPart (org.eclipse.ui.IEditorPart)11 IStatus (org.eclipse.core.runtime.IStatus)9 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)8 IProject (org.eclipse.core.resources.IProject)8 Status (org.eclipse.core.runtime.Status)8 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)8 List (java.util.List)7 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 ISelection (org.eclipse.jface.viewers.ISelection)7 FileEditorInput (org.eclipse.ui.part.FileEditorInput)7 PartInitException (org.eclipse.ui.PartInitException)5