/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
* Corporate:
* EADS Astrium SAS
* EADS CRC
* Individual:
* Claude Cazenave
*
* $Id: MCWizardPageNameOption.java,v 1.4 2008/04/08 11:53:42 ogor Exp $
*
* Changes
* -------
* 25 february 2008 : Initial public release (CC);
*
*/
package jsynoptic.plugins.merge.ui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;
import simtools.ui.WizardPage;
public class MCWizardPageNameOption extends WizardPage{
public static MenuResourceBundle resources = ResourceFinder.getMenu(MCWizardManager.class);
JRadioButton interpolationOrder0, interpolationOrder1;
JRadioButton timeRefIsRelative, timeRefIsAbsolute;
JPanel helpPanel;
JLabel helpImage;
JLabel helpText;
public MCWizardPageNameOption(){
super(resources.getString("pageNameOptionTitle"), resources.getString("pageNameOptionDescription"));
// Some help contents..
helpPanel = new JPanel(new GridLayout(1,2));
helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("order0PageNameOptionHelpTitle")));
helpText = new JLabel(resources.getString("order0PageNameOptionHelpText"));
helpText.setFont(new Font("Dialog", Font.PLAIN,12));
helpImage = new JLabel(resources.getIcon("order0PageNameOptionHelpImage"));
helpPanel.add(helpText);
helpPanel.add(helpImage);
//
JLabel interpolationOrder= new JLabel(resources.getString("interpolationOrder"));
interpolationOrder.setFont(new Font("Dialog", Font.PLAIN,12));
add(interpolationOrder, gbc);
gbc.gridy++;
interpolationOrder0 = new JRadioButton(resources.getString("interpolationOrder0"));
interpolationOrder1 = new JRadioButton(resources.getString("interpolationOrder1"));
interpolationOrder0.setSelected(true);//by default
ButtonGroup bg = new ButtonGroup();
bg.add(interpolationOrder0);
bg.add(interpolationOrder1);
interpolationOrder0.addActionListener(this);
interpolationOrder1.addActionListener(this);
add(interpolationOrder0, gbc);
gbc.gridy++;
add(interpolationOrder1, gbc);
gbc.gridy++;
add(Box.createVerticalStrut(20), gbc);
gbc.gridy++;
// time relative / absolute
JLabel timeRefFormat= new JLabel(resources.getString("collectionRefTime"));
timeRefFormat.setFont(new Font("Dialog", Font.PLAIN,12));
add(timeRefFormat, gbc);
gbc.gridy++;
timeRefIsRelative = new JRadioButton(resources.getString("relative"));
timeRefIsAbsolute = new JRadioButton(resources.getString("absolute"));
timeRefIsRelative.setSelected(true);//by default
ButtonGroup bg2 = new ButtonGroup();
bg2.add(timeRefIsRelative);
bg2.add(timeRefIsAbsolute);
add(timeRefIsRelative, gbc);
gbc.gridy++;
add(timeRefIsAbsolute, gbc);
gbc.gridy++;
gbc.insets = new Insets(20, 5, 5, 150);
gbc.gridy++;
add(helpPanel, gbc);
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if (source==interpolationOrder0) {
helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("order0PageNameOptionHelpTitle")));
helpText.setText(resources.getString("order0PageNameOptionHelpText"));
helpImage.setIcon(resources.getIcon("order0PageNameOptionHelpImage"));
} else if (source==interpolationOrder1){
helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("order1PageNameOptionHelpTitle")));
helpText.setText(resources.getString("order1PageNameOptionHelpText"));
helpImage.setIcon(resources.getIcon("order1PageNameOptionHelpImage"));
} else {
super.actionPerformed(e);
}
}
public String getProblem(){
return null;
}
public Map getInformation(){
HashMap ret = new HashMap();
int interpolationOrder=0;
if (interpolationOrder1.isSelected())
interpolationOrder=1;
ret.put(MCWizardManager.INTERPOLATION_ORDER, new Integer(interpolationOrder));
ret.put(MCWizardManager.COLLECTION_TIME_REFERENCE_IS_RELATIVE, new Boolean(timeRefIsRelative.isSelected()));
return ret;
}
}