org.formaria.swt
Class ToolItem

java.lang.Object
  extended by org.eclipse.swt.widgets.ToolItem
      extended by org.formaria.swt.ToolItem
All Implemented Interfaces:
Actionable, ModelHolder

public class ToolItem
extends org.eclipse.swt.widgets.ToolItem
implements Actionable, ModelHolder

Draws a coolitem

Copyright (c) Formaria Ltd., 2008

License: see license.txt $Revision: 2.18 $


Field Summary
protected  Menu menu
           
protected  DataModel model
           
protected  ToolBar tb
           
 
Constructor Summary
ToolItem(ToolBar parent, int style)
          Constructs a new toolitem for a toolbar
 
Method Summary
protected  void checkSubclass()
          Suppress the subclassing exception
 Menu getMenu()
           
 DataModel getModel()
          Get the model
 java.lang.String getText(DataModel xmodel, int i)
          Get the appropriate text inside the model
 java.lang.String getToolTip()
          Get the tooltip text
 void setAction(java.lang.Object action)
          Set an Action for the toolitem - does nothing
 int setAttribute(java.lang.String attribName, java.lang.Object attribValue)
          Set one or more attributes of the component.
 void setDataModel(DataModel xmodel)
          Set the DataModel which we will be generating the toolitem dropdown from
 void setImage(java.lang.String imageName)
          Set the image name
 void setToolTip(java.lang.String text)
          Set the tooltip text
 void update()
          Update the toolitem dropdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

menu

protected Menu menu

model

protected DataModel model

tb

protected final ToolBar tb
Constructor Detail

ToolItem

public ToolItem(ToolBar parent,
                int style)
Constructs a new toolitem for a toolbar

Parameters:
parent - parent toolbar
style - the style
Method Detail

checkSubclass

protected void checkSubclass()
Suppress the subclassing exception


setAction

public void setAction(java.lang.Object action)
Set an Action for the toolitem - does nothing

Specified by:
setAction in interface Actionable
Parameters:
action - the action object

setAttribute

public int setAttribute(java.lang.String attribName,
                        java.lang.Object attribValue)
Set one or more attributes of the component.

Parameters:
attribName - the name of the attribute
attribValue - the value of the attribute
Returns:
0 for success, non zero for failure or to require some further action

setDataModel

public void setDataModel(DataModel xmodel)
Set the DataModel which we will be generating the toolitem dropdown from

Specified by:
setDataModel in interface ModelHolder
Parameters:
xmodel - the DataModel of data

getModel

public DataModel getModel()
Get the model


update

public void update()
Update the toolitem dropdown

Specified by:
update in interface ModelHolder

getMenu

public Menu getMenu()

getText

public java.lang.String getText(DataModel xmodel,
                                int i)
Get the appropriate text inside the model

Parameters:
xmodel - parent model
i - index of the children
Returns:
the text

setToolTip

public void setToolTip(java.lang.String text)
Set the tooltip text

Parameters:
text - the new text

getToolTip

public java.lang.String getToolTip()
Get the tooltip text

Returns:
the existing text if any

setImage

public void setImage(java.lang.String imageName)
Set the image name

Parameters:
imageName - the relative URL of the new image