public abstract class PerspectiveMenu extends ContributionItem
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.
Modifier and Type | Field and Description |
---|---|
protected static String |
SHOW_PERSP_ID
Deprecated.
As of 3.5, replaced by
IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE |
Constructor and Description |
---|
PerspectiveMenu(IWorkbenchWindow window,
String id)
Constructs a new instance of
PerspectiveMenu . |
Modifier and Type | Method and Description |
---|---|
void |
fill(Menu menu,
int index)
The default implementation of this
IContributionItem
method does nothing. |
protected ArrayList |
getPerspectiveItems()
Returns the available list of perspectives to display in the menu.
|
protected boolean |
getShowActive()
Returns whether the menu item representing the active perspective
will have a check mark.
|
protected IWorkbenchWindow |
getWindow()
Returns the window for this menu.
|
boolean |
isDirty()
The default implementation of this
IContributionItem
method returns false . |
boolean |
isDynamic()
The default implementation of this
IContributionItem
method returns false . |
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.
|
dispose, fill, fill, fill, getId, getParent, isEnabled, isGroupMarker, isSeparator, isVisible, saveWidgetState, setId, setParent, setVisible, toString, update, update
@Deprecated protected static final String SHOW_PERSP_ID
IWorkbenchCommandConstants.PERSPECTIVES_SHOW_PERSPECTIVE
public PerspectiveMenu(IWorkbenchWindow window, String id)
PerspectiveMenu
.window
- the window containing this menuid
- the menu idpublic void fill(Menu menu, int index)
ContributionItem
IContributionItem
method does nothing. Subclasses may override.fill
in interface IContributionItem
fill
in class ContributionItem
menu
- the parent menuindex
- the index where the controls are inserted,
or -1
to insert at the endprotected ArrayList getPerspectiveItems()
By default, the list contains the perspective shortcuts for the current perspective.
Subclasses can override this method to return a different list.
ArrayList of perspective items IPerspectiveDescriptor
protected boolean getShowActive()
true
if a check mark is shown, false
otherwiseprotected IWorkbenchWindow getWindow()
public boolean isDirty()
ContributionItem
IContributionItem
method returns false
. Subclasses may override.isDirty
in interface IContributionItem
isDirty
in class ContributionItem
true
if this item is dirtypublic boolean isDynamic()
ContributionItem
IContributionItem
method returns false
. Subclasses may override.isDynamic
in interface IContributionItem
isDynamic
in class ContributionItem
true
if this item is dynamic, and
false
for normal itemsprotected abstract void run(IPerspectiveDescriptor desc)
desc
- the selected perspectiveprotected void run(IPerspectiveDescriptor desc, SelectionEvent event)
run(IPerspectiveDescriptor)
.desc
- the selected perspectiveevent
- SelectionEvent - the event send along with the selection
callbackprotected void showActive(boolean b)
showActive == true
then the
active perspective is hilighted with a check mark.b
- the new showActive flag
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.