Remote Systems
v6.4.1

com.ibm.etools.systems.core.ui.widgets
Class SystemConnectionCombo

java.lang.Object
  extended byComposite
      extended bycom.ibm.etools.systems.core.ui.widgets.SystemConnectionCombo
All Implemented Interfaces:
EventListener, ISystemCombo, ISystemResourceChangeEvents, ISystemResourceChangeListener
Direct Known Subclasses:
SystemRemoteConnectionCombo

public class SystemConnectionCombo
extends Composite
implements ISystemCombo, ISystemResourceChangeListener, ISystemResourceChangeEvents

This re-usable widget is for selecting a connection from the master list of connections. The list is subsettable by one or more system types. There is also the option of including a "New" button to the right of the connection dropdown, for the purpose of creating a new connection.

Without the New button, the composite is layed as follows:


   Connection: ______________________v  
 

With the New button, the composite is layed as follows:


   Connection: ______________v  New...
 

There are numerous ways to subset the connection list:

See Also:
Serialized Form

Field Summary
protected  Combo connectionCombo
           
protected  Label connectionLabel
           
static String copyright
           
protected  boolean listeningForConnectionEvents
           
protected  Button newButton
           
protected  boolean showLabel
           
protected  boolean showNewButton
           
protected  boolean showQualifiedNames
           
 
Fields inherited from interface com.ibm.etools.systems.core.ui.widgets.ISystemCombo
Copyright
 
Fields inherited from interface com.ibm.etools.systems.model.ISystemResourceChangeEvents
EVENT_ADD, EVENT_ADD_FILTER_REFERENCE, EVENT_ADD_FILTERSTRING_REFERENCE, EVENT_ADD_MANY, EVENT_ADD_RELATIVE, EVENT_CHANGE_CHILDREN, EVENT_CHANGE_FILTER_REFERENCE, EVENT_CHANGE_FILTERSTRING_REFERENCE, EVENT_COLLAPSE_ALL, EVENT_COLLAPSE_SELECTED, EVENT_COMMAND_FINISHED, EVENT_COMMAND_HISTORY_UPDATE, EVENT_COMMAND_MESSAGE, EVENT_COMMAND_RUN, EVENT_COMMAND_SHELL_FINISHED, EVENT_COMMAND_SHELL_REMOVED, EVENT_COMPILE_COMMAND_RUN, EVENT_DELETE, EVENT_DELETE_FILTER_REFERENCE, EVENT_DELETE_FILTERSTRING_REFERENCE, EVENT_DELETE_MANY, EVENT_EXPAND_SELECTED, EVENT_ICON_CHANGE, EVENT_MOVE_FILTER_REFERENCES, EVENT_MOVE_FILTERSTRING_REFERENCES, EVENT_MOVE_MANY, EVENT_MUST_COLLAPSE, EVENT_PROPERTY_CHANGE, EVENT_PROPERTYSHEET_UPDATE, EVENT_REFRESH, EVENT_REFRESH_REMOTE, EVENT_REFRESH_SELECTED, EVENT_REFRESH_SELECTED_FILTER, EVENT_REFRESH_SELECTED_PARENT, EVENT_RENAME, EVENT_RENAME_FILTER_REFERENCE, EVENT_REPLACE_CHILDREN, EVENT_REVEAL_AND_SELECT, EVENT_SEARCH_FINISHED, EVENT_SELECT, EVENT_SELECT_EXPAND, EVENT_SELECT_REMOTE, PROPERTYSHEET_UPDATE_EVENT
 
Constructor Summary
SystemConnectionCombo(Composite parent, int style, String[] systemTypes, SystemConnection defaultConnection, boolean showNewButton)
          Constructor for SystemConnectionCombo when there is an array of system types to restrict the connection list to.
SystemConnectionCombo(Composite parent, int style, String systemType, SystemConnection defaultConnection, boolean showNewButton)
          Constructor for SystemConnectionCombo when there is only a single system type to restrict the connection list to.
SystemConnectionCombo(Composite parent, int style, SubSystemFactory ssFactory, SystemConnection defaultConnection, boolean showNewButton)
          Constructor for SystemConnectionCombo when there is a subsystem factory to restrict the list to.
SystemConnectionCombo(Composite parent, int style, SystemConnection defaultConnection, boolean showNewButton, String ssFactoryCategory)
          Constructor for SystemConnectionCombo when there is a subsystem factory category to restrict the list to.
SystemConnectionCombo(Composite parent, int style, SystemConnection defaultConnection, boolean showNewButton, String ssFactoryCategory, boolean showLabel)
          Constructor for SystemConnectionCombo when there is a subsystem factory category to restrict the list to.
SystemConnectionCombo(Composite parent, int style, SystemConnection defaultConnection, String ssFactoryId, boolean showNewButton)
          Constructor for SystemConnectionCombo when there is a subsystem factory id to restrict the list to.
 
Method Summary
 void addModifyListener(ModifyListener listener)
          Register a listener interested in entry field modify events
 void addNewButtonSelectionListener(SelectionListener listener)
          Register a listener interested in when the new button is selected
protected  void addOurButtonSelectionListener()
           
protected  void addOurConnectionSelectionListener()
           
 void addSelectionChangedListener(ISelectionChangedListener listener)
          Register a listener interested in an item is selected in the combo box
 void addSelectionListener(SelectionListener listener)
          Register a listener interested in an item is selected in the combo box
 void clearSelection()
          Deselect
 void clearTextSelection()
          Clear the entered/selected contents of the combo box.
static Combo createCombo(Composite parent, boolean readonly)
          Creates a new combobox instance and sets the default layout data.
protected  Combo createConnectionCombo(Composite parent)
          Creates a new readonly connection combobox instance and sets the default layout data, with tooltip text.
protected static Button createPushButton(Composite group, ResourceBundle bundle, String key)
           
protected static Button createPushButton(Composite group, String label)
           
 Combo getCombo()
          Return the combo box widget
 SystemConnection[] getConnections()
           
 int getGridColumns()
          Return the number of grid data columns within this composite.
 String[] getItems()
          Get the items in the combo field
 Button getNewButton()
          Return the New... button widget
protected  SystemNewConnectionAction getNewConnectionAction(Shell shell, ISelectionProvider selectionProvider)
          Overridable method.
 Label getPromptLabel()
          Get the prompt Label widget
 ISelection getSelection()
           
 int getSelectionIndex()
          Get the index number of the currently selected item.
 SystemConnection getSystemConnection()
          Get the user selected SystemConnection object.
 String getText()
          Return the text in the connection combo entry field.
protected  void init(Composite parent, boolean showNewButton)
           
protected  void init(Composite parent, boolean showNewButton, boolean showLabel)
           
 void listenToConnectionEvents(boolean start)
          Have the SystemConnectionCombo listen to add/delete/rename events on connections and automatically update it's list of connections
protected  void populateConnectionCombo(Combo combo, String[] systemTypes, SystemConnection defaultConnection)
          Populates a readonly connection combobox instance with system connections for the given array of system types.
protected  boolean populateConnectionCombo(Combo combo, String ssFactoryId, SystemConnection defaultConnection)
          Populates a readonly connection combobox instance with system connections which have subsystems owned by a subsystem factory of the given subsystem factory id.
protected  boolean populateConnectionCombo(Combo combo, String systemType, SystemConnection defaultConnection, boolean preSelectIfNoMatch)
          Populates a readonly connection combobox instance with system connections for the given system type.
protected  boolean populateConnectionCombo(Combo combo, String systemType, SystemConnection defaultConnection, boolean preSelectIfNoMatch, boolean appendToCombo)
          Populates a readonly connection combobox instance with system connections for the given system type.
protected  boolean populateConnectionCombo(Combo combo, SubSystemFactory ssFactory, SystemConnection defaultConnection)
          Populates a readonly connection combobox instance with system connections which have subsystems owned by the given subsystem factory.
protected  boolean populateConnectionCombo(Combo combo, SystemConnection defaultConnection, String ssFactoryCategory)
          Populates a readonly connection combobox instance with system connections which have subsystems owned by a subsystem factory of the given subsystem factory category.
protected  Composite prepareComposite(int numColumns)
          Prepares this composite control and sets the default layout data.
 void refreshConnections()
          Refresh the list of connections
 void removeModifyListener(ModifyListener listener)
          Remove a previously set entry field listener.
 void removeNewButtonSelectionListener(SelectionListener listener)
          Remove a previously set new button selection listener.
 void removeSelectionChangedListener(ISelectionChangedListener listener)
          Remove a previously set combo box selection listener.
 void removeSelectionListener(SelectionListener listener)
          Remove a previously set combo box selection listener.
 void select(int selIdx)
          Select the combo dropdown list entry at the given index.
 void select(SystemConnection connection)
          Select a connection from the dropdown
 void setAutoUpperCase(boolean enable)
          Set auto-uppercase.
protected  void setBusyCursor(boolean setBusy)
          Helper method.
 void setButtonToolTipText(String tip)
          Same as setNewButtonToolTipText(String)
 void setButtonWidthHint(int widthHint)
          Set button width hint
 void setConnections(SystemConnection[] input)
           
protected  void setConnectionToolTipText()
           
 void setEnabled(boolean enabled)
          Disable/Enable all the child controls.
 boolean setFocus()
          Set the focus to the directory combo field
 void setItems(String[] items)
          Set the items in the combo field
 void setLabel(String label)
          Set the label to use for the prompt.
 void setNewButtonFocus()
          Set the focus to the new button
 void setNewButtonToolTipText(String tip)
          Set the tooltip text for the new button
 void setSelection(ISelection selection)
           
 void setSelectionIndex(int selIdx)
          Same as select(int)
 void setToolTipText(String tip)
          Set the tooltip text for the directory combo field
 void setWidthHint(int widthHint)
          Set the width hint for this whole composite Default is 180.
protected static String sub(String msg, String subOld, String subNew)
          Do string variable substitution.
 void systemResourceChanged(ISystemResourceChangeEvent event)
          This is the method in your class that will be called when a system resource changes.
 void widgetDisposed(DisposeEvent e)
          We are going away.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.etools.systems.model.ISystemResourceChangeListener
getShell
 

Field Detail

copyright

public static final String copyright
See Also:
Constant Field Values

connectionLabel

protected Label connectionLabel

connectionCombo

protected Combo connectionCombo

newButton

protected Button newButton

showNewButton

protected boolean showNewButton

showLabel

protected boolean showLabel

showQualifiedNames

protected boolean showQualifiedNames

listeningForConnectionEvents

protected boolean listeningForConnectionEvents
Constructor Detail

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             String systemType,
                             SystemConnection defaultConnection,
                             boolean showNewButton)
Constructor for SystemConnectionCombo when there is only a single system type to restrict the connection list to.

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
systemType - the system type to restrict the connection list to. Can be null or * for all.
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             String[] systemTypes,
                             SystemConnection defaultConnection,
                             boolean showNewButton)
Constructor for SystemConnectionCombo when there is an array of system types to restrict the connection list to.

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
systemTypes - the system type array to restrict the connection list to.
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             SubSystemFactory ssFactory,
                             SystemConnection defaultConnection,
                             boolean showNewButton)
Constructor for SystemConnectionCombo when there is a subsystem factory to restrict the list to.

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             SystemConnection defaultConnection,
                             String ssFactoryId,
                             boolean showNewButton)
Constructor for SystemConnectionCombo when there is a subsystem factory id to restrict the list to. To avoid collision with the constructor that takes a string for the system type, this one places the subystem factory Id string parameter after the defaultConnection constructor

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             SystemConnection defaultConnection,
                             boolean showNewButton,
                             String ssFactoryCategory)
Constructor for SystemConnectionCombo when there is a subsystem factory category to restrict the list to. To avoid collision with the constructor that takes a string for the system type, this one places the string parameter at the end.

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite

SystemConnectionCombo

public SystemConnectionCombo(Composite parent,
                             int style,
                             SystemConnection defaultConnection,
                             boolean showNewButton,
                             String ssFactoryCategory,
                             boolean showLabel)
Constructor for SystemConnectionCombo when there is a subsystem factory category to restrict the list to. To avoid collision with the constructor that takes a string for the system type, this one places the string parameter at the end.

Parameters:
parent - Parent composite
style - SWT style flags for overall composite widget. Typically just pass SWT.NULL
defaultConnection - the system connection to preselect. Pass null to preselect first connection.
showNewButton - true if a New... button is to be included in this composite
Method Detail

setAutoUpperCase

public void setAutoUpperCase(boolean enable)
Set auto-uppercase. When enabled, all non-quoted values are uppercases when added to the history.

This method is part of ISystemCombo, so we must support it, but it does not apply this combo widget since the contents are read-only. Hence, it does nothing!

Specified by:
setAutoUpperCase in interface ISystemCombo

init

protected void init(Composite parent,
                    boolean showNewButton)

init

protected void init(Composite parent,
                    boolean showNewButton,
                    boolean showLabel)

getNewConnectionAction

protected SystemNewConnectionAction getNewConnectionAction(Shell shell,
                                                           ISelectionProvider selectionProvider)
Overridable method. Returns action to be called when New... pressed.


getSystemConnection

public SystemConnection getSystemConnection()
Get the user selected SystemConnection object. Might be null if the list is empty.


getCombo

public Combo getCombo()
Return the combo box widget

Specified by:
getCombo in interface ISystemCombo

setWidthHint

public void setWidthHint(int widthHint)
Set the width hint for this whole composite Default is 180.

Specified by:
setWidthHint in interface ISystemCombo

setButtonWidthHint

public void setButtonWidthHint(int widthHint)
Set button width hint


getGridColumns

public int getGridColumns()
Return the number of grid data columns within this composite. Will vary depending if there is a New button or not.


getNewButton

public Button getNewButton()
Return the New... button widget


getPromptLabel

public Label getPromptLabel()
Get the prompt Label widget


setItems

public void setItems(String[] items)
Set the items in the combo field


getItems

public String[] getItems()
Get the items in the combo field


getText

public String getText()
Return the text in the connection combo entry field. This is only of limited value. You should call getSystemConnection() instead.

Specified by:
getText in interface ISystemCombo

setEnabled

public void setEnabled(boolean enabled)
Disable/Enable all the child controls.

Specified by:
setEnabled in interface ISystemCombo

setToolTipText

public void setToolTipText(String tip)
Set the tooltip text for the directory combo field

Specified by:
setToolTipText in interface ISystemCombo

setNewButtonToolTipText

public void setNewButtonToolTipText(String tip)
Set the tooltip text for the new button


setButtonToolTipText

public void setButtonToolTipText(String tip)
Same as setNewButtonToolTipText(String)

Specified by:
setButtonToolTipText in interface ISystemCombo

setLabel

public void setLabel(String label)
Set the label to use for the prompt.


setFocus

public boolean setFocus()
Set the focus to the directory combo field

Specified by:
setFocus in interface ISystemCombo

setNewButtonFocus

public void setNewButtonFocus()
Set the focus to the new button


select

public void select(int selIdx)
Select the combo dropdown list entry at the given index.

Specified by:
select in interface ISystemCombo

setSelectionIndex

public void setSelectionIndex(int selIdx)
Same as select(int)

Specified by:
setSelectionIndex in interface ISystemCombo

select

public void select(SystemConnection connection)
Select a connection from the dropdown


clearSelection

public void clearSelection()
Deselect

Specified by:
clearSelection in interface ISystemCombo

clearTextSelection

public void clearTextSelection()
Clear the entered/selected contents of the combo box. Clears only the text selection, not the list selection

Specified by:
clearTextSelection in interface ISystemCombo

getSelectionIndex

public int getSelectionIndex()
Get the index number of the currently selected item.

Specified by:
getSelectionIndex in interface ISystemCombo

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Register a listener interested in an item is selected in the combo box

Specified by:
addSelectionListener in interface ISystemCombo
See Also:
removeSelectionListener(SelectionListener)

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Remove a previously set combo box selection listener.

Specified by:
removeSelectionListener in interface ISystemCombo
See Also:
addSelectionListener(SelectionListener)

addNewButtonSelectionListener

public void addNewButtonSelectionListener(SelectionListener listener)
Register a listener interested in when the new button is selected

See Also:
removeNewButtonSelectionListener(SelectionListener)

removeNewButtonSelectionListener

public void removeNewButtonSelectionListener(SelectionListener listener)
Remove a previously set new button selection listener.

See Also:
addNewButtonSelectionListener(SelectionListener)

addModifyListener

public void addModifyListener(ModifyListener listener)
Register a listener interested in entry field modify events

See Also:
removeModifyListener(ModifyListener)

removeModifyListener

public void removeModifyListener(ModifyListener listener)
Remove a previously set entry field listener.

See Also:
addModifyListener(ModifyListener)

prepareComposite

protected Composite prepareComposite(int numColumns)
Prepares this composite control and sets the default layout data.


createConnectionCombo

protected Combo createConnectionCombo(Composite parent)
Creates a new readonly connection combobox instance and sets the default layout data, with tooltip text. Assign the listener to the passed in implementer of Listener.

This fills the combination with the names of all the active connections of the given system type.

Parameters:
parent - composite to put the button into.

createCombo

public static Combo createCombo(Composite parent,
                                boolean readonly)
Creates a new combobox instance and sets the default layout data.

Does NOT set the widthHint as that causes problems. Instead the combo will consume what space is available within this composite.

Parameters:
parent - composite to put the button into.

populateConnectionCombo

protected boolean populateConnectionCombo(Combo combo,
                                          String systemType,
                                          SystemConnection defaultConnection,
                                          boolean preSelectIfNoMatch)
Populates a readonly connection combobox instance with system connections for the given system type.

This fills the combination with the names of all the active connections of the given system type.

Parameters:
systemType - the system type to restrict the connection list to. Pass null or * for all system types
defaultConnection - the default system connection to preselect.
preSelectIfNoMatch - true if we should preselect the first item if the given connection is not found
Returns:
true if given default connection was found and selected

populateConnectionCombo

protected boolean populateConnectionCombo(Combo combo,
                                          String systemType,
                                          SystemConnection defaultConnection,
                                          boolean preSelectIfNoMatch,
                                          boolean appendToCombo)
Populates a readonly connection combobox instance with system connections for the given system type.

This fills the combination with the names of all the active connections of the given system type.

Parameters:
systemType - the system type to restrict the connection list to. Pass null or * for all system types
defaultConnection - the default system connection to preselect.
preSelectIfNoMatch - true if we should preselect the first item if the given connection is not found
appendToCombo - indicates whether or not to append to combo with population or replace
Returns:
true if given default connection was found and selected

populateConnectionCombo

protected void populateConnectionCombo(Combo combo,
                                       String[] systemTypes,
                                       SystemConnection defaultConnection)
Populates a readonly connection combobox instance with system connections for the given array of system types.

Parameters:
systemTypes - the system types to restrict the connection list to. Pass null or * for all system types
defaultConnection - the default system connection to preselect.

populateConnectionCombo

protected boolean populateConnectionCombo(Combo combo,
                                          SubSystemFactory ssFactory,
                                          SystemConnection defaultConnection)
Populates a readonly connection combobox instance with system connections which have subsystems owned by the given subsystem factory.

Parameters:
defaultConnection - the default system connection to preselect.
Returns:
true if given default connection was found and selected

populateConnectionCombo

protected boolean populateConnectionCombo(Combo combo,
                                          String ssFactoryId,
                                          SystemConnection defaultConnection)
Populates a readonly connection combobox instance with system connections which have subsystems owned by a subsystem factory of the given subsystem factory id.

Parameters:
defaultConnection - the default system connection to preselect.
Returns:
true if given default connection was found and selected

populateConnectionCombo

protected boolean populateConnectionCombo(Combo combo,
                                          SystemConnection defaultConnection,
                                          String ssFactoryCategory)
Populates a readonly connection combobox instance with system connections which have subsystems owned by a subsystem factory of the given subsystem factory category.

Parameters:
defaultConnection - the default system connection to preselect.
Returns:
true if given default connection was found and selected

sub

protected static String sub(String msg,
                            String subOld,
                            String subNew)
Do string variable substitution. Using you are replacing %1 (say) with a string

Returns:
message with all occurrences of variable substituted with data.

refreshConnections

public void refreshConnections()
Refresh the list of connections


systemResourceChanged

public void systemResourceChanged(ISystemResourceChangeEvent event)
This is the method in your class that will be called when a system resource changes. We want to listen to connection changes.

Specified by:
systemResourceChanged in interface ISystemResourceChangeListener
See Also:
ISystemResourceChangeEvent

listenToConnectionEvents

public void listenToConnectionEvents(boolean start)
Have the SystemConnectionCombo listen to add/delete/rename events on connections and automatically update it's list of connections


widgetDisposed

public void widgetDisposed(DisposeEvent e)
We are going away. De-Register ourselves as a listener for system resource change events


addOurButtonSelectionListener

protected void addOurButtonSelectionListener()

addOurConnectionSelectionListener

protected void addOurConnectionSelectionListener()

setConnectionToolTipText

protected void setConnectionToolTipText()

createPushButton

protected static Button createPushButton(Composite group,
                                         String label)

createPushButton

protected static Button createPushButton(Composite group,
                                         ResourceBundle bundle,
                                         String key)

addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener listener)
Register a listener interested in an item is selected in the combo box

See Also:
removeSelectionChangedListener(ISelectionChangedListener)

removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener listener)
Remove a previously set combo box selection listener.

See Also:
addSelectionChangedListener(ISelectionChangedListener)

getSelection

public ISelection getSelection()

setSelection

public void setSelection(ISelection selection)

getConnections

public SystemConnection[] getConnections()

setConnections

public void setConnections(SystemConnection[] input)

setBusyCursor

protected void setBusyCursor(boolean setBusy)
Helper method.
Set the cursor to the wait cursor (true) or restores it to the normal cursor (false).


Remote Systems
v6.4.1

Copyright © 2005 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.