Java Code Examples for org.eclipse.core.commands.operations.IOperationHistory#dispose()

The following examples show how to use org.eclipse.core.commands.operations.IOperationHistory#dispose() . 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: 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 2
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 3
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 4
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();
	}
}