/* ========================
* 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: MCWizardPageAddAsynchronousDataOption.java,v 1.3 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.Font;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JLabel;
import javax.swing.JPanel;
import jsynoptic.builtin.ui.DateTimePanel;
import simtools.data.async.TimeStampedDataSourceCollection;
import simtools.ui.MenuResourceBundle;
import simtools.ui.NumberField;
import simtools.ui.ResourceFinder;
import simtools.ui.WizardPage;
public class MCWizardPageAddAsynchronousDataOption extends WizardPage{
public static MenuResourceBundle resources = ResourceFinder.getMenu(MCWizardManager.class);
protected NumberField secondsTimeOffset;
protected DateTimePanel initialDate;
protected JLabel initialDateLabel;
boolean collectionIAsynchronous=false;
boolean collectionTimeRefIsRelative=false;
protected MCWizardManager wizardManager;
public MCWizardPageAddAsynchronousDataOption(MCWizardManager wizardManager){
super(resources.getString("pageAddOptionTitle"), resources.getString("pageAddOptionDescription"));
this.wizardManager = wizardManager;
setContents();
}
protected void setContents(){
// Offst (in seconds
JPanel offsetPanel = new JPanel (new BorderLayout());
JLabel offset= new JLabel(resources.getString("offset"));
offset.setFont(new Font("Dialog", Font.PLAIN,12));
offsetPanel.add(offset, BorderLayout.WEST);
offsetPanel.add(secondsTimeOffset = new NumberField(0.0, 10), BorderLayout.CENTER);
add(offsetPanel, gbc);
gbc.gridy++;
//
// An optional date for sync -> async or async -> sync format conversions
JPanel initialDatePanel = new JPanel(new BorderLayout());
initialDateLabel= new JLabel(resources.getString("initialDate"));
initialDateLabel.setFont(new Font("Dialog", Font.PLAIN,12));
initialDatePanel.add( initialDateLabel, BorderLayout.WEST);
initialDatePanel.add(initialDate = new DateTimePanel(0, TimeStampedDataSourceCollection.timeStampedDateFormat.getTimeZone()), BorderLayout.CENTER);
initialDate.setEnabled(false);
initialDateLabel.setEnabled(false);
add(initialDatePanel, gbc);
gbc.gridy++;
}
public String getProblem(){
return null;
}
public Map getInformation(){
HashMap ret = new HashMap();
double offset= secondsTimeOffset.getDoubleValue();
ret.put(MCWizardManager.TIME_REFERENCE_OFFSET + "_" + (wizardManager.numberOfAddedData-1), new Double(offset));
if (initialDateLabel.isEnabled()) {
ret.put(MCWizardManager.TIME_REFERENCE_INITIAL_DATE + "_" + (wizardManager.numberOfAddedData-1),new Long(initialDate.getValue()));
}
return ret;
}
public void setPageFromSettings(Map settings){
collectionIAsynchronous = (((Boolean)(settings.get(MCWizardManager.IS_ASYNCHRONOUS))).booleanValue());
collectionTimeRefIsRelative = (settings.get(MCWizardManager.COLLECTION_TIME_REFERENCE_IS_RELATIVE)!=null)? ((Boolean)(settings.get(MCWizardManager.COLLECTION_TIME_REFERENCE_IS_RELATIVE))).booleanValue() : !collectionIAsynchronous;
// For asynchronous data, enable initial data setting if merge collection has a time reference with relative format
initialDate.setEnabled(collectionTimeRefIsRelative);
initialDateLabel.setEnabled(collectionTimeRefIsRelative);
}
}