Creating a Dimension List or Dimension List Combo

The difference between coding a DimensionCombo and coding a DimensionList is a matter of semantics. The code for one bean works for the other bean if you substitute particular abbreviations. The abbreviations that you substitute are part of the names of the classes, interfaces, and properties that are specific to either DimensionCombo or DimensionList. To make the code for a DimensionCombo work for a DimensionList, simply replace all instances of "combo" with "list".

Example: Creating a new DimensionCombo and a new DimensionList

The following code example shows how to create a DimensionCombo and a DimensionList. Notice the similarities in the code. This example instantiates each bean without parameters, which will give them default physical dimensions. The default physical dimension for DimensionCombo are the values of the PreferredSize property of the Swing JComboBox . For a DimensionList, the default physical dimensions are the values of the PreferredSize property of the Swing JList.


// Create a DimensionCombo with default physical dimensions. DimensionCombo dimensionCombo = new DimensionCombo(); // Create a DimensionList with default physical dimensions. DimensionList dimensionList = new DimensionList();

Example: Creating a data model and specifying a dimension

The following example shows how to create a data model and specify the dimension for either a DimensionList or a DimensionCombo. The dimension is hierarchical, and the strHier variable specifies the hierarchy to use.

This example assumes an existing connection to a MetadataManager, which provides consolidated access to metadata objects that have been compiled from one or more metadata sources. The example also assumes that the m_queryBuilder variable is already defined, which means that the data model is being created with a QueryBuilder. You can also create a data model without a QueryBuilder.


// Create the data model QueryAccessUtilities qau = new QueryAccessUtilities(m_queryBuilder.getQueryContext().createQueryAccess(), null, m_queryBuilder.getErrorHandler()); QueryAccessDimensionModel qadm = new QueryAccessDimensionModel(qau, m_currentDimension, strHier); // Create a DimensionList with default physical dimensions. DimensionList dimensionList = new DimensionList(); // Set the data model for the dimension list dimensionList.setModel(qadm);

Creating a Dimension List Dialog or Dimension List Panel