Search in sources :

Example 36 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 37 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 38 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)

Example 39 with ExecutionException

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

the class UndoableOperation2ChangeAdapter method computeRedoableStatus.

public IStatus computeRedoableStatus(IProgressMonitor monitor) throws ExecutionException {
    if (fRedoChange == null)
        return new Status(IStatus.ERROR, RefactoringCorePlugin.getPluginId(), IStatus.ERROR, RefactoringCoreMessages.UndoableOperation2ChangeAdapter_no_redo_available, null);
    try {
        if (monitor == null)
            monitor = new NullProgressMonitor();
        RefactoringStatus status = fRedoChange.isValid(monitor);
        if (status.hasFatalError()) {
            // The operation can no longer be redone.
            fRedoChange = 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 40 with ExecutionException

use of org.eclipse.core.commands.ExecutionException in project translationstudio8 by heartsome.

the class NattableUtil method changeTgtState.

/**
	 * 改变Target的状态
	 * @param state
	 *            状态值("new", "final", "translated", "signed-off", "needs-adaptation", "needs-review-adaptation",
	 *            "needs-l10n", "needs-review-l10n", "needs-translation", "needs-review-translation");
	 */
public void changeTgtState(final List<String> selectedRowIds, final String state, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask(Messages.getString("utils.NattableUtil.task4"), 1);
    monitor.worked(1);
    final IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
    final IProgressMonitor monitor2 = monitor;
    Display.getDefault().syncExec(new Runnable() {

        public void run() {
            try {
                operationHistory.execute(new StateOperation("State", xliffEditor.getTable(), selectedRowIds, xliffEditor.getXLFHandler(), state), monitor2, null);
            } catch (ExecutionException e) {
                LOGGER.error("", e);
                MessageDialog.openError(xliffEditor.getSite().getShell(), Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage());
                e.printStackTrace();
            }
        }
    });
    monitor.done();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IOperationHistory(org.eclipse.core.commands.operations.IOperationHistory) StateOperation(net.heartsome.cat.ts.ui.xliffeditor.nattable.undoable.StateOperation) ExecutionException(org.eclipse.core.commands.ExecutionException)

Aggregations

ExecutionException (org.eclipse.core.commands.ExecutionException)66 CoreException (org.eclipse.core.runtime.CoreException)20 IFile (org.eclipse.core.resources.IFile)15 ArrayList (java.util.ArrayList)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 IStatus (org.eclipse.core.runtime.IStatus)12 Shell (org.eclipse.swt.widgets.Shell)12 Status (org.eclipse.core.runtime.Status)11 IEditorPart (org.eclipse.ui.IEditorPart)11 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 ISelection (org.eclipse.jface.viewers.ISelection)8 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)8 File (java.io.File)7 List (java.util.List)7 XLFHandler (net.heartsome.cat.ts.core.file.XLFHandler)7 XLIFFEditorImplWithNatTable (net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable)7 IProject (org.eclipse.core.resources.IProject)7 FileEditorInput (org.eclipse.ui.part.FileEditorInput)7