Java 类org.eclipse.core.commands.operations.OperationHistoryFactory 实例源码

项目:bts    文件:LinkedEditingUndoSupport.java   
public void undoDocumentChanges() {
    final ISourceViewer viewer = editor.getInternalSourceViewer();
    try {
        editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() {
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                if (viewer instanceof ITextViewerExtension6) {
                    IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
                    if (undoManager instanceof IUndoManagerExtension) {
                        IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
                        IUndoContext undoContext = undoManagerExtension.getUndoContext();
                        IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
                        while (undoManager.undoable()) {
                            if (startingUndoOperation != null
                                    && startingUndoOperation.equals(operationHistory.getUndoOperation(undoContext)))
                                return;
                            undoManager.undo();
                        }
                    }
                }
            }
        });
        syncUtil.waitForReconciler(editor);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
}
项目:statecharts    文件:SetEntryKindCommand.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
    entry = unwrap(HandlerUtil.getCurrentSelection(event));

    if (entry == null)
        return null;
    SetValueCommand setCommand = new SetValueCommand(new SetRequest(entry,
            SGraphPackage.Literals.ENTRY__KIND, getEntryKind()));
    IOperationHistory history = OperationHistoryFactory
            .getOperationHistory();
    try {
        history.execute(setCommand, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }

    return null;
}
项目:statecharts    文件:ToggleSubRegionLayoutCommand.java   
public Object execute(ExecutionEvent event) throws ExecutionException {
    view = unwrap(HandlerUtil.getCurrentSelection(event));

    TransactionalEditingDomain editingDomain = TransactionUtil
            .getEditingDomain(view);
    ToggleCommand toggleCommand = new ToggleCommand(editingDomain, view);

    try {
        OperationHistoryFactory.getOperationHistory().execute(
                toggleCommand, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }

    return null;
}
项目:OpenSPIFe    文件:UndoableOperationTestUtil.java   
/**
 * Execute the given operation in the supplied undo context
 * Tests that the operation can be executed, 
 * that the execute result isOK() and that no ExecutionException is thrown.
 * @param operation
 * @param undoContext
 */
public static final void executeOperation(IUndoableOperation operation, IUndoContext undoContext) {
    operation.addContext(undoContext);
    TestCase.assertTrue("Operation can't execute.", operation.canExecute());
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        IStatus result = history.execute(operation, null, null);
        TestCase.assertTrue("failed to execute: " + operation.getLabel(), result.isOK());
    } catch (ExecutionException ee) {
        TestCase.fail("failed to execute");
    }
    TestCase.assertFalse(operation.canExecute());
    IUndoContext[] contexts = operation.getContexts();
    if ((contexts != null) && (contexts.length > 0)) { 
        // Operations that don't accept contexts don't need to be undoable.
        // An example such operation is ClipboardCopyOperation, 
        // or any other AbstractEnsembleDoableOperation
        TestCase.assertTrue("Operation is not undoable.", operation.canUndo());
    }
}
项目:OpenSPIFe    文件:ScheduledOperation.java   
public static void toggleScheduledness(EPlanElement element) {
    IPlanEditApprover registry = PlanEditApproverRegistry.getInstance();
    if (!registry.canModify(element)) {
        return;
    }
    TriState oldValue = SpifePlanUtils.getScheduled(element);
    boolean value = (oldValue == TriState.FALSE);
    ScheduledOperation op = new ScheduledOperation(element, value);
    IUndoContext undoContext = TransactionUtils.getUndoContext(element);
    op.addContext(undoContext);
    try {
        OperationHistoryFactory.getOperationHistory().execute(op, null, null);
    } catch (ExecutionException e) {
        // should never occur
        LogUtil.error(e);
    }
}
项目:OpenSPIFe    文件:OneOfEachAction.java   
private void createAddOperation(PlanEditorModel model, final EPlanElement parent, final EPlanElement child) {
    IStructureModifier modifier = PlanStructureModifier.INSTANCE;
    PlanTransferable transferable = new PlanTransferable();
    transferable.setPlanElements(Collections.singletonList(child));
    IStructureLocation location = modifier.getInsertionLocation(transferable, new StructuredSelection(parent), InsertionSemantics.ON);
    AddOperation operation = new PlanAddOperation(transferable, modifier, location);
    IUndoContext undoContext = model.getUndoContext();
    operation.addContext(undoContext);
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        IStatus status = history.execute(operation, null, null);
        if (status instanceof JobOperationStatus) {
            ((JobOperationStatus) status).getJob().join();
        }
    } catch (Exception e) {
        trace.error("OneOfEachAction.createAddGroupOperation:operation", e);
    }
}
项目:OpenSPIFe    文件:ProfileDataPointColumnProvider.java   
@Override
public void modify(DataPoint oldDataPoint, Object value, IUndoContext undoContext) {
    if (value instanceof Date) {
        DataPoint newDataPoint = JScienceFactory.eINSTANCE.createEDataPoint((Date) value, oldDataPoint.getValue());
        SwapProfileDataPointOperation op = new SwapProfileDataPointOperation(profile, oldDataPoint, newDataPoint);
        if (undoContext != null) {
            op.addContext(undoContext);
        }
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        try {
            history.execute(op, null, null);
        } catch (ExecutionException e) {
            LogUtil.error(e);
        }
    }
}
项目:OpenSPIFe    文件:TemporalDetailProvider.java   
private void setCalculatedVariable(TemporalMember target, CalculatedVariable calculatedVariable) {
    Object oldValue = target.eGet(CALCULATED_VARIABLE_FEATURE);
    if (oldValue == calculatedVariable) {
        if (oldValue != CalculatedVariable.END) {
            calculatedVariable = CalculatedVariable.END;
        } else if (TemporalMemberUtils.hasDurationFormula(target)) {
            calculatedVariable = CalculatedVariable.START;
        } else {
            calculatedVariable = CalculatedVariable.DURATION;
        }
    }
    IUndoableOperation operation = new FeatureTransactionChangeOperation("Set calculated variable", target, CALCULATED_VARIABLE_FEATURE, oldValue, calculatedVariable);
    operation.addContext(EMFUtils.getUndoContext(target));
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    try {
        history.execute(operation, null, null);
    } catch (ExecutionException e) {
        LogUtil.error("failed to set calculated variable", e);
    }
}
项目:OpenSPIFe    文件:PlanElementRowEditPart.java   
private void addVisibleLabel(IFigure figure) {
    visibleLabel = new Label();
    visibleLabel.setBorder(new SimpleRaisedBorder());
    visibleLabel.addMouseListener(new MouseListener.Stub() {
        @Override
        public void mousePressed(MouseEvent me) {
            EPlanElement node = getModel();
            TriState oldValue = SpifePlanUtils.getVisible(node);
            if (!PlanEditApproverRegistry.getInstance().canModify(node)) {
                return;
            }
            try {
                VisibleOperation op = new VisibleOperation(node, oldValue == TriState.FALSE);
                op.addContext(TransactionUtils.getUndoContext(node));
                IOperationHistory history = OperationHistoryFactory.getOperationHistory();
                history.execute(op, null, null);
            } catch (Exception e) {
                trace.error(e.getMessage(), e);
            }
        }
    });
    updateVisibleVisual();
    figure.add(visibleLabel);
}
项目:OpenSPIFe    文件:OrderEventsAscendingHandler.java   
protected void runImpl(MultiPagePlanEditor editor, EPlan plan) {
    EPlanElement parent = getSelection(editor);
    if (parent==null){
        parent=plan;
    }
    List<EPlanChild> childList = new ArrayList<EPlanChild>();
    for (EPlanChild child : parent.getChildren()) {
        childList.add(child);
    }
    Collections.sort(childList, new ScheduledActivtyComparator());
    IStructureModifier modifier = PlanStructureModifier.INSTANCE;
    PlanTransferable transferable = new PlanTransferable();
    transferable.setPlanElements(childList);
    IStructureLocation location = modifier.getInsertionLocation(transferable, new StructuredSelection(parent), InsertionSemantics.ON);
    PlanEditorModel model = editor.getPlanEditorModel();
    MoveOperation operation = new PlanMoveOperation(transferable, modifier, location);
    IUndoContext undoContext = model.getUndoContext();
    operation.addContext(undoContext);
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        history.execute(operation, null, null);
    } catch (Exception e) {
        LogUtil.error(OrderEventsAscendingHandler.class.getName(), e);
    }
}
项目:OpenSPIFe    文件:UndoableObservableValue.java   
@Override
protected void doSetValue(final Object value) {
    Object oldValue = doGetValue();
    if (CommonUtils.equals(value, oldValue)) {
        return; // nothing to do
    }
    EStructuralFeature feature = (EStructuralFeature) pd.getFeature(target);
    String name = EMFUtils.getDisplayName(target, feature);
    IUndoableOperation operation = new ChangeObservableOperation("Edit " + name, value);
    EObject observed = (EObject) getObserved();
    operation = EMFUtils.addContributorOperations(operation, observed, feature, oldValue, value);
    IUndoContext context = gov.nasa.ensemble.emf.transaction.TransactionUtils.getUndoContext(observed);
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    IUndoableOperation previous = history.getUndoOperation(context);
    if (previous instanceof TextModifyUndoableObservableValue.TextModifyObservableOperation) {
        // Reset the TextModifyObservableOperation to clear the dirty flag on its TextModifyUndoableObservableValue
        ((TextModifyUndoableObservableValue.TextModifyObservableOperation) previous).reset();
        // Remove the TextModifyObservableOperation operation from the operation history as it should be replaced by the new operation
        history.replaceOperation(previous, new IUndoableOperation[0]);
    }
    CommonUtils.execute(operation, context);
}
项目:OpenSPIFe    文件:WidgetUtils.java   
/**
 * Execute the operation in the undo context, in a job.
 * 
 * If the operation is an IDisplayOperation, and both the widget and site are provided,
 * then the job will be created as a DisplayOperationJob.
 * 
 * If the operation can not be executed, it will be disposed.
 * 
 * @param operation
 * @param undoContext
 * @param widget
 * @param site
 */
public static void execute(final IUndoableOperation operation, IUndoContext undoContext, final Widget widget, final IWorkbenchSite site) {
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    IAdaptable adaptable = null;
    if ((operation instanceof IDisplayOperation) && (widget != null) && (site != null)) {
        IDisplayOperation displayOperation = (IDisplayOperation) operation;
        adaptable = new IDisplayOperation.Adaptable(displayOperation, widget, site);
    }
    if (undoContext != null) {
        operation.addContext(undoContext);
    }
    try {
        history.execute(operation, null, adaptable);
    } catch (ExecutionException e) {
        // should never occur
        LogUtil.error(e);
    }
}
项目:OpenSPIFe    文件:TestCutPasteOperation.java   
/**
 * @param plan
 * @param selectedElements
 * @param targetElements
 * @param assertPostconditions
 */
private void cutPasteElements(final OperationTestPlanRecord plan, final EPlanElement[] selectedElements, final EPlanElement[] targetElements, Runnable assertPostconditions) {
    final IStructuredSelection selection = new StructuredSelection(selectedElements);
    final IStructureModifier modifier = PlanStructureModifier.INSTANCE;
    ITransferable transferable = modifier.getTransferable(selection);
    IUndoableOperation cut = new PlanClipboardCutOperation(transferable, modifier);
    cut.addContext(TransactionUtils.getUndoContext(plan.plan));
    // cut
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        IStatus result = history.execute(cut, null, null);
        assertTrue("failed to execute: " + cut.getLabel(), result.isOK());
    } catch (ExecutionException ee) {
        fail("failed to execute");
    }

    final IStructuredSelection targetSelection = new StructuredSelection(targetElements);
    IUndoableOperation paste = new PlanClipboardPasteOperation(targetSelection, modifier);
    testUndoableOperation(plan.plan, paste, assertPostconditions);
}
项目:OpenSPIFe    文件:TestCopyPasteOperation.java   
/**
 * @param plan
 * @param selectedElements
 * @param targetElements
 * @param assertPostconditions
 */
private void copyPasteElements(final OperationTestPlanRecord plan, final EPlanElement[] selectedElements, final EPlanElement[] targetElements, final PasteOperationRunnable assertPostconditions) {
    final IStructuredSelection selection = new StructuredSelection(selectedElements);
    final IStructureModifier modifier = PlanStructureModifier.INSTANCE;
    ITransferable transferable = modifier.getTransferable(selection);
    IUndoableOperation copy = new ClipboardCopyOperation(transferable, modifier);

    // copy
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        history.execute(copy, null, null);
    } catch (ExecutionException ee) {
        fail("failed to execute");
    }

    final IStructuredSelection targetSelection = new StructuredSelection(targetElements);
    final PlanClipboardPasteOperation paste = new PlanClipboardPasteOperation(targetSelection, modifier);

    testUndoableOperation(plan.plan, paste, 
            new Runnable() {
                @Override
                public void run() {
                    assertPostconditions.run(paste);
                }
            });
}
项目:OpenSPIFe    文件:FeatureTransactionAddOperation.java   
public static <T> void execute(String label, EcoreEList<T> list, T object) {
    if (list.getEStructuralFeature().isUnique() && list.contains(object)) {
        return;
    }
    IUndoableOperation op = new FeatureTransactionAddOperation<T>(label, list, object);
    IUndoContext context = TransactionUtils.getUndoContext(list);
    if (context != null) {
        op.addContext(context);
        try {
            IOperationHistory history = OperationHistoryFactory.getOperationHistory();
            history.execute(op, null, null);
        } catch (Exception e) {
            LogUtil.error("execute", e);
        }
    }
}
项目:OpenSPIFe    文件:FeatureTransactionRemoveAllOperation.java   
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) {
    boolean containsOne = false;
    for (T item : list) {
        if (objects.contains(item)) {
            containsOne = true;
            break;
        }
    }
    if (!containsOne) {
        return;
    }
    IUndoableOperation op = new FeatureTransactionRemoveAllOperation<T>(label, list, objects);
    IUndoContext context = TransactionUtils.getUndoContext(list);
    if (context != null) {
        op.addContext(context);
        try {
            IOperationHistory history = OperationHistoryFactory.getOperationHistory();
            history.execute(op, null, null);
        } catch (Exception e) {
            LogUtil.error("execute", e);
        }
    }
}
项目:OpenSPIFe    文件:FeatureTransactionAddAllOperation.java   
public static <T> void execute(String label, EcoreEList<T> list, List<T> objects) {
    if (list.getEStructuralFeature().isUnique() && list.containsAll(objects)) {
        return;
    }
    IUndoableOperation op = new FeatureTransactionAddAllOperation<T>(label, list, objects);
    IUndoContext context = TransactionUtils.getUndoContext(list);
    if (context != null) {
        op.addContext(context);
        try {
            IOperationHistory history = OperationHistoryFactory.getOperationHistory();
            history.execute(op, null, null);
        } catch (Exception e) {
            LogUtil.error("execute", e);
        }
    }
}
项目:OpenSPIFe    文件:FeatureTransactionChangeOperation.java   
public static void execute(EObject object, EStructuralFeature feature, Object newValue) {
    Object oldValue = object.eGet(feature);
    if (CommonUtils.equals(oldValue, newValue)) {
        return;
    }
    String featureName = EMFUtils.getDisplayName(object, feature);
    String label = "Edit " + featureName;
    IUndoableOperation op = new FeatureTransactionChangeOperation(label, object, feature, oldValue, newValue);
    op = EMFUtils.addContributorOperations(op, object, feature, oldValue, newValue);
    IUndoContext context = TransactionUtils.getUndoContext(object);
    if (context != null) {
        op.addContext(context);
        try {
            IOperationHistory history = OperationHistoryFactory.getOperationHistory();
            history.execute(op, null, null);
        } catch (Exception e) {
            LogUtil.error("execute", e);
        }
    }
}
项目:OpenSPIFe    文件:FeatureTransactionRemoveOperation.java   
public static <T> void execute(String label, EcoreEList<T> list, T object) {
    if (!list.contains(object)) {
        return;
    }
    IUndoableOperation op = new FeatureTransactionRemoveOperation<T>(label, list, object);
    IUndoContext context = TransactionUtils.getUndoContext(list);
    if (context != null) {
        op.addContext(context);
        try {
            IOperationHistory history = OperationHistoryFactory.getOperationHistory();
            history.execute(op, null, null);
        } catch (Exception e) {
            LogUtil.error("execute", e);
        }
    }
}
项目:OpenSPIFe    文件:FixViolationsOperation.java   
private void doAddOperation(PlanEditorModel model, final EPlanElement parent, final List<EActivity> activities) {
    IStructureModifier modifier = PlanStructureModifier.INSTANCE;
    PlanTransferable transferable = new PlanTransferable();
    transferable.setPlanElements(activities);
    IStructureLocation location = modifier.getInsertionLocation(transferable, new StructuredSelection(parent), InsertionSemantics.ON);
    AddOperation operation = new PlanAddOperation(transferable, modifier, location);
    //IUndoContext undoContext = model.getUndoContext();
    //operation.addContext(undoContext);
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        @SuppressWarnings("unused")
        IStatus status = history.execute(operation, null, null);
    } catch (Exception e) {
        trace.error("FixViolationsOperation.doAddOperation:operation", e);
    }
}
项目:OpenSPIFe    文件:CommonPlugin.java   
/**
     * This method is called upon plug-in activation
     */
    @Override
    public void start(BundleContext context) throws Exception {
        super.start(context);
        OperationHistoryFactory.setOperationHistory(JobOperationHistory.INSTANCE);
        // configure logging
        // TODO this may cease working once the EnsembleLoggingConfigurator is extended
        ensembleProperties = initializeEnsembleProperties();
//      EnsemblePropertiesSurveyor.initialize();
        EnsembleLoggingConfigurator construct = MissionExtender.construct(EnsembleLoggingConfigurator.class);
        if (construct != null) {
            construct.configureLogging();
        } else {
            // logging not initialized
            System.err.println("EnsembleLoggingConfigurator == null");
        }

    }
项目:OpenSPIFe    文件:TestTemporalBoundColumn.java   
public void assertDeleteConstraint(PeriodicTemporalConstraint constraint, Timepoint timepoint) {
    TemporalBoundColumn column = new TemporalBoundColumn(TEST_PROVIDER, timepoint);
    EActivity a = constructBoundedActivity(constraint);
    ConstraintsMember originalFacet = column.getFacet(a);
    String originalText = column.getText(originalFacet);
    column.modify(originalFacet, "", undoContext);

    ConstraintsMember constraintsMember = a.getMember(ConstraintsMember.class, true);
    List<PeriodicTemporalConstraint> bounds = constraintsMember.getPeriodicTemporalConstraints();
    assertEquals("Number mismatch in bounds count after editing", 0, bounds.size());
    ConstraintsMember changedFacet = column.getFacet(a);
    assertEquals("Column text not equal", column.getText(changedFacet), "");

    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        history.undo(undoContext, null, null);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    ConstraintsMember finalFacet = column.getFacet(a);
    assertEquals("Error in undo operation", originalText, column.getText(finalFacet));
}
项目:tmxeditor8    文件:AddTuHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    TmxEditorViewer viewer = TmxEditorViewer.getInstance();
    if(viewer == null){
        return null;
    }
    TmxEditor editor = viewer.getTmxEditor();
    if(editor == null){
        return null;
    }
    String srcLang = editor.getSrcLang();
    String tgtLang = editor.getTgtLang();
    TmxTU tu = TmxEditorUtils.createTmxTu(srcLang, tgtLang);
    editor.addTu(tu);
    IOperationHistory histor = OperationHistoryFactory.getOperationHistory();
    histor.dispose(PlatformUI.getWorkbench().getOperationSupport().getUndoContext(), true, true, true);
    return null;
}
项目:tmxeditor8    文件:DeleteTuHandler.java   
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    TmxEditorViewer viewer = TmxEditorViewer.getInstance();
    if (viewer == null) {
        return null;
    }
    TmxEditor editor = viewer.getTmxEditor();
    if (editor == null) {
        return null;
    }
    if (editor.getTmxDataAccess().getDisplayTuCount() == 0
            || editor.getTmxEditorImpWithNattable().getSelectedRows().length == 0) {
        OpenMessageUtils.openMessage(IStatus.INFO, Messages.getString("tmxeditor.deleteTuHandler.noSelectedMsg"));
        return null;
    }
    boolean confirm = MessageDialog.openConfirm(HandlerUtil.getActiveShell(event),
            Messages.getString("tmxeditor.deleteTuHandler.warn.msg"),
            Messages.getString("tmxeditor.deleteTuHandler.warn.desc"));
    if (!confirm) {
        return null;
    }
    editor.deleteSelectedTu();
    IOperationHistory histor = OperationHistoryFactory.getOperationHistory();
    histor.dispose(PlatformUI.getWorkbench().getOperationSupport().getUndoContext(), true, true, true);
    return null;
}
项目:tmxeditor8    文件:TmxEditorViewer.java   
/**
 * 关闭TmxEditor,同时关闭AbstractDataAccess
 **/
public boolean closeTmx() {
    if (tmxEditor == null) {
        return true;
    }
    if (!tmxEditor.closeTmxEditor()) {
        return false;
    }
    tmxEditor = null;
    Control[] childs = container.getChildren();
    for (Control c : childs) {
        if (c != null && !c.isDisposed()) {
            c.dispose();
        }
    }
    fireCloseEvent();
    IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
    operationHistory.dispose(getSite().getWorkbenchWindow().getWorkbench().getOperationSupport().getUndoContext(),
            true, true, true);
    setFocus();
    String title = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getText();
    String[] s = title.split("-");
    PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().setText(s[0]);
    return true;
}
项目:ermasterr    文件:TestEditor.java   
/**
 * The <code>AbstractTextEditor</code> implementation of this
 * <code>IWorkbenchPart</code> method may be extended by subclasses.
 * Subclasses must call <code>super.dispose()</code>.
 * <p>
 * Note that many methods may return <code>null</code> after the editor is
 * disposed.
 * </p>
 */
@Override
public void dispose() {

    if (fTitleImage != null) {
        fTitleImage.dispose();
        fTitleImage = null;
    }

    disposeDocumentProvider();

    if (fSourceViewer != null) {
        fSourceViewer = null;
    }

    if (fConfiguration != null)
        fConfiguration = null;

    final IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    if (history != null) {
        if (fNonLocalOperationApprover != null)
            history.removeOperationApprover(fNonLocalOperationApprover);
        if (fLinearUndoViolationApprover != null)
            history.removeOperationApprover(fLinearUndoViolationApprover);
    }
    fNonLocalOperationApprover = null;
    fLinearUndoViolationApprover = null;

    super.dispose();
}
项目:ermaster-k    文件:TestEditor.java   
/**
 * The <code>AbstractTextEditor</code> implementation of this
 * <code>IWorkbenchPart</code> method may be extended by subclasses.
 * Subclasses must call <code>super.dispose()</code>.
 * <p>
 * Note that many methods may return <code>null</code> after the editor is
 * disposed.
 * </p>
 */
@Override
public void dispose() {

    if (fTitleImage != null) {
        fTitleImage.dispose();
        fTitleImage = null;
    }

    disposeDocumentProvider();

    if (fSourceViewer != null) {
        fSourceViewer = null;
    }

    if (fConfiguration != null)
        fConfiguration = null;

    IOperationHistory history = OperationHistoryFactory
            .getOperationHistory();
    if (history != null) {
        if (fNonLocalOperationApprover != null)
            history.removeOperationApprover(fNonLocalOperationApprover);
        if (fLinearUndoViolationApprover != null)
            history.removeOperationApprover(fLinearUndoViolationApprover);
    }
    fNonLocalOperationApprover = null;
    fLinearUndoViolationApprover = null;

    super.dispose();
}
项目:bts    文件:LinkedEditingUndoSupport.java   
public void startRecording(XtextEditor editor) {
    this.editor = editor;
    ISourceViewer viewer = editor.getInternalSourceViewer();
    if (viewer instanceof ITextViewerExtension6) {
        IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager();
        if (undoManager instanceof IUndoManagerExtension) {
            IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager;
            IUndoContext undoContext = undoManagerExtension.getUndoContext();
            IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
            startingUndoOperation = operationHistory.getUndoOperation(undoContext);
        }
    }
}
项目:statecharts    文件:CreateSubdiagramCommand.java   
protected void executeCommand(AbstractTransactionalCommand operation) {
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    try {
        history.execute(operation, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
项目:statecharts    文件:ToggleShowDocumentationCommand.java   
public static void executeCommand(ICommand cmd) {
    try {
        OperationHistoryFactory.getOperationHistory().execute(cmd, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
项目:statecharts    文件:AbstractSemanticModification.java   
protected void executeCommand(IUndoableOperation command, Resource resource) {
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    try {
        history.execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
}
项目:statecharts    文件:OrderElementControl.java   
public void widgetSelected(SelectionEvent e) {
    RepositionEObjectCommand command = new RepositionEObjectCommand(
            TransactionUtil.getEditingDomain(callback.getEObject()), "Reorder Elements", getListInput(),
            getSelectedObject(), displacement);
    try {
        OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e1) {
        e1.printStackTrace();
    }
    refreshInput();
}
项目:che    文件:RefactoringCorePlugin.java   
public static IUndoContext getUndoContext() {
  if (fRefactoringUndoContext == null) {
    fRefactoringUndoContext = new RefactoringUndoContext();
    IUndoContext workspaceContext =
        (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
    if (workspaceContext instanceof ObjectUndoContext) {
      ((ObjectUndoContext) workspaceContext).addMatch(fRefactoringUndoContext);
    }
    IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
    operationHistory.setLimit(fRefactoringUndoContext, 5);
  }
  return fRefactoringUndoContext;
}
项目:che    文件:RefactoringHistoryService.java   
/** {@inheritDoc} */
public void disconnect() {
  if (fReferenceCount > 0) {
    fManagerCache.clear();
    fReferenceCount--;
  }
  if (fReferenceCount == 0) {
    if (fOperationListener != null)
      OperationHistoryFactory.getOperationHistory()
          .removeOperationHistoryListener(fOperationListener);
    if (fResourceListener != null)
      ResourcesPlugin.getWorkspace().removeResourceChangeListener(fResourceListener);
    fOperationListener = null;
  }
}
项目:OpenSPIFe    文件:UndoableOperationTestUtil.java   
/**
 * Undo the given operation, which should be the next operation in the undo context.
 * Tests that the operation can be undone, that it is the next in the undo context,
 * that the undo result isOK() and that no ExecutionException is thrown.
 * @param operation
 * @param undoContext
 * @param undoingRedo supply true if undoing a redo, to get a different error string during failure
 */
public static final void undoOperation(IUndoableOperation operation, IUndoContext undoContext, boolean undoingRedo) {
    TestCase.assertTrue(operation.canUndo());
    String string = "failed to undo" + (undoingRedo ? " the redo" : "");
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        TestCase.assertSame("the supplied operation should be next on the undo stack", operation, history.getUndoOperation(undoContext));
        IStatus result = history.undo(undoContext, null, null);
        TestCase.assertTrue(string + ": " + operation.getLabel(), result.isOK());
    } catch (ExecutionException e) {
        TestCase.fail(string);
    }
    TestCase.assertFalse(operation.canUndo());
    TestCase.assertTrue(operation.canRedo());
}
项目:OpenSPIFe    文件:UndoableOperationTestUtil.java   
/**
 * Redo the given operation, which should be the next operation to redo in the undo context.
 * Tests that the operation can be redone, that it is the next to redo in the undo context,
 * that the redo result isOK() and that no ExecutionException is thrown.
 * @param operation
 * @param undoContext
 */
public static final void redoOperation(IUndoableOperation operation, IUndoContext undoContext) {
    TestCase.assertTrue(operation.canRedo());
    String string = "failed to redo";
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        TestCase.assertSame("the supplied operation should be next on the redo stack", operation, history.getRedoOperation(undoContext));
        IStatus result = history.redo(undoContext, null, null);
        TestCase.assertTrue(string + ": " + operation.getLabel(), result.isOK());
    } catch (ExecutionException e) {
        TestCase.fail(string);
    }
    TestCase.assertFalse(operation.canRedo());
    TestCase.assertTrue(operation.canUndo());
}
项目:OpenSPIFe    文件:TestTemporalTransferableExtension.java   
private void execute(IUndoableOperation operation, EPlan plan) {
    operation.addContext(TransactionUtils.getUndoContext(plan));
    // perform the operation
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        history.execute(operation, null, null);
    } catch (ExecutionException ee) {
        fail("failed to execute");
    }
}
项目:OpenSPIFe    文件:TestDirectPlanModifier.java   
private static void modifyStartTime(IPlanModifier modifier, EPlanElement element, Date newStart) throws ExecutionException {
    EPlan plan = EPlanUtils.getPlan(element);
    TemporalExtentsCache cache = new TemporalExtentsCache(plan);
    Map<EPlanElement, TemporalExtent> changedTimes = modifier.moveToStart(element, newStart, cache);
    SetExtentsOperation operation = new SetExtentsOperation("set start times", plan, changedTimes, cache);
    operation.addContext(TransactionUtils.getUndoContext(plan));
    IOperationHistory history = OperationHistoryFactory.getOperationHistory();
    history.execute(operation, null, null);
}
项目:OpenSPIFe    文件:OneOfEachAction.java   
private void createChainOperation(PlanEditorModel model, final List<EPlanChild> links) {
    IUndoContext undoContext = model.getUndoContext();
    PlanStructureModifier modifier = PlanStructureModifier.INSTANCE;
    ChainOperation operation = new ChainOperation(modifier, links, false);
    operation.addContext(undoContext);
    try {
        IOperationHistory history = OperationHistoryFactory.getOperationHistory();
        IStatus status = history.execute(operation, null, null);
        if (status instanceof JobOperationStatus) {
            ((JobOperationStatus) status).getJob().join();
        }
    } catch (Exception e) {
        trace.error("OneOfEachAction.createChainOperation:operation", e);
    }
}
项目:OpenSPIFe    文件:FixedTransactionEditingDomain.java   
@Override
public void dispose() {
    OperationHistoryFactory.getOperationHistory().dispose(undoContext, true, true, true);
    EMFUtils.clearReachableObjectsOfType(getResourceSet());
    super.dispose();
    getResourceSet().getLoadOptions().clear(); // clear XMLResource.OPTION_USE_PARSER_POOL
    getResourceSet().getResources().clear(); // help limit memory leaks
}