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