1 / 22

org.eclipse.jface.action-api

org.eclipse.jface.action-api. org.eclipse.jface.action. Provides support for shared UI resources such as menus, tool bars, and status lines. . Package Specification. Contribution managers

sydney
Download Presentation

org.eclipse.jface.action-api

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. org.eclipse.jface.action-api org.eclipse.jface.action Provides support for shared UI resources such as menus, tool bars, and status lines.

  2. Package Specification • Contribution managers • coordinate contributions to shared UI resources such as menus, menu bars, tool bars, and status lines. • maintains the contributions as a dynamic list of contribution items (IContributionItems). • Separators (Separator) can be included in contribution lists to break up the list's visual representation. • contribution lists can be organized into named groups via special group markers (GroupMarker) to facilitate programatic insertion at specific positions within the list. • Three specific contribution managers are provided: • a hierarchical menu manager (MenuManager). • a tool bar manager (ToolBarManager), and • a status line manager (StatusLineManager),

  3. Actions • Actions (IAction) • are commands which can be triggered from the UI, like the ones found in menus, toolbars, and buttons. • Menus and tools bars are typically populated with contribution items that delegate to actions (ActionContributionItem).

  4. IContributionItem • represents a contribution to a shared UI resource such as a menu or tool bar. • managed by a contribution manager. • For instance, • in a tool bara contribution item is a tool bar button or a separator. • In a menu bar a contribution item is a menu, and • in a menu a contribution item is a menu item or separator. • can realize itself in different SWT widgets, using the different fill methods. • can be used in different types of managers such as a MenuBarManager, a ToolBarManager, or a StatusLineManager. • internal api to the framework!!

  5. IContributionManager • A contribution manager organizes contributions to such UI components as menus, toolbars and status lines. • A contribution manager keeps track of a list of contribution items. • Each contribution item may has an optional identifier, which can be used to retrieve items from a manager, and for positioning items relative to each other. • The list of contribution items can be subdivided into named groupsusing special contribution items that serve as group markers.

  6. IContributionItem • fill(Composite parent) • Fills the given composite control with controls representing this contribution item.   • fill(CoolBar | Menu | ToolBar parent, int index) • Fills the given parent cool bar (menu, tool bar) with controls representing this contribution item.  index = -1 => append. • boolean isDirty(),isDynamic(), isEnabled(boolean), is/setVisible([boolean]) , isGroupMarker() , isSeparator() • Returns whether this contribution item is dirty (, dynamiv, visible in its manager,… ). • A dynamic contribution item contributes items conditionally, dependent on some internal state.

  7. getId() :String • return the id of this item • dispose() • Disposes of this contribution item. Called by the parent manager when the manager is being disposed. Clients should not call this method directly. • saveWidgetState() • Saves any state information of the control(s) owned by this contribution item.   • setParent(IContributionManager parent) • Sets the parent manager of this item void • update([Strign id] ) • Updates any SWT controls cached by this contribution item with any changes (for the given id property) which have been made to this contribution item since the last update.

  8. ContributionItem • implements IContributionItem • constructors: • ContributionItem([String id]) ; • IContributionManagergetParent() • Returns null if it has no contribution manager. • String toString()

  9. possible implementations • Separator  IContributionItem { … publicvoid fill(Menu menu, int index) { if (index >= 0) { new MenuItem(menu, SWT.SEPARATOR, index); } else { new MenuItem(menu, SWT.SEPARATOR); } } publicvoid fill(ToolBar toolbar, int index) { if (index >= 0) { new ToolItem(toolbar, SWT.SEPARATOR, index); } else { new ToolItem(toolbar, SWT.SEPARATOR); } }

  10. IContritutionManager • provides general protocol for adding, removing, and retrieving contribution items. • provides convenience methods to contribute actions. • should be implemented by all objects that wish to manage contributions. • known Implementions in this package, • MenuManager, • ToolBarManager • StatusLineManager

  11. IContributionManager • item management • add items : • add(IContributionItem | Action ) • append/prependToGroup(String groupName, IAction | IContributionItem ) • append or prepend the given item [for the action ] to the end [start] of the named group. • insertAfter/Before( String itemName, IAction | IContributionItem ). • remove items : • IContributinoItem remove(String id | IContributinoItem ) • removeAll() ;

  12. item query • IContributionItemfind(String id) • Finds the contribution item with the given id.  • IContributionItem[]getItems() • Returns all known contribution items. • boolean isEmpty() • voidmarkDirty() , isDirty(), update(boolean force) • Marks this contribution manager as dirty. • Returns whether the list of contributions is dirty. • Updates this manager's underlying widget(s) with any changes made to it or its items. • Normally changes to a contribution manager merely mark it as dirty, without updating the underlying widgets. This brings the underlying widgets up to date with any changes. • IContributionManagerOverridesgetOverrides() • The ContributionManager implementation of this method declared on IContributionManager returns the current overrides.

  13. abstract ContributionManager • implements IContributionManager • This class • maintains a list of contribution items and a dirty flag. • coalesces adjacent separators, hides beginning and ending separators. • deals with dynamically changing sets of contributions. • When the set of contributions does change dynamically, the changes are propagated to the control via the update method, which subclasses must implement. • Note: A ContributionItem cannot be shared between different ContributionManagers. • Construcotor: protected ContributionManager();

  14. protected  booleanallowItem(IContributionItem) • allows subclasses to prevent certain items in the contributions list. • protected  booleanhasDynamicItems() • Returns whether this contribution manager contains dynamic items. • [protected] indexOf(ICOntributinoItem | String id) • insert(int index, IContributionItem item) • Insert the item at the given index. • protected voidinternalSetItems(IContributionItem[] items) • An internal method for setting the order of the contribution items. • booleanreplaceItem(String id, IContributionItemnewIem) • Replaces the item of the given id with another contribution item. • setOverrides(IContributionManagerOverrides newOverrides) • Sets the overrides for this contribution manager • protected  itemAdded(IContributionItem item) ,itemRemoved(IContributionItem item) • The given item was added/removed to/from the list of contributions. mark the manager as dirty and updates the number of dynamic items, and the memento.

  15. Interface IContributionManagerOverrides • used by IContributionItem to determine if the values for certain properties have been overriden by their manager. • This interface is internal to the framework. • Method summary • IntegergetAccelerator(IContributionItem item), • StringgetAcceleratorText(IContributionItem item), • StringgetText(IContributionItem item) • not intended to be called outside of the workbench. • deprecated in 3.1.   • BooleangetEnabled(IContributionItem item) • Boolean.TRUE if the given contribution item should be enabled, • Boolean.FALSE if the item should be disabled, and • null if the item may determine its own enablement. 

  16. IAction • An action represents the non-UI side of a command which can be triggered by the end user. • Actions are typically associated with buttons, menu items, and items in tool bars. • The controls for a command are built by some container, which furnished the context where these controls appear and configures them with data from properties declared by the action. • When the end user triggers the command via its control, the action's run method is invoked to do the real work. • Actions support a predefined set of properties (and possibly others as well). • Clients of an action may register property change listeners so that they get notified whenever the value of a property changes.

  17. Clients should subclass the abstract base class Action to define concrete actions rather than implementing IAction from scratch. • This interface exists only to define the API for actions. It is not intended to be implemented by clients.

  18. IMenuManager • IContributionManager, IContributionItem • provides protocol for managing contributions to a menu bar and its sub menus. • An IMenuManager is also an IContributionItem, allowing sub-menus to be nested in parent menus. • internal to the framework; not to be implemented outside the framework. • concrete menu manager implementation • MenuManager.

  19. IMenuManager • MenuEvent source • add/removeMenuListener(MenuListner). • IMenuManagerfindMenuUsingPath(String path) • IContributionItemfindUsingPath(String path) • Finds the contribution item at the given path. • Finds the manager for the menu at the given path.   • path format: item_id (“/” item_id)* . • boolean get/setRemoveAllWhenShown(boolean) • Returns whether all items should be removed when the menu is about to show, but before notifying menu listeners. The default is false.

  20. MenuManager • extends ContributionManager (IMenuManager ) • A menu manager realizes itself and its items in a menu control; either as • a menu bar, • a sub-menu, or • a context menu. • This class may be instantiated; it may also be subclassed. • Constructors: • MenuManager([String text [, String id]]) • Creates a menu manager with the given text and id.

  21. MenucreateContextMenu(Control parent) • Creates and returns an SWT context menu control for this menu, and installs all registered contributions. • MenucreateMenuBar(Decorations parent) • Creates and returns an SWT menu bar control for this menu, for use in the given Decorations, and installs all registered contributions.   • MenucreateMenuBar(Shell parent) • Deprecated.use (2) instead.

  22. MenugetMenu() • Returns the SWT menu control for this menu manager.  • StringgetMenuText() • Returns the text shown in the menu.

More Related