private void updateActions(List<String> actionIds) { for (Iterator<String> ids = actionIds.iterator(); ids.hasNext();) { IAction action = getActionRegistry().getAction(ids.next()); if (action == null) { continue; } if (!(action instanceof UpdateAction)) { continue; } ((UpdateAction) action).update(); } }
private void updateEditMenu( IContributionManager menubar ) { IContributionItem editMenu = menubar.find( IWorkbenchActionConstants.M_EDIT ); if ( editMenu instanceof IMenuManager ) { ( (IMenuManager) editMenu ).addMenuListener( new IMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { refreshUpdateAction( ActionFactory.CUT.getId( ) ); refreshUpdateAction( ActionFactory.COPY.getId( ) ); refreshUpdateAction( ActionFactory.PASTE.getId( ) ); refreshUpdateAction( ActionFactory.DELETE.getId( ) ); } private void refreshUpdateAction( String actionId ) { if ( getActionRegistry( ) != null ) { RetargetAction action = (RetargetAction) getAction( actionId ); if ( action != null && action.getActionHandler( ) != null && action.getActionHandler( ) instanceof UpdateAction ) { ( (UpdateAction) action.getActionHandler( ) ).update( ); } } } } ); } }
/** * Updates the specified actions. * * @param actionIds * the list of ids of actions to update */ protected void updateActions( List actionIds ) { for ( Iterator ids = actionIds.iterator( ); ids.hasNext( ); ) { IAction action = getActionRegistry( ).getAction( ids.next( ) ); if ( null != action && action instanceof UpdateAction ) ( (UpdateAction) action ).update( ); } }
/** * Retrieves action item( value ) from the action registry with the given * action ID( key ). * * @param actionID * the given atcion ID. * @return The retrieved action item. */ protected IAction getAction( String actionID ) { IAction action = getActionRegistry( ).getAction( actionID ); if ( action instanceof UpdateAction ) { ( (UpdateAction) action ).update( ); } return action; }
/** * Updates the specified actions, if they are UpdateActions * * @param actionIds * the list of ids of actions to update */ public void updateActions(List actionIds) { for (Iterator ids = actionIds.iterator(); ids.hasNext();) { IAction action = getActionRegistry().getAction(ids.next()); if (null != action && action instanceof UpdateAction) ((UpdateAction) action).update(); } }
/** * Get the action extension points and register them as actions in the * graphical viewer */ private List<String> configureActionExtensions() { List<String> updateableActions = new ArrayList<>(); List<Action> actions = loadActionExtensions(); for (Action action : actions) { if (action instanceof EditorAction) ((EditorAction) action).setEditor(model.editor); actionRegistry.registerAction(action); if (action instanceof UpdateAction) updateableActions.add(action.getId()); actionExtensionIds.add(action.getId()); } return updateableActions; }
/** * A convenience method for updating a set of actions defined by the given * List of action IDs. The actions are found by looking up the ID in the * {@link #getActionRegistry() action registry}. If the corresponding action * is an {@link UpdateAction}, it will have its <code>update()</code> method * called. * * @param actionIds * the list of IDs to update */ protected void updateActions(List actionIds) { ActionRegistry registry = getActionRegistry(); Iterator iter = actionIds.iterator(); while (iter.hasNext()) { IAction action = registry.getAction(iter.next()); if (action instanceof UpdateAction) ((UpdateAction) action).update(); } }