org.eclipse.ui.operations.UndoRedoActionGroup Java Examples

The following examples show how to use org.eclipse.ui.operations.UndoRedoActionGroup. 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: JavaEditorBreadcrumbActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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 #2
Source File: AbstractFXEditor.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates the actions for this editor and registers them in the editor's
 * site action bar.
 *
 */
protected void createActions() {
	undoRedoActionGroup = new UndoRedoActionGroup(getSite(),
			(IUndoContext) getAdapter(IUndoContext.class), true);

	deleteAction = new DeleteAction();
	getContentViewer().setAdapter(deleteAction);

	selectAllAction = new SelectAllAction();
	getContentViewer().setAdapter(selectAllAction);
}
 
Example #3
Source File: AbstractFXView.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create actions for this view and registers at the action bars of the
 * view's site.
 */
protected void createActions() {
	IViewSite site = getViewSite();
	IActionBars actionBars = site.getActionBars();
	undoRedoActionGroup = new UndoRedoActionGroup(getSite(),
			(IUndoContext) getAdapter(IUndoContext.class), true);
	undoRedoActionGroup.fillActionBars(actionBars);

	deleteAction = new DeleteAction();
	getContentViewer().setAdapter(deleteAction);
	actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(),
			deleteAction);

	selectAllAction = new SelectAllAction();
	getContentViewer().setAdapter(selectAllAction);
	actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(),
			selectAllAction);

	zoomActionGroup = new ZoomActionGroup(new FitToViewportAction());
	getContentViewer().setAdapter(zoomActionGroup);
	fitToViewportActionGroup = new FitToViewportActionGroup();
	getContentViewer().setAdapter(fitToViewportActionGroup);
	scrollActionGroup = new ScrollActionGroup();
	getContentViewer().setAdapter(scrollActionGroup);

	IToolBarManager mgr = actionBars.getToolBarManager();
	zoomActionGroup.fillActionBars(actionBars);
	mgr.add(new Separator());
	fitToViewportActionGroup.fillActionBars(actionBars);
	mgr.add(new Separator());
	scrollActionGroup.fillActionBars(actionBars);
}
 
Example #4
Source File: FXEditorActionBarContributor.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Registers undo and redo action handlers for the given target editor. The
 * target editor is adapted for an {@link UndoRedoActionGroup}, which is
 * used to fill the action bars.
 *
 * @param targetEditor
 *            The editor to register undo and redo action handlers for.
 */
protected void registerUndoRedoActions(final IEditorPart targetEditor) {
	// XXX: IAdaptable.getAdapter() has been 'generified' with Mars.
	// However, to maintain backwards compatibility with Luna, we need to
	// explicitly cast here.
	final UndoRedoActionGroup undoRedoActionGroup = (UndoRedoActionGroup) targetEditor
			.getAdapter(UndoRedoActionGroup.class);
	if (undoRedoActionGroup != null) {
		undoRedoActionGroup.fillActionBars(getActionBars());
	}
}
 
Example #5
Source File: RefactorActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a new <code>RefactorActionGroup</code>. The group requires
 * that the selection provided by the part's selection provider is of type <code>
 * org.eclipse.jface.viewers.IStructuredSelection</code>.
 *
 * @param part the view part that owns this action group
 */
public RefactorActionGroup(IViewPart part) {
	this(part.getSite(), null);

	IUndoContext workspaceContext= (IUndoContext)ResourcesPlugin.getWorkspace().getAdapter(IUndoContext.class);
	fUndoRedoActionGroup= new UndoRedoActionGroup(part.getViewSite(), workspaceContext, true);

	installQuickAccessAction();
}
 
Example #6
Source File: XLIFFEditorImplWithNatTable.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void initializeOperationHistory() {
	// create a unique undo context to
	// represent this view's undo history
	undoContext = new ObjectUndoContext(this);

	// set the undo limit for this context based on the preference
	HISTORY.setLimit(undoContext, 99);

	// 初始化“重做、”“撤销”菜单项
	undoRedoGroup = new UndoRedoActionGroup(getSite(), undoContext, true);
}
 
Example #7
Source File: TmxEditorViewer.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IViewSite site) throws PartInitException {
	super.init(site);
	this.openCloseListener = new ArrayList<TmxEditorOpenCloseListener>();
	undoRedoActionGroup = new UndoRedoActionGroup(getSite(), getSite().getWorkbenchWindow().getWorkbench()
			.getOperationSupport().getUndoContext(), true);
	PlatformUI.getWorkbench().addWorkbenchListener(workbenchListener);
}
 
Example #8
Source File: XLIFFEditorImplWithNatTable.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void initializeOperationHistory() {
	// create a unique undo context to
	// represent this view's undo history
	undoContext = new ObjectUndoContext(this);

	// set the undo limit for this context based on the preference
	HISTORY.setLimit(undoContext, 99);

	// 初始化“重做、”“撤销”菜单项
	undoRedoGroup = new UndoRedoActionGroup(getSite(), undoContext, true);
}
 
Example #9
Source File: AbstractFXEditor.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@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
	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();
		}
	}
	if (UndoRedoActionGroup.class.equals(key)) {
		// used by action bar contributor
		return undoRedoActionGroup;
	}
	if (DeleteAction.class.equals(key)) {
		// used by action bar contributor
		return deleteAction;
	}
	if (SelectAllAction.class.equals(key)) {
		// used by action bar contributor
		return selectAllAction;
	}
	return super.getAdapter(key);
}
 
Example #10
Source File: UndoRedoActionProvider.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
public void init(ICommonActionExtensionSite anActionSite) {
	IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
			.getWorkspace().getAdapter(IUndoContext.class);
	undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
			workspaceContext, true);
}
 
Example #11
Source File: UndoRedoActionProvider.java    From tmxeditor8 with GNU General Public License v2.0 4 votes vote down vote up
public void init(ICommonActionExtensionSite anActionSite) {
	IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
			.getWorkspace().getAdapter(IUndoContext.class);
	undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
			workspaceContext, true);
}