⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showsavedresults.java

📁 emboss的linux版本的源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/**********************************************************************  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;import java.awt.*;import java.awt.event.*;import java.io.*;import java.util.*;import javax.swing.*;import javax.swing.border.*;import javax.swing.event.*;import javax.swing.tree.*;import org.emboss.jemboss.programs.*;import org.emboss.jemboss.soap.*;import org.emboss.jemboss.JembossParams;/**** Shows a list of results from the SOAP server* and displays individual result sets**/public class ShowSavedResults extends JFrame{  /** busy cursor */  private Cursor cbusy = new Cursor(Cursor.WAIT_CURSOR);   /** done cursor */  private Cursor cdone = new Cursor(Cursor.DEFAULT_CURSOR);  /** data list model */  private DefaultListModel datasets = new DefaultListModel();  /** result data list panel */  private ScrollPanel sp = new ScrollPanel();  /** text area for initial description of the saved results      window and the run information of the results */  private JTextArea aboutRes;   /** scrollpane for description of the results */  private JScrollPane aboutScroll;  /** scroll panel for result data */  private JScrollPane ss;  /** result status panel */  private JPanel resButtonStatus;  /** status field */  private JTextField statusField;  /** manu bar for results panel */  private JMenuBar resMenu = new JMenuBar();  /** refresh image */  private ImageIcon rfii;  /**  *  * @param frameName	title name for frame  *  */  public ShowSavedResults(String frameName)  {    super(frameName);    aboutRes = new JTextArea("Select a result set from"                              +"\nthose listed and details"                              +"\nof that analysis will be"                              +"\nshown here. Then you can"                              +"\neither delete or view those"                              +"\nresults using the buttons below.");    aboutScroll = new JScrollPane(aboutRes);      ss = new JScrollPane(sp);    ss.getViewport().setBackground(Color.white);//  resMenu.setLayout(new FlowLayout(FlowLayout.LEFT,10,1));    ClassLoader cl = getClass().getClassLoader();    rfii = new ImageIcon(cl.getResource("images/Refresh_button.gif"));//results status    resButtonStatus = new JPanel(new BorderLayout());    Border loweredbevel = BorderFactory.createLoweredBevelBorder();    Border raisedbevel = BorderFactory.createRaisedBevelBorder();    Border compound = BorderFactory.createCompoundBorder(raisedbevel,loweredbevel);    statusField = new JTextField();    statusField.setBorder(compound);    statusField.setEditable(false);  }  /**  *  * Show the saved results on the server.  * @param mysettings	jemboss settings  * @param frameName    title name for frame  *  */  public ShowSavedResults(final JembossParams mysettings, final JFrame f)  {    this("Saved Results on Server");         Dimension d = new Dimension(270,270);    ss.setPreferredSize(d);//  ss.setMaximumSize(d);    try    {      final ResultList reslist = new ResultList(mysettings);      JMenu resFileMenu = new JMenu("File");      resMenu.add(resFileMenu);      final JCheckBoxMenuItem listByProgram =                  new JCheckBoxMenuItem("List by program");      listByProgram.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)        {          listByProgramName();        }      });      resFileMenu.add(listByProgram);      JCheckBoxMenuItem listByDate =                  new JCheckBoxMenuItem("List by date",true);      listByDate.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)        {          listByDateRun(reslist,false);        }      });      resFileMenu.add(listByDate);      ButtonGroup group = new ButtonGroup();      group.add(listByProgram);      group.add(listByDate);      JButton refresh = new JButton(rfii);      refresh.setMargin(new Insets(0,1,0,1));      refresh.setToolTipText("Refresh");      resMenu.add(refresh);      refresh.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)         {          try          {            setCursor(cbusy);            ResultList newlist = new ResultList(mysettings);            setCursor(cdone);            if (newlist.getStatus().equals("0"))             {              reslist.updateRes(newlist.hash());              datasets.removeAllElements();              StringTokenizer tok = new StringTokenizer(                         (String)reslist.get("list"), "\n");              while (tok.hasMoreTokens())                datasets.addElement(convertToPretty(tok.nextToken()));              if(listByProgram.isSelected())                listByProgramName();              else                listByDateRun(reslist,false);            }             else             {              JOptionPane.showMessageDialog(null,                     newlist.getStatusMsg(), "Soap Error",                              JOptionPane.ERROR_MESSAGE);            }          }           catch (JembossSoapException eae)           {            AuthPopup ap = new AuthPopup(mysettings,f);            ap.setBottomPanel();            ap.setSize(380,170);            ap.pack();            ap.setVisible(true);          }        }      });      resFileMenu.addSeparator();      JMenuItem resFileMenuExit = new JMenuItem("Close");      resFileMenuExit.setAccelerator(KeyStroke.getKeyStroke(                    KeyEvent.VK_E, ActionEvent.CTRL_MASK));      resFileMenuExit.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)         {          dispose();        }      });      resFileMenu.add(resFileMenuExit);      setJMenuBar(resMenu);              // this is the list of saved results      listByDateRun(reslist,true);        final JList st = new JList(datasets);      st.setCellRenderer(new TabListCellRenderer());      st.addListSelectionListener(new ListSelectionListener()      {        public void valueChanged(ListSelectionEvent e)         {          if (e.getValueIsAdjusting())            return;          JList theList = (JList)e.getSource();          if (theList.isSelectionEmpty())           {            System.out.println("Empty selection");          }           else           {            int index = theList.getSelectedIndex();            String thisdata = convertToOriginal(datasets.elementAt(index));            aboutRes.setText((String)reslist.get(thisdata));            aboutRes.setCaretPosition(0);          }        }      });      st.addMouseListener(new MouseAdapter()       {        public void mouseClicked(MouseEvent e)         {          if (e.getClickCount() == 2)           {            try            {              setCursor(cbusy);              String project = convertToOriginal(st.getSelectedValue());              ResultList thisres = new ResultList(mysettings,project,                                              "show_saved_results");              new ShowResultSet(thisres.hash(),project,mysettings);              setCursor(cdone);            }             catch (JembossSoapException eae)             {                AuthPopup ap = new AuthPopup(mysettings,f);              ap.setBottomPanel();              ap.setSize(380,170);              ap.pack();              ap.setVisible(true);            }          }        }      });      sp.add(st);              // display retrieves all files and shows them in a window      JPanel resButtonPanel = new JPanel();      JButton showResButton = new JButton("Display");      showResButton.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e) 	{          String sel = convertToOriginal(st.getSelectedValue());  	  if(sel != null)          {	    try 	    {	      setCursor(cbusy);	      ResultList thisres = new ResultList(mysettings,                                   sel,"show_saved_results");               new ShowResultSet(thisres.hash(),sel,mysettings);	      setCursor(cdone);	    }             catch (JembossSoapException eae)            {              AuthPopup ap = new AuthPopup(mysettings,f);              ap.setBottomPanel();              ap.setSize(380,170);              ap.pack();              ap.setVisible(true);	    }  	  }   	  else   	  {            statusField.setText("Nothing selected to be displayed.");  	  }        }      });      // add a users note for that project      JButton addNoteButton = new JButton("Edit Notes");      addNoteButton.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)        {          String sel = convertToOriginal(st.getSelectedValue());          if(sel != null)          {            try            {              setCursor(cbusy);              ResultList thisres = new ResultList(mysettings,                           sel,"Notes","show_saved_results");              new ShowResultSet(thisres.hash(),sel,mysettings);              setCursor(cdone);            }            catch (JembossSoapException eae)            {              AuthPopup ap = new AuthPopup(mysettings,f);              ap.setBottomPanel();              ap.setSize(380,170);              ap.pack();              ap.setVisible(true);            }          }          else          {            statusField.setText("Selected a project!");          }        }      });              // delete removes the file on the server & edits the list      JButton delResButton = new JButton("Delete");      delResButton.addActionListener(new ActionListener()      {        public void actionPerformed(ActionEvent e)         {          Object sel[] = st.getSelectedValues();          if(sel != null)           {            String selList= new String("");            JTextPane delList = new JTextPane();            FontMetrics fm = delList.getFontMetrics(delList.getFont());            int maxWidth = 0;            for(int i=0;i<sel.length;i++)            {              if(i==sel.length-1)                selList=selList.concat((String)sel[i]);              else                selList=selList.concat(sel[i]+"\n");              int width = fm.stringWidth((String)sel[i]);              if(width>maxWidth)                maxWidth=width;            }            int ok = JOptionPane.OK_OPTION;            if(sel.length>1)            {              JScrollPane scrollDel = new JScrollPane(delList);              delList.setText(selList);              delList.setEditable(false);              delList.setCaretPosition(0);              Dimension d1 = delList.getPreferredSize();              int maxHeight = (int)d1.getHeight()+5;              if(maxHeight > 350)                maxHeight = 350;              else if(maxHeight < 50)                maxHeight = 50;                            scrollDel.setPreferredSize(new Dimension(maxWidth+30,maxHeight));              ok = JOptionPane.showConfirmDialog(null,                         scrollDel,"Confirm Deletion",                  JOptionPane.YES_NO_OPTION);            }            if(ok == JOptionPane.OK_OPTION)            {              try        // ask the server to delete these results	      {	        setCursor(cbusy);                 selList = convertToOriginal(selList);	        ResultList thisres = new ResultList(mysettings,selList,                                         "delete_saved_results"); 	        setCursor(cdone);	                       // amend the list                for(int i=0;i<sel.length;i++)                  datasets.removeElement(sel[i]);                                statusField.setText("Deleted " + sel.length + "  result(s)");     	        aboutRes.setText("");	        st.setSelectedIndex(-1);	      } 	      catch (JembossSoapException eae) 	      {                AuthPopup ap = new AuthPopup(mysettings,f);                ap.setBottomPanel();                ap.setSize(380,170);                ap.pack();                ap.setVisible(true);              }            }	  }           else           {            statusField.setText("Nothing selected for deletion.");	  }	}      });      resButtonPanel.add(delResButton);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -