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/>.
18 package jalview.jbgui;
20 import java.awt.BorderLayout;
21 import java.awt.Dimension;
22 import java.awt.FlowLayout;
24 import java.awt.GridBagLayout;
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.BorderFactory;
32 import javax.swing.JButton;
33 import javax.swing.JCheckBox;
34 import javax.swing.JList;
35 import javax.swing.JPanel;
36 import javax.swing.JProgressBar;
37 import javax.swing.JScrollPane;
38 import javax.swing.JTabbedPane;
39 import javax.swing.JTable;
40 import javax.swing.ListSelectionModel;
41 import javax.swing.border.TitledBorder;
44 * Preference dialog for jalview web services
48 public class GWsPreferences extends JPanel
50 protected JList sbrsList = new JList();
52 protected TitledBorder sbrsListTitleBorder = new TitledBorder(
53 "Simple Bioinformatics Rest Services");
55 protected JButton newSbrsUrl = new JButton();
57 protected JButton editSbrsUrl = new JButton();
59 protected JButton deleteSbrsUrl = new JButton();
61 // Web service status and url table
62 protected JTable wsList=new JTable();
64 protected TitledBorder wsListTitleBorder = new TitledBorder(
65 "Web Service Discovery URLS");
67 protected JButton newWsUrl = new JButton();
69 protected JButton editWsUrl = new JButton();
71 protected JButton deleteWsUrl = new JButton();
73 protected JButton moveWsUrlUp = new JButton();
75 protected JButton moveWsUrlDown = new JButton();
77 protected JCheckBox indexByHost = new JCheckBox();
79 protected JCheckBox indexByType = new JCheckBox();
81 protected JCheckBox enableJws2Services = new JCheckBox();
83 protected JCheckBox enableEnfinServices = new JCheckBox();
85 protected JCheckBox displayWsWarning = new JCheckBox();
87 protected JButton refreshWs = new JButton();
89 protected JButton resetWs = new JButton();
91 protected JProgressBar progressBar = new JProgressBar();
93 JScrollPane wsListPane = new JScrollPane();
95 JPanel wsListUrlPanel = new JPanel();
97 JPanel wsListPanel = new JPanel();
99 JPanel wsListButtons = new JPanel();
101 JPanel wsListNavButs = new JPanel();
103 JScrollPane srbsListPane = new JScrollPane();
105 JPanel srbsListUrlPanel = new JPanel();
107 JPanel srbsListPanel = new JPanel();
109 JPanel srbsListButtons = new JPanel();
111 JPanel srbsListNavButs = new JPanel();
113 BorderLayout myBorderlayout = new BorderLayout();
115 BorderLayout wsListBorderlayout = new BorderLayout();
117 BorderLayout srbsListBorderlayout = new BorderLayout();
119 GridBagLayout wsPrefLayout = new GridBagLayout();
121 GridBagLayout wsListLayout = new GridBagLayout();
123 GridBagLayout srbsListLayout = new GridBagLayout();
125 GridBagLayout wsMenuLayout = new GridBagLayout();
127 JPanel wsMenuButtons = new JPanel();
129 JPanel wsMenuRefreshButs = new JPanel();
131 public GWsPreferences()
136 private void jbInit()
139 refreshWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
140 refreshWs.setText("Refresh Services");
141 refreshWs.addActionListener(new ActionListener()
143 public void actionPerformed(ActionEvent e)
145 refreshWs_actionPerformed(e);
148 resetWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
149 resetWs.setText("Reset Services");
151 resetWs.addActionListener(new ActionListener()
153 public void actionPerformed(ActionEvent e)
155 resetWs_actionPerformed(e);
158 indexByHost.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
159 indexByHost.setText("Index by host");
161 .setToolTipText("Index web services in menu by the host site.");
162 indexByHost.addActionListener(new ActionListener()
164 public void actionPerformed(ActionEvent e)
166 indexByHost_actionPerformed(e);
169 indexByType.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
170 indexByType.setText("Index by type");
171 indexByType.addActionListener(new ActionListener()
173 public void actionPerformed(ActionEvent e)
175 indexByType_actionPerformed(e);
179 .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
180 enableEnfinServices.setText("Enable Enfin Services");
181 enableEnfinServices.addActionListener(new ActionListener()
183 public void actionPerformed(ActionEvent e)
185 enableEnfinServices_actionPerformed(e);
189 .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
190 enableJws2Services.setText("Enable JABAWS Services");
191 enableJws2Services.addActionListener(new ActionListener()
193 public void actionPerformed(ActionEvent e)
195 enableJws2Services_actionPerformed(e);
198 displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
199 displayWsWarning.setText("Display warnings");
201 .setToolTipText("<html>Check this option if you want to be informed<br>when a web service URL cannot be accessed by Jalview<br>when it starts up");
202 displayWsWarning.addActionListener(new ActionListener()
204 public void actionPerformed(ActionEvent e)
206 displayWsWarning_actionPerformed(e);
209 newWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
210 newWsUrl.setText("New Service URL");
211 newWsUrl.addActionListener(new ActionListener()
213 public void actionPerformed(ActionEvent e)
215 newWsUrl_actionPerformed(e);
218 editWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
219 editWsUrl.setText("Edit Service URL");
220 editWsUrl.addActionListener(new ActionListener()
222 public void actionPerformed(ActionEvent e)
224 editWsUrl_actionPerformed(e);
228 deleteWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
229 deleteWsUrl.setText("Delete Service URL");
230 deleteWsUrl.addActionListener(new ActionListener()
232 public void actionPerformed(ActionEvent e)
234 deleteWsUrl_actionPerformed(e);
237 moveWsUrlUp.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
238 moveWsUrlUp.setText("Up");
239 moveWsUrlUp.setToolTipText("Move URL up");
240 moveWsUrlUp.addActionListener(new ActionListener()
242 public void actionPerformed(ActionEvent e)
244 moveWsUrlUp_actionPerformed(e);
247 moveWsUrlDown.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
248 moveWsUrlDown.setText("Down");
249 moveWsUrlDown.setToolTipText("Move URL Down");
250 moveWsUrlDown.addActionListener(new ActionListener()
252 public void actionPerformed(ActionEvent e)
254 moveWsUrlDown_actionPerformed(e);
257 newSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
258 newSbrsUrl.setText("Add a SBRS definition");
259 newSbrsUrl.addActionListener(new ActionListener()
261 public void actionPerformed(ActionEvent e)
263 newSbrsUrl_actionPerformed(e);
266 editSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
267 editSbrsUrl.setText("Edit SBRS definition");
268 editSbrsUrl.addActionListener(new ActionListener()
270 public void actionPerformed(ActionEvent e)
272 editSbrsUrl_actionPerformed(e);
276 deleteSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
277 deleteSbrsUrl.setText("Delete SBRS definition");
278 deleteSbrsUrl.addActionListener(new ActionListener()
280 public void actionPerformed(ActionEvent e)
282 deleteSbrsUrl_actionPerformed(e);
286 setLayout(myBorderlayout);
287 setPreferredSize(new Dimension(500, 400));
288 progressBar.setPreferredSize(new Dimension(450, 20));
289 progressBar.setString("");
290 wsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
291 wsListUrlPanel.setLayout(new BorderLayout());
292 wsListPane.setBorder(BorderFactory.createEtchedBorder());
293 wsListPane.getViewport().add(wsList);
294 wsList.setPreferredSize(new Dimension(482,202));
295 wsListPane.setPreferredSize(new Dimension(380, 80));
296 wsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
297 wsList.setColumnSelectionAllowed(false);
298 wsList.addMouseListener(new MouseListener()
301 public void mouseClicked(MouseEvent e)
303 if (e.getClickCount() > 1)
305 editWsUrl_actionPerformed(null);
310 public void mouseEntered(MouseEvent e)
315 public void mouseExited(MouseEvent e)
319 public void mousePressed(MouseEvent e)
324 public void mouseReleased(MouseEvent e)
330 wsListButtons.setLayout(new FlowLayout());
331 wsListButtons.add(newWsUrl);
332 wsListButtons.add(editWsUrl);
333 wsListButtons.add(deleteWsUrl);
334 wsListButtons.setMinimumSize(new Dimension(350,80));
335 wsListNavButs.setSize(new Dimension(80, 80));
336 wsListNavButs.setPreferredSize(new Dimension(80, 80));
337 wsListNavButs.setLayout(new FlowLayout());
338 wsListNavButs.add(moveWsUrlUp);
339 wsListNavButs.add(moveWsUrlDown);
340 wsListUrlPanel.add(wsListPane, BorderLayout.CENTER);
341 wsListUrlPanel.add(wsListNavButs, BorderLayout.WEST);
342 wsListPanel.setBorder(wsListTitleBorder);
343 wsListPanel.setLayout(new BorderLayout());
344 wsListPanel.add(wsListUrlPanel, BorderLayout.NORTH);
345 wsListPanel.add(wsListButtons, BorderLayout.SOUTH);
347 srbsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
348 srbsListUrlPanel.setLayout(new BorderLayout());
349 srbsListPane.setBorder(BorderFactory.createEtchedBorder());
350 srbsListPane.getViewport().add(sbrsList);
351 sbrsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
352 sbrsList.addMouseListener(new MouseListener()
355 public void mouseClicked(MouseEvent e)
357 if (e.getClickCount() > 1)
359 editSbrsUrl_actionPerformed(null);
364 public void mouseEntered(MouseEvent e)
369 public void mouseExited(MouseEvent e)
373 public void mousePressed(MouseEvent e)
378 public void mouseReleased(MouseEvent e)
384 srbsListButtons.setLayout(new FlowLayout());
385 srbsListButtons.add(newSbrsUrl);
386 srbsListButtons.add(editSbrsUrl);
387 srbsListButtons.add(deleteSbrsUrl);
388 srbsListUrlPanel.add(srbsListPane, BorderLayout.CENTER);
389 srbsListPanel.setBorder(sbrsListTitleBorder);
390 srbsListPanel.setLayout(new BorderLayout());
391 srbsListPanel.add(srbsListUrlPanel, BorderLayout.NORTH);
392 srbsListPanel.add(srbsListButtons, BorderLayout.CENTER);
394 wsMenuButtons.setLayout(new GridLayout(2, 3));
395 wsMenuButtons.add(indexByHost);
396 wsMenuButtons.add(indexByType);
397 wsMenuButtons.add(enableJws2Services);
398 wsMenuButtons.add(enableEnfinServices);
399 wsMenuButtons.add(displayWsWarning);
400 wsMenuRefreshButs.setLayout(new FlowLayout());
401 wsMenuRefreshButs.setPreferredSize(new Dimension(480, 30));
402 wsMenuRefreshButs.setSize(new Dimension(480, 30));
403 wsMenuRefreshButs.add(refreshWs, null);
404 wsMenuRefreshButs.add(resetWs, null);
405 wsMenuRefreshButs.add(progressBar, null);
406 myBorderlayout.setHgap(3);
407 if (jalview.bin.Cache.getDefault("ENABLE_RSBS_EDITOR",false)) {
408 JTabbedPane listPanels=new JTabbedPane();
409 listPanels.addTab("JABAWS Servers",wsListPanel);
410 listPanels.addTab("RSB Services", srbsListPanel);
411 add(listPanels, BorderLayout.NORTH);
413 add(wsListPanel, BorderLayout.NORTH);
415 add(wsMenuButtons, BorderLayout.CENTER);
416 add(wsMenuRefreshButs, BorderLayout.SOUTH);
419 protected void deleteSbrsUrl_actionPerformed(ActionEvent e)
421 // TODO Auto-generated method stub
425 protected void editSbrsUrl_actionPerformed(ActionEvent e)
427 // TODO Auto-generated method stub
431 protected void newSbrsUrl_actionPerformed(ActionEvent e)
433 // TODO Auto-generated method stub
437 protected void displayWsWarning_actionPerformed(ActionEvent e)
439 // TODO Auto-generated method stub
443 protected void resetWs_actionPerformed(ActionEvent e)
448 protected void indexByType_actionPerformed(ActionEvent e)
453 protected void indexByHost_actionPerformed(ActionEvent e)
458 protected void newWsUrl_actionPerformed(ActionEvent e)
463 protected void editWsUrl_actionPerformed(ActionEvent e)
468 protected void deleteWsUrl_actionPerformed(ActionEvent e)
473 protected void moveWsUrlUp_actionPerformed(ActionEvent e)
478 protected void moveWsUrlDown_actionPerformed(ActionEvent e)
483 protected void enableEnfinServices_actionPerformed(ActionEvent e)
488 protected void enableJws2Services_actionPerformed(ActionEvent e)
493 protected void refreshWs_actionPerformed(ActionEvent e)