Package versusSNP.gui.dialogs

Source Code of versusSNP.gui.dialogs.RunBlastDialog

package versusSNP.gui.dialogs;

import java.awt.GridLayout;

import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

import versusSNP.Parameter;
import versusSNP.Size;
import versusSNP.blast.BlastExecutor;
import versusSNP.gui.UICaption;
import versusSNP.util.action.SelectAction;
import versusSNP.util.struct.MyInteger;

public class RunBlastDialog extends JOptionPane implements GenericDialog {
  private static final long serialVersionUID = -7497324116818319281L;
  private JComboBox selector1;
  private JComboBox selector2;
  private JComboBox selector3;
  private JComboBox selector4;
  private MyInteger id1, id2;
  private JTextField txtThresholds;
  private JCheckBox cbFilters;

  public RunBlastDialog(String[] genomeNames) {
    super();
    id1 = new MyInteger(0);
    id2 = new MyInteger(1);
    selector1 = new JComboBox(genomeNames);
    selector2 = new JComboBox(genomeNames);
    selector3 = new JComboBox(new Object[]{"BLASTN"});
    selector4 = new JComboBox(BlastExecutor.MATRICES);
    txtThresholds = new JTextField(Parameter.blast_run_thresholds);
    cbFilters = new JCheckBox(UICaption.dialog_label_run_blast_filters);
    txtThresholds.setToolTipText(UICaption.tooltip_label_run_blast_thresholds);
    cbFilters.setToolTipText(UICaption.tooltip_label_run_blast_filters);
    selector1.setSelectedIndex(id1.intValue());
    selector2.setSelectedIndex(id2.intValue());
    selector4.setSelectedItem(Parameter.blast_run_matrix);
    selector1.setPreferredSize(Size.dialog_combobox_selector);
    selector2.setPreferredSize(Size.dialog_combobox_selector);
    selector3.setPreferredSize(Size.dialog_combobox_selector);
    selector4.setPreferredSize(Size.dialog_combobox_selector);
    selector1.addActionListener(new SelectAction(id1));
    selector2.addActionListener(new SelectAction(id2));
  }

  @Override
  public int showDialog() {
    JPanel panel = new JPanel(new GridLayout(1,2));
    panel.add(new JLabel(UICaption.dialog_label_run_blast_thresholds));
    panel.add(txtThresholds);
    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_run_blast_program),
        selector3,
        new JLabel(UICaption.dialog_label_run_blast_matrix),
        selector4,
        panel, cbFilters },
        UICaption.dialog_caption_run_blast,
        JOptionPane.OK_CANCEL_OPTION,
        JOptionPane.PLAIN_MESSAGE,
        null, options, options[0]);
  }

  public int getId1() {
    return id1.intValue();
  }

  public int getId2() {
    return id2.intValue();
  }

  public int[] getIds() {
    return new int[]{id1.intValue(), id2.intValue()};
  }

  public String getMatrix() {
    return (String) selector4.getSelectedItem();
  }

  public String getThresholds() {
    return txtThresholds.getText();
  }

  public boolean hasFilters() {
    return cbFilters.isSelected();
  }
 
  public boolean checkThresholdsFormat() {
    return BlastExecutor.checkThresholdsFormat(txtThresholds.getText());
  }
}
TOP

Related Classes of versusSNP.gui.dialogs.RunBlastDialog

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.