/*
* IdlsavDataSourceFormatEditorPanel.java
*
*/
package org.autoplot.idlsupport;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JPanel;
import org.autoplot.datasource.URISplit;
import java.lang.Short; // because of Short object in this package.
import org.autoplot.datasource.DataSourceFormatEditorPanel;
/**
*
* @author jbf
*/
public class IdlsavDataSourceFormatEditorPanel extends javax.swing.JPanel implements DataSourceFormatEditorPanel {
/** Creates new form BinaryDataSourceFormatEditorPanel */
public IdlsavDataSourceFormatEditorPanel() {
initComponents();
}
String file;
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
typeComboBox = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
appendCB = new javax.swing.JCheckBox();
jLabel1.setText("Time Units:");
typeComboBox.setEditable(true);
typeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "t1970", "t2000", "cdfTT2000", "seconds since 2010-02-03T00:00" }));
jLabel2.setText("1-D, 2-D and 3-D data can be exported to IDLSave sets.");
appendCB.setText("append");
appendCB.setToolTipText("Append this to an existing IDLSav file");
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(jLabel1)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(typeComboBox, 0, 305, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(appendCB)
.add(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jLabel2)
.add(7, 7, 7)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(typeComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(appendCB)
.addContainerGap(60, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox appendCB;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JComboBox typeComboBox;
// End of variables declaration//GEN-END:variables
public JPanel getPanel() {
return this;
}
private String getParam( Map args, String name, String defl ) {
String s= args.get(name);
if ( s==null ) {
return defl;
} else {
return s;
}
}
public void setURI(String uri) {
URISplit split= URISplit.parse(uri);
Map args= URISplit.parseParams(split.params);
String s= getParam( args, "tunits", "t1970" );
typeComboBox.setSelectedItem(s);
appendCB.setSelected(getParam( args, "append", "F" ).equals("T"));
file= split.file;
}
public String getURI() {
String result= file;
Map args= new HashMap();
String s;
s= (String) typeComboBox.getSelectedItem();
if ( !s.equals("t1970") ) args.put( "tunits", s );
if ( appendCB.isSelected() ) args.put( "append", "T" );
String params= URISplit.formatParams(args);
if ( result==null ) result= "file:///";
URISplit ss= URISplit.parse(result);
if ( params.length()>0 ) {
ss.params= params;
}
return URISplit.format( ss );
}
}