Package de.chris_soft.nanodoa.gui.actions

Source Code of de.chris_soft.nanodoa.gui.actions.ShowConfigurationWizardAction

/**
* NanoDoA - File based document archive
*
* Copyright (C) 2011-2012 Christian Packenius, christian.packenius@googlemail.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package de.chris_soft.nanodoa.gui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.Properties;
import javax.swing.JOptionPane;
import de.chris_soft.nanodoa.NanoDoAMain;
import de.chris_soft.nanodoa.Restart;
import de.chris_soft.nanodoa.misc.ConfigurationWizard;
import de.chris_soft.utilities.AppProperties;
import de.chris_soft.utilities.FileUtils;

/**
* Action for showing configuration wizard (and restart NanoDoA after saving new configuration).
* @author Christian Packenius.
*/
public class ShowConfigurationWizardAction implements ActionListener {
  /**
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  @Override
  public void actionPerformed(ActionEvent e) {
    ConfigurationWizard cw = new ConfigurationWizard();
    Properties props = cw.start();
    try {
      if (props != null) {
        FileUtils.storeProperties(NanoDoAMain.nanodoaPropertiesFile, props);
        AppProperties.setPropertiesFile(NanoDoAMain.nanodoaPropertiesFile);
        Restart.prepareForRestart();
      }
    } catch (IOException exc) {
      JOptionPane.showMessageDialog(null, "The configurations couldn't be stored!", "Error!", JOptionPane.ERROR_MESSAGE);
    }
  }
}
TOP

Related Classes of de.chris_soft.nanodoa.gui.actions.ShowConfigurationWizardAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.