MultiPageEditorActionBarContributor delete action [message #237703] |
Tue, 07 August 2007 07:30  |
Eclipse User |
|
|
|
Originally posted by: alexjaquet.gmail.com
Hi,
After reading a post about MultiPageEditorActionBarContributor I write
my own. Unfortunatly I could not get delete action working.
here is my code
any hints would be appreciate
regards
package com.odcgroup.page.ui.action;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.gef.ui.actions.RedoRetargetAction;
import org.eclipse.gef.ui.actions.UndoRetargetAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
/**
* Represent the multi page editor contributor
*
* @author Alexandre Jaquet
*
*/
public class MultiPageUIActionBarContributor extends
MultiPageEditorActionBarContributor {
private List globalActionKeys = new ArrayList();
private List retargetActions = new ArrayList();
private ActionRegistry registry = new ActionRegistry();
/**
* Initialization
*/
public void init(IActionBars bars) {
buildActions();
declareGlobalActionKeys();
super.init(bars);
}
/**
* Builds the actions.
*
* @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions ()
*/
protected void buildActions() {
addRetargetAction(new UndoRetargetAction());
addRetargetAction(new RedoRetargetAction());
addRetargetAction(new AddWidgetToPaletteRetargetAction());
addRetargetAction(new CompileRetargetAction());
}
/**
* Adds the retarded actions.
*
* @param action
* The action to add
*/
protected void addRetargetAction(RetargetAction action) {
addAction(action);
retargetActions.add(action);
getPage().addPartListener(action);
addGlobalActionKey(action.getId());
}
/**
* Adds global action key.
*
* @param key
* The key to add
*/
protected void addGlobalActionKey(String key) {
globalActionKeys.add(key);
}
/**
* Adds to action registry an action.
*
* @param action
* The action to add
*/
protected void addAction(IAction action) {
getActionRegistry().registerAction(action);
}
/**
* Gets the registry.
*
* @return ActionRegistry
* The registry
*/
protected ActionRegistry getActionRegistry() {
return registry;
}
/**
* Declares the global action keys.
*
* @see
org.eclipse.gef.ui.actions.ActionBarContributor#declareGloba lActionKeys()
*/
protected void declareGlobalActionKeys() {
addGlobalActionKey(ActionFactory.UNDO.getId());
addGlobalActionKey(ActionFactory.REDO.getId());
addGlobalActionKey(ActionFactory.COPY.getId());
addGlobalActionKey(ActionFactory.PASTE.getId());
addGlobalActionKey(ActionFactory.DELETE.getId());
addGlobalActionKey(ActionFactory.SELECT_ALL.getId());
}
protected IAction getAction(String id) {
return getActionRegistry().getAction(id);
}
/**
* Adds the undo and redo items to the toolbar.
*
* @param tbm The IToolBarManager
* @see
org.eclipse.ui.part.EditorActionBarContributor#contributeToT oolBar(IToolBarManager)
*/
public void contributeToToolBar(IToolBarManager tbm) {
tbm.add(getAction(ActionFactory.UNDO.getId()));
tbm.add(getAction(ActionFactory.REDO.getId()));
tbm.add(getAction(AddWidgetToPaletteAction.ID));
tbm.add(getAction(CompileAction.ID));
}
/**
* Sets the page to active status.
*
* @param activeEditor
* The active editor
*/
public void setActivePage(IEditorPart activeEditor) {
ActionRegistry registry = (ActionRegistry)
activeEditor.getAdapter(ActionRegistry.class);
IActionBars bars = getActionBars();
for (int i = 0; i < globalActionKeys.size(); i++) {
String id = (String) globalActionKeys.get(i);
bars.setGlobalActionHandler(id, registry.getAction(id));
}
getActionBars().updateActionBars();
}
}
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06580 seconds