edu.wpi.ebob.internal.gui
Class Instance

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by edu.wpi.ebob.internal.gui.Instance
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, org.eclipse.swt.graphics.Drawable

public class Instance
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.core.runtime.IAdaptable

Represents an instance in the Object Bench. This keeps track of the actual object itself as well as the name of the object.

Author:
Liam Morley

Nested Class Summary
protected  class Instance.MethodComparator
          Sorts two methods by name.
 
Field Summary
private  org.eclipse.swt.graphics.Color bgColor
          the background color for all deselected instances.
private  org.eclipse.swt.graphics.Color bgColorActive
          the current color of this Instance, either bgColoror bgColorSelected.
private  org.eclipse.swt.graphics.Color bgColorSelected
          the background color for the one selected instance, if such an instance is selected.
private  org.eclipse.swt.widgets.Label classLabel
          displays what Class the object is.
protected static int DEFAULT_HEIGHT
          size of instance
protected static int DEFAULT_WIDTH
          size of instance
private  org.eclipse.swt.graphics.Color fgColor
          the foreground color for this instance.
private  org.eclipse.swt.graphics.Font font
          the font that all labels will be given.
private  java.lang.String name
          the name of the object.
private  org.eclipse.swt.widgets.Label nameLabel
          displays the name of the object.
private  IObject obj
          the object to keep track of.
private  org.eclipse.core.runtime.Preferences.IPropertyChangeListener prefChangeListener
           
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
Instance(org.eclipse.swt.widgets.Composite parent, java.lang.String name, IObject obj)
          Creates a new instance using obj as the underlying object and name as its name.
 
Method Summary
 void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)
          Makes sure children widgets also add the listeners they need.
protected  void changeProperty(java.lang.String property)
          changes a property of the instance based on a preference change.
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint)
           
 org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed)
           
 java.lang.Object getAdapter(java.lang.Class adapter)
           
 java.lang.String getInstanceName()
           
 IObject getObject()
           
 void inspect()
          launches the properties view.
 void menuAboutToShow(org.eclipse.jface.action.IMenuManager manager)
          A callback function that adds the instance-specific menu actions to the manager.
protected  void paintControl(org.eclipse.swt.events.PaintEvent pe)
          Handles drawing the background rectangle.
private  void refreshLabelColors()
          Sets the background color of the labels to the current background color.
private  void refreshLabelDetails()
          Sets the bounds and text for the labels, dependent on the size of the control.
private  void setBGColor()
          Sets the background color to the preferred color.
private  void setFGColor()
          Sets the foreground color to the preferred color.
 void setInstanceName(java.lang.String name)
          Sets the name of this instance to name.
protected  void setLabelText(org.eclipse.swt.widgets.Label label, java.lang.String text)
          Sets the label's text to text, provided there is enough horizontal space to accomodate it.
 void setMenu(org.eclipse.swt.widgets.Menu menu)
          sets menu for both this control as well as all controls which are children of this control.
 void setSelected(boolean isSelected)
          Sets this Instance's selected state to isSelected.
private  void setSelectedBGColor()
          Sets the background color to the preferred color.
 java.lang.String toString()
           
protected  void widgetDisposed()
          Handles disposing of the widget and anything in it that wouldn't otherwise get disposed.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

protected static final int DEFAULT_WIDTH
size of instance

See Also:
Constant Field Values

DEFAULT_HEIGHT

protected static final int DEFAULT_HEIGHT
size of instance

See Also:
Constant Field Values

fgColor

private org.eclipse.swt.graphics.Color fgColor
the foreground color for this instance. This is only kept so that it can be disposed of when the object is disposed of.


bgColor

private org.eclipse.swt.graphics.Color bgColor
the background color for all deselected instances.


bgColorSelected

private org.eclipse.swt.graphics.Color bgColorSelected
the background color for the one selected instance, if such an instance is selected.


bgColorActive

private org.eclipse.swt.graphics.Color bgColorActive
the current color of this Instance, either bgColoror bgColorSelected.


classLabel

private org.eclipse.swt.widgets.Label classLabel
displays what Class the object is.


font

private org.eclipse.swt.graphics.Font font
the font that all labels will be given.


name

private java.lang.String name
the name of the object.


nameLabel

private org.eclipse.swt.widgets.Label nameLabel
displays the name of the object.


obj

private IObject obj
the object to keep track of.


prefChangeListener

private org.eclipse.core.runtime.Preferences.IPropertyChangeListener prefChangeListener
Constructor Detail

Instance

public Instance(org.eclipse.swt.widgets.Composite parent,
                java.lang.String name,
                IObject obj)
Creates a new instance using obj as the underlying object and name as its name.

Parameters:
name - The name given to the object.
obj - The object represented by this instance.
Method Detail

addListener

public void addListener(int eventType,
                        org.eclipse.swt.widgets.Listener listener)
Makes sure children widgets also add the listeners they need.

Overrides:
addListener in class org.eclipse.swt.widgets.Widget
See Also:
Widget.addListener(int, Listener)

computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint)
Overrides:
computeSize in class org.eclipse.swt.widgets.Control
See Also:
Control.computeSize(int, int)

computeSize

public org.eclipse.swt.graphics.Point computeSize(int wHint,
                                                  int hHint,
                                                  boolean changed)
Overrides:
computeSize in class org.eclipse.swt.widgets.Composite
See Also:
Control.computeSize(int, int, boolean)

getAdapter

public java.lang.Object getAdapter(java.lang.Class adapter)
Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
See Also:
IAdaptable.getAdapter(java.lang.Class)

getInstanceName

public java.lang.String getInstanceName()
Returns:
the name of this instance.

getObject

public IObject getObject()
Returns:
Returns the real object that this instance represents.

inspect

public void inspect()
launches the properties view.


paintControl

protected void paintControl(org.eclipse.swt.events.PaintEvent pe)
Handles drawing the background rectangle.

Parameters:
pe - the paint event.

refreshLabelColors

private void refreshLabelColors()
Sets the background color of the labels to the current background color.


refreshLabelDetails

private void refreshLabelDetails()
Sets the bounds and text for the labels, dependent on the size of the control.


setInstanceName

public void setInstanceName(java.lang.String name)
Sets the name of this instance to name.

Parameters:
name - The new name for this instance.

setLabelText

protected void setLabelText(org.eclipse.swt.widgets.Label label,
                            java.lang.String text)
Sets the label's text to text, provided there is enough horizontal space to accomodate it. Otherwise, the last few characters of the label's text are replaced by an ellipsis and the label's tooltip text is set to the full value of text.

Parameters:
label - the label to set the text on.
text - the desired text

setSelected

public void setSelected(boolean isSelected)
Sets this Instance's selected state to isSelected.

Parameters:
isSelected - true if this Instance should be selected, false otherwise.

toString

public java.lang.String toString()
Overrides:
toString in class org.eclipse.swt.widgets.Widget
See Also:
Object.toString()

widgetDisposed

protected void widgetDisposed()
Handles disposing of the widget and anything in it that wouldn't otherwise get disposed.


setFGColor

private void setFGColor()
Sets the foreground color to the preferred color.

See Also:
OBPreferencePage.P_FG_COLOR

setBGColor

private void setBGColor()
Sets the background color to the preferred color.

See Also:
OBPreferencePage.P_BG_COLOR

setSelectedBGColor

private void setSelectedBGColor()
Sets the background color to the preferred color.

See Also:
OBPreferencePage.P_BG_COLOR

menuAboutToShow

public void menuAboutToShow(org.eclipse.jface.action.IMenuManager manager)
A callback function that adds the instance-specific menu actions to the manager. This also adds a Separator with IWorkbenchActionConstants.MB_ADDITIONS.


setMenu

public void setMenu(org.eclipse.swt.widgets.Menu menu)
sets menu for both this control as well as all controls which are children of this control.

Overrides:
setMenu in class org.eclipse.swt.widgets.Control
See Also:
Control.setMenu(Menu)

changeProperty

protected void changeProperty(java.lang.String property)
changes a property of the instance based on a preference change.

Parameters:
property - the property you wish to change, from OBPreferencePage.
See Also:
OBPreferencePage