2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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"));
99 new MigLayout("", "[grow 100, fill]", "[][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,
114 .getString("label.short_descriptive_name_for_service"),
115 new JLabel(MessageManager.getString("label.name")), name,
117 action = new JComboBox();
118 JvSwingUtils.mgAddtoLayout(cpanel,
119 MessageManager.getString("label.function_service_performs"),
120 new JLabel(MessageManager.getString("label.service_action")),
122 descr = new JTextArea(4, 60);
123 descrVp = new JScrollPane();
124 descrVp.setViewportView(descr);
125 JvSwingUtils.mgAddtoLayout(cpanel,
126 MessageManager.getString("label.brief_description_service"),
127 new JLabel(MessageManager.getString("label.description")),
130 url = new JTextArea(2, 60);
131 urlVp = new JScrollPane();
132 urlVp.setViewportView(url);
133 JvSwingUtils.mgAddtoLayout(cpanel,
134 MessageManager.getString("label.url_post_data_service"),
135 new JLabel(MessageManager.getString("label.post_url")), urlVp,
138 urlsuff = new JTextArea();
139 urlsuff.setColumns(60);
141 JvSwingUtils.mgAddtoLayout(cpanel,
142 MessageManager.getString("label.optional_suffix"),
143 new JLabel(MessageManager.getString("label.url_suffix")),
147 // details.add(cpanel = new JPanel(), BorderLayout.CENTER);
148 // cpanel.setLayout(new FlowLayout());
149 hSeparable = new JCheckBox(MessageManager.getString("label.per_seq"));
150 hSeparable.setToolTipText(JvSwingUtils.wrapTooltip(true,
151 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"));
164 vSeparable.setToolTipText(
165 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
166 "label.when_checked_job_visible_region_and_results")));
167 vSeparable.addActionListener(new ActionListener()
171 public void actionPerformed(ActionEvent arg0)
173 vSeparable_actionPerformed(arg0);
177 gapChar = new JComboBox();
178 JvSwingUtils.mgAddtoLayout(cpanel,
179 MessageManager.getString("label.preferred_gap_character"),
181 MessageManager.getString("label.gap_character") + ":"),
184 cpanel.add(hSeparable);
185 cpanel.add(vSeparable);
187 // Input and Output lists
189 JPanel iprmsList = new JPanel();
190 iprmsList.setBorder(new TitledBorder(
191 MessageManager.getString("label.data_input_parameters")));
192 iprmsList.setLayout(new MigLayout("", "[grow 90, fill][]"));
193 iprmVp = new JScrollPane();
194 iprmVp.getViewport().setView(iprms = new JList());
195 iprmsList.add(iprmVp);
196 iprms.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
197 iprms.addMouseListener(new MouseListener()
201 public void mouseReleased(MouseEvent e)
203 // TODO Auto-generated method stub
208 public void mousePressed(MouseEvent e)
210 // TODO Auto-generated method stub
215 public void mouseExited(MouseEvent e)
217 // TODO Auto-generated method stub
222 public void mouseEntered(MouseEvent e)
224 // TODO Auto-generated method stub
229 public void mouseClicked(MouseEvent e)
231 if (e.getClickCount() > 1)
233 iprmListSelection_doubleClicked();
238 JPanel iprmButs = new JPanel();
239 iprmButs.setLayout(new MigLayout());
241 iprmsAdd = JvSwingUtils.makeButton("+",
242 MessageManager.getString("action.add_input_parameter"),
247 public void actionPerformed(ActionEvent e)
249 iprmsAdd_actionPerformed(e);
253 iprmsRem = JvSwingUtils.makeButton("-",
254 MessageManager.getString("action.remove_input_parameter"),
259 public void actionPerformed(ActionEvent e)
261 iprmsRem_actionPerformed(e);
266 iprmButs.add(iprmsAdd, "wrap");
267 iprmButs.add(iprmsRem, "wrap");
268 iprmsList.add(iprmButs, "wrap");
269 inputs.add(iprmsList, "wrap");
273 rdataAdd = JvSwingUtils.makeButton("+",
274 MessageManager.getString("action.add_return_datatype"),
279 public void actionPerformed(ActionEvent e)
281 rdataAdd_actionPerformed(e);
285 rdataRem = JvSwingUtils.makeButton("-",
286 MessageManager.getString("action.remove_return_datatype"),
291 public void actionPerformed(ActionEvent e)
293 rdataRem_actionPerformed(e);
297 rdataNup = JvSwingUtils.makeButton(
298 MessageManager.getString("action.move_up"),
299 MessageManager.getString("label.move_return_type_up_order"),
304 public void actionPerformed(ActionEvent e)
306 rdataNup_actionPerformed(e);
310 rdataNdown = JvSwingUtils.makeButton(
311 MessageManager.getString("action.move_down"),
312 MessageManager.getString("label.move_return_type_down_order"),
317 public void actionPerformed(ActionEvent e)
319 rdataNdown_actionPerformed(e);
324 JPanel rparamList = new JPanel();
325 rparamList.setBorder(new TitledBorder(
326 MessageManager.getString("label.data_returned_by_service")));
327 rparamList.setLayout(new MigLayout("", "[grow 90, fill][]"));
329 rdata.setToolTipText(MessageManager.getString(
330 "label.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(
392 new MigLayout("", "[grow 100, fill]", "[grow 100, fill]"));
393 urldescPane.setBorder(new TitledBorder(
394 MessageManager.getString("label.rsbs_encoded_service")));
395 urldescPane.add(urldescVp, "span");
396 paste.add(urldescPane, "span");
397 urldescPane.setToolTipText(JvSwingUtils.wrapTooltip(true,
398 MessageManager.getString("label.flat_file_representation")));
400 parseRes = new JTextArea();
401 parseResVp = new JScrollPane();
402 parseResVp.setViewportView(parseRes);
403 parseRes.setWrapStyleWord(true);
404 parseRes.setColumns(60);
405 parseWarnings = new JPanel(
406 new MigLayout("", "[grow 100, fill]", "[grow 100, fill]"));
407 parseWarnings.setBorder(new TitledBorder(
408 MessageManager.getString("label.parsing_errors")));
409 parseWarnings.setToolTipText(JvSwingUtils.wrapTooltip(true,
410 MessageManager.getString("label.result_of_parsing_rsbs")));
411 parseWarnings.add(parseResVp, "center");
412 parseRes.setEditable(false);
413 paste.add(parseWarnings, "span");
414 setLayout(new BorderLayout());
415 add(panels, BorderLayout.CENTER);
416 okButton = JvSwingUtils.makeButton(
417 MessageManager.getString("action.ok"), "", new ActionListener()
421 public void actionPerformed(ActionEvent e)
423 ok_actionPerformed();
426 cancelButton = JvSwingUtils.makeButton(
427 MessageManager.getString("action.cancel"), "",
432 public void actionPerformed(ActionEvent e)
434 cancel_actionPerformed();
440 protected void rdata_rightClicked(MouseEvent arg0)
442 // TODO Auto-generated method stub
446 protected void iprmListSelection_doubleClicked()
448 // TODO Auto-generated method stub
452 protected void hSeparable_actionPerformed(ActionEvent arg0)
454 // TODO Auto-generated method stub
458 protected void vSeparable_actionPerformed(ActionEvent arg0)
460 // TODO Auto-generated method stub
464 protected void cancel_actionPerformed()
466 // TODO Auto-generated method stub
470 protected void ok_actionPerformed()
472 // TODO Auto-generated method stub
476 protected void iprmsAdd_actionPerformed(ActionEvent e)
478 // TODO Auto-generated method stub
482 protected void iprmsRem_actionPerformed(ActionEvent e)
484 // TODO Auto-generated method stub
488 protected void rdataAdd_actionPerformed(ActionEvent e)
490 // TODO Auto-generated method stub
494 protected void rdataRem_actionPerformed(ActionEvent e)
496 // TODO Auto-generated method stub
500 protected void rdataNup_actionPerformed(ActionEvent e)
502 // TODO Auto-generated method stub
506 protected void rdataNdown_actionPerformed(ActionEvent e)
508 // TODO Auto-generated method stub
512 protected void ok_actionPerformed(ActionEvent e)
514 // TODO Auto-generated method stub
518 protected void cancel_actionPerformed(ActionEvent e)
520 // TODO Auto-generated method stub