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