package versusSNP.gui.dialogs;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import versusSNP.Size;
import versusSNP.gui.UICaption;
import versusSNP.util.action.BrowseAction;
import versusSNP.util.action.EditAction;
import versusSNP.util.action.SelectAction;
import versusSNP.util.struct.MyInteger;
public class SNPExporterDialog extends JOptionPane implements GenericDialog {
private static final long serialVersionUID = -3749831462126283835L;
private JComboBox selector;
private JPanel panel;
private MyInteger id;
private JTextField txtPath;
private JButton btnBrowse;
private StringBuffer path;
public SNPExporterDialog() {
super();
id = new MyInteger(0);
path = new StringBuffer();
panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
txtPath = new JTextField();
btnBrowse = new JButton(UICaption.dialog_caption_browse);
selector = new JComboBox(new Object[] { UICaption.panel_caption_s,
UICaption.panel_caption_ns, UICaption.panel_caption_in_del,
UICaption.panel_caption_snp });
selector.addActionListener(new SelectAction(id));
selector.setSelectedIndex(id.intValue());
txtPath.setPreferredSize(Size.dialog_textfield_path);
btnBrowse.setPreferredSize(Size.dialog_button_browse);
btnBrowse.addActionListener(new BrowseAction(txtPath, JFileChooser.SAVE_DIALOG));
txtPath.getDocument().addDocumentListener(new EditAction(path));
panel.add(txtPath);
panel.add(btnBrowse);
}
@Override
public int showDialog() {
Object[] options = {UICaption.dialog_option_ok, UICaption.dialog_option_cancel};
return showOptionDialog(null, new Object[] {
new JLabel(UICaption.dialog_label_snpexporter_which_table),
selector,
new JLabel(UICaption.dialog_label_snpexporter_file),
panel },
UICaption.dialog_caption_snpexporter,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, options, options[0]);
}
public String getPath() {
return path.toString();
}
public int getId() {
return id.intValue();
}
}