JAL-972 workaround for working out source URL for pre DAS 1.6 sources.
[jalview.git] / src / jalview / jbgui / GWsPreferences.java
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
4  * 
5  * This file is part of Jalview.
6  * 
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.
10  * 
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.
15  * 
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;
19
20 import java.awt.BorderLayout;
21 import java.awt.Dimension;
22 import java.awt.FlowLayout;
23 import java.awt.Font;
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;
30
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;
42
43 /**
44  * Preference dialog for jalview web services
45  * 
46  * @author JimP
47  */
48 public class GWsPreferences extends JPanel
49 {
50   protected JList sbrsList = new JList();
51
52   protected TitledBorder sbrsListTitleBorder = new TitledBorder(
53           "Simple Bioinformatics Rest Services");
54
55   protected JButton newSbrsUrl = new JButton();
56
57   protected JButton editSbrsUrl = new JButton();
58
59   protected JButton deleteSbrsUrl = new JButton();
60
61   // Web service status and url table
62   protected JTable wsList=new JTable();
63   
64   protected TitledBorder wsListTitleBorder = new TitledBorder(
65           "Web Service Discovery URLS");
66
67   protected JButton newWsUrl = new JButton();
68
69   protected JButton editWsUrl = new JButton();
70
71   protected JButton deleteWsUrl = new JButton();
72
73   protected JButton moveWsUrlUp = new JButton();
74
75   protected JButton moveWsUrlDown = new JButton();
76
77   protected JCheckBox indexByHost = new JCheckBox();
78
79   protected JCheckBox indexByType = new JCheckBox();
80
81   protected JCheckBox enableJws2Services = new JCheckBox();
82
83   protected JCheckBox enableEnfinServices = new JCheckBox();
84
85   protected JCheckBox displayWsWarning = new JCheckBox();
86
87   protected JButton refreshWs = new JButton();
88
89   protected JButton resetWs = new JButton();
90
91   protected JProgressBar progressBar = new JProgressBar();
92
93   JScrollPane wsListPane = new JScrollPane();
94
95   JPanel wsListUrlPanel = new JPanel();
96
97   JPanel wsListPanel = new JPanel();
98
99   JPanel wsListButtons = new JPanel();
100
101   JPanel wsListNavButs = new JPanel();
102
103   JScrollPane srbsListPane = new JScrollPane();
104
105   JPanel srbsListUrlPanel = new JPanel();
106
107   JPanel srbsListPanel = new JPanel();
108
109   JPanel srbsListButtons = new JPanel();
110
111   JPanel srbsListNavButs = new JPanel();
112
113   BorderLayout myBorderlayout = new BorderLayout();
114
115   BorderLayout wsListBorderlayout = new BorderLayout();
116   
117   BorderLayout srbsListBorderlayout = new BorderLayout();
118
119   GridBagLayout wsPrefLayout = new GridBagLayout();
120
121   GridBagLayout wsListLayout = new GridBagLayout();
122
123   GridBagLayout srbsListLayout = new GridBagLayout();
124
125   GridBagLayout wsMenuLayout = new GridBagLayout();
126
127   JPanel wsMenuButtons = new JPanel();
128
129   JPanel wsMenuRefreshButs = new JPanel();
130
131   public GWsPreferences()
132   {
133     jbInit();
134   }
135
136   private void jbInit()
137   {
138
139     refreshWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
140     refreshWs.setText("Refresh Services");
141     refreshWs.addActionListener(new ActionListener()
142     {
143       public void actionPerformed(ActionEvent e)
144       {
145         refreshWs_actionPerformed(e);
146       }
147     });
148     resetWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
149     resetWs.setText("Reset Services");
150
151     resetWs.addActionListener(new ActionListener()
152     {
153       public void actionPerformed(ActionEvent e)
154       {
155         resetWs_actionPerformed(e);
156       }
157     });
158     indexByHost.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
159     indexByHost.setText("Index by host");
160     indexByHost
161             .setToolTipText("Index web services in menu by the host site.");
162     indexByHost.addActionListener(new ActionListener()
163     {
164       public void actionPerformed(ActionEvent e)
165       {
166         indexByHost_actionPerformed(e);
167       }
168     });
169     indexByType.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
170     indexByType.setText("Index by type");
171     indexByType.addActionListener(new ActionListener()
172     {
173       public void actionPerformed(ActionEvent e)
174       {
175         indexByType_actionPerformed(e);
176       }
177     });
178     enableEnfinServices
179             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
180     enableEnfinServices.setText("Enable Enfin Services");
181     enableEnfinServices.addActionListener(new ActionListener()
182     {
183       public void actionPerformed(ActionEvent e)
184       {
185         enableEnfinServices_actionPerformed(e);
186       }
187     });
188     enableJws2Services
189             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
190     enableJws2Services.setText("Enable JABAWS Services");
191     enableJws2Services.addActionListener(new ActionListener()
192     {
193       public void actionPerformed(ActionEvent e)
194       {
195         enableJws2Services_actionPerformed(e);
196       }
197     });
198     displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
199     displayWsWarning.setText("Display warnings");
200     displayWsWarning
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()
203     {
204       public void actionPerformed(ActionEvent e)
205       {
206         displayWsWarning_actionPerformed(e);
207       }
208     });
209     newWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
210     newWsUrl.setText("New Service URL");
211     newWsUrl.addActionListener(new ActionListener()
212     {
213       public void actionPerformed(ActionEvent e)
214       {
215         newWsUrl_actionPerformed(e);
216       }
217     });
218     editWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
219     editWsUrl.setText("Edit Service URL");
220     editWsUrl.addActionListener(new ActionListener()
221     {
222       public void actionPerformed(ActionEvent e)
223       {
224         editWsUrl_actionPerformed(e);
225       }
226     });
227
228     deleteWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
229     deleteWsUrl.setText("Delete Service URL");
230     deleteWsUrl.addActionListener(new ActionListener()
231     {
232       public void actionPerformed(ActionEvent e)
233       {
234         deleteWsUrl_actionPerformed(e);
235       }
236     });
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()
241     {
242       public void actionPerformed(ActionEvent e)
243       {
244         moveWsUrlUp_actionPerformed(e);
245       }
246     });
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()
251     {
252       public void actionPerformed(ActionEvent e)
253       {
254         moveWsUrlDown_actionPerformed(e);
255       }
256     });
257     newSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
258     newSbrsUrl.setText("Add a SBRS definition");
259     newSbrsUrl.addActionListener(new ActionListener()
260     {
261       public void actionPerformed(ActionEvent e)
262       {
263         newSbrsUrl_actionPerformed(e);
264       }
265     });
266     editSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
267     editSbrsUrl.setText("Edit SBRS definition");
268     editSbrsUrl.addActionListener(new ActionListener()
269     {
270       public void actionPerformed(ActionEvent e)
271       {
272         editSbrsUrl_actionPerformed(e);
273       }
274     });
275
276     deleteSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
277     deleteSbrsUrl.setText("Delete SBRS definition");
278     deleteSbrsUrl.addActionListener(new ActionListener()
279     {
280       public void actionPerformed(ActionEvent e)
281       {
282         deleteSbrsUrl_actionPerformed(e);
283       }
284     });
285
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()
299     {
300
301       public void mouseClicked(MouseEvent e)
302       {
303         if (e.getClickCount() > 1)
304         {
305           editWsUrl_actionPerformed(null);
306         }
307
308       }
309
310       public void mouseEntered(MouseEvent e)
311       {
312
313       }
314
315       public void mouseExited(MouseEvent e)
316       {
317       }
318
319       public void mousePressed(MouseEvent e)
320       {
321
322       }
323
324       public void mouseReleased(MouseEvent e)
325       {
326
327       }
328
329     });
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);
346
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()
353     {
354
355       public void mouseClicked(MouseEvent e)
356       {
357         if (e.getClickCount() > 1)
358         {
359           editSbrsUrl_actionPerformed(null);
360         }
361
362       }
363
364       public void mouseEntered(MouseEvent e)
365       {
366
367       }
368
369       public void mouseExited(MouseEvent e)
370       {
371       }
372
373       public void mousePressed(MouseEvent e)
374       {
375
376       }
377
378       public void mouseReleased(MouseEvent e)
379       {
380
381       }
382
383     });
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);
393
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);
412     } else {
413         add(wsListPanel, BorderLayout.NORTH);
414     }
415     add(wsMenuButtons, BorderLayout.CENTER);
416     add(wsMenuRefreshButs, BorderLayout.SOUTH);
417   }
418
419   protected void deleteSbrsUrl_actionPerformed(ActionEvent e)
420   {
421     // TODO Auto-generated method stub
422     
423   }
424
425   protected void editSbrsUrl_actionPerformed(ActionEvent e)
426   {
427     // TODO Auto-generated method stub
428     
429   }
430
431   protected void newSbrsUrl_actionPerformed(ActionEvent e)
432   {
433     // TODO Auto-generated method stub
434     
435   }
436
437   protected void displayWsWarning_actionPerformed(ActionEvent e)
438   {
439     // TODO Auto-generated method stub
440     
441   }
442
443   protected void resetWs_actionPerformed(ActionEvent e)
444   {
445
446   }
447
448   protected void indexByType_actionPerformed(ActionEvent e)
449   {
450
451   }
452
453   protected void indexByHost_actionPerformed(ActionEvent e)
454   {
455
456   }
457
458   protected void newWsUrl_actionPerformed(ActionEvent e)
459   {
460
461   }
462
463   protected void editWsUrl_actionPerformed(ActionEvent e)
464   {
465
466   }
467
468   protected void deleteWsUrl_actionPerformed(ActionEvent e)
469   {
470
471   }
472
473   protected void moveWsUrlUp_actionPerformed(ActionEvent e)
474   {
475
476   }
477
478   protected void moveWsUrlDown_actionPerformed(ActionEvent e)
479   {
480
481   }
482
483   protected void enableEnfinServices_actionPerformed(ActionEvent e)
484   {
485
486   }
487
488   protected void enableJws2Services_actionPerformed(ActionEvent e)
489   {
490
491   }
492
493   protected void refreshWs_actionPerformed(ActionEvent e)
494   {
495
496   }
497
498 }