2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import jalview.gui.JvSwingUtils;
24 import jalview.util.MessageManager;
26 import java.awt.BorderLayout;
27 import java.awt.event.ActionEvent;
28 import java.awt.event.ActionListener;
29 import java.awt.event.MouseEvent;
30 import java.awt.event.MouseListener;
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.ListSelectionModel;
42 import javax.swing.border.TitledBorder;
44 import net.miginfocom.swing.MigLayout;
46 public class GRestServiceEditorPane extends JPanel
49 protected JTabbedPane panels;
51 protected JPanel details, inputs, paste;
53 protected JTextArea urldesc, url, urlsuff, name, descr, parseRes;
55 protected JComboBox action, gapChar;
59 protected JButton okButton;
61 protected JButton cancelButton;
67 protected JList iprms;
69 protected JList rdata;
71 JScrollPane iprmVp, rdataVp, parseResVp, urlVp, descrVp, urldescVp;
73 JButton rdataAdd, rdataRem, rdataNdown, rdataNup;
75 JButton iprmsAdd, iprmsRem;
77 protected JCheckBox hSeparable;
79 protected JCheckBox vSeparable;
81 protected JPanel parseWarnings;
83 public GRestServiceEditorPane()
88 protected void jbInit()
90 details = new JPanel();
91 details.setName(MessageManager.getString("label.details"));
92 details.setLayout(new MigLayout());
93 inputs = new JPanel();
94 inputs.setName(MessageManager.getString("label.input_output"));
95 inputs.setLayout(new MigLayout("", "[grow 85,fill][]", ""));
97 paste.setName(MessageManager.getString("label.cut_paste"));
98 paste.setLayout(new MigLayout("", "[grow 100, fill]",
99 "[][grow 100,fill]"));
101 panels = new JTabbedPane();
102 panels.addTab(details.getName(), details);
103 panels.addTab(inputs.getName(), inputs);
104 panels.addTab(paste.getName(), paste);
108 // Name and URL Panel
110 name = new JTextArea(1, 12);
112 JvSwingUtils.mgAddtoLayout(cpanel, MessageManager
113 .getString("label.short_descriptive_name_for_service"),
114 new JLabel(MessageManager.getString("label.name")), name,
116 action = new JComboBox();
117 JvSwingUtils.mgAddtoLayout(cpanel,
118 MessageManager.getString("label.function_service_performs"),
119 new JLabel(MessageManager.getString("label.service_action")),
121 descr = new JTextArea(4, 60);
122 descrVp = new JScrollPane();
123 descrVp.setViewportView(descr);
124 JvSwingUtils.mgAddtoLayout(cpanel,
125 MessageManager.getString("label.brief_description_service"),
126 new JLabel(MessageManager.getString("label.description")),
129 url = new JTextArea(2, 60);
130 urlVp = new JScrollPane();
131 urlVp.setViewportView(url);
132 JvSwingUtils.mgAddtoLayout(cpanel,
133 MessageManager.getString("label.url_post_data_service"),
134 new JLabel(MessageManager.getString("label.post_url")), urlVp,
137 urlsuff = new JTextArea();
138 urlsuff.setColumns(60);
140 JvSwingUtils.mgAddtoLayout(cpanel, MessageManager
141 .getString("label.optional_suffix"),
142 new JLabel(MessageManager.getString("label.url_suffix")),
146 // details.add(cpanel = new JPanel(), BorderLayout.CENTER);
147 // cpanel.setLayout(new FlowLayout());
148 hSeparable = new JCheckBox(MessageManager.getString("label.per_seq"));
150 .setToolTipText(JvSwingUtils
151 .wrapTooltip(true, MessageManager.getString("label.job_created_when_checked")));
152 hSeparable.addActionListener(new ActionListener()
156 public void actionPerformed(ActionEvent arg0)
158 hSeparable_actionPerformed(arg0);
162 vSeparable = new JCheckBox(
163 MessageManager.getString("label.result_vertically_separable"));
165 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.when_checked_job_visible_region_and_results")));
166 vSeparable.addActionListener(new ActionListener()
170 public void actionPerformed(ActionEvent arg0)
172 vSeparable_actionPerformed(arg0);
176 gapChar = new JComboBox();
177 JvSwingUtils.mgAddtoLayout(cpanel,
178 MessageManager.getString("label.preferred_gap_character"),
179 new JLabel(MessageManager.getString("label.gap_character")
180 + ":"), gapChar, "wrap");
182 cpanel.add(hSeparable);
183 cpanel.add(vSeparable);
185 // Input and Output lists
187 JPanel iprmsList = new JPanel();
188 iprmsList.setBorder(new TitledBorder(MessageManager
189 .getString("label.data_input_parameters")));
190 iprmsList.setLayout(new MigLayout("", "[grow 90, fill][]"));
191 iprmVp = new JScrollPane();
192 iprmVp.getViewport().setView(iprms = new JList());
193 iprmsList.add(iprmVp);
194 iprms.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
195 iprms.addMouseListener(new MouseListener()
199 public void mouseReleased(MouseEvent e)
201 // TODO Auto-generated method stub
206 public void mousePressed(MouseEvent e)
208 // TODO Auto-generated method stub
213 public void mouseExited(MouseEvent e)
215 // TODO Auto-generated method stub
220 public void mouseEntered(MouseEvent e)
222 // TODO Auto-generated method stub
227 public void mouseClicked(MouseEvent e)
229 if (e.getClickCount() > 1)
231 iprmListSelection_doubleClicked();
236 JPanel iprmButs = new JPanel();
237 iprmButs.setLayout(new MigLayout());
239 iprmsAdd = JvSwingUtils.makeButton("+",
240 MessageManager.getString("action.add_input_parameter"),
245 public void actionPerformed(ActionEvent e)
247 iprmsAdd_actionPerformed(e);
251 iprmsRem = JvSwingUtils.makeButton("-",
252 MessageManager.getString("action.remove_input_parameter"),
257 public void actionPerformed(ActionEvent e)
259 iprmsRem_actionPerformed(e);
264 iprmButs.add(iprmsAdd, "wrap");
265 iprmButs.add(iprmsRem, "wrap");
266 iprmsList.add(iprmButs, "wrap");
267 inputs.add(iprmsList, "wrap");
271 rdataAdd = JvSwingUtils.makeButton("+",
272 MessageManager.getString("action.add_return_datatype"),
277 public void actionPerformed(ActionEvent e)
279 rdataAdd_actionPerformed(e);
283 rdataRem = JvSwingUtils.makeButton("-",
284 MessageManager.getString("action.remove_return_datatype"),
289 public void actionPerformed(ActionEvent e)
291 rdataRem_actionPerformed(e);
295 rdataNup = JvSwingUtils.makeButton(
296 MessageManager.getString("action.move_up"),
297 MessageManager.getString("label.move_return_type_up_order"),
302 public void actionPerformed(ActionEvent e)
304 rdataNup_actionPerformed(e);
308 rdataNdown = JvSwingUtils.makeButton(
309 MessageManager.getString("action.move_down"),
310 MessageManager.getString("label.move_return_type_down_order"),
315 public void actionPerformed(ActionEvent e)
317 rdataNdown_actionPerformed(e);
322 JPanel rparamList = new JPanel();
323 rparamList.setBorder(new TitledBorder(MessageManager
324 .getString("label.data_returned_by_service")));
325 rparamList.setLayout(new MigLayout("", "[grow 90, fill][]"));
327 rdata.setToolTipText(MessageManager
328 .getString("label.right_click_to_edit_currently_selected_parameter"));
329 rdata.addMouseListener(new MouseListener()
333 public void mouseReleased(MouseEvent arg0)
335 // TODO Auto-generated method stub
340 public void mousePressed(MouseEvent arg0)
346 public void mouseExited(MouseEvent arg0)
348 // TODO Auto-generated method stub
353 public void mouseEntered(MouseEvent arg0)
355 // TODO Auto-generated method stub
360 public void mouseClicked(MouseEvent arg0)
362 if (arg0.getButton() == MouseEvent.BUTTON3)
364 rdata_rightClicked(arg0);
369 rdataVp = new JScrollPane();
370 rdataVp.getViewport().setView(rdata);
371 rparamList.add(rdataVp);
372 JPanel rparamButs = new JPanel();
373 rparamButs.setLayout(new MigLayout());
374 rparamButs.add(rdataAdd, "wrap");
375 rparamButs.add(rdataRem, "wrap");
376 rparamButs.add(rdataNup, "wrap");
377 rparamButs.add(rdataNdown, "wrap");
378 rparamList.add(rparamButs, "wrap");
379 inputs.add(rparamList, "wrap");
381 // Parse flat-text to a service
383 urldesc = new JTextArea(4, 60);
384 urldesc.setEditable(true);
385 urldesc.setWrapStyleWord(true);
386 urldescVp = new JScrollPane();
387 urldescVp.setViewportView(urldesc);
388 JPanel urldescPane = new JPanel();
389 urldescPane.setLayout(new MigLayout("", "[grow 100, fill]",
390 "[grow 100, fill]"));
391 urldescPane.setBorder(new TitledBorder(MessageManager
392 .getString("label.rsbs_encoded_service")));
393 urldescPane.add(urldescVp, "span");
394 paste.add(urldescPane, "span");
396 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.flat_file_representation")));
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]",
404 "[grow 100, fill]"));
405 parseWarnings.setBorder(new TitledBorder(MessageManager
406 .getString("label.parsing_errors")));
408 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.result_of_parsing_rsbs")));
409 parseWarnings.add(parseResVp, "center");
410 parseRes.setEditable(false);
411 paste.add(parseWarnings, "span");
412 setLayout(new BorderLayout());
413 add(panels, BorderLayout.CENTER);
414 okButton = JvSwingUtils.makeButton(
415 MessageManager.getString("action.ok"), "", new ActionListener()
419 public void actionPerformed(ActionEvent e)
421 ok_actionPerformed();
424 cancelButton = JvSwingUtils.makeButton(
425 MessageManager.getString("action.cancel"), "",
430 public void actionPerformed(ActionEvent e)
432 cancel_actionPerformed();
438 protected void rdata_rightClicked(MouseEvent arg0)
440 // TODO Auto-generated method stub
444 protected void iprmListSelection_doubleClicked()
446 // TODO Auto-generated method stub
450 protected void hSeparable_actionPerformed(ActionEvent arg0)
452 // TODO Auto-generated method stub
456 protected void vSeparable_actionPerformed(ActionEvent arg0)
458 // TODO Auto-generated method stub
462 protected void cancel_actionPerformed()
464 // TODO Auto-generated method stub
468 protected void ok_actionPerformed()
470 // TODO Auto-generated method stub
474 protected void iprmsAdd_actionPerformed(ActionEvent e)
476 // TODO Auto-generated method stub
480 protected void iprmsRem_actionPerformed(ActionEvent e)
482 // TODO Auto-generated method stub
486 protected void rdataAdd_actionPerformed(ActionEvent e)
488 // TODO Auto-generated method stub
492 protected void rdataRem_actionPerformed(ActionEvent e)
494 // TODO Auto-generated method stub
498 protected void rdataNup_actionPerformed(ActionEvent e)
500 // TODO Auto-generated method stub
504 protected void rdataNdown_actionPerformed(ActionEvent e)
506 // TODO Auto-generated method stub
510 protected void ok_actionPerformed(ActionEvent e)
512 // TODO Auto-generated method stub
516 protected void cancel_actionPerformed(ActionEvent e)
518 // TODO Auto-generated method stub