Merge branch 'releases/Release_2_10_2b1_Branch'
[jalview.git] / src / jalview / jbgui / GWsPreferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10  * of the License, or (at your option) any later version.
11  *  
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.
16  * 
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.
20  */
21 package jalview.jbgui;
22
23 import jalview.util.MessageManager;
24
25 import java.awt.BorderLayout;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
28 import java.awt.Font;
29 import java.awt.GridBagLayout;
30 import java.awt.GridLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.awt.event.MouseEvent;
34 import java.awt.event.MouseListener;
35
36 import javax.swing.BorderFactory;
37 import javax.swing.JButton;
38 import javax.swing.JCheckBox;
39 import javax.swing.JList;
40 import javax.swing.JPanel;
41 import javax.swing.JProgressBar;
42 import javax.swing.JScrollPane;
43 import javax.swing.JTabbedPane;
44 import javax.swing.JTable;
45 import javax.swing.ListSelectionModel;
46 import javax.swing.border.TitledBorder;
47
48 /**
49  * Preference dialog for jalview web services
50  * 
51  * @author JimP
52  */
53 public class GWsPreferences extends JPanel
54 {
55   protected JList sbrsList = new JList();
56
57   protected TitledBorder sbrsListTitleBorder = new TitledBorder(
58           MessageManager
59                   .getString("label.simple_bioinformatics_rest_services"));
60
61   protected JButton newSbrsUrl = new JButton();
62
63   protected JButton editSbrsUrl = new JButton();
64
65   protected JButton deleteSbrsUrl = new JButton();
66
67   // Web service status and url table
68   protected JTable wsList = new JTable();
69
70   protected TitledBorder wsListTitleBorder = new TitledBorder(
71           MessageManager.getString("label.web_service_discovery_urls"));
72
73   protected JButton newWsUrl = new JButton();
74
75   protected JButton editWsUrl = new JButton();
76
77   protected JButton deleteWsUrl = new JButton();
78
79   protected JButton moveWsUrlUp = new JButton();
80
81   protected JButton moveWsUrlDown = new JButton();
82
83   protected JCheckBox indexByHost = new JCheckBox();
84
85   protected JCheckBox indexByType = new JCheckBox();
86
87   protected JCheckBox enableJws2Services = new JCheckBox();
88
89   protected JCheckBox enableEnfinServices = new JCheckBox();
90
91   protected JCheckBox displayWsWarning = new JCheckBox();
92
93   protected JButton refreshWs = new JButton();
94
95   protected JButton resetWs = new JButton();
96
97   protected JProgressBar progressBar = new JProgressBar();
98
99   JScrollPane wsListPane = new JScrollPane();
100
101   JPanel wsListUrlPanel = new JPanel();
102
103   JPanel wsListPanel = new JPanel();
104
105   JPanel wsListButtons = new JPanel();
106
107   JPanel wsListNavButs = new JPanel();
108
109   JScrollPane srbsListPane = new JScrollPane();
110
111   JPanel srbsListUrlPanel = new JPanel();
112
113   JPanel srbsListPanel = new JPanel();
114
115   JPanel srbsListButtons = new JPanel();
116
117   JPanel srbsListNavButs = new JPanel();
118
119   BorderLayout myBorderlayout = new BorderLayout();
120
121   BorderLayout wsListBorderlayout = new BorderLayout();
122
123   BorderLayout srbsListBorderlayout = new BorderLayout();
124
125   GridBagLayout wsPrefLayout = new GridBagLayout();
126
127   GridBagLayout wsListLayout = new GridBagLayout();
128
129   GridBagLayout srbsListLayout = new GridBagLayout();
130
131   GridBagLayout wsMenuLayout = new GridBagLayout();
132
133   JPanel wsMenuButtons = new JPanel();
134
135   JPanel wsMenuRefreshButs = new JPanel();
136
137   public GWsPreferences()
138   {
139     jbInit();
140   }
141
142   private void jbInit()
143   {
144
145     refreshWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
146     refreshWs.setText(MessageManager.getString("action.refresh_services"));
147     refreshWs.addActionListener(new ActionListener()
148     {
149       public void actionPerformed(ActionEvent e)
150       {
151         refreshWs_actionPerformed(e);
152       }
153     });
154     resetWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
155     resetWs.setText(MessageManager.getString("action.reset_services"));
156
157     resetWs.addActionListener(new ActionListener()
158     {
159       public void actionPerformed(ActionEvent e)
160       {
161         resetWs_actionPerformed(e);
162       }
163     });
164     indexByHost.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
165     indexByHost.setText(MessageManager.getString("label.index_by_host"));
166     indexByHost.setToolTipText(MessageManager
167             .getString("label.index_web_services_menu_by_host_site"));
168     indexByHost.addActionListener(new ActionListener()
169     {
170       public void actionPerformed(ActionEvent e)
171       {
172         indexByHost_actionPerformed(e);
173       }
174     });
175     indexByType.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
176     indexByType.setText(MessageManager.getString("label.index_by_type"));
177     indexByType.addActionListener(new ActionListener()
178     {
179       public void actionPerformed(ActionEvent e)
180       {
181         indexByType_actionPerformed(e);
182       }
183     });
184     enableJws2Services
185             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
186     enableJws2Services.setText(
187             MessageManager.getString("label.enable_jabaws_services"));
188     enableJws2Services.addActionListener(new ActionListener()
189     {
190       public void actionPerformed(ActionEvent e)
191       {
192         enableJws2Services_actionPerformed(e);
193       }
194     });
195     displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
196     displayWsWarning
197             .setText(MessageManager.getString("label.display_warnings"));
198     displayWsWarning.setToolTipText("<html>" + MessageManager.getString(
199             "label.option_want_informed_web_service_URL_cannot_be_accessed_jalview_when_starts_up"));
200     displayWsWarning.addActionListener(new ActionListener()
201     {
202       public void actionPerformed(ActionEvent e)
203       {
204         displayWsWarning_actionPerformed(e);
205       }
206     });
207     newWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
208     newWsUrl.setText(MessageManager.getString("label.new_service_url"));
209     newWsUrl.addActionListener(new ActionListener()
210     {
211       public void actionPerformed(ActionEvent e)
212       {
213         newWsUrl_actionPerformed(e);
214       }
215     });
216     editWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
217     editWsUrl.setText(MessageManager.getString("label.edit_service_url"));
218     editWsUrl.addActionListener(new ActionListener()
219     {
220       public void actionPerformed(ActionEvent e)
221       {
222         editWsUrl_actionPerformed(e);
223       }
224     });
225
226     deleteWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
227     deleteWsUrl
228             .setText(MessageManager.getString("label.delete_service_url"));
229     deleteWsUrl.addActionListener(new ActionListener()
230     {
231       public void actionPerformed(ActionEvent e)
232       {
233         deleteWsUrl_actionPerformed(e);
234       }
235     });
236     moveWsUrlUp.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
237     moveWsUrlUp.setText(MessageManager.getString("action.move_up"));
238     moveWsUrlUp
239             .setToolTipText(MessageManager.getString("label.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(MessageManager.getString("action.move_down"));
249     moveWsUrlDown.setToolTipText(
250             MessageManager.getString("label.move_url_down"));
251     moveWsUrlDown.addActionListener(new ActionListener()
252     {
253       public void actionPerformed(ActionEvent e)
254       {
255         moveWsUrlDown_actionPerformed(e);
256       }
257     });
258     newSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
259     newSbrsUrl
260             .setText(MessageManager.getString("label.add_sbrs_definition"));
261     newSbrsUrl.addActionListener(new ActionListener()
262     {
263       public void actionPerformed(ActionEvent e)
264       {
265         newSbrsUrl_actionPerformed(e);
266       }
267     });
268     editSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
269     editSbrsUrl.setText(
270             MessageManager.getString("label.edit_sbrs_definition"));
271     editSbrsUrl.addActionListener(new ActionListener()
272     {
273       public void actionPerformed(ActionEvent e)
274       {
275         editSbrsUrl_actionPerformed(e);
276       }
277     });
278
279     deleteSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
280     deleteSbrsUrl.setText(
281             MessageManager.getString("label.delete_sbrs_definition"));
282     deleteSbrsUrl.addActionListener(new ActionListener()
283     {
284       public void actionPerformed(ActionEvent e)
285       {
286         deleteSbrsUrl_actionPerformed(e);
287       }
288     });
289
290     setLayout(myBorderlayout);
291     setPreferredSize(new Dimension(500, 400));
292     progressBar.setPreferredSize(new Dimension(450, 20));
293     progressBar.setString("");
294     wsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
295     wsListUrlPanel.setLayout(new BorderLayout());
296     wsListPane.setBorder(BorderFactory.createEtchedBorder());
297     wsListPane.getViewport().add(wsList);
298     wsList.setPreferredSize(new Dimension(482, 202));
299     wsListPane.setPreferredSize(new Dimension(380, 80));
300     wsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
301     wsList.setColumnSelectionAllowed(false);
302     wsList.addMouseListener(new MouseListener()
303     {
304
305       public void mouseClicked(MouseEvent e)
306       {
307         if (e.getClickCount() > 1)
308         {
309           editWsUrl_actionPerformed(null);
310         }
311
312       }
313
314       public void mouseEntered(MouseEvent e)
315       {
316
317       }
318
319       public void mouseExited(MouseEvent e)
320       {
321       }
322
323       public void mousePressed(MouseEvent e)
324       {
325
326       }
327
328       public void mouseReleased(MouseEvent e)
329       {
330
331       }
332
333     });
334     wsListButtons.setLayout(new FlowLayout());
335     wsListButtons.add(newWsUrl);
336     wsListButtons.add(editWsUrl);
337     wsListButtons.add(deleteWsUrl);
338     wsListButtons.setMinimumSize(new Dimension(350, 80));
339     wsListNavButs.setSize(new Dimension(80, 80));
340     wsListNavButs.setPreferredSize(new Dimension(80, 80));
341     wsListNavButs.setLayout(new FlowLayout());
342     wsListNavButs.add(moveWsUrlUp);
343     wsListNavButs.add(moveWsUrlDown);
344     wsListUrlPanel.add(wsListPane, BorderLayout.CENTER);
345     wsListUrlPanel.add(wsListNavButs, BorderLayout.WEST);
346     wsListPanel.setBorder(wsListTitleBorder);
347     wsListPanel.setLayout(new BorderLayout());
348     wsListPanel.add(wsListUrlPanel, BorderLayout.NORTH);
349     wsListPanel.add(wsListButtons, BorderLayout.SOUTH);
350
351     srbsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
352     srbsListUrlPanel.setLayout(new BorderLayout());
353     srbsListPane.setBorder(BorderFactory.createEtchedBorder());
354     srbsListPane.getViewport().add(sbrsList);
355     sbrsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
356     sbrsList.addMouseListener(new MouseListener()
357     {
358
359       public void mouseClicked(MouseEvent e)
360       {
361         if (e.getClickCount() > 1)
362         {
363           editSbrsUrl_actionPerformed(null);
364         }
365
366       }
367
368       public void mouseEntered(MouseEvent e)
369       {
370
371       }
372
373       public void mouseExited(MouseEvent e)
374       {
375       }
376
377       public void mousePressed(MouseEvent e)
378       {
379
380       }
381
382       public void mouseReleased(MouseEvent e)
383       {
384
385       }
386
387     });
388     srbsListButtons.setLayout(new FlowLayout());
389     srbsListButtons.add(newSbrsUrl);
390     srbsListButtons.add(editSbrsUrl);
391     srbsListButtons.add(deleteSbrsUrl);
392     srbsListUrlPanel.add(srbsListPane, BorderLayout.CENTER);
393     srbsListPanel.setBorder(sbrsListTitleBorder);
394     srbsListPanel.setLayout(new BorderLayout());
395     srbsListPanel.add(srbsListUrlPanel, BorderLayout.NORTH);
396     srbsListPanel.add(srbsListButtons, BorderLayout.CENTER);
397
398     wsMenuButtons.setLayout(new GridLayout(2, 3));
399     wsMenuButtons.add(indexByHost);
400     wsMenuButtons.add(indexByType);
401     wsMenuButtons.add(enableJws2Services);
402     wsMenuButtons.add(displayWsWarning);
403     wsMenuRefreshButs.setLayout(new FlowLayout());
404     wsMenuRefreshButs.setPreferredSize(new Dimension(480, 30));
405     wsMenuRefreshButs.setSize(new Dimension(480, 30));
406     wsMenuRefreshButs.add(refreshWs, null);
407     wsMenuRefreshButs.add(resetWs, null);
408     wsMenuRefreshButs.add(progressBar, null);
409     myBorderlayout.setHgap(3);
410     if (jalview.bin.Cache.getDefault("ENABLE_RSBS_EDITOR", false))
411     {
412       JTabbedPane listPanels = new JTabbedPane();
413       listPanels.addTab("JABAWS Servers", wsListPanel);
414       listPanels.addTab("RSB Services", srbsListPanel);
415       add(listPanels, BorderLayout.NORTH);
416     }
417     else
418     {
419       add(wsListPanel, BorderLayout.NORTH);
420     }
421     add(wsMenuButtons, BorderLayout.CENTER);
422     add(wsMenuRefreshButs, BorderLayout.SOUTH);
423   }
424
425   protected void deleteSbrsUrl_actionPerformed(ActionEvent e)
426   {
427     // TODO Auto-generated method stub
428
429   }
430
431   protected void editSbrsUrl_actionPerformed(ActionEvent e)
432   {
433     // TODO Auto-generated method stub
434
435   }
436
437   protected void newSbrsUrl_actionPerformed(ActionEvent e)
438   {
439     // TODO Auto-generated method stub
440
441   }
442
443   protected void displayWsWarning_actionPerformed(ActionEvent e)
444   {
445     // TODO Auto-generated method stub
446
447   }
448
449   protected void resetWs_actionPerformed(ActionEvent e)
450   {
451
452   }
453
454   protected void indexByType_actionPerformed(ActionEvent e)
455   {
456
457   }
458
459   protected void indexByHost_actionPerformed(ActionEvent e)
460   {
461
462   }
463
464   protected void newWsUrl_actionPerformed(ActionEvent e)
465   {
466
467   }
468
469   protected void editWsUrl_actionPerformed(ActionEvent e)
470   {
471
472   }
473
474   protected void deleteWsUrl_actionPerformed(ActionEvent e)
475   {
476
477   }
478
479   protected void moveWsUrlUp_actionPerformed(ActionEvent e)
480   {
481
482   }
483
484   protected void moveWsUrlDown_actionPerformed(ActionEvent e)
485   {
486
487   }
488
489   protected void enableEnfinServices_actionPerformed(ActionEvent e)
490   {
491
492   }
493
494   protected void enableJws2Services_actionPerformed(ActionEvent e)
495   {
496
497   }
498
499   protected void refreshWs_actionPerformed(ActionEvent e)
500   {
501
502   }
503
504 }