The goal of this exercise is to give you an understanding of how to add and use BI Beans customizers (for graph title and QueryBuilder) to modify the presentation that is displayed in this application.
You will insert the logic that is required to add the graph title customizer to the application. This tool enables an end user to change the title text and title text properties for a graph. The next step will be to add a customized QueryBuilder to the application. The QueryBuilder enables an end user to change the data that is displayed in a presentation. The QueryBuilder has properties that enable different types of selection functionality to be displayed or hidden for the end user.
In this section, you will add a graph title customizer, which enables the user to interact and change the title properties of a graph. This tool will be invoked from a menu item.
First, you will add the menu item and the code to support the menu item. The code will make the appropriate calls to a Panel Dialog class that will be added in the next section. Note: The dialog is called only if the current view is a Graph. More code would be required to make the Title customizer work for a Crosstab. This can be achieved very easily, but is outside the scope of the current tutorial.
Title Customizer...
as the
value for the actionCommand property and the text
property. Enter m_mnuTitle
as the value for the name
property. Notice that the new menu item label(text) has changed to Title Customizer....import oracle.bali.ewt.dialog.JEWTDialog;
and then copy and paste the following code right below it. These classes,
added to the declaration section, are used by the Dialog class, which will
be added shortly.// Title class that is used by Graph Title Customizer and Dialog Class
import oracle.dss.graph.gui.Title;
import javax.swing.border.EmptyBorder;
import javax.swing.border.Border;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.BoxLayout;
import javax.swing.KeyStroke;
import java.awt.event.KeyEvent;
import oracle.bali.ewt.button.DialogButtonBar;
import oracle.bali.ewt.border.GrayPane
;
import oracle.bali.ewt.util.WindowUtils;
import oracle.dss.graph.gui.BasePanel;
private QueryManager getQueryManager() throws Throwable
// Title Panel Declaration
private Title m_titlePanel;
// inner class to display Title formatting Customizer panels in a Dialog
class PanelDialog extends JDialog implements ActionListener
{
// start of constructor
public PanelDialog(Frame parentFrame, String title, JPanel panel)
{
super(parentFrame);
setTitle(title);
setModal(true);
this.panel = panel;
JComponent content = (JComponent) getContentPane();
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.setBorder(_sBorder);
content.setBackground(UIManager.getColor(oracle.bali.ewt.olaf.ColorScheme.DARK_LOOK));
GrayPane gp = new GrayPane(this.panel);
content.add(gp);
DialogButtonBar buttonPanel = new DialogButtonBar();
buttonPanel.setBorder(_sBorderButtons);
JPanel buttonPanel_east = new JPanel();
// creating and adding apply button
applyButton = new JButton("Apply");
buttonPanel.add(applyButton, DialogButtonBar.CONSTRAINT_NULL);
applyButton.addActionListener(this);
getRootPane().setDefaultButton(applyButton);
// creating and adding cancel button
cancelButton = new JButton("Cancel");
buttonPanel.add(cancelButton, DialogButtonBar.CONSTRAINT_FINISH);
cancelButton.addActionListener(this);
cancelButton.registerKeyboardAction(this,
KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
JComponent.WHEN_IN_FOCUSED_WINDOW);
getContentPane().add(buttonPanel);
setResizable(false);
pack();
}
// end of constructor
/**
* implementing action listener
*
* @param e instance of ActionEvent
*/
public void actionPerformed(ActionEvent e)
{
// if cancel button is pressed, then do nothing
and close the dialog
if(e.getSource() == cancelButton) {
setVisible(false);
dispose();
getParent().repaint();
}
// if apply button is pressed, then apply the changes
to the graph and close the dialog
else if(e.getSource() == applyButton) {
if(panel instanceof BasePanel) {
((BasePanel)panel).apply();
}
setVisible(false);
dispose();
}
}
// data member
private JButton applyButton;
private JButton cancelButton;
private JPanel panel;
// The extra room around the border
private Border _sBorder = new EmptyBorder(6, 6, 8, 5);
private Border _sBorderButtons = new EmptyBorder(8, 10, 0, 10);
}
m_mnuTitle_ActionPerformed
as the name and choose OK.m_mnuTitle_actionPerformed
method:if (m_activeView instanceof Graph)
{
if (m_titlePanel == null) {
m_titlePanel = new Title((Graph)m_activeView);
}
else {
m_titlePanel.setGraph((Graph)m_activeView);
}
PanelDialog panelDialog = new PanelDialog( WindowUtils.parentFrame(this),
"Graph Title Customizer", m_titlePanel );
panelDialog.show();
}
If the view is a graph, then this code opens a Title Panel for the
view to allow the user to change titles (through the code that you added earlier).Sales Variance Report
Retail Sales Variance for Top 5 Countries based on Sales in
Asia
This section shows how to specify the QueryBuilder capabilities
that will be available for the end user of your application.
You will insert additional code in the mnuQB_ActionPerformed
method to enable this customization.
The code that you insert modifies the appearance of the QueryBuilder dialog in the folllowing way:
These are a few examples of the customization that can be applied to the QueryBuilder. The rich API of the QueryBuilder makes its functionality available in a variety of ways that enable its use by both power users and casual users in an organization.
void mnuQB_ActionPerformed(ActionEvent event)
mnuQB_ActionPerformed
method, search for the following
line of code: QueryBuilder queryBuilder = new QueryBuilder(getFrame());
and position the cursor after that line.// Choose the main panels
queryBuilder.setVisiblePanels (QueryBuilder.ITEMS | QueryBuilder.DIMENSIONS
| QueryBuilder.LAYOUT);
// Choose the tabs on the DimensionPanel
queryBuilder.setVisibleDimensionPanels (QueryBuilder.MEMBERS | QueryBuilder.STEPS
| QueryBuilder.PREVIEW);
// Disallow apply
queryBuilder.setApplyAllowed(false);
// Allow the user to switch between dimensions on the DimensionPanel
queryBuilder.setDimensionVisible(true);
// Disable changing the hierarchy from the DimensionPanel
queryBuilder.setHierarchyVisible(false);
To learn more about the API and customization options, refer to the BI Beans javadoc.
In this exercise, you learned how to add a graph title customizer that is used to edit the title text and to specify title properties. You also learned about QueryBuilder customization options that modify the capabilities available to an end user.