Package org.eclipse.ui.actions
Class PerspectiveMenu
java.lang.Object
org.eclipse.jface.action.ContributionItem
org.eclipse.ui.actions.PerspectiveMenu
- All Implemented Interfaces:
IContributionItem
- Direct Known Subclasses:
ChangeToPerspectiveMenu,OpenNewPageMenu,OpenNewWindowMenu,OpenPerspectiveMenu
A menu for perspective selection.
A PerspectiveMenu is used to populate a menu with perspective
shortcut items. If the user selects one of these items an action is performed
for the selected perspective.
The visible perspective items within the menu are dynamic and reflect the available set generated by each subclass. The default available set consists of the perspective shortcut list of the current perspective.
This class is abstract. Subclasses must implement the run
method, which performs a specialized action for the selected perspective.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPerspectiveMenu(IWorkbenchWindow window, String id) Constructs a new instance ofPerspectiveMenu. -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()The default implementation of thisIContributionItemmethod does nothing.voidThe default implementation of thisIContributionItemmethod does nothing.protected ArrayList<IPerspectiveDescriptor>Returns the available list of perspectives to display in the menu.protected booleanReturns whether the menu item representing the active perspective will have a check mark.protected IWorkbenchWindowReturns the window for this menu.booleanisDirty()The default implementation of thisIContributionItemmethod returnsfalse.booleanThe default implementation of thisIContributionItemmethod returnsfalse.protected abstract voidrun(IPerspectiveDescriptor desc) Runs an action for a particular perspective.protected voidrun(IPerspectiveDescriptor desc, SelectionEvent event) Runs an action for a particular perspective.protected voidshowActive(boolean b) Sets the showActive flag.Methods inherited from class org.eclipse.jface.action.ContributionItem
fill, fill, fill, getId, getParent, isEnabled, isGroupMarker, isSeparator, isVisible, saveWidgetState, setId, setParent, setVisible, toString, update, update
-
Field Details
-
SHOW_PERSP_ID
Deprecated.As of 3.5, replaced byIWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE- Since:
- 3.4
- See Also:
-
-
Constructor Details
-
PerspectiveMenu
Constructs a new instance ofPerspectiveMenu.- Parameters:
window- the window containing this menuid- the menu id
-
-
Method Details
-
fill
Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod does nothing. Subclasses may override.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem- Parameters:
menu- the parent menuindex- the index where the controls are inserted, or-1to insert at the end
-
getPerspectiveItems
Returns the available list of perspectives to display in the menu.By default, the list contains the perspective shortcuts for the current perspective.
Subclasses can override this method to return a different list.
- Returns:
- an
ArrayListof perspective itemsIPerspectiveDescriptor
-
getShowActive
protected boolean getShowActive()Returns whether the menu item representing the active perspective will have a check mark.- Returns:
trueif a check mark is shown,falseotherwise
-
getWindow
Returns the window for this menu.- Returns:
- the window
-
isDirty
public boolean isDirty()Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod returnsfalse. Subclasses may override.- Specified by:
isDirtyin interfaceIContributionItem- Overrides:
isDirtyin classContributionItem- Returns:
trueif this item is dirty
-
isDynamic
public boolean isDynamic()Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod returnsfalse. Subclasses may override.- Specified by:
isDynamicin interfaceIContributionItem- Overrides:
isDynamicin classContributionItem- Returns:
trueif this item is dynamic, andfalsefor normal items
-
run
Runs an action for a particular perspective. The behavior of the action is defined by the subclass.- Parameters:
desc- the selected perspective
-
run
Runs an action for a particular perspective. The behavior of the action is defined by the subclass. By default, this just callsrun(IPerspectiveDescriptor).- Parameters:
desc- the selected perspectiveevent- SelectionEvent - the event send along with the selection callback
-
showActive
protected void showActive(boolean b) Sets the showActive flag. IfshowActive == truethen the active perspective is hilighted with a check mark.- Parameters:
b- the new showActive flag
-
dispose
public void dispose()Description copied from class:ContributionItemThe default implementation of thisIContributionItemmethod does nothing. Subclasses may override.- Specified by:
disposein interfaceIContributionItem- Overrides:
disposein classContributionItem
-
IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE