com.tensegrity.gui.swt.control.multiselect
Class SelectionBox

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.eclipse.swt.widgets.Canvas
                      extended bycom.tensegrity.gui.swt.control.multiselect.SelectionBox
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable, java.util.EventListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.internal.SWTEventListener
Direct Known Subclasses:
AnchorSelectionBox, GradientSelectionBox, MarkerSelectionBox, PaintItemSelectionBox, PatternSelectionBox

public abstract class SelectionBox
extends org.eclipse.swt.widgets.Canvas
implements org.eclipse.swt.events.MouseListener

Abstract base class to display multiple items on one page so that the user can choose one directly.

Version:
$Id: SelectionBox.java,v 1.4 2005/03/22 16:06:57 ArndHouben Exp $
Author:
Arnd Houben

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
SelectionBox(org.eclipse.swt.widgets.Composite parent, int style, int columns)
          Constructor which requires the amount of columns to use for displaying the different items.
 
Method Summary
 void addItem(java.lang.Object item)
          Adds the given item to the selection box
 void addItems(java.lang.Object[] items)
          Adds the items to the selection box.
 void addSelectionListener(org.eclipse.swt.events.SelectionListener sl)
          Adds the specified listener to the list of all selection listeners which get notified when an item was selected
protected abstract  org.eclipse.swt.widgets.Control createControl(org.eclipse.swt.widgets.Composite parent, java.lang.Object item)
          Returns a suitable control widget to display the given item object.
abstract  java.lang.Object getSelection()
          Returns the selected item.
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
           
 void mouseDown(org.eclipse.swt.events.MouseEvent me)
           
 void mouseUp(org.eclipse.swt.events.MouseEvent e)
           
 void removeSelectionListener(org.eclipse.swt.events.SelectionListener sl)
          Removes the specified listener from the list of all selection listeners
protected abstract  void setSelection(org.eclipse.swt.widgets.Control control)
          Sets the selected control object.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, 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, computeSize, 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, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectionBox

public SelectionBox(org.eclipse.swt.widgets.Composite parent,
                    int style,
                    int columns)
Constructor which requires the amount of columns to use for displaying the different items.

Parameters:
parent - the composite to add this SelectionBox to
style - SWT style bits
columns - amount of columns to use
Method Detail

createControl

protected abstract org.eclipse.swt.widgets.Control createControl(org.eclipse.swt.widgets.Composite parent,
                                                                 java.lang.Object item)
Returns a suitable control widget to display the given item object. This control is also the source of mouse events within this selection box.

Returns:
control for displaying an item

setSelection

protected abstract void setSelection(org.eclipse.swt.widgets.Control control)
Sets the selected control object. Implementing classes should take care of that the corresponding item object can be received by getSelection().

Parameters:
control - the selected control widget

getSelection

public abstract java.lang.Object getSelection()
Returns the selected item.

Returns:
selected item or null if none was selected.

addItems

public final void addItems(java.lang.Object[] items)
Adds the items to the selection box.

Parameters:
items - an array of items

addItem

public final void addItem(java.lang.Object item)
Adds the given item to the selection box

Parameters:
item - an arbitrary item

addSelectionListener

public final void addSelectionListener(org.eclipse.swt.events.SelectionListener sl)
Adds the specified listener to the list of all selection listeners which get notified when an item was selected

Parameters:
sl - a selection listener instance

removeSelectionListener

public final void removeSelectionListener(org.eclipse.swt.events.SelectionListener sl)
Removes the specified listener from the list of all selection listeners

Parameters:
sl - a selection listener instance

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent me)
Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent e)
Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.