下面列出了怎么用org.eclipse.ui.operations.UndoRedoActionGroup的API类实例代码及写法,或者点击链接到github查看源代码。
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)
});
}
/**
* 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);
}
/**
* 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);
}
/**
* 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());
}
}
/**
* 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();
}
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);
}
@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);
}
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);
}
@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);
}
public void init(ICommonActionExtensionSite anActionSite) {
IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
.getWorkspace().getAdapter(IUndoContext.class);
undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
workspaceContext, true);
}
public void init(ICommonActionExtensionSite anActionSite) {
IUndoContext workspaceContext = (IUndoContext) ResourcesPlugin
.getWorkspace().getAdapter(IUndoContext.class);
undoRedoGroup = new UndoRedoActionGroup(((ICommonViewerWorkbenchSite) anActionSite.getViewSite()).getSite(),
workspaceContext, true);
}