org.eclipse.core.commands.operations.IUndoContext Java Examples
The following examples show how to use
org.eclipse.core.commands.operations.IUndoContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MvcFxUiModule.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Binds a factory for the creation of * {@link HistoryBasedDirtyStateProvider} as {@link IDirtyStateProvider}. */ protected void bindIDirtyStateProviderFactory() { binder().bind(IDirtyStateProviderFactory.class) .toInstance(new IDirtyStateProviderFactory() { @Override public IDirtyStateProvider create( IWorkbenchPart workbenchPart) { return new HistoryBasedDirtyStateProvider( (IOperationHistory) workbenchPart .getAdapter(IOperationHistory.class), (IUndoContext) workbenchPart .getAdapter(IUndoContext.class)); } }); }
Example #2
Source File: UndoCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public boolean isEnabled() { final IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; if(editor != null){ final IOperationHistory history = (IOperationHistory) editor.getAdapter(IOperationHistory.class); final IUndoContext context = (IUndoContext) editor.getAdapter(IUndoContext.class); if(history != null && context != null){ final IUndoableOperation[] undoHistory = history.getUndoHistory(context); if (undoHistory != null && undoHistory.length != 0) { final IUndoableOperation ctxt = undoHistory[undoHistory.length - 1]; final String ctxtLabel = ctxt.getLabel(); if(ctxtLabel != null && ctxtLabel.contains("Lane")){//Avoid Exception on undo //$NON-NLS-1$ return false ; } else { return ctxt.canUndo(); } } } else { return false; } } return false; }
Example #3
Source File: UndoablePropertySheetPage.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Constructs a new {@link UndoablePropertySheetPage} using the provided * {@link IOperationHistory}. * * @param operationHistory * The {@link IOperationHistory} shared with the editor/view. * @param undoContext * The {@link IUndoContext} shared with the editor/view. * @param workbenchPart * The {@link IWorkbenchPart} this * {@link UndoablePropertySheetPage} is related to. . * */ @Inject public UndoablePropertySheetPage(@Assisted IWorkbenchPart workbenchPart, IOperationHistory operationHistory, IUndoContext undoContext) { this.workbenchPart = workbenchPart; this.operationHistory = operationHistory; this.undoContext = undoContext; this.operationHistoryListener = new IOperationHistoryListener() { @Override public void historyNotification(OperationHistoryEvent event) { if (event.getEventType() == OperationHistoryEvent.ABOUT_TO_REDO || event.getEventType() == OperationHistoryEvent.ABOUT_TO_UNDO) { refresh(); } } }; operationHistory.addOperationHistoryListener(operationHistoryListener); setRootEntry(createRootEntry()); }
Example #4
Source File: UndoablePropertySheetEntry.java From gef with Eclipse Public License 2.0 | 6 votes |
/** * Constructs a new root entry. * * @param workbenchPart * The {@link IWorkbenchPart} to adapt for an * {@link IPropertySource}, in case no values are provided. * @param operationHistory * The {@link IOperationHistory} to use. * @param undoContext * The {@link IUndoContext} to use. */ public UndoablePropertySheetEntry(IWorkbenchPart workbenchPart, IOperationHistory operationHistory, IUndoContext undoContext) { this.workbenchPart = workbenchPart; this.operationHistory = operationHistory; this.undoContext = undoContext; this.operationHistoryListener = new IOperationHistoryListener() { @Override public void historyNotification(OperationHistoryEvent event) { refreshFromRoot(); } }; this.operationHistory .addOperationHistoryListener(operationHistoryListener); }
Example #5
Source File: JavaEditorBreadcrumbActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public JavaEditorBreadcrumbActionGroup(JavaEditor javaEditor, ISelectionProvider selectionProvider) { super(new ActionGroup[] { new BreadcrumbActionGroup(javaEditor), new UndoRedoActionGroup(javaEditor.getEditorSite(), (IUndoContext) ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class), true), new NewWizardsActionGroup(javaEditor.getEditorSite()), new JavaSearchActionGroup(javaEditor.getEditorSite(), selectionProvider), new NavigateActionGroup(javaEditor.getEditorSite(), selectionProvider), new CCPActionGroup(javaEditor.getEditorSite(), selectionProvider), new GenerateBuildPathActionGroup(javaEditor.getEditorSite(), selectionProvider), new GenerateActionGroup(javaEditor.getEditorSite(), selectionProvider), new RefactorActionGroup(javaEditor.getEditorSite(), selectionProvider), new BuildActionGroup(javaEditor.getEditorSite(), selectionProvider), new ProjectActionGroup(javaEditor.getEditorSite(), selectionProvider), new WorkingSetActionGroup(javaEditor.getEditorSite(), selectionProvider) }); }
Example #6
Source File: XLIFFEditorActionHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@Override public void runWithEvent(Event event) { if (viewer != null && !viewer.getTextWidget().isDisposed()) { XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent(); // 先保存在撤销,除非以后取消两种模式,否则不要删除此判断 if (viewer.canDoOperation(ITextOperationTarget.UNDO)) { HsMultiActiveCellEditor.commit(true); } IOperationHistory history = OperationHistoryFactory.getOperationHistory(); IUndoContext undoContext = (IUndoContext) xliffEditor.getTable().getData(IUndoContext.class.getName()); if (history.canUndo(undoContext)) { try { history.undo(undoContext, null, null); undoBean.setCrosseStep(undoBean.getCrosseStep() + 1); } catch (ExecutionException e) { e.printStackTrace(); } } XLIFFEditorImplWithNatTable.getCurrent().redraw(); updateActionsEnableState(); return; } if (undoAction != null) { undoAction.runWithEvent(event); return; } }
Example #7
Source File: CellEditorGlobalActionHanlder.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Update the state. */ public void updateEnabledState() { IOperationHistory opHisotry = OperationHistoryFactory.getOperationHistory(); IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext(); if (opHisotry.canUndo(context)) { setEnabled(true); return; } if (viewer != null && !viewer.getTextWidget().isDisposed()) { setEnabled(viewer.canDoOperation(ITextOperationTarget.UNDO)); return; } setEnabled(false); }
Example #8
Source File: CellEditorGlobalActionHanlder.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void runWithEvent(Event event) { TeActiveCellEditor.commit(); IOperationHistory history = OperationHistoryFactory.getOperationHistory(); IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext(); if (history.canUndo(context)) { try { history.undo(context, null, null); updateActionsEnableState(); } catch (ExecutionException e) { e.printStackTrace(); } } }
Example #9
Source File: CalcitePane.java From mat-calcite-plugin with Apache License 2.0 | 5 votes |
private void installUndoRedoSupport() { IUndoContext undoContext = ((IUndoManagerExtension) queryViewer.getUndoManager()).getUndoContext(); UndoActionHandler undoAction = new UndoActionHandler(getSite(), undoContext); RedoActionHandler redoAction = new RedoActionHandler(getSite(), undoContext); undoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO); redoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO); IActionBars actionBars = getEditor().getEditorSite().getActionBars(); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), undoAction); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), redoAction); actionBars.updateActionBars(); }
Example #10
Source File: XLIFFEditorActionHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void runWithEvent(Event event) { if (viewer != null && !viewer.getTextWidget().isDisposed()) { // 如果跨越焦点撤销,则先撤销非焦点 try { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); IUndoContext undoContext = (IUndoContext) XLIFFEditorImplWithNatTable.getCurrent().getTable() .getData(IUndoContext.class.getName()); history.redo(undoContext, null, null); // int crossSegment = undoBean.getCrosseStep(); // if (crossSegment > 0) { // history.redo(undoContext, null, null); // undoBean.setCrosseStep(crossSegment - 1); // undoBean.setSaveStatus(-1); // } else if (undoBean.getSaveStatus() == -1) { // XLIFFEditorImplWithNatTable.getCurrent().jumpToRow(undoBean.getUnSaveRow()); // viewer.setText(undoBean.getUnSaveText()); // undoBean.setCrosseStep(0); // undoBean.setSaveStatus(0); // } else { // viewer.doOperation(ITextOperationTarget.REDO); // } } catch (ExecutionException e) { e.printStackTrace(); } System.out.println(undoBean.getCrosseStep()); updateActionsEnableState(); return; } if (redoAction != null) { redoAction.runWithEvent(event); return; } }
Example #11
Source File: AbstractFXView.java From gef with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") @Override public Object getAdapter(final Class key) { // Provide a default selection provider (subclasses may overwrite by // handling the key and returning a different implementation // replace with binding if (ISelectionProvider.class.equals(key)) { if (selectionProvider != null) { return selectionProvider; } } // contribute to Properties view (only created if required) if (IPropertySheetPage.class.equals(key)) { if (propertySheetPage == null) { propertySheetPage = createPropertySheetPage(); } if (propertySheetPage != null) { return propertySheetPage; } } if (IUndoContext.class.equals(key)) { if (domain instanceof HistoricizingDomain) { return ((HistoricizingDomain) domain).getUndoContext(); } } if (IOperationHistory.class.equals(key)) { if (domain instanceof HistoricizingDomain) { return ((HistoricizingDomain) domain).getOperationHistory(); } } return super.getAdapter(key); }
Example #12
Source File: RemoveAllTagsOperation.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public RemoveAllTagsOperation(String label, NatTable table, XLFHandler handler, List<String> rowIds) { super(label); IUndoContext context = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(context); this.table = table; this.handler = handler; this.rowIds = rowIds; }
Example #13
Source File: LockOperation.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * * @param label * @param natTable * @param rowIdList * @param handler * @param lock */ public LockOperation(String label, NatTable natTable, List<String> rowIdList, XLFHandler handler, boolean lock) { super(label); IUndoContext context = (IUndoContext) natTable.getData(IUndoContext.class.getName()); addContext(context); this.table = natTable; this.rowIdList = rowIdList; this.handler = handler; this.lock = lock; }
Example #14
Source File: MergeSegmentOperation.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public MergeSegmentOperation(String label, XLIFFEditorImplWithNatTable xliffEditor, XLFHandler handler, List<String> rowIdList) { super(label); this.xliffEditor = xliffEditor; NatTable table = xliffEditor.getTable(); IUndoContext context = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(context); this.rowIdList = rowIdList; this.handler = handler; oldSegFragMap = new HashMap<String, String>(); }
Example #15
Source File: UpdateSegmentsOperation.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private UpdateSegmentsOperation(XLIFFEditorImplWithNatTable xliffEditor, XLFHandler handler, List<String> rowIds, int column, boolean approved, String matchType, String quality) { super("Update Segments"); this.xliffEditor = xliffEditor; this.table = xliffEditor.getTable(); IUndoContext undoContext = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(undoContext); // 绑定上下文 this.handler = handler; this.rowIds = rowIds; this.approved = approved; segmentCache = handler.getTuNodes(rowIds); // 缓存未修改前的文本段 this.matchType = matchType; this.quality = quality; }
Example #16
Source File: AbstractFXEditorTests.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Binds a factory for the creation of * {@link HistoryBasedDirtyStateProvider} as * {@link IDirtyStateProvider}. */ protected void bindIDirtyStateProviderFactory() { binder().bind(IDirtyStateProviderFactory.class).toInstance(new IDirtyStateProviderFactory() { @Override public IDirtyStateProvider create(IWorkbenchPart workbenchPart) { return new HistoryBasedDirtyStateProvider( (IOperationHistory) workbenchPart.getAdapter(IOperationHistory.class), (IUndoContext) workbenchPart.getAdapter(IUndoContext.class)); } }); }
Example #17
Source File: UpdateDataOperation.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public UpdateDataOperation(NatTable table, DataLayer dataLayer, UpdateDataAndAutoResizeCommand command) { super("Typing"); IUndoContext undoContext = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(undoContext); Object currentValue = dataLayer.getDataProvider().getDataValue(command.getColumnPosition(), command.getRowPosition()); // Object currentValue = dataLayer.getDataValueByPosition(command2.getColumnPosition(), command2.getRowPosition()); oldValue = currentValue == null ? new UpdateDataBean() : new UpdateDataBean((String) currentValue, null, null); this.dataLayer = dataLayer; this.command = command; this.table = table; viewportLayer = LayerUtil.getLayer(table, ViewportLayer.class); }
Example #18
Source File: CellEditorGlobalActionHanlder.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void runWithEvent(Event event) { TeActiveCellEditor.commit(); IOperationHistory history = OperationHistoryFactory.getOperationHistory(); IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext(); if (history.canRedo(context)) { try { history.redo(context, null, null); updateActionsEnableState(); } catch (ExecutionException e) { e.printStackTrace(); } } }
Example #19
Source File: CellEditorGlobalActionHanlder.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Update the state. */ public void updateEnabledState() { IOperationHistory opHisotry = OperationHistoryFactory.getOperationHistory(); IUndoContext context = PlatformUI.getWorkbench().getOperationSupport().getUndoContext(); if (opHisotry.canRedo(context)) { setEnabled(true); return; } if (viewer != null && !viewer.getTextWidget().isDisposed()) { setEnabled(viewer.canDoOperation(ITextOperationTarget.REDO)); return; } setEnabled(false); }
Example #20
Source File: SendTOTmOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public SendTOTmOperation(String label, NatTable natTable, List<String> rowIdList, XLFHandler handler, String state) { super(label); IUndoContext context = (IUndoContext) natTable.getData(IUndoContext.class.getName()); addContext(context); this.table = natTable; this.rowIdList = rowIdList; this.handler = handler; this.state = state; this.oldState = handler.getTuPropValue(rowIdList, "hs:send-to-tm"); }
Example #21
Source File: NeedsReviewOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public NeedsReviewOperation(String label, NatTable natTable, List<String> rowIdList, XLFHandler handler, String state) { super(label); IUndoContext context = (IUndoContext) natTable.getData(IUndoContext.class.getName()); addContext(context); this.table = natTable; this.rowIdList = rowIdList; this.handler = handler; this.state = state; this.oldState = handler.getTuPropValue(rowIdList, "hs:needs-review"); }
Example #22
Source File: SplitSegmentOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public SplitSegmentOperation(String label, XLIFFEditorImplWithNatTable xliffEditor, XLFHandler handler, int rowIndex, int offset) { super(label); this.xliffEditor = xliffEditor; IUndoContext context = (IUndoContext) xliffEditor.getTable().getData(IUndoContext.class.getName()); addContext(context); this.handler = handler; this.offset = offset; this.rowIndex = rowIndex; this.rowId = handler.getRowId(rowIndex); }
Example #23
Source File: UpdateSegmentsOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private UpdateSegmentsOperation(XLIFFEditorImplWithNatTable xliffEditor, XLFHandler handler, List<String> rowIds, int column, boolean approved, String matchType, String quality) { super("Update Segments"); this.xliffEditor = xliffEditor; this.table = xliffEditor.getTable(); IUndoContext undoContext = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(undoContext); // 绑定上下文 this.handler = handler; this.rowIds = rowIds; this.approved = approved; segmentCache = handler.getTuNodes(rowIds); // 缓存未修改前的文本段 this.matchType = matchType; this.quality = quality; }
Example #24
Source File: MergeSegmentOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public MergeSegmentOperation(String label, XLIFFEditorImplWithNatTable xliffEditor, XLFHandler handler, List<String> rowIdList) { super(label); this.xliffEditor = xliffEditor; NatTable table = xliffEditor.getTable(); IUndoContext context = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(context); this.rowIdList = rowIdList; this.handler = handler; oldSegFragMap = new HashMap<String, String>(); }
Example #25
Source File: LockOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * * @param label * @param natTable * @param rowIdList * @param handler * @param lock */ public LockOperation(String label, NatTable natTable, List<String> rowIdList, XLFHandler handler, boolean lock) { super(label); IUndoContext context = (IUndoContext) natTable.getData(IUndoContext.class.getName()); addContext(context); this.table = natTable; this.rowIdList = rowIdList; this.handler = handler; this.lock = lock; }
Example #26
Source File: RemoveAllTagsOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public RemoveAllTagsOperation(String label, NatTable table, XLFHandler handler, List<String> rowIds) { super(label); IUndoContext context = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(context); this.table = table; this.handler = handler; this.rowIds = rowIds; }
Example #27
Source File: UpdateDataOperation.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public UpdateDataOperation(NatTable table, DataLayer dataLayer, UpdateDataCommand command) { super("Typing"); IUndoContext undoContext = (IUndoContext) table.getData(IUndoContext.class.getName()); addContext(undoContext); Object currentValue = dataLayer.getDataValueByPosition(command.getColumnPosition(), command.getRowPosition()); oldValue = currentValue == null ? new UpdateDataBean() : new UpdateDataBean((String) currentValue, null, null); this.dataLayer = dataLayer; this.command = command; this.table = table; viewportLayer = LayerUtil.getLayer(table, ViewportLayer.class); }
Example #28
Source File: BonitaOperationHistory.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void dispose(final IUndoContext context, final boolean flushUndo, final boolean flushRedo, final boolean flushContext) { // dispose of any limit that was set for the context if it is not to be // used again. if (context instanceof EditingDomainUndoContext) { final EditingDomainUndoContext editingDomainContext = (EditingDomainUndoContext) context; final EditingDomain editingDomain = editingDomainContext.getEditingDomain(); if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() != null) { final IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences(); for (final IEditorReference editorRef : editorReferences) { try { final IWorkbenchPart part = editorRef.getPart(false); if (part instanceof DiagramEditor) { final DiagramEditor editor = (DiagramEditor) part; if (editor.getEditingDomain() != null && editor.getEditingDomain().equals(editingDomain)) { return;// do not dispose if the editing domain // is else } } } catch (final Exception e) { BonitaStudioLog.error(e); } } } } defaultOperationHistory.dispose(context, flushUndo, flushRedo, flushContext); }
Example #29
Source File: RedoCommandHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public boolean isEnabled() { IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; IOperationHistory history = (IOperationHistory) editor.getAdapter(IOperationHistory.class); IUndoContext context = (IUndoContext) editor.getAdapter(IUndoContext.class); if(history != null && context != null ){ return history.canRedo(context); } else { return false; } }
Example #30
Source File: TestUndoRedoStackLimit.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private int retrieveLimit(SWTBotEditor botEditor) { IEditorPart editor = botEditor.getReference().getEditor(false); IOperationHistory history = editor.getAdapter(IOperationHistory.class); IUndoContext context = editor.getAdapter(IUndoContext.class); if (history != null && context != null) { return history.getLimit(context); } return -1; }