UniVista Programmer's Guide

UniVista.gui

StudyEditor


Intent | Structure | Participants | Sample Code | Known Uses

Intent

The StudyEditor is the workspace for Study objects. This allows the creation and editing of Screen objects, which compose the Study. The UI editing area is done within the ScreenRenderer object, which is just a UI container (refer to the UI diagram below). Once a Study is complete, it is then saved to the backing store, in this case the database. All menu item calls are defined within this class.

Structure



Participants

Sample Code

To create a new menu item for the MenuBar or the PopupMenu, follow the following example.
// create the menu item
JMenuItem newItem = new JMenuItem("MenuName");
newItem.setMnemonic('M');
newItem.setToolTipText("A tip");

// add a listener defined somewhere else, or do it in-place
newItem.addActionListener(new SomeActionListener());
popup.add(newItem);
Most actions are supported through Callbacks (UniVista.support). An example of this is in saving a Study when a menu item was selected.
// lisetner for the save menu item
class SaveListener implements ActionListener {
public void actionPerformed(ActionEvent evt) {
askSaveStudyChanges();
}
}

// ask if changes are to be saved to the current study
private void askSaveStudyChanges(){
if(editedStudy!=null) {
(new SaveChangesDialog(new SaveStudyCallback(),
(Callback)null)).setVisible(true);
}
}
And the Callback defined in this case looks like this.
class SaveStudyCallback implements Callback {
public void entryPoint(Object obj) {
try {
if (actualStudy != null)
DatabaseHelper.updateOneStudy(actualStudy);
} catch (Exception e) {
//+++ insert error handling code here
}
}
}

Known Uses

The only instance of the StudyEditor that gets created is from the main menu. This means that the UniVistaMain (UniVista.gui) class is responsible for reacting to a user's command event.



Contact the UniVista Team | Main Page | Table of Contents