Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2011 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
  
  package org.eclipse.xtext.ui.editor.embedded;
  
 import java.util.List;
 import java.util.Map;
 
 import  org.eclipse.core.runtime.Assert;
 import  org.eclipse.jface.action.GroupMarker;
 import  org.eclipse.jface.action.IAction;
 import  org.eclipse.jface.action.IMenuListener;
 import  org.eclipse.jface.action.IMenuManager;
 import  org.eclipse.jface.action.MenuManager;
 import  org.eclipse.jface.action.Separator;
 import  org.eclipse.jface.commands.ActionHandler;
 import  org.eclipse.jface.text.ITextOperationTarget;
 import  org.eclipse.jface.text.source.ISourceViewer;
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.custom.ST;
 import  org.eclipse.swt.custom.StyledText;
 import  org.eclipse.swt.events.DisposeEvent;
 import  org.eclipse.swt.events.DisposeListener;
 import  org.eclipse.swt.events.FocusEvent;
 import  org.eclipse.swt.events.FocusListener;
 import  org.eclipse.swt.widgets.Menu;
 import  org.eclipse.swt.widgets.Shell;
 import  org.eclipse.ui.ActiveShellExpression;
 import  org.eclipse.ui.IWorkbench;
 import  org.eclipse.ui.IWorkbenchCommandConstants;
 import  org.eclipse.ui.contexts.IContextActivation;
 import  org.eclipse.ui.contexts.IContextService;
 import  org.eclipse.ui.handlers.IHandlerActivation;
 import  org.eclipse.ui.handlers.IHandlerService;
 import  org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
 import  org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import  org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
 import  org.eclipse.ui.texteditor.IUpdate;
 import  org.eclipse.ui.texteditor.ResourceAction;
 import  org.eclipse.ui.texteditor.TextNavigationAction;
 

Author(s):
Sebastian Zarnekow - Initial contribution and API
 
 public class EmbeddedEditorActions {
 
 	public static final String EMBEDDED_TEXT_EDITOR_SCOPE = "org.eclipse.xtext.ui.embeddedTextEditorScope";
 
 	public static class Factory {
 		
 		@Inject(optional=true)
 		protected IWorkbench workbench;
 		
 		protected EmbeddedEditorActions createActions(ISourceViewer viewer) {
 			return new EmbeddedEditorActions(viewer);
 		}
 		
 	}
 	
 		// navigation
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.LINE_UP, ST.LINE_UP),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.LINE_DOWN, ST.LINE_DOWN),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.LINE_START, ST.LINE_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.LINE_END, ST.LINE_END),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.COLUMN_PREVIOUS, ST.COLUMN_PREVIOUS),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.COLUMN_NEXT, ST.COLUMN_NEXT),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.PAGE_UP, ST.PAGE_UP),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.PAGE_DOWN, ST.PAGE_DOWN),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, ST.WORD_PREVIOUS),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.WORD_NEXT, ST.WORD_NEXT),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.TEXT_START, ST.TEXT_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.TEXT_END, ST.TEXT_END),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.WINDOW_START, ST.WINDOW_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.WINDOW_END, ST.WINDOW_END),
 		// selection
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_LINE_UP, ST.SELECT_LINE_UP),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_LINE_DOWN, ST.SELECT_LINE_DOWN),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, ST.SELECT_LINE_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_LINE_END, ST.SELECT_LINE_END),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_COLUMN_PREVIOUS, ST.SELECT_COLUMN_PREVIOUS),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_COLUMN_NEXT, ST.SELECT_COLUMN_NEXT),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_PAGE_UP, ST.SELECT_PAGE_UP),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_PAGE_DOWN, ST.SELECT_PAGE_DOWN),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, ST.SELECT_WORD_PREVIOUS),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT,  ST.SELECT_WORD_NEXT),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_TEXT_START, ST.SELECT_TEXT_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_TEXT_END, ST.SELECT_TEXT_END),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_WINDOW_START, ST.SELECT_WINDOW_START),
 		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.SELECT_WINDOW_END, ST.SELECT_WINDOW_END),
 		// modification
//		new IdMapEntry(IWorkbenchCommandConstants.EDIT_CUT, ST.CUT),
//		new IdMapEntry(IWorkbenchCommandConstants.EDIT_COPY, ST.COPY),
//		new IdMapEntry(IWorkbenchCommandConstants.EDIT_PASTE, ST.PASTE),
		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS, ST.DELETE_PREVIOUS),
		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.DELETE_NEXT, ST.DELETE_NEXT),
		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, ST.DELETE_WORD_PREVIOUS),
		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, ST.DELETE_WORD_NEXT),
		// miscellaneous
		new ActionDefinitionToStyledTextAction(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, ST.TOGGLE_OVERWRITE)
	};
	protected final Map<String, IAction> allActions = Maps.newHashMap();
	protected final ISourceViewer viewer;
	protected final IWorkbench workbench;
	public EmbeddedEditorActions(ISourceViewer viewer, IWorkbench workbench) {
		this. = viewer;
		this. = workbench;
	}
	protected void initialize() {
		final List<IHandlerActivation> handlerActivations = Lists.newArrayListWithExpectedSize(3);
		final IHandlerService handlerService = (IHandlerService) .getAdapter(IHandlerService.class);
		final IContextService contextService = (IContextService) .getAdapter(IContextService.class);
		Shell shell = .getTextWidget().getShell();
		final ActiveShellExpression expression = new ActiveShellExpression(shell);
		final IContextActivation contextActivation = contextService.activateContext(expression);
		shell.addDisposeListener(new DisposeListener() {
			public void widgetDisposed(DisposeEvent e) {
				handlerService.deactivateHandlers(handlerActivations);
				contextService.deactivateContext(contextActivation);
			}
		});
		.getTextWidget().addFocusListener(new FocusListener() {
			public void focusLost(FocusEvent e) {
				handlerService.deactivateHandlers(handlerActivations);
				handlerActivations.clear();
			}
			public void focusGained(FocusEvent e) {
				for(final IAction action.values()) {
					handlerActivations.add(handlerService.activateHandler(
							action.getActionDefinitionId(), new ActionHandler(action), expressiontrue));
				}
			}
		});
		// create context menu
		MenuManager manager = new MenuManager(nullnull);
		manager.setRemoveAllWhenShown(true);
		manager.addMenuListener(new IMenuListener() {
			public void menuAboutToShow(IMenuManager mgr) {
			}
		});
		StyledText text = .getTextWidget();
		Menu menu = manager.createContextMenu(text);
		text.setMenu(menu);
		List<ActionActivationCodeactivationCodes = Lists.newArrayList();
		setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_RIGHT_TAB,'\t', -1, SWT.NONE);
		setActionActivationCode(activationCodes, ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
		.getTextWidget().addVerifyKeyListener(new ActivationCodeTrigger(activationCodes));
	}
	protected void fillContextMenu(IMenuManager menu) {
		menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, .get(ITextEditorActionConstants.UNDO));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, .get(ITextEditorActionConstants.REDO));
		menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, .get(ITextEditorActionConstants.CUT));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, .get(ITextEditorActionConstants.COPY));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, .get(ITextEditorActionConstants.PASTE));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, .get(ITextEditorActionConstants.SELECT_ALL));
		menu.add(new Separator(ITextEditorActionConstants.GROUP_GENERATE));
		menu.appendToGroup(ITextEditorActionConstants.GROUP_GENERATE, .get("ContentAssistProposal")); //$NON-NLS-1$
	}
	protected void setActionActivationCode(List<ActionActivationCodeactivationCodesString actionIDchar activationCharacterint activationKeyCodeint activationStateMask) {
		ActionActivationCode foundfindActionActivationCode(activationCodesactionID);
		if (found == null) {
			foundnew ActionActivationCode(actionID);
			activationCodes.add(found);
		}
		found.fCharacteractivationCharacter;
		found.fKeyCodeactivationKeyCode;
		found.fStateMaskactivationStateMask;
	}
		int sizeactivationCodes.size();
		for (int i= 0; i < sizei++) {
			ActionActivationCode codeactivationCodes.get(i);
			if (actionID.equals(code.fActionId))
				return code;
		}
		return null;
	}
	protected void createActions() {
		StyledText textWidget.getTextWidget();
		for (int i= 0; i < .i++) {
			IAction actionnew TextNavigationAction(textWidgetentry.getAction());
			action.setActionDefinitionId(entry.getActionId());
			setAction(entry.getActionId(), action);
		}
		ResourceAction action;
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Undo.", ITextOperationTarget.UNDO); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.UNDO_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
		setAction(ITextEditorActionConstants.UNDO, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Redo.", ITextOperationTarget.REDO); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.REDO_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);
		setAction(ITextEditorActionConstants.REDO, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Cut.", ITextOperationTarget.CUT); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_CUT);
		setAction(ITextEditorActionConstants.CUT, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Copy.", ITextOperationTarget.COPY, true); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_COPY);
		setAction(ITextEditorActionConstants.COPY, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Paste.", ITextOperationTarget.PASTE); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_PASTE);
		setAction(ITextEditorActionConstants.PASTE, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.Delete.", ITextOperationTarget.DELETE); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_ACTION);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
		setAction(ITextEditorActionConstants.DELETE, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLine.".false); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE);
		setAction(ITextEditorActionConstants.DELETE_LINE, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.CutLine.".true); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE);
		setAction(ITextEditorActionConstants.CUT_LINE, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToBeginning.".false); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_BEGINNING_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_BEGINNING);
		setAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToBeginning.".true); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_BEGINNING_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_BEGINNING);
		setAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.DeleteLineToEnd.".false); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_END_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_END);
		setAction(ITextEditorActionConstants.DELETE_LINE_TO_END, action);
		actionnew TextViewerDeleteLineAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.CutLineToEnd.".true); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_END_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_END);
		setAction(ITextEditorActionConstants.CUT_LINE_TO_END, action);
		actionnew TextViewerJoinLinesAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.JoinLines."" "); //$NON-NLS-1$ //$NON-NLS-2$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.JOIN_LINES_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.JOIN_LINES);
		setAction(ITextEditorActionConstants.JOIN_LINES, action);
		actionnew TextViewerMarkAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.SetMark.".); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.SET_MARK_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SET_MARK);
		setAction(ITextEditorActionConstants.SET_MARK, action);
		actionnew TextViewerMarkAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.ClearMark.".); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.CLEAR_MARK_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CLEAR_MARK);
		setAction(ITextEditorActionConstants.CLEAR_MARK, action);
		actionnew TextViewerMarkAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.SwapMark.".); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.SWAP_MARK_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SWAP_MARK);
		setAction(ITextEditorActionConstants.SWAP_MARK, action);
		actionnew TextViewerShiftAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.ShiftRight.", ITextOperationTarget.SHIFT_RIGHT); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_RIGHT_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
		setAction(ITextEditorActionConstants.SHIFT_RIGHT, action);
		actionnew TextViewerShiftAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.ShiftRight.", ITextOperationTarget.SHIFT_RIGHT) { //$NON-NLS-1$
			public void update() {
			}
		};
		action.setActionDefinitionId(ITextEditorActionConstants.SHIFT_RIGHT_TAB);
		setAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, action);
		actionnew TextViewerShiftAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.ShiftLeft.", ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_LEFT_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
		setAction(ITextEditorActionConstants.SHIFT_LEFT, action);
		action = new TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.ContentAssist.", ISourceViewer.CONTENTASSIST_PROPOSALS);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
		setAction(ITextEditorActionConstants.CONTENT_ASSIST, action);
		action = new TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.SelectAll.", ITextOperationTarget.SELECT_ALL);
		action.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_SELECT_ALL);
		setAction(ITextEditorActionConstants.SELECT_ALL, action);
		actionnew TextViewerMoveLinesAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesUp."truefalse); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
		setAction(ITextEditorActionConstants.MOVE_LINE_UP, action);
		actionnew TextViewerMoveLinesAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.MoveLinesDown."falsefalse); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
		setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action);
		actionnew TextViewerMoveLinesAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineUp."truetrue); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
		setAction(ITextEditorActionConstants.COPY_LINE_UP, action);
		actionnew TextViewerMoveLinesAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.CopyLineDown."falsetrue); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
		setAction(ITextEditorActionConstants.COPY_LINE_DOWN, action);
		actionnew TextViewerOperationAction(EmbeddedEditorMessages.getBundleForConstructedKeys(), "Editor.QuickAssist.", ISourceViewer.QUICK_ASSIST); //$NON-NLS-1$
		action.setHelpContextId(IAbstractTextEditorHelpContextIds.QUICK_ASSIST_ACTION);
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
		setAction(ITextEditorActionConstants.QUICK_ASSIST, action);
	}
	protected void setAction(String actionIDfinal IAction action) {
		Assert.isNotNull(actionID);
		if (action == null) {
			.remove(actionID);
else {
			if (action.getId() == null)
				action.setId(actionID); // make sure the action ID has been set
			.put(actionIDaction);
		}
	}
	protected IAction get(String actionId) {
		return .get(actionId);
	}
	protected void updateAllActions() {
		for(IAction action.values()) {
			update(action);
		}
	}
	protected void updateSelectionDependentActions() {
	}
	protected void updateAction(String actionId) {
		IAction action = get(actionId);
		update(action);
	}
	private void update(IAction action) {
		if (action instanceof IUpdate)
			((IUpdate) action).update();
	}
New to GrepCode? Check out our FAQ X