package versusSNP.gui.dialogs;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
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 AlignmentLoaderDialog extends JOptionPane implements GenericDialog {
private static final long serialVersionUID = -6597077658956538876L;
private JComboBox selector1;
private JComboBox selector2;
private MyInteger id1, id2;
private JTextField txtPath;
private JButton btnBrowse;
private StringBuffer path;
public AlignmentLoaderDialog(String[] genomeNames) {
id1 = new MyInteger(0);
id2 = new MyInteger(1);
selector1 = new JComboBox(genomeNames);
selector2 = new JComboBox(genomeNames);
selector1.setSelectedIndex(id1.intValue());
selector2.setSelectedIndex(id2.intValue());
selector1.setPreferredSize(Size.dialog_combobox_selector);
selector2.setPreferredSize(Size.dialog_combobox_selector);
selector1.addActionListener(new SelectAction(id1));
selector2.addActionListener(new SelectAction(id2));
path = new StringBuffer();
txtPath = new JTextField();
btnBrowse = new JButton(UICaption.dialog_caption_browse);
txtPath.setPreferredSize(Size.dialog_textfield_path);
btnBrowse.setPreferredSize(Size.dialog_button_browse);
btnBrowse.addActionListener(new BrowseAction(txtPath));
txtPath.getDocument().addDocumentListener(new EditAction(path));
}
public int showDialog() {
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(txtPath);
panel.add(btnBrowse);
Object[] options = {UICaption.dialog_option_ok, UICaption.dialog_option_cancel};
return showOptionDialog(null, new Object[] {
new JLabel(UICaption.dialog_label_querysubjectselect_query),
selector1,
new JLabel(UICaption.dialog_label_querysubjectselect_subject),
selector2,
new JLabel(UICaption.dialog_label_alignmentloader_file),
panel },
UICaption.dialog_caption_alignmentloader,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,
null, options, options[0]);
}
public String getPath() {
return path.toString();
}
public int getId1() {
return id1.intValue();
}
public int getId2() {
return id2.intValue();
}
public int[] getIds() {
return new int[]{id1.intValue(), id2.intValue()};
}
}