private JMenuItem addMenuItem(final IApplication application, String title,
final int sheetType, final ISession session) {
JMenuItem menuItem = new JMenuItem(title);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
DialogWidget frame = (DialogWidget) isInternalFrameUsed(application, sheetType);
if (frame == null) {
if (sheetType == FB_SHEET_TYPE_ROLE) {
frame = new FirebirdManagerRoleFrame(session);
} else if (sheetType == FB_SHEET_TYPE_GRANT) {
frame = new FirebirdManagerGrantFrame(session);
} else if (sheetType == FB_SHEET_TYPE_BACKUP){
frame = new FirebirdManagerBackupRestoreFrame(session.getApplication());
} else if (sheetType == FB_SHEET_TYPE_CREATE){
frame = new FirebirdManagerCreateDatabaseFrame(session.getApplication());
} else if (sheetType == FB_SHEET_TYPE_USER){
frame = new FirebirdManagerUserManagerFrame(session.getApplication());
}
application.getMainFrame().addWidget(frame);
frame.pack();
if (frame instanceof FirebirdManagerBackupRestoreFrame) {
frame.setSize(new Dimension(650, frame.getHeight()));
} else if (frame instanceof FirebirdManagerUserManagerFrame) {
frame.setSize(new Dimension(frame.getWidth(), 500));
}
DialogWidget.centerWithinDesktop(frame);
} else {
frame.setVisible(true);
frame.moveToFront();
}
try {
frame.setSelected(true);
if (frame instanceof IFirebirdManagerFrame) {
((IFirebirdManagerFrame)frame).setFocusToFirstEmptyInputField();
}
} catch (PropertyVetoException e) {
log.error(e.getLocalizedMessage());