LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.win.swing
Class LySwingRelation

java.lang.Object
  extended by leon.view.graphic.LyGraphicalObject
      extended by leon.view.win.swing.LySwingObject
          extended by leon.view.win.swing.LySwingFieldItem
              extended by leon.view.win.swing.LySwingRelation
All Implemented Interfaces:
java.awt.event.ItemListener, java.util.EventListener, LyActionListener, LyEventTransmitter, LyGetValueInterface, LyGraphicalComponent, LyGraphicalFieldItem, LyGraphicalRelation, LyViewComponent, LyFreeInterface, LySetEditableInterface, LySetEnabledInterface, LySetIdleInterface, LySetLinksInterface, LySwingComponent

public class LySwingRelation
extends LySwingFieldItem
implements LySwingComponent, LyGraphicalRelation, java.awt.event.ItemListener, LyActionListener, LySetEnabledInterface, LySetEditableInterface, LyGetValueInterface, LySetIdleInterface

This class implements the Relation object (as described in the dtd) for swing viewer.

An input field of Relation type allows to choose one or more values among a list of values. This list offers generally application objects belonging to a same class and is used to establish a relation between an object and one or more objects of this class. It is possible to specify whether the relation is multiple or not.

See Also:
LyRelation

Field Summary
static java.lang.String __VERSION
           
static java.lang.String DEFAULT_EMPTY_LINK
          Empty link.
static char ITEM_SEP
          Separator between relation items.
static int RELATION_BORDER
          Number of pixels of the border, -1 for auto size (2 pixels by default).
static char VALUE_SEP
          Deprecated.  
 
Constructor Summary
LySwingRelation(LyRelation relation)
          Class constructor of a Relation object for the Swing target.
 
Method Summary
 void actionPerformed(LyActionEvent actionEvent)
          (non-Javadoc).
 void addItemToComboAt(java.awt.Component combo, java.lang.Object item, int pos)
          Adds an item in the specified combo at the specified position.
 void addItemToMultiSelectorAt(java.awt.Component multiSelector, java.lang.Object item, int pos)
          Adds an item in the specified multiselector at the specified position.
 void addLink(LyLink link, int pos)
          Adds the specified link at the specified position.
 void clearCombo(java.awt.Component combo)
          Removes all the items of a combo box.
 java.awt.Component createAutoCompletionCombo()
          Creates a new editable comboBox for the relations elements.
 java.awt.Component createAutoCompletionMultiSelector(LyEnvironment env, java.awt.Color color)
          Creates a new editable multiselector component to represent a multiselection relation.
 java.awt.Component createCombo()
          Creates a new ComboBox for the relations elements and registers the key listeners.
 java.awt.Component createMultiSelector(LyEnvironment env, java.awt.Color color)
          Creates a new multiselector component to represent a multiselection relation.
 void fillAutoCompletionMultiSelector(java.awt.Component multiSelector, LyLink paramLink, boolean addLink)
          Sets the content of the auto-completion multiselector depending on the relation's links.
 void fillMultiSelector(java.awt.Component multiSelector, LyLink paramLink, boolean addLink)
          Sets the content of the multiselector depending on the relation's links.
 java.lang.Object getComboItemAt(java.awt.Component combo, int index)
          Gets the combo item at the specified index in the given combo box.
 int getComboItemCount(java.awt.Component combo)
          Gets the number of combo items in the specified combo box.
 int getComboSelectedIndex(java.awt.Component combo)
          Gets the index of the specified combo box in the current combo.
 java.awt.Component getComponent()
          (non-Javadoc).
 java.lang.String getMultiSelectorValue(java.awt.Component multiSelector)
          Gets the multiselector value of the specified multiselector.
 java.lang.String getValue()
          (non-Javadoc).
 void initialize()
          Initializes the relation component.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Processes changed state event only if relation is not multiple.
 void removeItemFromComboAt(java.awt.Component combo, int pos)
          Removes the item from the given combo at the specified position.
 void removeLink(LyLink link)
          Removes the specified link of the relation.
 void setComboSelectedIndex(java.awt.Component combo, int selectedIndex)
          Sets the selected index of the combo.
 void setContent()
          Refreshes the content of the relation component.
 void setEditable(boolean editable)
          Sets the editable status of the field item.
 void setEnabled(boolean status)
          Indicates the parent editable status.
 void setIdle(boolean status)
          Sets the idle mode on this component.
 void setMultiSelectorSelectedObject(java.awt.Component multiSelector, java.lang.Object selectedObject, boolean selected)
          Selects/unselects an object id in the multiselector.
 void setSelected(LyLink link, boolean selected)
          Sets the selected flag for the given link in this component.
 void setValue(java.lang.String value)
          Sets current value.
 
Methods inherited from class leon.view.win.swing.LySwingFieldItem
getActionTransmitter, getSelectionTransmitter
 
Methods inherited from class leon.view.win.swing.LySwingObject
getBounds, getChildrenBounds, getDefaultFrame
 
Methods inherited from class leon.view.graphic.LyGraphicalObject
expand, free, getController, getEnv, getEnvironment, getIdCode, getIntResource, getMessage, getMessage, getResource, getString, getString, getString, getViewComponent, getViewManager, isFreed, isFreeing, isImageAnimated, processDemand, processDemand, testResource, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface leon.view.graphic.LyGraphicalComponent
free, getViewComponent
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

ITEM_SEP

public static final char ITEM_SEP
Separator between relation items.

See Also:
Constant Field Values

VALUE_SEP

public static final char VALUE_SEP
Deprecated. 
Separator between values ids.

See Also:
Constant Field Values

DEFAULT_EMPTY_LINK

public static final java.lang.String DEFAULT_EMPTY_LINK
Empty link. A space filled String is used to pack correctly its container components.

See Also:
Constant Field Values

RELATION_BORDER

public static int RELATION_BORDER
Number of pixels of the border, -1 for auto size (2 pixels by default).

Constructor Detail

LySwingRelation

public LySwingRelation(LyRelation relation)
Class constructor of a Relation object for the Swing target.

Parameters:
relation - a RELATION component defined for every type of view targets. This relation is initialized for the swing view and filled with its default values.
Method Detail

initialize

public void initialize()
Initializes the relation component.


setContent

public void setContent()
Refreshes the content of the relation component.

See Also:
setContent(LyLink, boolean)

createCombo

public java.awt.Component createCombo()
Creates a new ComboBox for the relations elements and registers the key listeners.

Returns:
a new empty ComboBox

createAutoCompletionCombo

public java.awt.Component createAutoCompletionCombo()
Creates a new editable comboBox for the relations elements.

Returns:
a new empty editable ComboBox

createMultiSelector

public java.awt.Component createMultiSelector(LyEnvironment env,
                                              java.awt.Color color)
Creates a new multiselector component to represent a multiselection relation.

Parameters:
env - the environment needed to find mutliselector images
color - the selection color, not used in this implementation
Returns:
a new empty multiselector

createAutoCompletionMultiSelector

public java.awt.Component createAutoCompletionMultiSelector(LyEnvironment env,
                                                            java.awt.Color color)
Creates a new editable multiselector component to represent a multiselection relation.

Parameters:
env - the environment needed to find mutliselector images
color - the selection color, not used in this implementation
Returns:
a new empty editable multiselector

clearCombo

public void clearCombo(java.awt.Component combo)
Removes all the items of a combo box.

Parameters:
combo - the combo box to unfill

setComboSelectedIndex

public void setComboSelectedIndex(java.awt.Component combo,
                                  int selectedIndex)
Sets the selected index of the combo.

Parameters:
combo - select the items of this combo box
selectedIndex - index of the item to select in the combo box
See Also:
getComboSelectedIndex(Component)

setMultiSelectorSelectedObject

public void setMultiSelectorSelectedObject(java.awt.Component multiSelector,
                                           java.lang.Object selectedObject,
                                           boolean selected)
Selects/unselects an object id in the multiselector.

Parameters:
multiSelector - the source multiselector
selectedObject - sets or unsets the selected flag for this given object
selected - the selected flag for the given object

fillMultiSelector

public void fillMultiSelector(java.awt.Component multiSelector,
                              LyLink paramLink,
                              boolean addLink)
Sets the content of the multiselector depending on the relation's links.

Parameters:
multiSelector - the multiselector to fill
paramLink - a link that may be or may not be in the parent list
addLink - specifies if we should adds the links or discard them

fillAutoCompletionMultiSelector

public void fillAutoCompletionMultiSelector(java.awt.Component multiSelector,
                                            LyLink paramLink,
                                            boolean addLink)
Sets the content of the auto-completion multiselector depending on the relation's links.

Parameters:
multiSelector - the multiselector to fill
paramLink - a link that may be or may not be in the parent list
addLink - specifies if we should adds the links or discard them

getComboSelectedIndex

public int getComboSelectedIndex(java.awt.Component combo)
Gets the index of the specified combo box in the current combo.

Parameters:
combo - the combo that is searched in the current combo box
Returns:
the selected index of the combo
See Also:
setComboSelectedIndex(Component, int)

getMultiSelectorValue

public java.lang.String getMultiSelectorValue(java.awt.Component multiSelector)
Gets the multiselector value of the specified multiselector.

Parameters:
multiSelector - the multiselector component that is searched for its selection
Returns:
the multiselector selection as a String

addItemToComboAt

public void addItemToComboAt(java.awt.Component combo,
                             java.lang.Object item,
                             int pos)
Adds an item in the specified combo at the specified position.

Parameters:
combo - the combo box component
item - the item to add
pos - the position of the item in the combo

removeItemFromComboAt

public void removeItemFromComboAt(java.awt.Component combo,
                                  int pos)
Removes the item from the given combo at the specified position.

Parameters:
combo - the combo containing the item to remove
pos - the position of the item to remove

addItemToMultiSelectorAt

public void addItemToMultiSelectorAt(java.awt.Component multiSelector,
                                     java.lang.Object item,
                                     int pos)
Adds an item in the specified multiselector at the specified position.

Parameters:
multiSelector - the multiselector component
item - the item to add
pos - the position of the item in the combo

getComboItemCount

public int getComboItemCount(java.awt.Component combo)
Gets the number of combo items in the specified combo box.

Parameters:
combo - the combo box
Returns:
the number of elements in the combo

getComboItemAt

public java.lang.Object getComboItemAt(java.awt.Component combo,
                                       int index)
Gets the combo item at the specified index in the given combo box.

Parameters:
combo - the combo box
index - the index of the item
Returns:
the item at the specified index from the combo

setIdle

public void setIdle(boolean status)
Sets the idle mode on this component. Implements idle mode on relations.

Specified by:
setIdle in interface LySetIdleInterface
Parameters:
status - new idle status (LySetIdleInterface interface)
See Also:
LySetIdleInterface.setIdle(boolean)

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Processes changed state event only if relation is not multiple.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
See Also:
ItemListener.itemStateChanged(java.awt.event.ItemEvent)

setSelected

public void setSelected(LyLink link,
                        boolean selected)
Sets the selected flag for the given link in this component.

Parameters:
link - the link to set
selected - the selected flag

actionPerformed

public void actionPerformed(LyActionEvent actionEvent)
(non-Javadoc).

Specified by:
actionPerformed in interface LyActionListener
See Also:
LyActionListener.actionPerformed(leon.view.event.LyActionEvent)

getValue

public java.lang.String getValue()
(non-Javadoc).

Specified by:
getValue in interface LyGetValueInterface
See Also:
LyGetValueInterface.getValue()

setValue

public void setValue(java.lang.String value)
Sets current value.

Parameters:
value - the new value
See Also:
getValue()

setEditable

public void setEditable(boolean editable)
Sets the editable status of the field item.

Specified by:
setEditable in interface LySetEditableInterface
Parameters:
editable - new status
See Also:
LySetEditableInterface.setEditable(boolean)

setEnabled

public void setEnabled(boolean status)
Indicates the parent editable status. The component is editable if its editable state is true and if its parent edition status is true.

Specified by:
setEnabled in interface LySetEnabledInterface
Parameters:
status - new enabled status

getComponent

public java.awt.Component getComponent()
(non-Javadoc).

Specified by:
getComponent in interface LySwingComponent
Overrides:
getComponent in class LySwingObject
Returns:
this Swing view component
See Also:
LySwingComponent.getComponent()

addLink

public void addLink(LyLink link,
                    int pos)
Adds the specified link at the specified position.

Specified by:
addLink in interface LyGraphicalRelation
Specified by:
addLink in interface LySetLinksInterface
Parameters:
link - the link to add to this relation
pos - the position of the link in this relation component
See Also:
LySetLinksInterface.addLink(leon.view.LyLink, int)

removeLink

public void removeLink(LyLink link)
Removes the specified link of the relation.

Specified by:
removeLink in interface LyGraphicalRelation
Specified by:
removeLink in interface LySetLinksInterface
Parameters:
link - The links to remove to links list.
See Also:
LySetLinksInterface.removeLink(leon.view.LyLink)

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com