Search in sources :

Example 1 with UpdateMarkersOperation

use of org.eclipse.ui.ide.undo.UpdateMarkersOperation in project tdq-studio-se by Talend.

the class TdDialogMarkerProperties method saveChanges.

/**
 * Saves the changes made in the dialog if needed. Creates a new marker if needed. Updates the existing marker only
 * if there have been changes.
 */
@SuppressWarnings("unchecked")
private void saveChanges() {
    Map attrs = getMarkerAttributes();
    IUndoableOperation op = null;
    if (marker == null) {
        if (resource == null)
            return;
        op = new CreateMarkersOperation(type, attrs, resource, getCreateOperationTitle());
    } else {
        if (isDirty()) {
            op = new UpdateMarkersOperation(marker, attrs, getModifyOperationTitle(), true);
        }
    }
    if (op != null) {
        try {
            PlatformUI.getWorkbench().getOperationSupport().getOperationHistory().execute(op, null, WorkspaceUndoUtil.getUIInfoAdapter(getShell()));
        } catch (ExecutionException e) {
            if (e.getCause() instanceof CoreException) {
                ErrorDialog.openError(getShell(), MarkerMessages.Error, null, ((CoreException) e.getCause()).getStatus());
            } else {
                IDEWorkbenchPlugin.log(e.getMessage(), e);
            }
        }
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IUndoableOperation(org.eclipse.core.commands.operations.IUndoableOperation) UpdateMarkersOperation(org.eclipse.ui.ide.undo.UpdateMarkersOperation) ExecutionException(org.eclipse.core.commands.ExecutionException) HashMap(java.util.HashMap) Map(java.util.Map) CreateMarkersOperation(org.eclipse.ui.ide.undo.CreateMarkersOperation)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IUndoableOperation (org.eclipse.core.commands.operations.IUndoableOperation)1 CoreException (org.eclipse.core.runtime.CoreException)1 CreateMarkersOperation (org.eclipse.ui.ide.undo.CreateMarkersOperation)1 UpdateMarkersOperation (org.eclipse.ui.ide.undo.UpdateMarkersOperation)1