com.tssap.util.ui.reuse.chooser.impl
Class DropDownSelector

com.tssap.util.ui.reuse.chooser.impl.DropDownSelector
All Implemented Interfaces:
IDropDownSelector, IEditable, IGenericComponent, IGridLayoutPaneContainer, IReuseable

public class DropDownSelector
implements IDropDownSelector

Title: Reuseable Drop Down Selector Description: Component consisting of a combo box (drop down menu) or textField and a push button.

With an itemsMaxLength (number of elements in combo box) of 0, you can determine that a textField is shown. Otherwise the combobox will be displayed. example usage:
IDropDownSelector dds; IDisplayableChooser pushButtonChooser = new FileChooser(FileChooser.DIRECTORY_CHOOSER); IGridLayoutPane componentsGridpane = gridpane.addGridLayoutPane( DropDownSelector.NUM_GRID_COLS); SelectionListener sl = new TestSelectionListener(); String[] historyData = new String[] { "E:\\", "A:\\", "D:\\" }; dds = new DropDownSelector(3); dds.setSelectorDescription("blabla"); dds.setDescriptionPositionLeft(false); dds.setReadOnly(false); dds.setHistory(historyData); dds.setButtonText("Browse"); dds.setHasPushButton(true); dds.setPushButtonChooser(pushButtonChooser); dds.addSelectionListener(sl); dds.createPartControl(componentsGridpane); Copyright: Copyright (c) 2002 Company: SAP AG

Version:
1.0

Field Summary
static int NUM_GRID_COLS
           
 
Constructor Summary
DropDownSelector()
           
DropDownSelector(int itemsMaxLength)
           
 
Method Summary
 void addHistoryEntry(java.lang.String entry)
           
 void addSelectionToHistory()
           
 void focusGained(org.eclipse.swt.events.FocusEvent e)
           
 void focusLost(org.eclipse.swt.events.FocusEvent e)
           
 org.eclipse.swt.graphics.Image getButtonImage()
           
 java.lang.String getButtonText()
           
 java.lang.String getButtonTooltip()
           
 org.eclipse.swt.widgets.Control getControl()
           
 java.lang.String[] getHistory()
           
 int getHistoryLength()
          Returns the itemsMaxLength.
 int getItemsMaxLength()
           
 IChooser getPushButtonChooser()
           
 java.lang.String getSelectorDescription()
           
 java.lang.String getText()
           
 int getUserGridNumOfColumns()
          Returns number of columns for userArea given to method initContainer(IGridLayoutPane userArea)
 boolean hasPushButton()
           
 void initContainer(IGridLayoutPane userArea)
          Initialize component's UI.
 boolean isDescriptorPositionLeft()
           
 boolean isGrabHorizontal()
          Returns the isGrabHorizontal.
 boolean isReadOnly()
          Returns the readOnly.
 boolean isSelectionToHistory()
           
 boolean isUserGridEqualColSize()
          Returns true if userArea given to method initContainer(IGridLayoutPane userArea) has to have equal column widths
 void setButtonImage(org.eclipse.swt.graphics.Image buttonImage)
          calling this method after having called createPartControl(..) will throw an exception!
 void setButtonText(java.lang.String buttonText)
          calling this method after having called createPartControl(..) will throw an exception!
 void setButtonTooltip(java.lang.String buttonTooltip)
          calling this method after having called createPartControl(..) will throw an exception!
 void setDescriptionPositionLeft(boolean left)
          calling this method after having called createPartControl(..) will throw an exception!
 void setEnabled(boolean enabled)
          Set whether or not the component and all its subcomponents are enabled.
 void setHasPushButton(boolean hasPushButton)
          calling this method after having called createPartControl(..) will throw an exception!
 void setHistory(java.lang.String[] items)
          adapts history[] to defined size
Case 1:
history[] consists of less items than the defined max number of items to be shown in the combo box (itemsMaxLength):
history[] will be filled up with Strings until the size of itemsMaxLength is reached

Case 2:
history[]'s size is greater or equals itemsMaxLength:
only a defined number of the latest values remain in history[]
 void setIsGrabHorizontal(boolean isGrabHorizontal)
          Sets the isGrabHorizontal.
 void setItemsMaxLength(int itemsMaxLength)
          Sets the itemsMaxLength.
 void setPushButtonChooser(IChooser pushButtonChooser)
          calling this method after having called createPartControl(..) will throw an exception!
 void setReadOnly(boolean readOnly)
          Sets the readOnly, that is defines if the combobox/pushButton/textField shall be read-only or editable.
 void setSelectionToHistory(boolean selectionToHistory)
          calling this method after having called createPartControl(..) will throw an exception!
 void setSelectorDescription(java.lang.String description)
          calling this method after having called createPartControl(..) will throw an exception!
 void setText(java.lang.String text)
           
 void setTextFieldReadOnly(boolean readOnly)
          hacked coding in order to set only the text field of DropDownSelector to read-only
 
Methods inherited from interface com.tssap.util.ui.reuse.IGenericComponent
addModifyListener, addSelectionListener, createPartControl, createPartControl, getTitle, refresh, removeModifyListener, removeSelectionListener, setTitle
 
Methods inherited from interface com.tssap.util.ui.IEditable
isEditable, setEditable
 
Methods inherited from interface com.tssap.util.ui.reuse.IReuseable
createPartControl, isEnabled
 

Field Detail

NUM_GRID_COLS

public static final int NUM_GRID_COLS
Constructor Detail

DropDownSelector

public DropDownSelector(int itemsMaxLength)

DropDownSelector

public DropDownSelector()
Method Detail

getControl

public org.eclipse.swt.widgets.Control getControl()
Specified by:
getControl in interface IDropDownSelector

initContainer

public void initContainer(IGridLayoutPane userArea)
Description copied from interface: IGridLayoutPaneContainer
Initialize component's UI. Implementor has to fill the given grid layout pane. The number of columns comes from call to method getUserGridNumOfColumns(). If grid columns have equal widths is decided through call to isUserGridEqualColSize().
Specified by:
initContainer in interface IGridLayoutPaneContainer
See Also:
IGridLayoutPaneContainer.initContainer(IGridLayoutPane)

isUserGridEqualColSize

public boolean isUserGridEqualColSize()
Description copied from interface: IGridLayoutPaneContainer
Returns true if userArea given to method initContainer(IGridLayoutPane userArea) has to have equal column widths
Specified by:
isUserGridEqualColSize in interface IGridLayoutPaneContainer
See Also:
IGridLayoutPaneContainer.isUserGridEqualColSize()

getUserGridNumOfColumns

public int getUserGridNumOfColumns()
Description copied from interface: IGridLayoutPaneContainer
Returns number of columns for userArea given to method initContainer(IGridLayoutPane userArea)
Specified by:
getUserGridNumOfColumns in interface IGridLayoutPaneContainer
See Also:
IGridLayoutPaneContainer.getUserGridNumOfColumns()

getHistory

public java.lang.String[] getHistory()
Specified by:
getHistory in interface IDropDownSelector

setHistory

public void setHistory(java.lang.String[] items)
adapts history[] to defined size
Case 1:
history[] consists of less items than the defined max number of items to be shown in the combo box (itemsMaxLength):
history[] will be filled up with Strings until the size of itemsMaxLength is reached

Case 2:
history[]'s size is greater or equals itemsMaxLength:
only a defined number of the latest values remain in history[]
Specified by:
setHistory in interface IDropDownSelector
Parameters:
items - String[] to be added to history[]

addSelectionToHistory

public void addSelectionToHistory()
Specified by:
addSelectionToHistory in interface IDropDownSelector

addHistoryEntry

public void addHistoryEntry(java.lang.String entry)
Specified by:
addHistoryEntry in interface IDropDownSelector

getHistoryLength

public int getHistoryLength()
Returns the itemsMaxLength.
Returns:
int

setItemsMaxLength

public void setItemsMaxLength(int itemsMaxLength)
Sets the itemsMaxLength.
Specified by:
setItemsMaxLength in interface IDropDownSelector
Parameters:
itemsMaxLength - The itemsMaxLength to set. Has to be >= 0.

isReadOnly

public boolean isReadOnly()
Returns the readOnly.
Specified by:
isReadOnly in interface IDropDownSelector
Returns:
boolean

setTextFieldReadOnly

public void setTextFieldReadOnly(boolean readOnly)
hacked coding in order to set only the text field of DropDownSelector to read-only
Specified by:
setTextFieldReadOnly in interface IDropDownSelector
Parameters:
readOnly -  
See Also:
TypeComponent2, com.tssap.j2ee.ui.ejb.components.fields.PrimaryKeyEditorComponent

setReadOnly

public void setReadOnly(boolean readOnly)
Sets the readOnly, that is defines if the combobox/pushButton/textField shall be read-only or editable.
Specified by:
setReadOnly in interface IDropDownSelector
Parameters:
readOnly - The readOnly to set

focusGained

public void focusGained(org.eclipse.swt.events.FocusEvent e)
Specified by:
focusGained in interface IDropDownSelector
See Also:
org.eclipse.swt.events.FocusListener#focusGained(FocusEvent)

focusLost

public void focusLost(org.eclipse.swt.events.FocusEvent e)
Specified by:
focusLost in interface IDropDownSelector
See Also:
org.eclipse.swt.events.FocusListener#focusLost(FocusEvent)

getButtonImage

public org.eclipse.swt.graphics.Image getButtonImage()
Specified by:
getButtonImage in interface IDropDownSelector
See Also:
IDropDownSelector.getButtonImage()

getButtonText

public java.lang.String getButtonText()
Specified by:
getButtonText in interface IDropDownSelector
See Also:
IDropDownSelector.getButtonText()

getButtonTooltip

public java.lang.String getButtonTooltip()
Specified by:
getButtonTooltip in interface IDropDownSelector
See Also:
IDropDownSelector.getButtonTooltip()

getText

public java.lang.String getText()
Specified by:
getText in interface IDropDownSelector
See Also:
IDropDownSelector.getText()

getItemsMaxLength

public int getItemsMaxLength()
Specified by:
getItemsMaxLength in interface IDropDownSelector
See Also:
IDropDownSelector.getItemsMaxLength()

getPushButtonChooser

public IChooser getPushButtonChooser()
Specified by:
getPushButtonChooser in interface IDropDownSelector
See Also:
IDropDownSelector.getPushButtonChooser()

getSelectorDescription

public java.lang.String getSelectorDescription()
Specified by:
getSelectorDescription in interface IDropDownSelector
See Also:
IDropDownSelector.getSelectorDescription()

hasPushButton

public boolean hasPushButton()
Specified by:
hasPushButton in interface IDropDownSelector
See Also:
IDropDownSelector.hasPushButton()

isSelectionToHistory

public boolean isSelectionToHistory()
Specified by:
isSelectionToHistory in interface IDropDownSelector
See Also:
IDropDownSelector.isSelectionToHistory()

setButtonImage

public void setButtonImage(org.eclipse.swt.graphics.Image buttonImage)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setButtonImage in interface IDropDownSelector
Parameters:
buttonImage - an image of type org.eclipse.swt.graphics.Image
See Also:
IDropDownSelector.setButtonImage(Image)

setButtonText

public void setButtonText(java.lang.String buttonText)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setButtonText in interface IDropDownSelector
Parameters:
buttonText -  
See Also:
IDropDownSelector.setButtonText(String)

setButtonTooltip

public void setButtonTooltip(java.lang.String buttonTooltip)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setButtonTooltip in interface IDropDownSelector
See Also:
IDropDownSelector.setButtonTooltip(String)

setHasPushButton

public void setHasPushButton(boolean hasPushButton)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setHasPushButton in interface IDropDownSelector
See Also:
IDropDownSelector.setHasPushButton(boolean)

setPushButtonChooser

public void setPushButtonChooser(IChooser pushButtonChooser)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setPushButtonChooser in interface IDropDownSelector
Parameters:
pushButtonChooser - chooser that defines what will happen when clicking on the pushButton
See Also:
IDropDownSelector.setPushButtonChooser(IChooser)

setSelectionToHistory

public void setSelectionToHistory(boolean selectionToHistory)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setSelectionToHistory in interface IDropDownSelector
Parameters:
selectionToHistory - - adds the selected value to history
See Also:
IDropDownSelector.setSelectionToHistory(boolean)

setSelectorDescription

public void setSelectorDescription(java.lang.String description)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setSelectorDescription in interface IDropDownSelector
Parameters:
description - - the description of the component as a whole
See Also:
IDropDownSelector.setSelectorDescription(String)

isDescriptorPositionLeft

public boolean isDescriptorPositionLeft()

setDescriptionPositionLeft

public void setDescriptionPositionLeft(boolean left)
calling this method after having called createPartControl(..) will throw an exception!
Specified by:
setDescriptionPositionLeft in interface IDropDownSelector
Parameters:
left - - setting this value to true will arrange description on the left hand side of the component - otherwise on top of it.

setText

public void setText(java.lang.String text)
Specified by:
setText in interface IDropDownSelector
Parameters:
text - - the default text to be displayed in the components textField/combo box

isGrabHorizontal

public boolean isGrabHorizontal()
Returns the isGrabHorizontal.
Returns:
boolean

setIsGrabHorizontal

public void setIsGrabHorizontal(boolean isGrabHorizontal)
Sets the isGrabHorizontal.
Specified by:
setIsGrabHorizontal in interface IDropDownSelector
Parameters:
isGrabHorizontal - The isGrabHorizontal to set

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: IReuseable
Set whether or not the component and all its subcomponents are enabled.
Specified by:
setEnabled in interface IReuseable
See Also:
IReuseable.setEnabled(boolean)


Copyright © 2005 SAP AG. All Rights Reserved.