1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 *******************************************************************************/
18 package jalview.jbgui;
20 import jalview.gui.JvSwingUtils;
22 import java.awt.BorderLayout;
23 import java.awt.Dimension;
24 import java.awt.FlowLayout;
25 import java.awt.GridLayout;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.MouseEvent;
29 import java.awt.event.MouseListener;
31 import javax.swing.BoxLayout;
32 import javax.swing.JButton;
33 import javax.swing.JCheckBox;
34 import javax.swing.JComboBox;
35 import javax.swing.JLabel;
36 import javax.swing.JList;
37 import javax.swing.JPanel;
38 import javax.swing.JScrollPane;
39 import javax.swing.JTabbedPane;
40 import javax.swing.JTextArea;
41 import javax.swing.JViewport;
42 import javax.swing.ListSelectionModel;
43 import javax.swing.UIManager;
44 import javax.swing.border.TitledBorder;
45 import javax.swing.event.CaretEvent;
46 import javax.swing.event.CaretListener;
47 import javax.swing.event.DocumentEvent;
48 import javax.swing.event.DocumentListener;
49 import javax.swing.event.ListSelectionListener;
51 import net.miginfocom.swing.MigLayout;
53 public class GRestServiceEditorPane extends JPanel {
55 protected JTabbedPane panels;
57 protected JPanel details, inputs, paste;
59 protected JTextArea urldesc, url, urlsuff, name, descr, parseRes;
61 protected JComboBox action, gapChar;
65 protected JButton okButton;
67 protected JButton cancelButton;
73 protected JList iprms;
75 protected JList rdata;
77 JScrollPane iprmVp, rdataVp, parseResVp, urlVp, descrVp, urldescVp;
79 JButton rdataAdd, rdataRem, rdataNdown, rdataNup;
81 JButton iprmsAdd, iprmsRem;
83 protected JCheckBox hSeparable;
85 protected JCheckBox vSeparable;
87 protected JPanel parseWarnings;
89 public GRestServiceEditorPane()
94 protected void jbInit()
96 details = new JPanel();
97 details.setName("Details");
98 details.setLayout(new MigLayout());
99 inputs = new JPanel();
100 inputs.setName("Input/Output");
101 inputs.setLayout(new MigLayout("","[grow 85,fill][]",""));
102 paste = new JPanel();
103 paste.setName("Cut'n'Paste");
104 paste.setLayout(new MigLayout("","[grow 100, fill]","[][grow 100,fill]"));
106 panels = new JTabbedPane();
107 panels.addTab(details.getName(), details);
108 panels.addTab(inputs.getName(), inputs);
109 panels.addTab(paste.getName(), paste);
113 // Name and URL Panel
115 name = new JTextArea(1, 12);
118 .mgAddtoLayout(cpanel, "Short descriptive name for service",
119 new JLabel("Name:"), name,"wrap");
120 action = new JComboBox();
124 "What kind of function the service performs (e.g. alignment, analysis, search, etc).",
125 new JLabel("Service Action:"), action,"wrap");
126 descr = new JTextArea(4, 60);
127 descrVp = new JScrollPane();
128 descrVp.setViewportView(descr);
129 JvSwingUtils.mgAddtoLayout(cpanel, "Brief description of service",
130 new JLabel("Description:"), descrVp,"wrap");
132 url = new JTextArea(2, 60);
133 urlVp = new JScrollPane();
134 urlVp.setViewportView(url);
138 "URL to post data to service. Include any special parameters needed here",
139 new JLabel("POST URL:"), urlVp,"wrap");
141 urlsuff = new JTextArea();
142 urlsuff.setColumns(60);
147 "Optional suffix added to URL when retrieving results from service",
148 new JLabel("URL Suffix:"), urlsuff,"wrap");
151 // details.add(cpanel = new JPanel(), BorderLayout.CENTER);
152 // cpanel.setLayout(new FlowLayout());
153 hSeparable = new JCheckBox("per Sequence");
155 .setToolTipText("<html>"
157 .wrapTooltip("When checked, a job is created for every sequence in the current selection.")
159 hSeparable.addActionListener(new ActionListener()
163 public void actionPerformed(ActionEvent arg0)
165 hSeparable_actionPerformed(arg0);
169 vSeparable = new JCheckBox("Results are vertically separable");
171 .setToolTipText("<html>"
173 .wrapTooltip("When checked, a single job is created for the visible region and results"
174 + " mapped back onto their location in the alignment. Otherwise, a job would be"
175 + " created for every contiguous region visible in the alignment or current"
176 + " selection (e.g. a multiple alignment).")
178 vSeparable.addActionListener(new ActionListener()
182 public void actionPerformed(ActionEvent arg0)
184 vSeparable_actionPerformed(arg0);
188 gapChar = new JComboBox();
192 "Which gap character does this service prefer ?",
193 new JLabel("Gap Character:"), gapChar,"wrap");
196 cpanel.add(hSeparable);
197 cpanel.add(vSeparable);
199 // Input and Output lists
201 JPanel iprmsList = new JPanel();
202 iprmsList.setBorder(new TitledBorder("Data input parameters"));
203 iprmsList.setLayout(new MigLayout("","[grow 90, fill][]"));
204 iprmVp = new JScrollPane();
205 iprmVp.getViewport().setView(iprms = new JList());
206 iprmsList.add(iprmVp);
207 iprms.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
208 iprms.addMouseListener(new MouseListener()
212 public void mouseReleased(MouseEvent e)
214 // TODO Auto-generated method stub
219 public void mousePressed(MouseEvent e)
221 // TODO Auto-generated method stub
226 public void mouseExited(MouseEvent e)
228 // TODO Auto-generated method stub
233 public void mouseEntered(MouseEvent e)
235 // TODO Auto-generated method stub
240 public void mouseClicked(MouseEvent e)
242 if (e.getClickCount()>1) {
243 iprmListSelection_doubleClicked();
248 JPanel iprmButs = new JPanel();
249 iprmButs.setLayout(new MigLayout());
251 iprmsAdd = JvSwingUtils.makeButton("+", "Add input parameter",
256 public void actionPerformed(ActionEvent e)
258 iprmsAdd_actionPerformed(e);
262 iprmsRem = JvSwingUtils.makeButton("-",
263 "Remove selected input parameter", new ActionListener()
267 public void actionPerformed(ActionEvent e)
269 iprmsRem_actionPerformed(e);
274 iprmButs.add(iprmsAdd,"wrap");
275 iprmButs.add(iprmsRem,"wrap");
276 iprmsList.add(iprmButs, "wrap");
277 inputs.add(iprmsList, "wrap");
281 rdataAdd = JvSwingUtils.makeButton("+", "Add return datatype",
286 public void actionPerformed(ActionEvent e)
288 rdataAdd_actionPerformed(e);
292 rdataRem = JvSwingUtils.makeButton("-", "Remove return datatype",
297 public void actionPerformed(ActionEvent e)
299 rdataRem_actionPerformed(e);
303 rdataNup = JvSwingUtils.makeButton("Move Up",
304 "Move return type up order", new ActionListener()
308 public void actionPerformed(ActionEvent e)
310 rdataNup_actionPerformed(e);
314 rdataNdown = JvSwingUtils.makeButton("Move Down",
315 "Move return type down order", new ActionListener()
319 public void actionPerformed(ActionEvent e)
321 rdataNdown_actionPerformed(e);
326 JPanel rparamList = new JPanel();
327 rparamList.setBorder(new TitledBorder("Data returned by service"));
328 rparamList.setLayout(new MigLayout("","[grow 90, fill][]"));
330 rdata.setToolTipText("Right click to edit currently selected parameter.");
331 rdata.addMouseListener(new MouseListener()
335 public void mouseReleased(MouseEvent arg0)
337 // TODO Auto-generated method stub
342 public void mousePressed(MouseEvent arg0)
348 public void mouseExited(MouseEvent arg0)
350 // TODO Auto-generated method stub
355 public void mouseEntered(MouseEvent arg0)
357 // TODO Auto-generated method stub
362 public void mouseClicked(MouseEvent arg0)
364 if (arg0.getButton()==MouseEvent.BUTTON3)
366 rdata_rightClicked(arg0);
371 rdataVp = new JScrollPane();
372 rdataVp.getViewport().setView(rdata);
373 rparamList.add(rdataVp);
374 JPanel rparamButs = new JPanel();
375 rparamButs.setLayout(new MigLayout());
376 rparamButs.add(rdataAdd,"wrap");
377 rparamButs.add(rdataRem,"wrap");
378 rparamButs.add(rdataNup,"wrap");
379 rparamButs.add(rdataNdown,"wrap");
380 rparamList.add(rparamButs,"wrap");
381 inputs.add(rparamList,"wrap");
383 // Parse flat-text to a service
386 urldesc = new JTextArea(4,60);
387 urldesc.setEditable(true);
388 urldesc.setWrapStyleWord(true);
389 urldescVp = new JScrollPane();
390 urldescVp.setViewportView(urldesc);
391 JPanel urldescPane = new JPanel();
392 urldescPane.setLayout(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
393 urldescPane.setBorder(new TitledBorder("RSBS Encoded Service"));
394 urldescPane.add(urldescVp, "span");
395 paste.add(urldescPane,"span");
396 urldescPane.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism"));
398 parseRes = new JTextArea();
399 parseResVp = new JScrollPane();
400 parseResVp.setViewportView(parseRes);
401 parseRes.setWrapStyleWord(true);
402 parseRes.setColumns(60);
403 parseWarnings = new JPanel(new MigLayout("","[grow 100, fill]", "[grow 100, fill]"));
404 parseWarnings.setBorder(new TitledBorder("Parsing errors"));
405 parseWarnings.setToolTipText("<html>"+JvSwingUtils.wrapTooltip("Results of parsing the RSBS representation")+"</html>");
406 parseWarnings.add(parseResVp, "center");
407 parseRes.setEditable(false);
408 paste.add(parseWarnings, "span");
409 setLayout(new BorderLayout());
410 add(panels, BorderLayout.CENTER);
411 okButton = JvSwingUtils.makeButton("OK", "", new ActionListener()
415 public void actionPerformed(ActionEvent e)
417 ok_actionPerformed();
420 cancelButton = JvSwingUtils.makeButton("Cancel", "",
425 public void actionPerformed(ActionEvent e)
427 cancel_actionPerformed();
433 protected void rdata_rightClicked(MouseEvent arg0)
435 // TODO Auto-generated method stub
439 protected void iprmListSelection_doubleClicked()
441 // TODO Auto-generated method stub
445 protected void hSeparable_actionPerformed(ActionEvent arg0)
447 // TODO Auto-generated method stub
451 protected void vSeparable_actionPerformed(ActionEvent arg0)
453 // TODO Auto-generated method stub
457 protected void cancel_actionPerformed()
459 // TODO Auto-generated method stub
463 protected void ok_actionPerformed()
465 // TODO Auto-generated method stub
469 protected void iprmsAdd_actionPerformed(ActionEvent e)
471 // TODO Auto-generated method stub
475 protected void iprmsRem_actionPerformed(ActionEvent e)
477 // TODO Auto-generated method stub
481 protected void rdataAdd_actionPerformed(ActionEvent e)
483 // TODO Auto-generated method stub
487 protected void rdataRem_actionPerformed(ActionEvent e)
489 // TODO Auto-generated method stub
493 protected void rdataNup_actionPerformed(ActionEvent e)
495 // TODO Auto-generated method stub
499 protected void rdataNdown_actionPerformed(ActionEvent e)
501 // TODO Auto-generated method stub
505 protected void ok_actionPerformed(ActionEvent e)
507 // TODO Auto-generated method stub
511 protected void cancel_actionPerformed(ActionEvent e)
513 // TODO Auto-generated method stub