This topic provides sample code for creating a DimensionListDialog
.
The code for creating an OLAPDimensionListPanel
is nearly identical
to that for a DimensionListDialog
, except that the constructor
for the OLAPDimensionListPanel
takes only two arguments, which
are the dialog or frame and the data model.
The following code example shows how to create a DimensionListDialog
and display it. The dialog is displayed as a result of an action by the user
within the application's user interface, which is that the user has clicked
a button.
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 code in this example assumes that the
variables in the following list exist:
m_queryBuilder
-- Identifies that the data model is being
created with a QueryBuilder
. You can also create a data model
without a QueryBuilder
.
top_parent
-- The top-level dialog box or frame that serves
as the parent for the dimension list. By specifying the top-level dialog
or a frame in the constructor, you ensure that the focus for the dimension
list and its associated dialogs is maintained properly.
Tip: When you use the constructor in this manner, you can also specify an icon for the top-level dialog or a frame that is propagated to the dimension list's panels and associated dialogs. The following sample line of code shows how to set this icon.
top_parent.setIconImage(java.awt.Toolkit.getDefaultToolkit().createImage("myicon.gif"));
my_button
-- The button over which the DimensionListDialog
is centered when it is displayed.
// Create the DimensionListDialog within a frame QueryAccessDimensionModel qadm = new QueryAccessDimensionModel (m_queryBuilder.getQueryContext().createQueryAccess(), null, m_queryBuilder.getErrorHandler(), m_currentDimension, strHier, m_queryBuilder.getMetadataManager()); DimensionListDialog dlg = new DimensionListDialog(top_parent, qadm, my_button); //Optionally set the locale and selection mode dlg.setLocale(m_queryBuilder.getLocale()); dlg.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // Display the DimensionListDialog. if (dlg.display() == DimensionListDialog.OK); else if (dimensionListDialog.display() == DimensionListDialog.CANCEL);
Creating a Dimension List or Dimension List Combo
Structure and Interactions of the Dimension List Beans