Class WTQuery

java.lang.Object
wt.clients.beans.query.WTPanel
wt.clients.beans.query.WTQuery
All Implemented Interfaces:
ActionListener, ItemListener, PropertyChangeListener, EventListener
Direct Known Subclasses:
WTChooser, WTChooser

public class WTQuery extends wt.clients.beans.query.WTPanel implements ActionListener, ItemListener, PropertyChangeListener
WTQuery provides a tool that allows you to include in your application the ability to search for objects in the local Windchill database. WTQuery is comprised of an optional title, a Tab panel containing an input area for search criteria, 3 required buttons, 3 optional buttons, a check box indicating whether to append to or replace the search results and a list area for displaying search results.

A WTQuery object provides the ability to search for objects of a specified class. A WTSchema object is used to specify which modeled Windchill business class and associated attributes are to be used in configuring the WTQuery object. The Tab panel and results viewing list are dynamically constructed based on the schema provided. When calling WTQuery it is necessary to specify a WTSchema object.

The search results viewing list presents the results of the database query. The user can clear this area by clicking the clear button. There is a check box available to the user that determines whether to clear the list area between invocations of clicking the Find button. By default the list area allows multiple objects to be selected. To restrict the list area to single selection use the setMultipleMode() method. To obtain the list of selected objects use either the getSelectedDetails() or getSelectedDetail() method depending on whether multiple or single selection mode is in use.

The buttons display in two columns. The required column contains Find, Stop and Clear. The optional column contains OK, Close and Help. The functionality for the required buttons and the Help button is handled by WTQuery. The calling application can register a listener to be notified when the OK or Close buttons are clicked. To register a listener, create a WTQueryListener object and call the addListener() method using the WTQueryListener object as input.

For example to add WTQuery to a panel:

     Panel queryPanel;
     try {

        // Create WTQuery without a status area.
        WTQuery myQuery = new WTQuery("My Query Panel", SearchTask.ALL_VERSIONS, false);
        myQuery.setSchema("C:wt.doc.WTDocument; G:Search Criteria; A:name; D:versionIdentifier; G:More Search Criteria; A:description;");

        // Set single selection mode
        myQuery.setMultipleMode(false);

        // --- Hide the right column of buttons.
        myQuery.setDialogButtonsVisible(false);

        // Set Layout.
        queryPanel.setLayout(new BorderLayout());
        queryPanel.add("Center", myQuery);

        // Add event listener.
        myQuery.addListener(new WTQueryListener() {
           public void queryEvent(WTQueryEvent e)
           {
              if (e.getType().equals(WTQueryEvent.COMMAND ))
              {
                 if (e.getCommand().equals(WTQuery.OkCMD) )
                 {
                    // The Ok button is clicked, get the selected objects.
                    WTQuery query_source = (WTQuery)e.getSource();
                          WTObject[] objs = query_source.getSelectedDetails();
                    // Continue with code that will process the selected object array
                 }
              }
           }
              // Add help listener
        myQuery.addHelpListener(helpListener);
        }catch (Exception e)   {}
  


Supported API: true

Extendable: true
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The value for the "Clear button clicked" command event type.
    static final String
    The value for the "Find button clicked" command event type.
    static final String
    The value for the "OK button clicked" command event type.
    static final String
    The value for the "Close button clicked" command event type.
    static final String
    The value for the "Stop button clicked" command event type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default no-arg constructor.
    WTQuery(String a_title, String search_filter, boolean show_status)
    Constructor specifying a title, search filter and whether to include a status display area as part of this component.
    WTQuery(String a_title, String search_filter, boolean show_status, boolean show_iba)
    Constructor specifying a title, search filter, status display flag and a IBA tab flag.
    WTQuery(String a_title, String search_filter, boolean show_status, boolean show_iba, boolean doc_finder)
    Constructor specifying a title, search filter and whether to include a status display area as part of this component, as well as showing IBA associated and if to allow for the searching of Documents.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Method addHelpListener adds the given listener to be notified of PropertyChangeEvents in the help system.
    void
    Method addListener adds the given listener to be notified of WTQueryEvents.
    Returns a string array containing the width of each column in the results viewing area.
    int
    Gets the default width for each column in the results viewing area.
    getDetail(int a_index)
    Return the object at the specified row in the results list area.
    boolean
    Return true if multiple selection mode is enabled in the results list area, false if single selection mode is in use.
    Return the schema currently being used.
    Return the selected object in the results list area.
    Return the list of selected objects in the results list area.
    void
    Method removeHelpListener removes a listener which was being notified of PropertyChangeEvents in the help system.
    void
    Method removeHelpListener removes a listener which was being notified of PropertyChangeEvents in the help system.
    void
    Sets the width of each column in the results viewing area.
    void
    setColumnWidth(int width)
    Sets the default width for each column in the results viewing area.
    void
    setMultipleMode(boolean mode)
    Set the multiple selection mode in the results list area.
    void
    setSchema(WTSchema a_schema)
    Set the schema to use.
    void
    setStatusVisible(boolean visible)
    Set the visibility of the status area.
    int
    Return the current number of objects in the results list area.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • FindCMD

      public static final String FindCMD
      The value for the "Find button clicked" command event type. A WTQueryEvent is fired when the Find button is clicked with a WTQueryEvent.COMMAND type and command value of FindCMD.

      Supported API: true
      See Also:
    • StopCMD

      public static final String StopCMD
      The value for the "Stop button clicked" command event type. A WTQueryEvent is fired when the Stop button is clicked with a WTQueryEvent.COMMAND type and command value of StopCMD.

      Supported API: true
      See Also:
    • ClearCMD

      public static final String ClearCMD
      The value for the "Clear button clicked" command event type. A WTQueryEvent is fired when the Clear button is clicked with a WTQueryEvent.COMMAND type and command value of ClearCMD.

      Supported API: true
      See Also:
    • OkCMD

      public static final String OkCMD
      The value for the "OK button clicked" command event type. A WTQueryEvent is fired when the OK button is clicked with a WTQueryEvent.COMMAND type and command value of OkCMD.

      Supported API: true
      See Also:
    • QuitCMD

      public static final String QuitCMD
      The value for the "Close button clicked" command event type. A WTQueryEvent is fired when the Close button is clicked with a WTQueryEvent.COMMAND type and command value of QuitCMD.

      Supported API: true
      See Also:
  • Constructor Details

    • WTQuery

      public WTQuery()
      Default no-arg constructor.

      Supported API: true
    • WTQuery

      public WTQuery(String a_title, String search_filter, boolean show_status)
      Constructor specifying a title, search filter and whether to include a status display area as part of this component.

      Supported API: true
      Parameters:
      a_title - the title displayed above the Tab panel. when processing the query command. See wt.query.SearchTask for search filter string constants.
      show_status - set to true if a status area should be created to display status messages, otherwise false.
      See Also:
      • SearchTask
    • WTQuery

      public WTQuery(String a_title, String search_filter, boolean show_status, boolean show_iba, boolean doc_finder)
      Constructor specifying a title, search filter and whether to include a status display area as part of this component, as well as showing IBA associated and if to allow for the searching of Documents.

      Supported API: true
      Parameters:
      a_title - the title displayed above the Tab panel. when processing the query command. See wt.query.SearchTask for search filter string constants.
      show_status - set to true if a status area should be created to display status messages, otherwise false.
      show_iba -
      doc_finder -
      See Also:
      • SearchTask
    • WTQuery

      public WTQuery(String a_title, String search_filter, boolean show_status, boolean show_iba)
      Constructor specifying a title, search filter, status display flag and a IBA tab flag.

      Supported API: true
      Parameters:
      a_title - the title displayed above the Tab panel.
      search_filter - used when processing the query command. See wt.query.SearchTask for search filter string constants.
      show_status - set to true if a status area should be created to display status messages, otherwise false.
      show_iba - set to true if the IBA tab should be shown
      See Also:
      • SearchTask
  • Method Details

    • setColumnSizes

      public void setColumnSizes(String[] list) throws PropertyVetoException
      Sets the width of each column in the results viewing area. The width is set in pixels. Setting the column sizes to null will turn auto resizing on.

      Supported API: true
      Parameters:
      list - a string array containing results viewing area column sizes in pixels
      Throws:
      PropertyVetoException - if the specified property value is unacceptable
      See Also:
    • getColumnSizes

      public String[] getColumnSizes()
      Returns a string array containing the width of each column in the results viewing area. The width of the column is in pixels. If columns are being automatically sized, it will return null.

      Supported API: true
      Returns:
      a string array containing column sizes in pixels
      See Also:
    • setColumnWidth

      public void setColumnWidth(int width)
      Sets the default width for each column in the results viewing area. The width is set in pixels. Setting the column width will cause each column in the results viewing area to have the same initial size. In order to set a separate width for each column use setColumnSizes. Setting this vaule to 0 turns, auto resizing on.

      Supported API: true
      Parameters:
      width - the default results viewing area column size in pixels
      See Also:
    • getColumnWidth

      public int getColumnWidth()
      Gets the default width for each column in the results viewing area. The width is returned in pixels.

      Supported API: true
      Returns:
      default results area column size in pixels
      See Also:
    • 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:
    • getSchema

      public WTSchema getSchema()
      Return the schema currently being used. The schema describes the attributes to be used as search criteria in the Tab panel and attributes to be displayed in the results list area.

      Supported API: true
      Returns:
      the current schema that is in use.
    • setSchema

      public void setSchema(WTSchema a_schema)
      Set the schema to use. The schema describes the attributes to be used as search criteria in the Tab panel and attributes to be displayed in the results list area.

      Supported API: true
      Parameters:
      a_schema - The schema used to obtain attributes for the Tab panel and results list area.
    • setStatusVisible

      public void setStatusVisible(boolean visible)
      Set the visibility of the status area. The status area is an optional component whose visibility can be controlled by this method.

      Supported API: true
      Parameters:
      visible - true if the status area is visible, otherwise false.
    • setMultipleMode

      public void setMultipleMode(boolean mode) throws PropertyVetoException
      Set the multiple selection mode in the results list area.

      Supported API: true
      Parameters:
      mode - true enables multiple selection, false enables single selection.
      Throws:
      PropertyVetoException - if the specified property value is unacceptable.
    • getMultipleMode

      public boolean getMultipleMode()
      Return true if multiple selection mode is enabled in the results list area, false if single selection mode is in use.

      Supported API: true
      Returns:
      true if multiple selection mode is in use, false for single selection.
    • totalDetails

      public int totalDetails()
      Return the current number of objects in the results list area.

      Supported API: true
      Returns:
      The current number of objects in the results list area.
    • getDetail

      public WTObject getDetail(int a_index)
      Return the object at the specified row in the results list area.

      Supported API: true
      Parameters:
      a_index - The index of the row to obtain the object.
      Returns:
      the object at the specified row in the results list area.
    • getSelectedDetail

      public WTObject getSelectedDetail()
      Return the selected object in the results list area.

      Supported API: true
      Returns:
      the selected object in the results list area.
    • getSelectedDetails

      public WTObject[] getSelectedDetails()
      Return the list of selected objects in the results list area.

      Supported API: true
      Returns:
      the list of selected objects in the results list area.
    • addListener

      public void addListener(WTQueryListener a_listener)
      Method addListener adds the given listener to be notified of WTQueryEvents. A WTQueryEvent is fired when a button is clicked, a status message is ready or the selection has been changed in the results viewing area.

      Supported API: true
      Parameters:
      a_listener - The WTQueryListener to be notified of WTQueryEvents.
      See Also:
    • removeListener

      public void removeListener(WTQueryListener a_listener)
      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:
      a_listener - the WTQueryistener to be removed as a listener of events generated by the help system of this panel.
      See Also: