ilog.webui.dhtml.components

Class IlxWComboBox

  • All Implemented Interfaces:
    ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, ilog.webui.dhtml.IlxWJSObject, java.awt.event.ActionListener, java.awt.ItemSelectable, java.io.Serializable, java.util.EventListener, javax.swing.event.ListDataListener


    public class IlxWComboBox
    extends ilog.webui.dhtml.components.IlxWLabelWrapper
    implements javax.swing.event.ListDataListener, java.awt.ItemSelectable, java.awt.event.ActionListener
    A combo box component.

    The combo box component relies on a model, instance of javax.swing.ComboBoxModel. It may be rendered in several modes, determined by the value of the "mode" CSS style. Possible values for the mode style are:

    • system: renders the combo box as a <select> HTML element. This mode is not supported if the combo box has a renderer or an editor. In this case, the component tries to render itself in the "arrow" mode.
    • link: renders the combo box as a hyperlink which, once clicked pops up a menu just under the link. If the combo box has an editor, this mode is not supported, and the component tries to render itself in "arrow" mode. The combo box may also not support this mode with some Web browsers (Netscape 3 & Netscape 4.7 for instance). In this case, the component tries render itself in the "linkdialog" mode.
    • arrow: renders the combo box as Swing combo box: the current renderer or the current editor is displayed, and an arrow button is displayed to the right. A click on the arrow button pops up a menu with the possible items. The combo box may not support this mode with some Web browsers (Netscape 3 & Netscape 4.7 for instance). In this case, the component tries render itself in the "arrowdialog" mode.
    • linkdialog: Same as the link mode but a dialog box is popped up displaying the available items, instead of a drop down list.
    • arrowdialog: Same as the arrow mode but a dialog box is popped up displaying the available items, instead of a drop down list.
    If no mode is set, the component always first tries to render in system mode. To set the current mode, you can either write a CSS style sheet:
     ComboBox
     {
       mode: arrow;
     }
     
    ... or dynamically set the style on the object:
     myComboBox.getStyle().set("mode", "arrow");
     
    See Also:
    Serialized Form
    • Field Detail

      • MODEL_PROPERTY

        public static final java.lang.String MODEL_PROPERTY
        The model bound property name.
        See Also:
        Constant Field Values
      • EDITOR_PROPERTY

        public static final java.lang.String EDITOR_PROPERTY
        The editor bound property name.
        See Also:
        Constant Field Values
      • EDITABLE_PROPERTY

        public static final java.lang.String EDITABLE_PROPERTY
        The editable bound property name.
        See Also:
        Constant Field Values
      • ENABLED_PROPERTY

        public static final java.lang.String ENABLED_PROPERTY
        The enabled bound property name.
        See Also:
        Constant Field Values
      • ACTION_PROPERTY

        public static final java.lang.String ACTION_PROPERTY
        The action bound property name.
        See Also:
        Constant Field Values
      • RENDERER_PROPERTY

        public static final java.lang.String RENDERER_PROPERTY
        The renderer bound property name.
        See Also:
        Constant Field Values
      • model

        protected javax.swing.ComboBoxModel model
      • isEditable

        protected boolean isEditable
      • actionCommand

        protected java.lang.String actionCommand
      • ui

        protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI ui
        Access to allow another UI to the combo box (JSF)
    • Constructor Detail

      • IlxWComboBox

        public IlxWComboBox(javax.swing.ComboBoxModel aModel)
        Creates an IlxWComboBox that takes its items from an existing ComboBoxModel.
        Parameters:
        aModel - The ComboBoxModel that provides the displayed list of items.
      • IlxWComboBox

        public IlxWComboBox(java.lang.Object[] items)
        Creates an IlxWComboBox that contains the elements in the specified array.
      • IlxWComboBox

        public IlxWComboBox(java.util.Vector items)
        Creates an IlxWComboBox that contains the elements in the specified Vector.
      • IlxWComboBox

        public IlxWComboBox()
        Creates an IlxWComboBox with a default data model. Use addItem to add items.
    • Method Detail

      • setModel

        public void setModel(javax.swing.ComboBoxModel model)
        Sets the data model that the IlxWComboBox uses to obtain the list of items.
        Parameters:
        model - The combo box model that provides the displayed list of items.
      • getModel

        public javax.swing.ComboBoxModel getModel()
        Returns the data model currently used by the IlxWComboBox.
        Returns:
        The combo box model that provides the displayed list of items.
      • setEditable

        public void setEditable(boolean aFlag)
        Determines whether the IlxWComboBox field is editable.

        An editable IlxWComboBox allows the user to type into the field or select an item from the list to initialize the field, after which it can be edited.

        A non editable IlxWComboBox displays the selected item in the field, but the selection cannot be modified.

        Parameters:
        aFlag - A boolean value, where true indicates that the field is editable.
      • isEditable

        public boolean isEditable()
        Returns True if the IlxWComboBox is editable.
        Returns:
        true if the combo box can be edited; false otherwise.
      • setRenderer

        public void setRenderer(IlxWListCellRenderer renderer)
        Sets the renderer that paints the item selected from the list in the IlxWComboBox field.

        The renderer is used if the IlxWComboBox is not editable, otherwise the editor is used to render and edit the selected item.

        The default renderer displays a string, obtained by calling the selected object's toString method. Other renderers can handle graphic images and composite items.

        To display the selected item, aRenderer.getListCellRendererComponent is called, passing the list object and an index of -1.

        Parameters:
        renderer - The ListCellRenderer that displays the selected item.
        See Also:
        setEditor(ilog.webui.dhtml.components.IlxWComboBoxEditor)
      • getRenderer

        public IlxWListCellRenderer getRenderer()
        Returns the renderer used to display the selected item in the IlxWComboBox field.
        Returns:
        The list cell renderer that displays the selected item.
      • setEditor

        public void setEditor(IlxWComboBoxEditor editor)
        Sets the editor used to paint and edit the selected item in the IlxWComboBox field.

        The editor is used only if the receiving IlxWComboBox is editable. If not editable, the combo box uses the renderer to render the selected item.

        Parameters:
        editor - The IlxWComboBoxEditor that displays the selected item.
        See Also:
        setRenderer(ilog.webui.dhtml.components.IlxWListCellRenderer)
      • getEditor

        public IlxWComboBoxEditor getEditor()
        Returns the editor used to render and edit the selected item in the IlxWComboBox field.
        Returns:
        The combo box editor that displays the selected item.
      • configureEditor

        public void configureEditor(IlxWComboBoxEditor anEditor,
                           java.lang.Object anItem)
        Initializes the editor with the specified item.
        Parameters:
        anEditor - The IlxWComboBoxEditor that displays the list item in the combo box field and allows it to be edited.
        anItem - The object to display and edit in the field.
      • setSelectedItem

        public void setSelectedItem(java.lang.Object anObject)
        Sets the selected item in the IlxWComboBox by specifying the object in the list.

        If anObject is in the list, the list displays with anObject selected. If the object does not exist in the list, the default data model selects the first item in the list.

        Parameters:
        anObject - The list object to select.
      • getSelectedItem

        public java.lang.Object getSelectedItem()
        Returns the currently selected item.
        Returns:
        The currently selected object in the data model.
      • setSelectedIndex

        public void setSelectedIndex(int index)
        Selects the item at index anIndex.
        Parameters:
        index - An int specifying the list item to select, where 0 specifies the first item in the list.
      • getSelectedIndex

        public int getSelectedIndex()
        Returns the index of the currently selected item in the list.

        The result is not always defined if the IlxWComboBox box allows selected items that are not in the list. Returns -1 if there is no selected item or if the user specified an item which is not in the list.

        Returns:
        An int specifying the list item that is currently selected 0 specifies the first item in the list, -1 indicates that no item is selected or that the currently selected item is not in the list.
      • addItemListener

        public void addItemListener(java.awt.event.ItemListener listener)
        Adds an item listener.

        aListener will receive an event when the selected item changes.

        Specified by:
        addItemListener in interface java.awt.ItemSelectable
        Parameters:
        listener - The item listener that is to be notified.
      • removeItemListener

        public void removeItemListener(java.awt.event.ItemListener listener)
        Removes an item listener.
        Specified by:
        removeItemListener in interface java.awt.ItemSelectable
        Parameters:
        listener - The item listener to remove.
      • addActionListener

        public void addActionListener(java.awt.event.ActionListener l)
        Adds an action listener.

        The listener will receive an action event the user finishes making a selection.

        Parameters:
        l - The action listener that is to be notified.
      • removeActionListener

        public void removeActionListener(java.awt.event.ActionListener l)
        Removes an action listener.
        Parameters:
        l - The action listener to remove.
      • setActionCommand

        public void setActionCommand(java.lang.String aCommand)
        Sets the action command that should be included in the event sent to action listeners.
        Parameters:
        aCommand - A string containing the "command" that is sent to action listeners. The same listener can then do different things depending on the command it receives.
      • getActionCommand

        public java.lang.String getActionCommand()
        Returns the action command that is included in the event sent to action listeners.
        Returns:
        the string containing the command that is sent to action listeners. This command is an arbitrary character string.
      • fireItemStateChanged

        protected void fireItemStateChanged(java.awt.event.ItemEvent e)
        Notify all listeners that have registered interest for notification on this event type.
        See Also:
        EventListenerList
      • getItemListeners

        public java.awt.event.ItemListener[] getItemListeners()
      • fireActionEvent

        protected void fireActionEvent()
        Notify all listeners that have registered interest for notification on this event type.
      • getActionListeners

        public java.awt.event.ActionListener[] getActionListeners()
      • selectedItemChanged

        protected void selectedItemChanged()
        This method is called when the selected item changes.

        Its default implementation notifies the item listeners.

      • getSelectedObjects

        public java.lang.Object[] getSelectedObjects()
        Returns an array containing the selected item.
        Specified by:
        getSelectedObjects in interface java.awt.ItemSelectable
        Returns:
        An array of objects containing one element -- the selected item.
      • actionPerformed

        public void actionPerformed(java.awt.event.ActionEvent e)
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
      • getUI

        protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI(IlxWPort port)
        Parameters:
        port - The current port.
        Returns:
        the UI of the combo box.
      • getUI

        protected ilog.webui.dhtml.components.IlxWComboBox.ComboBoxUI getUI()
        Returns:
        the UI of the combo box.
      • intervalAdded

        public void intervalAdded(javax.swing.event.ListDataEvent e)
        Specified by:
        intervalAdded in interface javax.swing.event.ListDataListener
      • intervalRemoved

        public void intervalRemoved(javax.swing.event.ListDataEvent e)
        Specified by:
        intervalRemoved in interface javax.swing.event.ListDataListener
      • contentsChanged

        public void contentsChanged(javax.swing.event.ListDataEvent e)
        Specified by:
        contentsChanged in interface javax.swing.event.ListDataListener
      • setEnabled

        public void setEnabled(boolean b)
        Enables the combo box so that items can be selected.

        When the combo box is disabled, items cannot be selected and values cannot be typed into its field (if it is editable).

        Parameters:
        b - A boolean value, where true enables the component and false disables it.
      • isEnabled

        public boolean isEnabled()
        Determines whether this component is enabled.
        Returns:
        true if this component is enabled.
        See Also:
        setEnabled(boolean)
      • getItemCount

        public int getItemCount()
        Returns the number of items in the list.
        Returns:
        an int equal to the number of items in the list.
      • getItemAt

        public java.lang.Object getItemAt(int index)
        Returns the list item at the specified index.
        Parameters:
        index - An int indicating the list position, where the first item starts at zero.
        Returns:
        the Object at that list position.
      • getAction

        public IlxWAction getAction()
        Gets the action that will be called when the user selects an item in the combo box.

        By default, this action is a Java action (IlxWJavaAction) of which the perform method calls setSelectedItem on the combo box.

        If the given action is a Java action (IlxWJavaAction), the argument array passed to the perform method is a 1-length array containing the selected item. If the given action is a JS action (IlxWJSAction), the argument array passed when calling the associated function is a 1-length array containing the string representation of the selected item.

        Returns:
        the action to perform when the user selects an item.
        See Also:
        setAction(ilog.webui.dhtml.components.IlxWAction)
      • setAction

        public void setAction(IlxWAction action)
        Sets the action that will be called when the user selects an item in the combo box.
        Parameters:
        action - The action to perform when the user selects an item from the list.
        See Also:
        getAction()
      • setOnChangeJSAction

        public void setOnChangeJSAction(java.lang.String onChangeAction)
      • getOnChangeJSAction

        public java.lang.String getOnChangeJSAction()
      • update

        public void update(org.w3c.dom.Element elt)
      • notifyDependencies

        public void notifyDependencies(IlxWPort port)
        Specified by:
        notifyDependencies in interface ilog.webui.dhtml.IlxWDependencyProvider
        Overrides:
        notifyDependencies in class IlxWComponent

© Copyright IBM Corp. 1987, 2017