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
-
Constructor Summary
ConstructorDescriptionPerspectiveMenu
(IWorkbenchWindow window, String id) Constructs a new instance ofPerspectiveMenu
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
The default implementation of thisIContributionItem
method does nothing.void
The default implementation of thisIContributionItem
method does nothing.protected ArrayList<IPerspectiveDescriptor>
Returns the available list of perspectives to display in the menu.protected boolean
Returns whether the menu item representing the active perspective will have a check mark.protected IWorkbenchWindow
Returns the window for this menu.boolean
isDirty()
The default implementation of thisIContributionItem
method returnsfalse
.boolean
The default implementation of thisIContributionItem
method returnsfalse
.protected abstract void
run
(IPerspectiveDescriptor desc) Runs an action for a particular perspective.protected void
run
(IPerspectiveDescriptor desc, SelectionEvent event) Runs an action for a particular perspective.protected void
showActive
(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:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
menu
- the parent menuindex
- the index where the controls are inserted, or-1
to 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
ArrayList
of perspective itemsIPerspectiveDescriptor
-
getShowActive
protected boolean getShowActive()Returns whether the menu item representing the active perspective will have a check mark.- Returns:
true
if a check mark is shown,false
otherwise
-
getWindow
Returns the window for this menu.- Returns:
- the window
-
isDirty
public boolean isDirty()Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method returnsfalse
. Subclasses may override.- Specified by:
isDirty
in interfaceIContributionItem
- Overrides:
isDirty
in classContributionItem
- Returns:
true
if this item is dirty
-
isDynamic
public boolean isDynamic()Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method returnsfalse
. Subclasses may override.- Specified by:
isDynamic
in interfaceIContributionItem
- Overrides:
isDynamic
in classContributionItem
- Returns:
true
if this item is dynamic, andfalse
for 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 == true
then the active perspective is hilighted with a check mark.- Parameters:
b
- the new showActive flag
-
dispose
public void dispose()Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
dispose
in interfaceIContributionItem
- Overrides:
dispose
in classContributionItem
-
IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE