2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, 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/>.
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
56 protected JTabbedPane panels;
58 protected JPanel details, inputs, paste;
60 protected JTextArea urldesc, url, urlsuff, name, descr, parseRes;
62 protected JComboBox action, gapChar;
66 protected JButton okButton;
68 protected JButton cancelButton;
74 protected JList iprms;
76 protected JList rdata;
78 JScrollPane iprmVp, rdataVp, parseResVp, urlVp, descrVp, urldescVp;
80 JButton rdataAdd, rdataRem, rdataNdown, rdataNup;
82 JButton iprmsAdd, iprmsRem;
84 protected JCheckBox hSeparable;
86 protected JCheckBox vSeparable;
88 protected JPanel parseWarnings;
90 public GRestServiceEditorPane()
95 protected void jbInit()
97 details = new JPanel();
98 details.setName("Details");
99 details.setLayout(new MigLayout());
100 inputs = new JPanel();
101 inputs.setName("Input/Output");
102 inputs.setLayout(new MigLayout("", "[grow 85,fill][]", ""));
103 paste = new JPanel();
104 paste.setName("Cut'n'Paste");
105 paste.setLayout(new MigLayout("", "[grow 100, fill]",
106 "[][grow 100,fill]"));
108 panels = new JTabbedPane();
109 panels.addTab(details.getName(), details);
110 panels.addTab(inputs.getName(), inputs);
111 panels.addTab(paste.getName(), paste);
115 // Name and URL Panel
117 name = new JTextArea(1, 12);
119 JvSwingUtils.mgAddtoLayout(cpanel,
120 "Short descriptive name for service", new JLabel("Name:"),
122 action = new JComboBox();
126 "What kind of function the service performs (e.g. alignment, analysis, search, etc).",
127 new JLabel("Service Action:"), action, "wrap");
128 descr = new JTextArea(4, 60);
129 descrVp = new JScrollPane();
130 descrVp.setViewportView(descr);
131 JvSwingUtils.mgAddtoLayout(cpanel, "Brief description of service",
132 new JLabel("Description:"), descrVp, "wrap");
134 url = new JTextArea(2, 60);
135 urlVp = new JScrollPane();
136 urlVp.setViewportView(url);
140 "URL to post data to service. Include any special parameters needed here",
141 new JLabel("POST URL:"), urlVp, "wrap");
143 urlsuff = new JTextArea();
144 urlsuff.setColumns(60);
149 "Optional suffix added to URL when retrieving results from service",
150 new JLabel("URL Suffix:"), urlsuff, "wrap");
153 // details.add(cpanel = new JPanel(), BorderLayout.CENTER);
154 // cpanel.setLayout(new FlowLayout());
155 hSeparable = new JCheckBox("per Sequence");
157 .setToolTipText("<html>"
159 .wrapTooltip("When checked, a job is created for every sequence in the current selection.")
161 hSeparable.addActionListener(new ActionListener()
165 public void actionPerformed(ActionEvent arg0)
167 hSeparable_actionPerformed(arg0);
171 vSeparable = new JCheckBox("Results are vertically separable");
173 .setToolTipText("<html>"
175 .wrapTooltip("When checked, a single job is created for the visible region and results"
176 + " mapped back onto their location in the alignment. Otherwise, a job would be"
177 + " created for every contiguous region visible in the alignment or current"
178 + " selection (e.g. a multiple alignment).")
180 vSeparable.addActionListener(new ActionListener()
184 public void actionPerformed(ActionEvent arg0)
186 vSeparable_actionPerformed(arg0);
190 gapChar = new JComboBox();
191 JvSwingUtils.mgAddtoLayout(cpanel,
192 "Which gap character does this service prefer ?", new JLabel(
193 "Gap Character:"), gapChar, "wrap");
195 cpanel.add(hSeparable);
196 cpanel.add(vSeparable);
198 // Input and Output lists
200 JPanel iprmsList = new JPanel();
201 iprmsList.setBorder(new TitledBorder("Data input parameters"));
202 iprmsList.setLayout(new MigLayout("", "[grow 90, fill][]"));
203 iprmVp = new JScrollPane();
204 iprmVp.getViewport().setView(iprms = new JList());
205 iprmsList.add(iprmVp);
206 iprms.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
207 iprms.addMouseListener(new MouseListener()
211 public void mouseReleased(MouseEvent e)
213 // TODO Auto-generated method stub
218 public void mousePressed(MouseEvent e)
220 // TODO Auto-generated method stub
225 public void mouseExited(MouseEvent e)
227 // TODO Auto-generated method stub
232 public void mouseEntered(MouseEvent e)
234 // TODO Auto-generated method stub
239 public void mouseClicked(MouseEvent e)
241 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
385 urldesc = new JTextArea(4, 60);
386 urldesc.setEditable(true);
387 urldesc.setWrapStyleWord(true);
388 urldescVp = new JScrollPane();
389 urldescVp.setViewportView(urldesc);
390 JPanel urldescPane = new JPanel();
391 urldescPane.setLayout(new MigLayout("", "[grow 100, fill]",
392 "[grow 100, fill]"));
393 urldescPane.setBorder(new TitledBorder("RSBS Encoded Service"));
394 urldescPane.add(urldescVp, "span");
395 paste.add(urldescPane, "span");
397 .setToolTipText("<html>"
399 .wrapTooltip("Flat file representation of this rest service using the Really Simple Bioinformatics Service formalism"));
401 parseRes = new JTextArea();
402 parseResVp = new JScrollPane();
403 parseResVp.setViewportView(parseRes);
404 parseRes.setWrapStyleWord(true);
405 parseRes.setColumns(60);
406 parseWarnings = new JPanel(new MigLayout("", "[grow 100, fill]",
407 "[grow 100, fill]"));
408 parseWarnings.setBorder(new TitledBorder("Parsing errors"));
410 .setToolTipText("<html>"
412 .wrapTooltip("Results of parsing the RSBS representation")
414 parseWarnings.add(parseResVp, "center");
415 parseRes.setEditable(false);
416 paste.add(parseWarnings, "span");
417 setLayout(new BorderLayout());
418 add(panels, BorderLayout.CENTER);
419 okButton = JvSwingUtils.makeButton("OK", "", new ActionListener()
423 public void actionPerformed(ActionEvent e)
425 ok_actionPerformed();
428 cancelButton = JvSwingUtils.makeButton("Cancel", "",
433 public void actionPerformed(ActionEvent e)
435 cancel_actionPerformed();
441 protected void rdata_rightClicked(MouseEvent arg0)
443 // TODO Auto-generated method stub
447 protected void iprmListSelection_doubleClicked()
449 // TODO Auto-generated method stub
453 protected void hSeparable_actionPerformed(ActionEvent arg0)
455 // TODO Auto-generated method stub
459 protected void vSeparable_actionPerformed(ActionEvent arg0)
461 // TODO Auto-generated method stub
465 protected void cancel_actionPerformed()
467 // TODO Auto-generated method stub
471 protected void ok_actionPerformed()
473 // TODO Auto-generated method stub
477 protected void iprmsAdd_actionPerformed(ActionEvent e)
479 // TODO Auto-generated method stub
483 protected void iprmsRem_actionPerformed(ActionEvent e)
485 // TODO Auto-generated method stub
489 protected void rdataAdd_actionPerformed(ActionEvent e)
491 // TODO Auto-generated method stub
495 protected void rdataRem_actionPerformed(ActionEvent e)
497 // TODO Auto-generated method stub
501 protected void rdataNup_actionPerformed(ActionEvent e)
503 // TODO Auto-generated method stub
507 protected void rdataNdown_actionPerformed(ActionEvent e)
509 // TODO Auto-generated method stub
513 protected void ok_actionPerformed(ActionEvent e)
515 // TODO Auto-generated method stub
519 protected void cancel_actionPerformed(ActionEvent e)
521 // TODO Auto-generated method stub