org.eclipse.core.commands.operations.IOperationHistory Java Examples

The following examples show how to use org.eclipse.core.commands.operations.IOperationHistory. 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: TmxEditorViewer.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 关闭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 #2
Source File: AddTuHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
@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: UndoCommandHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #4
Source File: ProblemHoverTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testBug357516_bookmark() throws Exception {
	IResource resource = editor.getResource();
	HashMap<String, Object> attributes = new HashMap<String, Object>();
	attributes.put(IMarker.MESSAGE, CUSTOM_MARKER_TEST_MESSAGE);
	attributes.put(IMarker.LINE_NUMBER, 1);
	attributes.put(IMarker.LOCATION, resource.getFullPath().toPortableString());
	IUndoableOperation operation= new CreateMarkersOperation(IMarker.BOOKMARK, attributes, resource, CUSTOM_MARKER_TEST_MESSAGE);
	IOperationHistory operationHistory= PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
	try {
		operationHistory.execute(operation, null, null);
	} catch (ExecutionException x) {
		fail(x.getMessage());
	}
	String hoverInfo = hover.getHoverInfo(editor.getInternalSourceViewer(), 0);
	assertNotNull(hoverInfo);
	assertTrue(hoverInfo.contains(CUSTOM_MARKER_TEST_MESSAGE));
}
 
Example #5
Source File: HistoricizingDomain.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Sets the {@link IOperationHistory} that is used by this
 * {@link HistoricizingDomain} to the given value. Operation history
 * listeners are un-/registered accordingly.
 *
 * @param operationHistory
 *            The new {@link IOperationHistory} for this domain.
 */
@Inject
public void setOperationHistory(IOperationHistory operationHistory) {
	if (this.operationHistory != null
			&& this.operationHistory != operationHistory) {
		this.operationHistory
				.removeOperationHistoryListener(transactionListener);
	}
	if (this.operationHistory != operationHistory) {
		this.operationHistory = operationHistory;
		if (this.operationHistory != null) {
			this.operationHistory
					.addOperationHistoryListener(transactionListener);
			if (undoContext != null) {
				this.operationHistory.setLimit(undoContext,
						DEFAULT_UNDO_LIMIT);
			}
		}
	}
}
 
Example #6
Source File: DeleteTuHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
@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 #7
Source File: WaitForRefactoringCondition.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@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 #8
Source File: MvcFxUiModule.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #9
Source File: SetEntryKindCommand.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
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 #10
Source File: CreateSubdiagramCommand.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void executeCommand(AbstractTransactionalCommand operation) {
	IOperationHistory history = OperationHistoryFactory.getOperationHistory();
	try {
		history.execute(operation, new NullProgressMonitor(), null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
}
 
Example #11
Source File: FitToViewportLockAction.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Disables all viewport listeners that react to scroll offset, viewport
 * transformation, or viewport-/scrollable-/content-bounds changes.
 */
protected void disableViewportListeners() {
	infiniteCanvas.horizontalScrollOffsetProperty()
			.removeListener(scrollOffsetChangeListener);
	infiniteCanvas.verticalScrollOffsetProperty()
			.removeListener(scrollOffsetChangeListener);
	contentTransform.removeEventHandler(
			TransformChangedEvent.TRANSFORM_CHANGED, trafoChangeListener);
	contentBoundsProperty.removeListener(contentBoundsChangeListener);
	infiniteCanvas.widthProperty().removeListener(sizeChangeListener);
	infiniteCanvas.heightProperty().removeListener(sizeChangeListener);

	IDomain domain = getViewer().getDomain();
	if (domain instanceof HistoricizingDomain) {
		IOperationHistory history = ((HistoricizingDomain) domain)
				.getOperationHistory();
		history.removeOperationHistoryListener(operationHistoryListener);
	}
}
 
Example #12
Source File: FitToViewportLockAction.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Enables all viewport listeners that react to scroll offset, viewport
 * transformation, or viewport-/scrollable-/content-bounds changes.
 * <p>
 * Moreover, stores the content bounds size, so that the size can later be
 * tested for changes.
 */
protected void enableViewportListeners() {
	infiniteCanvas.horizontalScrollOffsetProperty()
			.addListener(scrollOffsetChangeListener);
	infiniteCanvas.verticalScrollOffsetProperty()
			.addListener(scrollOffsetChangeListener);
	contentTransform.addEventHandler(
			TransformChangedEvent.TRANSFORM_CHANGED, trafoChangeListener);
	contentBoundsProperty.addListener(contentBoundsChangeListener);
	infiniteCanvas.widthProperty().addListener(sizeChangeListener);
	infiniteCanvas.heightProperty().addListener(sizeChangeListener);

	IDomain domain = getViewer().getDomain();
	if (domain instanceof HistoricizingDomain) {
		IOperationHistory history = ((HistoricizingDomain) domain)
				.getOperationHistory();
		history.addOperationHistoryListener(operationHistoryListener);
	}
}
 
Example #13
Source File: UndoablePropertySheetEntry.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #14
Source File: UndoablePropertySheetPage.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * 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 #15
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
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 #16
Source File: XLIFFEditorActionHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@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 #17
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #18
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
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 #19
Source File: UpdateDataCommandHandler.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected boolean doCommand(UpdateDataCommand command) {
	IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory();
	try {
		UpdateDataOperation op = new UpdateDataOperation(table, bodyLayerStack, command);
		op.addContext(PlatformUI.getWorkbench().getOperationSupport().getUndoContext());
		operationHistory.execute(op, null, null);
	} catch (ExecutionException e) {
		e.printStackTrace();
	}
	return true;
}
 
Example #20
Source File: XLIFFEditorActionHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
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 #21
Source File: NattableUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 添加或者取消疑问
 * @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 #22
Source File: CellEditorGlobalActionHanlder.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #23
Source File: NattableUtil.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 添加或者取消疑问
 * @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 #24
Source File: NattableUtil.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 设置是否添加到记忆库
 * @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 #25
Source File: UndoManager.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IStatus proceedRedoing(
    final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {

  if (!enabled) return Status.OK_STATUS;

  if (currentActiveEditor == null) {
    log.info("Redo called on an unknown editor");
    return Status.OK_STATUS;
  }

  if (log.isDebugEnabled()) log.debug(opInfo(operation));

  if (operation.getLabel().equals(TYPING_LABEL)
      || operation.getLabel().equals(NullOperation.LABEL)) {

    updateCurrentLocalAtomicOperation(null);
    storeCurrentLocalOperation();

    SWTUtils.runSafeSWTSync(
        log,
        new Runnable() {
          @Override
          public void run() {
            log.debug("redoing operation " + operation);
            redo(currentActiveEditor);

            /*
             * For reactivating redo an undo has to be simulated, so
             * the Eclipse history knows, there is something to
             * redo.
             */
            if (undoHistory.canRedo(currentActiveEditor)) simulateUndo();
          }
        });
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}
 
Example #26
Source File: UndoManager.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public IStatus proceedUndoing(
    final IUndoableOperation operation, IOperationHistory history, IAdaptable info) {

  if (!enabled) return Status.OK_STATUS;

  if (currentActiveEditor == null) {
    log.info("Undo called on an unknown editor");
    return Status.OK_STATUS;
  }

  if (log.isDebugEnabled()) log.debug(opInfo(operation));

  if (operation.getLabel().equals(TYPING_LABEL)) {
    updateCurrentLocalAtomicOperation(null);
    storeCurrentLocalOperation();

    SWTUtils.runSafeSWTSync(
        log,
        new Runnable() {
          @Override
          public void run() {
            log.debug("undoing operation " + operation);
            undo(currentActiveEditor);

            if (undoHistory.canRedo(currentActiveEditor)) simulateUndo();
          }
        });
    return Status.CANCEL_STATUS;
  }
  return Status.OK_STATUS;
}
 
Example #27
Source File: MoveConnectorWizard.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public MoveConnectorWizard(final IOperationHistory operationHistory,
        final TransactionalEditingDomain editingDomain,
        final Collection<Connector> connectorsToMove) {
    checkArgument(connectorsToMove != null && !connectorsToMove.isEmpty(), "connectorsToMove cannot be null or empty");
    this.connectorsToMove = connectorsToMove;
    sourceProcess = sourceProcess();
    this.editingDomain = editingDomain;
    this.operationHistory = operationHistory;
    targetLocation = new WritableValue(sourceConnectableElement(), ConnectableElement.class);
    connectorEventObservable = new WritableValue(connectorEvent(), String.class);
}
 
Example #28
Source File: MoveConnectorWizardTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_add_a_MoveConnectorWizardPage() throws Exception {
    final MoveConnectorWizard wizard = new MoveConnectorWizard(mock(IOperationHistory.class), mock(TransactionalEditingDomain.class),
            newArrayList(aConnector().in(aPool()).build()));

    wizard.addPages();

    assertThat(wizard.getPage(MoveConnectorWizardPage.class.getName())).isNotNull();
}
 
Example #29
Source File: MoveConnectorWizardTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_execute_ChangeConnectorContainerCommand_on_finish() throws Exception {
    final IOperationHistory operationHistory = mock(IOperationHistory.class);
    final MoveConnectorWizard wizard = new MoveConnectorWizard(operationHistory, mock(InternalTransactionalEditingDomain.class),
            newArrayList(aConnector().in(aPool()).build()));

    wizard.addPages();
    wizard.performFinish();

    verify(operationHistory).execute(notNull(IUndoableOperation.class), any(IProgressMonitor.class), any(IAdaptable.class));
}
 
Example #30
Source File: ProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated BonitaSoft
* Open intro if all editors are closed.
* Force OperationHistory to be cleaned.
*/
@Override
public void dispose() {
	TransactionalEditingDomain domain = getEditingDomain();
	if (processPref != null) {
		processPref.removePropertyChangeListener(paletteChangeListener);
	}
	IOperationHistory history = (IOperationHistory) getAdapter(IOperationHistory.class);
	if (history != null) {
		history.dispose(getUndoContext(), true, true, true);
	}
	super.dispose();

	//Remove event broker listener for editingDomain
	if (domain != null) {
		final DiagramEventBroker eventBroker = DiagramEventBroker.getInstance(domain);
		if (eventBroker != null) {
			DiagramEventBroker.stopListening(domain);
		}
		domain = null;
	}

	//avoid Memory leak
	if (getDiagramGraphicalViewer() != null) {
		getDiagramGraphicalViewer().deselectAll();
		if (getDiagramGraphicalViewer().getVisualPartMap() != null) {
			getDiagramGraphicalViewer().getVisualPartMap().clear();
		}
		if (getDiagramGraphicalViewer().getEditPartRegistry() != null) {
			getDiagramGraphicalViewer().getEditPartRegistry().clear();
		}
	}

	//GMF bug, avoid memory leak
	final RulerComposite rulerComposite = getRulerComposite();
	if (rulerComposite != null) {
		rulerComposite.dispose();
	}
}