edu.wpi.ebob.internal.gui
Class InstanceContainer

java.lang.Object
  extended by edu.wpi.ebob.internal.gui.InstanceContainer
All Implemented Interfaces:
ObjectBenchListener, java.util.EventListener, org.eclipse.jface.viewers.ISelectionProvider

public class InstanceContainer
extends java.lang.Object
implements org.eclipse.jface.viewers.ISelectionProvider, ObjectBenchListener

A graphical container for instances in the Object Bench. This listens to changes in the Object Bench model.

Author:
Liam Morley

Field Summary
private  org.eclipse.jface.action.MenuManager menuMgr
          The menu manager for this container.
private  ICMouseListener mListener
          a mouse listener for handling selection
private  org.eclipse.swt.widgets.Composite panel
          the panel which will contain all instances
private  org.eclipse.swt.custom.ScrolledComposite sc
          the scrolling container which contains panel.
private  Instance selectedInstance
          the currently selected instance in the container
private  org.eclipse.jface.util.ListenerList selectionChangedListeners
          a list of all selection listeners
 
Constructor Summary
InstanceContainer(org.eclipse.swt.widgets.Composite parent)
          constructs a new container with a given parent.
 
Method Summary
 void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
           
private  void fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
          alerts all listeners to any changes.
 org.eclipse.jface.action.MenuManager getContextMenu(org.eclipse.jface.action.IAction[] items)
          retrieves the context menu for the purposes of display, based on the items supplied.
 org.eclipse.jface.viewers.ISelection getSelection()
           
private  void hookDnD()
          facilitates drag and drop functionality.
 void objectAdded(ObjectBenchEvent event)
          Invoked when an object has been added to the Object Bench.
 void objectRemoved(ObjectBenchEvent event)
          Invoked when an object has been removed from the Object Bench.
 void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
           
 void setFocus()
          gives the container focus.
 void setSelection(org.eclipse.jface.viewers.ISelection selection)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panel

private final org.eclipse.swt.widgets.Composite panel
the panel which will contain all instances


sc

private final org.eclipse.swt.custom.ScrolledComposite sc
the scrolling container which contains panel.


selectionChangedListeners

private final org.eclipse.jface.util.ListenerList selectionChangedListeners
a list of all selection listeners


mListener

private final ICMouseListener mListener
a mouse listener for handling selection


selectedInstance

private Instance selectedInstance
the currently selected instance in the container


menuMgr

private org.eclipse.jface.action.MenuManager menuMgr
The menu manager for this container. In charge of instance children as well.

Constructor Detail

InstanceContainer

public InstanceContainer(org.eclipse.swt.widgets.Composite parent)
constructs a new container with a given parent.

Parameters:
parent - the parent composite that this container will live inside of.
Method Detail

addSelectionChangedListener

public void addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
Specified by:
addSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.addSelectionChangedListener(ISelectionChangedListener)

fireSelectionChanged

private void fireSelectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent event)
alerts all listeners to any changes.

Parameters:
event - an event that listeners should be aware of.

getContextMenu

public org.eclipse.jface.action.MenuManager getContextMenu(org.eclipse.jface.action.IAction[] items)
retrieves the context menu for the purposes of display, based on the items supplied.

Returns:
the context menu for the container.

getSelection

public org.eclipse.jface.viewers.ISelection getSelection()
Specified by:
getSelection in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.getSelection()

hookDnD

private void hookDnD()
facilitates drag and drop functionality.


objectAdded

public void objectAdded(ObjectBenchEvent event)
Description copied from interface: ObjectBenchListener
Invoked when an object has been added to the Object Bench.

Specified by:
objectAdded in interface ObjectBenchListener
Parameters:
event - an event describing the object being added.
See Also:
ObjectBenchListener.objectAdded(ObjectBenchEvent)

objectRemoved

public void objectRemoved(ObjectBenchEvent event)
Description copied from interface: ObjectBenchListener
Invoked when an object has been removed from the Object Bench.

Specified by:
objectRemoved in interface ObjectBenchListener
Parameters:
event - an event describing the object being removed.
See Also:
ObjectBenchListener.objectRemoved(ObjectBenchEvent)

removeSelectionChangedListener

public void removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener listener)
Specified by:
removeSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.removeSelectionChangedListener(ISelectionChangedListener)

setFocus

public void setFocus()
gives the container focus.


setSelection

public void setSelection(org.eclipse.jface.viewers.ISelection selection)
Specified by:
setSelection in interface org.eclipse.jface.viewers.ISelectionProvider
See Also:
ISelectionProvider.setSelection(ISelection)