Class AssociationsPanel

java.lang.Object
java.awt.Component
java.awt.Container
wt.clients.beans.AssociationsPanel
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable

public class AssociationsPanel extends Container implements ItemSelectable
This bean has a dev-time and run-time component. At dev-time, this component can be dragged from the component library in Visual Cafe and dropped onto a container. The properties can also be edited by using Visual Cafe's Property Editor. At run-time, this class retrieves the links of the object and displays them in a multilist. The bean has an Edit and View mode. In edit mode, the user can add new relationships, remove existing relationships, and update existing relationships by editing the attributes on the link. In view mode, the user can view the relationships and view the attributes on the link. The bean keeps track of the creates, updates, and removes and is able to persist the changes when save() is invoked. The following is an example of how to use the bean:
                associationsPanel1 = new wt.clients.beans.AssociationsPanel();
                associationsPanel1.setRole("someRole");
                associationsPanel1.setChooserOptions(wt.clients.beans.query.ChooserOptions.SOME_SEARCH_LIST);
                try {
                        java.lang.String[] tempString = new java.lang.String[5];
                        tempString[0] = display("nameColumn");
                        tempString[1] = display("numberColumn");
                        tempString[2] = display(SomeRB.TITLE_COLUMN);
                        tempString[3] = display(SomeRB.PART_TYPE_COLUMN);
                        tempString[4] = display(SomeRB.SOURCE_COLUMN);
                        associationsPanel1.setLabels(tempString);
                }
                catch(java.beans.PropertyVetoException e) { }
                try {
                        associationsPanel1.setLinkClassName("someClass");
                }
                catch(wt.util.WTPropertyVetoException e) { }
                try {
                        associationsPanel1.setObjectClassName("anotherClass");
                }
                catch(java.lang.ClassNotFoundException e) { }
                try {
                        java.lang.String[] tempString = new java.lang.String[5];
                        tempString[0] = new java.lang.String("name");
                        tempString[1] = new java.lang.String("number");
                        tempString[2] = new java.lang.String("title");
                        tempString[3] = new java.lang.String("partType");
                        tempString[4] = new java.lang.String("source");
                        associationsPanel1.setOtherSideAttributes(tempString);
                }
                catch(wt.util.WTPropertyVetoException e) { }
                try {
                        associationsPanel1.setOtherSideClassName("someClass");
                }
                catch(java.lang.ClassNotFoundException e) { }
                associationsPanel1.setMode("Edit");
                try {
                        java.lang.String[] tempString = new java.lang.String[1];
                        tempString[0] = new java.lang.String("description");
                        associationsPanel1.setLinkAttributes(tempString);
                }
                catch(wt.util.WTPropertyVetoException e) { }
                associationsPanel1.setBounds(0,0,530,62);
                associationsPanel1.setBackground(new Color(12632256));
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.weightx = 1.0;
                gbc.weighty = 1.0;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.insets = new Insets(0,0,0,0);
                ((GridBagLayout)panel3.getLayout()).setConstraints(associationsPanel1, gbc);
                panel3.add(associationsPanel1);
                associationsPanel1.addHelpListener(helpListener);
       associationsPanel1.setObject(taskLogic.getCurrentObject());
       associationsPanel1.setEnabled(true);
                associationsPanel1.save(taskLogic.getCurrentObject());
            associationsPanel1.getHelpContext().stopIt();
   
The class accommodates validating and persisting changes only when the save() method is invoked. To turn on this behavior invoke the setSaveUpdatesOnly(true) method. The normal behavior is to verify and persist all association entries even though some of the entries are not changed. When the normal behavior is used existing described by documents that are in a checked out state by another user will error when the save() method is invoked. This results in adds, removes, or updates not being saved. If this is not the desired behavior then invoke the setSaveUpdatesOnly(true) method immediately after instantiating the class.

Supported API: true.

Extendable: true.
See Also:
  • Constructor Details

    • AssociationsPanel

      public AssociationsPanel()
      This is the no arg constructor that creates the panel with a multilist, a view button, and an attributesForm which will be used to display or edit the attributes on the link.

      Supported API: true.
    • AssociationsPanel

      public AssociationsPanel(String mode)
      This creates an instance of the associationsPanel and sets the mode to the parameter.

      Supported API: true.
  • Method Details

    • localize

      protected void localize()
      This method sets the text of the components to the localized string from the resource bundle.

      Supported API: true.
    • getMinimumSize

      public Dimension getMinimumSize()
      This returns the minimum size that will be used at dev-time and at run-time depending on the layout.

      Supported API: true.
      Overrides:
      getMinimumSize in class Container
    • getMinimumSize

      public Dimension getMinimumSize(int cols, int rows)
      This returns the minimum size that will be used at dev-time and at run-time depending on the layout.

      Supported API: true.
    • getPreferredSize

      public Dimension getPreferredSize()
      This returns the preferred size that will be used at dev-time and at run-time depending on the layout.

      Supported API: true.
      Overrides:
      getPreferredSize in class Container
    • getPreferredSize

      public Dimension getPreferredSize(int cols, int rows)
      This returns the preferred size that will be used at dev-time and at run-time depending on the layout.

      Supported API: true.
    • isDirty

      public boolean isDirty()
      This returns a boolean value representing whether or not the user has modified anything.

      Supported API: true.
    • setDirty

      protected void setDirty(boolean flag)
      This sets the dirty flag and should be called when the user makes some action to change the state of the bean.

      Supported API: true.
    • isCurrentLinkAttributeDirty

      protected boolean isCurrentLinkAttributeDirty()
      This returns a boolean value representing whether or not the user has modified the current link attribute(s).

      Supported API: true.
    • setCurrentLinkAttributeDirty

      protected void setCurrentLinkAttributeDirty(boolean flag)
      This sets the dirty flag and should be called when the user makes some action to change the state of the bean.

      Supported API: true.
    • setMode

      public void setMode(String mode)
      This is used to set the mode of the bean to either EDIT_MODE or VIEW_MODE and the GUI will be updated based on the mode.

      Supported API: true.
    • getMode

      public String getMode()
      This is the public getter that returns the current mode of the bean.

      Supported API: true.
    • setChooserOptions

      public void setChooserOptions(String options)
      This is used to set the list of classes that the user can pick from on the frame that pops up when the user clicks the Add button.

      Supported API: true.
    • getChooserOptions

      public String getChooserOptions()
      This is used to get the list of classes that the user can pick from on the frame that pops up when the user clicks the Add button.

      Supported API: true.
    • setShowIBA

      public void setShowIBA(boolean show_iba)
      Used to set if IBA tab will show up.

      Supported API: true.
    • getShowIBA

      public boolean getShowIBA()
      Get whether IBA tab will show.

      Supported API: true.
    • getObject

      public Object getObject()
      This is the public getter that will return the object that is being edited or viewed.

      Supported API: true.
    • setObject

      public void setObject(Object object)
      This is the public setter that will set the object that to be edited or viewed. It will spawn a thread that navigates the relationships on the object and populates the multilist with the links of type linkClass.

      Supported API: true.
    • setRole

      public void setRole(String role)
      This is the public setter for the role that will be navigated.

      Supported API: true.
    • getRole

      public String getRole()
      This is the public getter for the role that is navigated.

      Supported API: true.
    • setObjectClass

      public void setObjectClass(Class object_class)
      This is the public setter for the objectClass whose links will be navigated & updated, or viewed.

      Supported API: true.
    • getObjectClass

      public Class getObjectClass()
      This is the public getter for the objectClass whose links are navigated & updated, or viewed.

      Supported API: true.
    • setObjectClassName

      public void setObjectClassName(String object_class) throws ClassNotFoundException
      This is the public setter for the objectClassName which is the string that represents the objectClass whose links will be navigated & updated, or viewed.

      Supported API: true.
      Throws:
      ClassNotFoundException
    • getObjectClassName

      public String getObjectClassName()
      This is the public getter for the objectClassName which is the string that represents the objectClass whose links are navigated & updated, or viewed.

      Supported API: true.
    • getOtherSideClass

      public Class getOtherSideClass()
      This is the public getter that returns the class that is being navigated to along the role.

      Supported API: true.
    • setOtherSideClass

      public void setOtherSideClass(Class other_side)
      This is the public setter that sets the class to be navigated to along the role.

      Supported API: true.
    • getOtherSideClassName

      public String getOtherSideClassName()
      This is the public getter that returns the name of the class that is being navigated to along the role.

      Supported API: true.
    • setOtherSideClassName

      public void setOtherSideClassName(String other_side) throws ClassNotFoundException
      This is the public setter that sets the name of the class to be navigated to along the role.

      Supported API: true.
      Throws:
      ClassNotFoundException
    • setLinkClassName

      public void setLinkClassName(String class_name) throws WTPropertyVetoException
      This sets the name of the linkClass that is being traversed.

      Supported API: true.
      Throws:
      WTPropertyVetoException
    • getLinkClassName

      public String getLinkClassName()
      This gets the name of the linkClass that to be traversed.

      Supported API: true.
    • setLinkAttributes

      public void setLinkAttributes(String[] link_attributes) throws WTPropertyVetoException
      This sets the names of the attributes of the other-side class that will be displayed in the columns of the multilist.

      Supported API: true.
      Throws:
      WTPropertyVetoException
    • getLinkAttributes

      public String[] getLinkAttributes()
      This gets the names of the attributes of the other-side class that are displayed in the columns of the multilist.

      Supported API: true.
    • setMultiListLinkAttributes

      public void setMultiListLinkAttributes(String[] link_attributes) throws WTPropertyVetoException, PropertyVetoException, ClassNotFoundException, WTIntrospectionException
      This sets the names of the attributes of the link class that will be displayed in the columns of the multilist.

      Supported API: true.
      Throws:
      WTPropertyVetoException
      PropertyVetoException
      ClassNotFoundException
      WTIntrospectionException
    • getMultiListLinkAttributes

      public String[] getMultiListLinkAttributes()
      This gets the names of the attributes of the link class that are displayed in the columns of the multilist.

      Supported API: true.
    • setLinkSchema

      public void setLinkSchema(wt.clients.beans.Schema schema) throws PropertyVetoException
      This is used at dev-time when the developer uses the schema editor to select the class and the attributes of the link. This method takes the users entries and sets the linkClassName and the linkAttributes.

      Supported API: true.
      Throws:
      PropertyVetoException
    • getLinkSchema

      public wt.clients.beans.Schema getLinkSchema()
      This method returns the linkSchema set by the developer at dev-time

      Supported API: true.
    • setModel

      public void setModel(AssociationsModel model) throws PropertyVetoException
      This method sets the model class used to navigate the relationship. If no model class is defined, the bean uses PersistenceHelper.manage.navigate to return the QueryResult containing the link classes and the other side objects.

      Supported API: true.
      Throws:
      PropertyVetoException
    • setOtherSideSchema

      public void setOtherSideSchema(wt.clients.beans.Schema schema) throws PropertyVetoException, ClassNotFoundException
      This is used at dev-time when the developer uses the schema editor to select the class and the attributes of the other-side object. This method takes the users entries and sets the otherSideClassName and the otherSideAttributes.

      Supported API: true.
      Throws:
      PropertyVetoException
      ClassNotFoundException
    • getOtherSideSchema

      public wt.clients.beans.Schema getOtherSideSchema()
      This method returns the otherSideSchema set by the developer at dev-time

      Supported API: true.
    • setFrame

      public void setFrame(Frame frame)
      This is the public setter used to set the Frame that started this bean.

      Supported API: true.
    • getFrame

      public Frame getFrame()
      This is the public getter used to get the Frame that started this bean.

      Supported API: true.
    • setOtherSideAttributes

      public void setOtherSideAttributes(String[] attributes)
      This is the public setter used to set the otherSideAttributes that are displayed in the multilist.

      Supported API: true.
    • getOtherSideAttributes

      public String[] getOtherSideAttributes()
      This is the public getter used to get the otherSideAttributes that are displayed in the multilist.

      Supported API: true.
    • setLabels

      public void setLabels(String[] labels) throws PropertyVetoException
      This sets the labels that will be used as the column headers for the multilist.

      Supported API: true.
      Throws:
      PropertyVetoException
    • getLabels

      public String[] getLabels()
      This gets the labels that are used as the column headers for the multilist.

      Supported API: true.
    • getSaveUpdatesOnly

      public boolean getSaveUpdatesOnly()
      This is the public getter that returns the boolean value of the saveUpdatesOnly flag.

      Supported API: true.
    • setSaveUpdatesOnly

      public void setSaveUpdatesOnly(boolean flagValue)
      This sets the boolean value of the saveUpdatesOnly flag. The flag is used when the save() method is invoked and determines whether or not all links are validated and then persisted. When set to true, only those links that have been added are validated and persisted. When set to false, all links are validated and persisted, even though a change may not of occurred. The default value for the flag is false.

      Supported API: true.
    • setRelativeColumnWidths

      public void setRelativeColumnWidths(String[] widths) throws PropertyVetoException
      This method is used to set the widths of the of the multilist relative to 1 which represents the smallest column width. A width of 2 will create a width twice the size of the column of width 1.

      Supported API: true.
      Throws:
      PropertyVetoException
    • getRelativeColumnWidths

      public String[] getRelativeColumnWidths()
      This method is used to get the widths of the of the multilist relative to 1 which represents the smallest column width. A width of 2 will create a width twice the size of the column of width 1.

      Supported API: true.
    • refresh

      public void refresh() throws PropertyVetoException
      This method redraws the column widths after the multilist has been displayed.

      Supported API: true.
      Throws:
      PropertyVetoException
    • setForeground

      public void setForeground(Color color)
      This sets the foreground of the panel.

      Supported API: true.
      Overrides:
      setForeground in class Component
    • getForeground

      public Color getForeground()
      This gets the foreground of the panel.

      Supported API: true.
      Overrides:
      getForeground in class Component
    • setBackground

      public void setBackground(Color color)
      This sets the background of the panel.

      Supported API: true.
      Overrides:
      setBackground in class Component
    • getBackground

      public Color getBackground()
      This gets the background of the panel.

      Supported API: true.
      Overrides:
      getBackground in class Component
    • setFont

      public void setFont(Font font)
      This sets the font of the panel.

      Supported API: true.
      Overrides:
      setFont in class Container
    • getFont

      public Font getFont()
      This gets the font of the panel.

      Supported API: true.
      Specified by:
      getFont in interface MenuContainer
      Overrides:
      getFont in class Component
    • save

      public Persistable save(Persistable persistable) throws WTException, WTIntrospectionException
      This is used to save the links the to Persistable passed in. It persists the created & updated links, and deletes the removed links.

      Supported API: true.
      Throws:
      WTException
      WTIntrospectionException
    • createUI

      protected void createUI() throws WTPropertyVetoException
      This adds and removes fields based on the mode

      Supported API: true.
      Throws:
      WTPropertyVetoException
    • removeEditButtons

      protected void removeEditButtons()
      This removes the buttons that are associated with the edit mode

      Supported API: true.
    • addEditButtons

      protected void addEditButtons()
      This adds the buttons that are associated with the edit mode

      Supported API: true.
    • createEditButtons

      protected void createEditButtons()
      This creates the buttons used in edit mode

      Supported API: true.
    • resetHashtables

      protected void resetHashtables()
      This resets the hashtables

      Supported API: true.
    • updateLinks

      protected void updateLinks() throws WTIntrospectionException, WTException
      This updates the links with the results of the user's actions

      Supported API: true.
      Throws:
      WTIntrospectionException
      WTException
    • resetLabels

      protected void resetLabels() throws PropertyVetoException
      This resets the column headers with the context of the labels property and the multiListLinkAttributes property.

      Supported API: true.
      Throws:
      PropertyVetoException
    • defaultColumnWidths

      protected void defaultColumnWidths() throws PropertyVetoException
      This initialized the column widths of the multilist to equal widths with a hidden last column.

      Supported API: true.
      Throws:
      PropertyVetoException
    • populate

      protected void populate()
      This retrieves the links on the object and displays them in the multilist.

      Supported API: true.
    • addToTable

      this adds a new object to the table

      Supported API: true.
      Throws:
      InvalidRoleException
      WTException
      InvocationTargetException
      IllegalAccessException
      NoSuchMethodException
    • updateTableLinkValues

      Update the string values displayed in the MultiList.

      Supported API: true.
      Throws:
      InvalidRoleException
      WTException
      InvocationTargetException
      IllegalAccessException
      NoSuchMethodException
    • addSelectedObject

      This creates a new link to an object selected by the user and adds it to the multilist.

      Supported API: true.
      Throws:
      WTIntrospectionException
      IllegalAccessException
      NoSuchMethodException
      InstantiationException
      ClassNotFoundException
      InvocationTargetException
      WTException
    • removeSelectedObject

      protected void removeSelectedObject(BinaryLink link) throws WTException, InvalidRoleException
      this removes the link that the user has selected from the links hashtable and adds it to the removedLinks hashtable if it is persistent so that it can be removed from the db.

      Supported API: true.
      Throws:
      WTException
      InvalidRoleException
    • launchQueryDialog

      protected void launchQueryDialog() throws WTException
      This launches a dialog that will allow the user to select an object and add it to the multilist, create a new link to it, and edit the link.

      Supported API: true.
      Throws:
      WTException
    • launchChooserDialog

      protected void launchChooserDialog() throws WTException
      This launches a dialog that will allow the user to select an object and add it to the multilist, create a new link to it, and edit the link.

      Supported API: true.
      Throws:
      WTException
    • getSelectedObjects

      public Object[] getSelectedObjects()
      This returns the objects that the user has currently selected in the multilist. If no objects are selected, null is returned. This returns the other-side Persistable object, not the link.

      Supported API: true.
      Specified by:
      getSelectedObjects in interface ItemSelectable
    • getSelectedObject

      public Persistable getSelectedObject() throws InvalidRoleException, WTException
      This returns the object that the user has currently selected in the multilist.

      Supported API: true.
      Throws:
      InvalidRoleException
      WTException
    • getSelectedLink

      public BinaryLink getSelectedLink()
      This returns the link represented by the row that the user has selected in the multilist.

      Supported API: true.
    • viewSelectedObject

      protected void viewSelectedObject()
      This will use the TaskDelegate for the selected object to launch a view of that object.

      Supported API: true.
    • getHelpContext

      public HelpContext getHelpContext()
      This returns the helpContext being used for online help.

      Supported API: true.
    • getHelpSystem

      public HelpSystem getHelpSystem()
      This returns the helpSystem being used for online help.

      Supported API: true.
    • addHelpListener

      public void addHelpListener(PropertyChangeListener pcl)
      Method addHelpListener adds the given listener to be notified of PropertyChangeEvents in the help system. Tool description PropertyChangeEvents are generated when the user mouses over the buttons and list of ContentItems in this panel. The given listener will be notified of those events.

      Supported API: true.
      Parameters:
      pcl - The PropertyChangeListener to be notified of PropertyChangeEvents generated by the help system.
      See Also:
    • removeHelpListener

      public void removeHelpListener(PropertyChangeListener pcl)
      Method removeHelpListener removes a listener which was being notified of PropertyChangeEvents in the help system. If the given listener is not currently a listener, no changes are made.

      Supported API: true.
      Parameters:
      pcl - the PropertyChangeListener to be removed as a listener of events generated by the help system of this panel.
      See Also:
    • setEnabled

      public void setEnabled(boolean b)
      This sets the panel and it's components to enabled or disabled based on the passed in boolean.

      Supported API: true.
      Overrides:
      setEnabled in class Component
    • setFieldState

      protected void setFieldState(boolean b, Container container)
      This sets the fields to either editable or enabled depending on the boolean and the type of component. It recurses through all of the fields in the passed container.

      Supported API: true.
    • requestFocus

      public void requestFocus()
      Calling requestFocus() on this panel will set the focus to the first field in the panel which is the multilist.

      Supported API: true.
      Overrides:
      requestFocus in class Component