map.put(ActionKey.APP_ADD, new PolicyAction(ActionKey.APP_ADD, rb.getString("addapp"), PolicyUtilities.createImageIcon("/images/new_16.png")) {
@Override
public void actionPerformed(ActionEvent e) {
ApplicationModel app = new ApplicationModel();
app.setId(PolicyUtilities.getNewApplicationId());
app.setName(rb.getString("newapp") + "_" + new Integer(app.getId()).toString());
app.setBaseA(ApplicationBase.NONE);
app.setBaseC(ApplicationBase.NONE);
app.setBaseI(ApplicationBase.NONE);
if (dbModel.addApplication(app)) {
dbModel.setCurrentApplication(app);
}
}
});
map.put(ActionKey.APP_DELETE, new PolicyAction(ActionKey.APP_DELETE, rb.getString("delapp"), PolicyUtilities.createImageIcon("/images/delete_16.png")) {
@Override
public void actionPerformed(ActionEvent e) {
ac.removeApplication();
}
});
map.put(ActionKey.APP_JUMPTO, new PolicyAction(ActionKey.APP_JUMPTO, rb.getString("jump")) {
@Override
public void actionPerformed(ActionEvent e) {
ac.jumpToList();
}
});
map.put(ActionKey.APP_ADDLIST, new PolicyAction(ActionKey.APP_ADDLIST, rb.getString("add")) {
@Override
public void actionPerformed(ActionEvent e) {
ApplicationModel app = dbModel.getCurrentApplication();
List<ReceiverListModel> lists = new ArrayList(dbModel.getReceiverLists());
lists.removeAll(app.getReceiverLists());
if (lists.size() > 0) {
Object[] listnames = new Object[lists.size()];
for (int i = 0; i < lists.size(); i++) {
listnames[i] = lists.get(i);
}
ListSelectionDialog lsd = new ListSelectionDialog();
lsd.showDialog(listnames);
ReceiverListModel selection = (ReceiverListModel) lsd.getResult();
if (selection != null) {
app.addReceiverList(selection);
}
} else if(PolicyUtilities.isShowWarnings()) {
mb = PolicyUtilities.getMessageBundle();
PolicyUtilities.showMessageDialog(mb.getString("nolistavailable"), JOptionPane.INFORMATION_MESSAGE);
}
}
});
map.put(ActionKey.APP_DELETELIST, new PolicyAction(ActionKey.APP_DELETELIST, rb.getString("delete")) {
@Override
public void actionPerformed(ActionEvent e) {
ac.deleteList();
}
});
map.put(ActionKey.MAIN_OPENDB, new PolicyAction(ActionKey.MAIN_OPENDB, rb.getString("opendb")) {
@Override
public void actionPerformed(ActionEvent e) {
SelectDBDialog dlgSelectDB = new SelectDBDialog(MainFrame.getInstance(), true);
dlgSelectDB.setVisible(true);
}
});
map.put(ActionKey.MAIN_SAVE, new PolicyAction(ActionKey.MAIN_SAVE, rb.getString("save"), PolicyUtilities.createImageIcon("/images/save_24.png")) {
@Override
public void actionPerformed(ActionEvent e) {
XMLPolicyDBWriter writer = new XMLPolicyDBWriter();
try {
writer.savePolicyDB(dbModel.getFilePath());
} catch (Exception ex) {
Logger.getLogger(ActionFactory.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
map.put(ActionKey.MAIN_SAVEAS, new PolicyAction(ActionKey.MAIN_SAVEAS, rb.getString("saveas"), PolicyUtilities.createImageIcon("/images/save_24.png")) {
@Override
public void actionPerformed(ActionEvent e) {
XMLPolicyDBWriter writer = new XMLPolicyDBWriter();
try {
String path = PolicyUtilities.showSaveDialog();
writer.savePolicyDB(path);
} catch (Exception ex) {
Logger.getLogger(ActionFactory.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
map.put(ActionKey.MAIN_ADD, new PolicyAction(ActionKey.MAIN_ADD, rb.getString("addapp"), PolicyUtilities.createImageIcon("/images/new_24.png")) {
@Override
public void actionPerformed(ActionEvent e) {
switch (dbModel.getActiveItem()) {
case APP:
ApplicationModel app = new ApplicationModel();
app.setId(PolicyUtilities.getNewApplicationId());
app.setName(rb.getString("newapp") + "_" + new Integer(app.getId()).toString());
app.setBaseA(ApplicationBase.NONE);
app.setBaseC(ApplicationBase.NONE);
app.setBaseI(ApplicationBase.NONE);
if (dbModel.addApplication(app)) {
dbModel.setCurrentApplication(app);
}
break;
case LIST: