Adding Options to the New Menu

The Administration Services development framework provides one dialog box for the New menu. When New is selected, the framework creates and displays an instance of the com.essbase.eas.framework.client.ui.filedlgs.NewDialog.java class. The Essbase plug-in and Administration Services plug-in add the following tabs:

The dialog box class includes the following items:

To add a panel and tab to the New dialog box, add a class called NewDialogHandler to the plug-in root package. In our example, this would be com.MyPlugin.ConsoleTreeHandler. Add a method called “populatePanel()” to this class. Example source code:

public void populatePanel(JTabbedPane panel) {
  // create an instance of the right kind of panel
  CNewDialogScrollPanel s = new CNewDialogScrollPane();
  s.setHorizontalScrollBarPolicy(JscrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  s.setVerticalScrollBarPolicy(JscrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  
  // create a list model that has some items in it.
  DefaultListModel model = new DefaultListModel();
  model.addElement(new JLabel("XTD Connection");
  model.addElement(new Jlabel("SQL Connection");
  
  // make sure the list box has a selected item
  list.setSelectedIndex(0);
  
  // toss the list into the scroll pane and ensure that the new
   // dialog box will call this instance when the OK button is
  // clicked.
  s.getViewport().add(list);
  s.setOkHandler(this);
  
  // add this panel to the tabbed panel we were given
  panel.add("My Objects", s);
  
}

For this to work correctly, you must add the following method to the class:

public void handleOk(Component component) {
  if (component instanceof CNewDialogScrollPane) {
    CNewDialogScrollPane scroller = (CNewDialogScrollPane) component;
    Component control = scroller.getViewport().getComponent(0);
    if (control != null) && (control instanceof JList)) {
      // extract the selected item in the JList.
      // ensure that it is one of the ones we added.
      // take the appropriate action.
    }
  }
}

Items of interest for this operation: