コード例 #1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (dbm.isDatabaseOpen()) {
     File newFile = gui.showSaveDialog();
     if (newFile != null) {
       try {
         dbm.saveAs(newFile);
       } catch (IOException ex) {
         log.error("error saving database", ex);
         gui.showMessageDialog(
             ex.getMessage(), I18n.getString("TITLE_DATABASE_ERROR"), JOptionPane.ERROR_MESSAGE);
       }
     }
   }
 }
コード例 #2
0
  SaveAsDatabaseAction(Gui gui) {
    this.gui = gui;
    this.dbm = gui.getWeapon().getDatabaseManager();
    I18n.setText(this, "ACTION_SAVE_AS");

    // enable on load
    gui.getWeapon()
        .getEventSupport()
        .addPropertyChangeListener(
            EventType.DATABASE_STATE,
            new PropertyChangeListener() {
              @Override
              public void propertyChange(PropertyChangeEvent e) {
                DatabaseState state = (DatabaseState) e.getNewValue();
                setEnabled(state == DatabaseState.OPEN_CLEAN || state == DatabaseState.OPEN_DIRTY);
              }
            });
    setEnabled(dbm.isDatabaseOpen());
  }