/*
* Duplicate Detector Copyright (C) 2010 Marco Biscaro <marcobiscaro2112@gmail.com>
*
* This file is part of Duplicate Detector.
*
* Duplicate Detector 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
* (at your option) any later version.
*
* Duplicate Detector 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 Duplicate Detector. If not, see <http://www.gnu.org/licenses/>.
*/
package com.googlecode.duplicatedetector.controller;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Locale;
import javax.swing.SwingUtilities;
import com.googlecode.duplicatedetector.i18n.Languages;
import com.googlecode.duplicatedetector.i18n.Messages;
import com.googlecode.duplicatedetector.properties.PropertiesManager;
import com.googlecode.duplicatedetector.view.MainFrame;
/**
* Changes the language and restart the application.
*
* @author Marco Biscaro
*/
public class ChangeLanguageActionListener implements ActionListener {
private Component comp;
private Locale locale;
public ChangeLanguageActionListener(Component comp, Locale locale) {
this.comp = comp;
this.locale = locale;
}
@Override
public void actionPerformed(ActionEvent e) {
if (Messages.getLocale().equals(locale)) {
return;
}
// TODO confirm?
Messages.setLocale(locale);
PropertiesManager.setProperty("language", Languages.getName(locale));
SwingUtilities.getWindowAncestor(comp).dispose();
new MainFrame().setVisible(true);
}
}