Package versusSNP.gui.dialogs

Source Code of versusSNP.gui.dialogs.ORFLoaderDialog

package versusSNP.gui.dialogs;

import java.awt.FlowLayout;

import javax.swing.JButton;
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.gui.widgets.MyFileFilter;
import versusSNP.util.action.BrowseAction;
import versusSNP.util.action.EditAction;
import versusSNP.util.action.EditEnsureAction;

public class ORFLoaderDialog extends JOptionPane implements GenericDialog {
  private static final long serialVersionUID = -586886513046933069L;
  private JPanel panel1;
  private JPanel panel2;
  private JPanel panel3;
  private JTextField txtLabel, txtPath1, txtPath2;
  private JButton btnBrowse1, btnBrowse2;
  private StringBuffer path1, path2, name;

  public ORFLoaderDialog() {
    super();
    name = new StringBuffer();
    path1 = new StringBuffer();
    path2 = new StringBuffer();
    panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel2 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel3 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    txtLabel = new JTextField();
    txtPath1 = new JTextField();
    txtPath2 = new JTextField();
    btnBrowse1 = new JButton(UICaption.dialog_caption_browse);
    btnBrowse2 = new JButton(UICaption.dialog_caption_browse);
    txtLabel.setPreferredSize(Size.dialog_textfield_label);
    txtPath1.setPreferredSize(Size.dialog_textfield_path);
    txtPath2.setPreferredSize(Size.dialog_textfield_path);
    btnBrowse1.setPreferredSize(Size.dialog_button_browse);
    btnBrowse2.setPreferredSize(Size.dialog_button_browse);
    btnBrowse1.addActionListener(new BrowseAction(txtPath1,
        new MyFileFilter[] {
          new MyFileFilter(new String[] { "txt" }, UICaption.dialog_filter_file_tabbed),
          new MyFileFilter(new String[] { "csv" }, UICaption.dialog_filter_file_csv)}));
    btnBrowse2.addActionListener(new BrowseAction(txtPath2,
        new MyFileFilter[] {new MyFileFilter(new String[] { "fas", "fasta" }, UICaption.dialog_filter_file_fasta)}));
//    txtLabel.getDocument().addDocumentListener(new EditAction(name));
    txtPath1.getDocument().addDocumentListener(new EditAction(path1));
    txtPath2.getDocument().addDocumentListener(new EditAction(path2));
    panel1.add(txtLabel);
    panel2.add(txtPath1);
    panel2.add(btnBrowse1);
    panel3.add(txtPath2);
    panel3.add(btnBrowse2);
  }
 
  public ORFLoaderDialog(String[] genomeNames) {
    this();
    txtLabel.getDocument().addDocumentListener(new EditEnsureAction(name,  genomeNames, txtLabel));
  }

  public int showDialog() {
    Object[] options = {UICaption.dialog_option_ok, UICaption.dialog_option_cancel};
    return showOptionDialog(null, new Object[] {
        new JLabel(UICaption.dialog_label_orfloader_genome_name),
        panel1,
        new JLabel(UICaption.dialog_label_orfloader_orf_position),
        panel2,
        new JLabel(UICaption.dialog_label_orfloader_orf_sequence),
        panel3 },
        UICaption.dialog_caption_orfloader,
        JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.PLAIN_MESSAGE,
        null, options, options[0]);
  }

  public String getPath1() {
    return path1.toString();
  }

  public String getPath2() {
    return path2.toString();
  }

  public String getName() {
    return name.toString();
  }
}
TOP

Related Classes of versusSNP.gui.dialogs.ORFLoaderDialog

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.