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