|
IBM Rational Performance Tester SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.core.commands.common.EventManager
org.eclipse.jface.action.AbstractAction
org.eclipse.jface.action.Action
org.eclipse.ui.actions.BaseSelectionListenerAction
com.ibm.rational.common.test.editor.framework.kernel.actions.NewModelElementAction
public class NewModelElementAction
NewModelElementAction is a base class to be used to contribute actions to "Add" and "Insert" sub-menus in Test Editor.
Typically, such action needs to be created in the protocol's plugin class once and registered with RptMenuManager
as follows:
RptMenuManager mm = TestEditorPlugin.getMenuManager(); mm.registerAddActionGroup( ... ) mm.registerInsertActionGroup( ... )
Plugin may register any number of add and insert groups and publish their names so other plugin can contribute their actions. The groups are needed to visually separate menu items in a menu. If the same action is to be displayed in both "Add" and "Insert" menu, to separate instances must be created. Once registered, the actions are managed by Test Editor infrastructure and are shared between multiple open tests.
When user selects a menu item, NewModelElementAction
calls ExtActionHandler#createNew(CBActioneElement parent)
to
actually create a child object.
RptMenuManager
,
EditorNewActionGroup
,
(extension point)
,
ExtActionHandler
Field Summary | |
---|---|
static int |
ADD
constant indicating that this action adds, rather then inserts new elements |
protected Map |
m_contributions
|
protected ArrayList |
m_parents
|
protected boolean |
m_valid
The value of this flag can be set to false by NewModelElementAction.addChild(List, CBActionElement) method to stop processing. |
Fields inherited from interface org.eclipse.jface.action.IAction |
---|
AS_CHECK_BOX, AS_DROP_DOWN_MENU, AS_PUSH_BUTTON, AS_RADIO_BUTTON, AS_UNSPECIFIED, CHECKED, DESCRIPTION, ENABLED, HANDLED, IMAGE, RESULT, TEXT, TOOL_TIP_TEXT |
Constructor Summary | |
---|---|
NewModelElementAction(String type)
Create an action for model element type type . |
|
NewModelElementAction(String type,
boolean loadExtensions)
Create an action for model element type type and load contributions (if any)
made through com.ibm.rational.test.common.editor.framework.newElementActionContributor extension point. |
Method Summary | |
---|---|
protected void |
addChild(List children,
CBActionElement child)
Adds or inserts a new children into a list of children. |
protected void |
clearCache()
|
protected CBActionElement |
createNewModelObject(CBActionElement parent)
Finds ExtActionHandler for its type and calls createnewObject method. |
CBActionElement |
doCreate(CBActionElement parent)
This method is called from run{} method. |
int |
getInsertPoint()
|
ExtActionHandler |
getMyActionHandler()
|
ArrayList |
getNewElements()
|
TestEditor |
getTestEditor()
|
protected void |
init()
Extracts text and image descriptor from ExtLabelProvider>/code> |
boolean |
isRefreshEnabled()
|
protected boolean |
isValidParent(Object object)
This method is called from updateSelection and is used to determine whether this action should be enabled or disabled. |
protected void |
refreshTest(CBActionElement parent,
CBActionElement child)
|
protected boolean |
relocateChildren(CBActionElement oldParent,
CBActionElement newParent)
|
void |
run()
Calls doCreate method, and refreshes the Test in the tree. |
void |
setInsertPoint(int insertPoint)
Set dynamically by test editor framework as selection in the editor tree changes. |
void |
setRefreshEnabled(boolean refreshEnabled)
|
void |
setTestEditor(TestEditor editor)
|
protected void |
updateMode(ExtActionHandler prov)
|
boolean |
updateSelection(IStructuredSelection selection)
This method is called by editor framework when selection changes in the editor's tree or when the editor become active. |
Methods inherited from class org.eclipse.ui.actions.BaseSelectionListenerAction |
---|
getStructuredSelection, runWithEvent, selectionChanged, selectionChanged |
Methods inherited from class org.eclipse.jface.action.AbstractAction |
---|
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener |
Methods inherited from class org.eclipse.core.commands.common.EventManager |
---|
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.eclipse.jface.action.IAction |
---|
addPropertyChangeListener, removePropertyChangeListener |
Field Detail |
---|
public static int ADD
protected ArrayList m_parents
protected Map m_contributions
protected boolean m_valid
false
by NewModelElementAction.addChild(List, CBActionElement)
method to stop processing.
Constructor Detail |
---|
public NewModelElementAction(String type)
type
.
type
- String Type of a CBActionElement object that this action produces.public NewModelElementAction(String type, boolean loadExtensions)
type
and load contributions (if any)
made through com.ibm.rational.test.common.editor.framework.newElementActionContributor
extension point.
type
- String Type of a CBActionElement object that this action produces.loadExtensions
- boolean
. If true
the newElementActionContributor
extension will be loaded.Method Detail |
---|
protected void init()
ExtLabelProvider>/code>
protected CBActionElement createNewModelObject(CBActionElement parent)
ExtActionHandler
for its type and calls createnewObject
method.
parent
- CBActionElement. Object that is typically selected in the editor's tree.
protected void updateMode(ExtActionHandler prov)
public void run()
doCreate
method, and refreshes the Test in the tree.
run
in interface IAction
run
in class Action
IAction.run()
public CBActionElement doCreate(CBActionElement parent)
run{}
method. It does the following:
ExtContentProvider
for the parent and obtains its list of children,
createNewModelObject
to create new child object,
instanceof
EMF EList)
ModelStateManager.setStatusNew(child, getTestEditor())
parent
- CBActionElement selected in the tree
protected boolean relocateChildren(CBActionElement oldParent, CBActionElement newParent)
oldParent
- CBActionElementnewParent
- CBActionElement
true
if chilfdren were relocated, false
if there was an error. Typically,
some element could not be moved to different parent element.protected void addChild(List children, CBActionElement child)
instaceof
EList, the model change occures.
Otherwise clients need to make sure the new child objects is indeed added to a model.
This method is called by doCreate
only if the children
obtained from parent's ExtContentProvider is of (sub-)type
of EMF EList
.
children
- List of childrenchild
- protected void refreshTest(CBActionElement parent, CBActionElement child)
public TestEditor getTestEditor()
public boolean isRefreshEnabled()
public void setRefreshEnabled(boolean refreshEnabled)
refreshEnabled
- The refreshEnabled to set.public boolean updateSelection(IStructuredSelection selection)
If isValidParent()
returns false
and extensions are loaded, the list of contributions is checked to see whether
the parent/child relation was allowed declaretively.
updateSelection
in class BaseSelectionListenerAction
BaseSelectionListenerAction.updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
protected void clearCache()
clearCache
in class BaseSelectionListenerAction
protected boolean isValidParent(Object object)
updateSelection
and is used to determine whether this action should be enabled or disabled.
If client decides that the argument is one of the recognised types, suitable to have a child object of the type handled by this action,
this method should return true
. If the parent's type is not suitable or not recognised, the method should return false
.
If isValidParent()
returns false
and extensions are loaded, the list of contributions is checked to see whether
the parent/child relation was allowed declaretively (by updateSelection
method).
This implementation simply calls:
CBActionElement element = (CBActionElement)object; return getTestEditor().getProviders( element ).getActionHandler().isValidParent( element );
object
-
public void setTestEditor(TestEditor editor)
editor
- public int getInsertPoint()
public void setInsertPoint(int insertPoint)
Clients should not call this method.
insertPoint
- The insertPoint to set.public ArrayList getNewElements()
public ExtActionHandler getMyActionHandler()
|
IBM Rational Performance Tester SDK | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |