Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse GEF
3.3

org.eclipse.gef.ui.actions
Class WorkbenchPartAction

java.lang.Object
  extended by
org.eclipse.gef.ui.actions.WorkbenchPartAction
Direct Known Subclasses:
CopyTemplateAction, EditorPartAction, PrintAction, SelectionAction, StackAction

public abstract class WorkbenchPartAction
extends java.lang.Object

Base class for actions involving a WorkbenchPart. The workbench part is useful for obtaining data needed by the action. For example, selection can be obtained using the part's site. Anything can potentially be obtained using org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class).


Constructor Summary
WorkbenchPartAction ( IWorkbenchPart part)
          Constructs a WorkbenchPartAction for the given part.
WorkbenchPartAction ( IWorkbenchPart part, int style)
          Constructs a WorkbenchPartAction for the given part and style.
 
Method Summary
protected abstract  boolean calculateEnabled ()
          Calculates and returns the enabled state of this action.
 void dispose ()
          Disposes the action when it is no longer needed.
protected  void execute ( Command command)
          Executes the given Command using the command stack.
protected   CommandStack getCommandStack ()
          Returns the editor's command stack.
protected   IWorkbenchPart getWorkbenchPart ()
          Returns the workbench part given in the constructor
protected  void init ()
          Initializes this action.
 boolean isEnabled ()
          Returns true if the action is enabled.
protected  void refresh ()
          Refreshes the properties of this action.
 void setLazyEnablementCalculation (boolean value)
          Sets lazy calculation of the isEnabled property.
protected  void setWorkbenchPart ( IWorkbenchPart part)
          Sets the workbench part.
 void update ()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbenchPartAction

public WorkbenchPartAction(
IWorkbenchPart part)
Constructs a WorkbenchPartAction for the given part.

Parameters:
part - the workbench part

WorkbenchPartAction

public WorkbenchPartAction(
IWorkbenchPart part,
                           int style)
Constructs a WorkbenchPartAction for the given part and style.

Parameters:
part - the workbench part
style - one of AS_PUSH_BUTTON, AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_RADIO_BUTTON, and AS_UNSPECIFIED.
Method Detail

calculateEnabled

protected abstract boolean calculateEnabled()
Calculates and returns the enabled state of this action.

Returns:
true if the action is enabled

dispose

public void dispose()
Disposes the action when it is no longer needed.


execute

protected void execute(
Command command)
Executes the given Command using the command stack. The stack is obtained by calling getCommandStack(), which uses IAdapatable to retrieve the stack from the workbench part.

Parameters:
command - the command to execute

getCommandStack

protected 
CommandStack getCommandStack()
Returns the editor's command stack. This is done by asking the workbench part for its CommandStack via org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class).

Returns:
the command stack

getWorkbenchPart

protected 
IWorkbenchPart getWorkbenchPart()
Returns the workbench part given in the constructor

Returns:
the workbench part

init

protected void init()
Initializes this action.


isEnabled

public boolean isEnabled()
Returns true if the action is enabled. If the action determines enablemenu lazily, then calculateEnabled() is always called. Otherwise, the enablement state set using Action.setEnabled(boolean) is returned.

Returns:
true if the action is enabled
See Also:
setLazyEnablementCalculation(boolean)

refresh

protected void refresh()
Refreshes the properties of this action.


setLazyEnablementCalculation

public void setLazyEnablementCalculation(boolean value)
Sets lazy calculation of the isEnabled property. If this value is set to true, then the action will always use calculateEnabled() whenever isEnabled() is called.

Sometimes a value of false can be used to improve performance and reduce the number of times calculateEnabled() is called. However, the client must then call the update() method at the proper times to force the update of enablement.

Sometimes a value of true can be used to improve performance. If an Action only appears in a dynamic context menu, then there is no reason to agressively update its enablement status because the user cannot see the Action. Instead, its enablement only needs to be determined when asked for, or lazily.

The default value for this setting is true.

Parameters:
value - true if the enablement should be lazy

setWorkbenchPart

protected void setWorkbenchPart(
IWorkbenchPart part)
Sets the workbench part.

Parameters:
part - the workbench part

update

public void update()
See Also:
UpdateAction.update()

Eclipse GEF
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire