📄 buildjembossform.java
字号:
/********************************************************************** This library is free software; you can redistribute it and/or* modify it under the terms of the GNU Library General Public* License as published by the Free Software Foundation; either* version 2 of the License, or (at your option) any later version.** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Library General Public License for more details.** You should have received a copy of the GNU Library General Public* License along with this library; if not, write to the* Free Software Foundation, Inc., 59 Temple Place - Suite 330,* Boston, MA 02111-1307, USA.** @author: Copyright (C) Tim Carver*********************************************************************/package org.emboss.jemboss.gui.form;import java.awt.*;import javax.swing.Box;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JComboBox;import javax.swing.JEditorPane;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JMenuBar;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JProgressBar;import javax.swing.JScrollPane;import javax.swing.JTabbedPane;import javax.swing.JTextField;import javax.swing.JTextPane;import javax.swing.WindowConstants;import javax.swing.event.ChangeListener;import javax.swing.event.ChangeEvent;import org.apache.regexp.*;import java.util.Hashtable;import java.util.Vector;import java.util.Arrays;import java.util.Comparator;import java.awt.event.*;import java.io.*;import org.emboss.jemboss.parser.ParseAcd;import org.emboss.jemboss.programs.*;import org.emboss.jemboss.*;import org.emboss.jemboss.gui.*;import org.emboss.jemboss.soap.*;import org.emboss.jemboss.gui.sequenceChooser.*;import org.emboss.jemboss.graphics.Graph2DPlot;import org.emboss.jemboss.server.JembossServer;/**** Responsible for displaying the graphical representation* of the ACD EMBOSS files.** Generates & runs command lines and display results.** @author T. J. Carver**/public class BuildJembossForm implements ActionListener { private ReportFormat rf; private AlignFormat af; private TextFieldSink textf[]; private TextFieldInt textInt[]; private TextFieldFloat textFloat[]; private JTextField rangeField[]; private JCheckBox checkBox[]; private InputSequenceAttributes inSeqAttr[]; private ListFilePanel filelist[]; private MultiTextField multiTextField[]; /** png/jemboss graphics selection */ private JComboBox graphics; protected static OutputSequenceAttributes outSeqAttr; private Box advSectionBox; private Box addSectionBox; protected static JPanel advSection; protected static JPanel addSection; protected static JPanel reqdSection; protected static JPanel outSection; protected static JPanel inpSection; private JembossComboPopup fieldOption[]; private JList multiOption[]; private SetInFileCard inSeq[]; private JButton balign; private String applName; private String db[]; private String[] envp; private String cwd; private ParseAcd parseAcd; private Cursor cbusy = new Cursor(Cursor.WAIT_CURSOR); private Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR);// result files private String seqoutResult; private String outfileResult; private String helptext = ""; private boolean withSoap; private JFrame f; private ScrollPanel p2; private String embossBin; private int numofFields; private JembossParams mysettings; public BuildJembossForm(String appDescription, String db[], final String applName, String[] envp, String cwd, String acdText, final boolean withSoap, ScrollPanel p2, final JembossParams mysettings, final JFrame f) { this.f = f; this.p2 = p2; this.db = db; this.cwd = cwd; this.mysettings = mysettings; this.withSoap = withSoap; embossBin = mysettings.getEmbossBin(); this.envp = envp; this.applName = applName; JPanel pC = new JPanel();// pC.setBackground(Color.white); p2.add(pC, applName); pC.setLayout(new BorderLayout()); Box fieldPane = Box.createVerticalBox(); parseAcd = new ParseAcd(acdText,false); numofFields = parseAcd.getNumofFields(); attach(pC, fieldPane, appDescription);// JScrollPane scroll = new JScrollPane(fieldPane);// pC.add(scroll, BorderLayout.CENTER); pC.add(fieldPane,BorderLayout.CENTER);// get help for current application if(!withSoap) { String command = embossBin.concat("tfm " + applName + " -html -nomore"); RunEmbossApplication2 rea = new RunEmbossApplication2(command,envp,null); rea.waitFor(); helptext = rea.getProcessStdout(); }// Help button ClassLoader cl = this.getClass().getClassLoader(); JButton bhelp = new JButton(new ImageIcon( cl.getResource("images/Information_button.gif"))); bhelp.addActionListener(this); bhelp.setMargin(new Insets(0,1,0,1)); bhelp.setToolTipText("Help"); bhelp.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String text = ""; String url = null; if(!withSoap) text = helptext; else { String urlEmbassyPrefix = parseAcd.getUrlPrefix(); url = mysettings.getembURL(); if(urlEmbassyPrefix != null) url = url + "apps/release/4.0/embassy/" +applName+ "/" ; else url = url + "apps/release/4.0/emboss/apps/"; url = url+applName+".html"; } JEditorPane htmlPane = null; if(url == null) { try { new Browser(url,applName,true,text,mysettings); } catch(IOException ioe1){} } else if(mysettings.isUseTFM()) { GetHelp thishelp = new GetHelp(applName,mysettings); text = thishelp.getHelpText(); try { new Browser(url,applName,true,text,mysettings); } catch(IOException ioe3){} } else { try { new Browser(url,applName,mysettings); } catch(IOException ioe2) { GetHelp thishelp = new GetHelp(applName,mysettings); text = thishelp.getHelpText(); try { new Browser(url,applName,true,text,mysettings); } catch(IOException ioe3){} } } } }); balign = new JButton("Show Alignment"); balign.addActionListener(this);// Go button ImageIcon rfii = new ImageIcon(cl.getResource("images/Go_button.gif")); JButton bgo = new JButton(rfii); bgo.setActionCommand("GO"); bgo.setMargin(new Insets(0,0,0,0)); bgo.addActionListener(this); Box tools; tools = Box.createHorizontalBox(); tools.add(Box.createRigidArea(new Dimension(2,0))); tools.add(bgo); tools.add(Box.createRigidArea(new Dimension(4,0))); tools.add(bhelp); // Advanced options if(advSectionBox != null || addSectionBox != null) { JButton badvanced = new JButton("Advanced Options"); badvanced.addActionListener(this); tools.add(Box.createRigidArea(new Dimension(4,0))); tools.add(badvanced); } tools.add(Box.createRigidArea(new Dimension(4,0))); tools.add(balign); balign.setVisible(false); tools.add(Box.createHorizontalGlue()); fieldPane.add(Box.createRigidArea(new Dimension(0,10))); fieldPane.add(tools); fieldPane.add(Box.createVerticalStrut(10)); bgo.setMinimumSize(new Dimension(200, 40)); bgo.setMaximumSize(new Dimension(200, 40));// additional section if(addSectionBox != null) { fieldPane.add(addSectionBox); addSectionBox.setVisible(false); }// advanced section if(advSectionBox != null) { fieldPane.add(advSectionBox); advSectionBox.setVisible(false); } fieldPane.add(Box.createVerticalGlue()); } public void attach(JPanel p3, Box fieldPane, String appDescription) { String appN = "";// get total number of Swing components int ntextf = parseAcd.getNumTextf(); int nint = parseAcd.getNumNint(); int nfloat = parseAcd.getNumNfloat(); int nbool = parseAcd.getNumBool(); int nseqs = parseAcd.getNumSeq(); int nlist = parseAcd.getNumList(); int mlist = parseAcd.getNumMList(); int nrange = parseAcd.getNumRange(); int nflist = parseAcd.getNumFileList(); int nmultiText = parseAcd.getNumMultiTextField(); textf = new TextFieldSink[ntextf]; textInt = new TextFieldInt[nint]; textFloat = new TextFieldFloat[nfloat]; checkBox = new JCheckBox[nbool]; inSeqAttr = new InputSequenceAttributes[nseqs]; filelist = new ListFilePanel[nflist]; fieldOption = new JembossComboPopup[nlist]; multiOption = new JList[mlist]; rangeField = new JTextField[nrange]; inSeq = new SetInFileCard[nseqs]; multiTextField = new MultiTextField[nmultiText]; // JRadioButton rpaste[] = new JRadioButton [nseqs]; Box lab[] = new Box[numofFields]; for(int j=0;j<nbool;j++) checkBox[j] = new JCheckBox(); for(int j=0;j<ntextf;j++) { textf[j] = new TextFieldSink(); Dimension d = new Dimension(150, 30); textf[j].setPreferredSize(d); textf[j].setMinimumSize(d); textf[j].setMaximumSize(d); } for(int j=0;j<nint;j++) { textInt[j] = new TextFieldInt(); Dimension d = new Dimension(150, 30); textInt[j].setPreferredSize(d); textInt[j].setMinimumSize(d); textInt[j].setMaximumSize(d); } for(int j=0;j<nfloat;j++) { textFloat[j] = new TextFieldFloat(); Dimension d = new Dimension(150, 30); textFloat[j].setPreferredSize(d); textFloat[j].setMinimumSize(d); textFloat[j].setMaximumSize(d); } for(int j=0;j<nrange;j++) { rangeField[j] = new TextFieldSink(); Dimension d = new Dimension(150, 30); rangeField[j].setPreferredSize(d); rangeField[j].setMinimumSize(d); rangeField[j].setMaximumSize(d); } int nsection = parseAcd.getNumSection(); if(nsection==0) nsection = 1; int nfield = 0; advSectionBox = null; addSectionBox = null; reqdSection = null; outSection = null; inpSection = null;// if(withSoap)// { if(parseAcd.isBatchable() && !parseAcd.getExpectedCPU().equalsIgnoreCase("low")) Jemboss.resultsManager.updateMode("batch"); else Jemboss.resultsManager.updateMode("interactive");// } String type[] = {"PNG","Jemboss Graphics"}; graphics = new JComboBox(type); for(int j=0;j<nsection;j++) { if(nfield < numofFields) { SectionPanel sp = new SectionPanel(f,p3,fieldPane,parseAcd, nfield,multiTextField,textf,textInt,textFloat,rangeField,checkBox, inSeqAttr,fieldOption,multiOption,inSeq,filelist,graphics, db,appDescription,lab,numofFields,mysettings,withSoap,envp); if(sp.isReportFormat()) rf = sp.getReportFormat(); if(sp.isAlignFormat()) af = sp.getAlignFormat(); if(sp.isAdvancedSection()) { advSectionBox = sp.getSectionBox(); advSection = sp.getSectionPanel(); } else if(sp.isAdditionalSection()) { addSectionBox = sp.getSectionBox(); addSection = sp.getSectionPanel(); } else if(sp.getSectionBox() != null) { fieldPane.add(sp.getSectionBox()); if(sp.isInputSection()) inpSection = sp.getSectionPanel(); else if(sp.isRequiredSection()) reqdSection = sp.getSectionPanel(); else if(sp.isOutputSection()) outSection = sp.getSectionPanel(); } nfield = sp.getFieldNum(); } } }/**** Action events Exit, Help, GO, & Show results* **/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -