org.eclipse.core.commands.operations.OperationHistoryFactory Java Examples
The following examples show how to use
org.eclipse.core.commands.operations.OperationHistoryFactory.
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: BonitaStudioApplication.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public Object start(final IApplicationContext context) { START_TIME = System.currentTimeMillis(); //avoid the execution of AutoBuild job during startup addBuildJobListener(); if (display == null) { display = PlatformUI.createDisplay(); } if (!isJavaVersionSupported(display)) { return IApplication.EXIT_OK; } initWorkspaceLocation(); executePreStartupContributions(); //set our custom operation factory OperationHistoryFactory.setOperationHistory(new BonitaOperationHistory()); return createAndRunWorkbench(display); }
Example #2
Source File: AddTuHandler.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example #3
Source File: ConnectorSection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected Button createMoveConnectorButton(final Composite buttonsComposite) { final Button moveButton = getWidgetFactory().createButton( buttonsComposite, Messages.copyMove, SWT.FLAT); moveButton.setLayoutData(GridDataFactory.fillDefaults() .minSize(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).create()); moveButton.addListener(SWT.Selection, new Listener() { @Override public void handleEvent(final Event event) { final WizardDialog dialog = new WizardDialog(Display.getDefault() .getActiveShell(), new MoveConnectorWizard(OperationHistoryFactory.getOperationHistory(), getEditingDomain(), ((IStructuredSelection) tableViewer.getSelection()).toList())); if (dialog.open() == Dialog.OK) { tableViewer.refresh(); } } }); return moveButton; }
Example #4
Source File: DiagramFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void doSave(final Object content) { final Resource resource = getEMFResource(); final TransactionalEditingDomain editingDomain = TransactionUtil.getEditingDomain(resource); try { OperationHistoryFactory.getOperationHistory().execute( new SaveDiagramResourceCommand(content, editingDomain, resource), Repository.NULL_PROGRESS_MONITOR, null); } catch (final ExecutionException e1) { BonitaStudioLog.error(e1); } if (content instanceof DiagramDocumentEditor) { ((DiagramDocumentEditor) content).doSave(Repository.NULL_PROGRESS_MONITOR); } try { resource.save(ProcessDiagramEditorUtil.getSaveOptions()); } catch (final IOException e) { BonitaStudioLog.error(e); } }
Example #5
Source File: DeleteTuHandler.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@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; }
Example #6
Source File: ToggleSubRegionLayoutCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
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; }
Example #7
Source File: SetEntryKindCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
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; }
Example #8
Source File: ProcessDataViewer.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
protected void moveData(final IStructuredSelection structuredSelection) { final DataAware container = (DataAware) getDataContainerObservable().getValue(); final MoveDataWizard moveDataWizard = new MoveDataWizard(container); if (createWizardDialog(moveDataWizard, IDialogConstants.FINISH_LABEL).open() == Dialog.OK) { final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement(); try { final MoveDataCommand cmd = new MoveDataCommand(TransactionUtil.getEditingDomain(dataAware), container, structuredSelection.toList(), dataAware); OperationHistoryFactory.getOperationHistory().execute(cmd, null, null); if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) { final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue(); String dataNames = ""; for (final Object d : data) { dataNames = dataNames + ((Element) d).getName() + ","; } dataNames = dataNames.substring(0, dataNames.length() - 1); MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle, Messages.bind(Messages.PromoteDataWarningMessage, dataNames)); } } catch (final ExecutionException e1) { BonitaStudioLog.error(e1); } } }
Example #9
Source File: CreateSubdiagramCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void executeCommand(AbstractTransactionalCommand operation) { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); try { history.execute(operation, new NullProgressMonitor(), null); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #10
Source File: AbstractDataSection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("unchecked") protected void moveData(final IStructuredSelection structuredSelection) { final MoveDataWizard moveDataWizard = new MoveDataWizard((DataAware) getEObject()); if (new WizardDialog(Display.getDefault().getActiveShell(), moveDataWizard).open() == Dialog.OK) { final DataAware dataAware = moveDataWizard.getSelectedDataAwareElement(); try { final MoveDataCommand cmd = new MoveDataCommand(getEditingDomain(), (DataAware) getEObject(), structuredSelection.toList(), dataAware); OperationHistoryFactory.getOperationHistory().execute(cmd, null, null); if (!(cmd.getCommandResult().getStatus().getSeverity() == Status.OK)) { final List<Object> data = (List<Object>) cmd.getCommandResult().getReturnValue(); String dataNames = ""; for (final Object d : data) { dataNames = dataNames + ((Element) d).getName() + ","; } dataNames = dataNames.substring(0, dataNames.length() - 1); MessageDialog.openWarning(Display.getDefault().getActiveShell(), Messages.PromoteDataWarningTitle, Messages.bind(Messages.PromoteDataWarningMessage, dataNames)); } } catch (final ExecutionException e1) { BonitaStudioLog.error(e1); } refresh(); } }
Example #11
Source File: WaitForRefactoringCondition.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override public boolean test() throws Exception { boolean _xblockexpression = false; { final IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); IUndoableOperation _xifexpression = null; if (this.isRedo) { _xifexpression = operationHistory.getRedoOperation(this.getUndoContext()); } else { _xifexpression = operationHistory.getUndoOperation(this.getUndoContext()); } String _label = null; if (_xifexpression!=null) { _label=_xifexpression.getLabel(); } final String label = _label; _xblockexpression = label.startsWith("Rename "); } return _xblockexpression; }
Example #12
Source File: TmxEditorViewer.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * 关闭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; }
Example #13
Source File: AbstractSwitchLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void mousePressed(MouseEvent me) { try { IUndoableOperation c = getSwitchLaneCommand(type); OperationHistoryFactory.getOperationHistory().execute(c,null,null); me.consume(); refresh(); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #14
Source File: NattableUtil.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 添加或者取消疑问 * @param selectedRowIds * @param state * ; */ public void changIsQuestionState(List<String> selectedRowIds, String state) { IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); try { operationHistory.execute(new NeedsReviewOperation("need-review", xliffEditor.getTable(), selectedRowIds, xliffEditor.getXLFHandler(), state), null, null); } catch (ExecutionException e) { LOGGER.error("", e); MessageDialog.openError(xliffEditor.getSite().getShell(), Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage()); e.printStackTrace(); } }
Example #15
Source File: NattableUtil.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 设置是否添加到记忆库 * @param selectedRowIds * @param state * "yes" or "no"; */ public void changeSendToTmState(List<String> selectedRowIds, String state) { IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); try { operationHistory.execute(new SendTOTmOperation("send-to-tm", xliffEditor.getTable(), selectedRowIds, xliffEditor.getXLFHandler(), state), null, null); } catch (ExecutionException e) { LOGGER.error("", e); MessageDialog.openError(xliffEditor.getSite().getShell(), Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage()); e.printStackTrace(); } }
Example #16
Source File: JSEditor.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Returns current undo level. * * @return current undo level. */ private int getUndoLevel( ) { SourceViewer viewer = getViewer( ); IUndoableOperation[] history = viewer == null ? null : OperationHistoryFactory.getOperationHistory( ) .getUndoHistory( new ObjectUndoContext( viewer.getDocument( ) ) ); return history == null ? -1 : history.length; }
Example #17
Source File: UndoManager.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void dispose() { OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(historyListener); sessionManager.removeSessionLifecycleListener(sessionLifecycleListener); editorManager.getActivityProducer().removeActivityListener(activityListener); enabled = false; eclipseHistory.removeOperationApprover(operationBlocker); editorManager.removeSharedEditorListener(sharedEditorListener); }
Example #18
Source File: GMFTools.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param targetEClass * @param node * @return */ public static GraphicalEditPart convert(EClass targetEClass, final GraphicalEditPart node, ElementTypeResolver elementTypeResolver, String editorType) { TransactionalEditingDomain editingDomain = node.getEditingDomain(); final ConvertBPMNTypeCommand cmd = new ConvertBPMNTypeCommand(editingDomain, targetEClass, node, elementTypeResolver); try { OperationHistoryFactory.getOperationHistory().execute(cmd, null, null); } catch (ExecutionException e) { BonitaStudioLog.error(e); } GraphicalEditPart targetEditPart = (GraphicalEditPart) cmd.getCommandResult().getReturnValue(); return targetEditPart; }
Example #19
Source File: UpdateSizeLaneSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(final MouseEvent me) { try { final IFigure f = ((CustomMainProcessEditPart) laneEditPart.getParent().getParent().getParent()).getFigure() ; IFigure p = f ; while(!(p instanceof Viewport)){ p = p.getParent(); } final int y = ((Viewport)p).getVerticalRangeModel().getValue() ; IGraphicalEditPart targetEp = laneEditPart; if(type.equals(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT)||type.equals(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT)){ targetEp = getPoolEditPart(); } final IUndoableOperation c = new UpdatePoolSizeCommand(targetEp, type); OperationHistoryFactory.getOperationHistory().execute(c,null,null); me.consume(); laneEditPart.getViewer().setSelection(new StructuredSelection(targetEp)); refresh(); laneEditPart.getViewer().setSelection(new StructuredSelection(getHost())); ((Viewport)p).setVerticalLocation(y); } catch (final ExecutionException e) { e.printStackTrace(); } }
Example #20
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 #21
Source File: SwitchPoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public void mousePressed(MouseEvent me) { try { IUndoableOperation c = new SwitchPoolOrderCommand((IGraphicalEditPart) getHost(), type); OperationHistoryFactory.getOperationHistory().execute(c,null,null); me.consume(); refresh(); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #22
Source File: UpdateSizePoolSelectionEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void mousePressed(MouseEvent me) { try { IFigure f = ((CustomMainProcessEditPart) poolEditPart.getParent()).getFigure() ; IFigure p = f ; while(!(p instanceof Viewport)){ p = p.getParent(); } int y = ((Viewport)p).getVerticalRangeModel().getValue() ; int x = ((Viewport)p).getHorizontalRangeModel().getValue() ; IUndoableOperation c = new UpdatePoolSizeCommand(poolEditPart, type); OperationHistoryFactory.getOperationHistory().execute(c,null,null); me.consume(); poolEditPart.getViewer().setSelection(new StructuredSelection(poolEditPart)); refresh(); poolEditPart.getViewer().setSelection(new StructuredSelection(getHost())); if(type.equals(ADD_RIGHT)){ ((Viewport)p).setHorizontalLocation(x+150); } ((Viewport)p).setVerticalLocation(y); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #23
Source File: ExtractAsCallActivityHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); ExtractAsCallActivityTransactionalCommand command = new ExtractAsCallActivityTransactionalCommand(editor); OperationHistoryFactory.getOperationHistory().execute(command, null, null); CommandResult commandResult = command.getCommandResult(); if (!commandResult.getStatus().isOK()) { MessageDialog.openError(editor.getSite().getShell(), Messages.extractSubprocessError, commandResult.getStatus().getMessage()); } return commandResult.getStatus(); }
Example #24
Source File: TestEditor.java From ermaster-b with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #25
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 #26
Source File: TestEditor.java From ermasterr with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #27
Source File: ToggleShowDocumentationCommand.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public static void executeCommand(ICommand cmd) { try { OperationHistoryFactory.getOperationHistory().execute(cmd, new NullProgressMonitor(), null); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #28
Source File: AbstractSemanticModification.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void executeCommand(IUndoableOperation command, Resource resource) { IOperationHistory history = OperationHistoryFactory.getOperationHistory(); try { history.execute(command, new NullProgressMonitor(), null); } catch (ExecutionException e) { e.printStackTrace(); } }
Example #29
Source File: OrderElementControl.java From statecharts with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #30
Source File: NattableUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 添加或者取消疑问 * @param selectedRowIds * @param state * ; */ public void changIsQuestionState(List<String> selectedRowIds, String state) { IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); try { operationHistory.execute(new NeedsReviewOperation("need-review", xliffEditor.getTable(), selectedRowIds, xliffEditor.getXLFHandler(), state), null, null); } catch (ExecutionException e) { LOGGER.error("", e); MessageDialog.openError(xliffEditor.getSite().getShell(), Messages.getString("utils.NattableUtil.msgTitle2"), e.getMessage()); e.printStackTrace(); } }