JAL-1372 i18n and tweaking set/unset representative sequence
[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
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(MessageManager
187             .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.setText(MessageManager
197             .getString("label.display_warnings"));
198     displayWsWarning
199             .setToolTipText("<html>"
200                     + MessageManager
201                             .getString("label.option_want_informed_web_service_URL_cannot_be_accessed_jalview_when_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(MessageManager.getString("label.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(MessageManager.getString("label.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(MessageManager
230             .getString("label.delete_service_url"));
231     deleteWsUrl.addActionListener(new ActionListener()
232     {
233       public void actionPerformed(ActionEvent e)
234       {
235         deleteWsUrl_actionPerformed(e);
236       }
237     });
238     moveWsUrlUp.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
239     moveWsUrlUp.setText(MessageManager.getString("action.move_up"));
240     moveWsUrlUp.setToolTipText(MessageManager
241             .getString("label.move_url_up"));
242     moveWsUrlUp.addActionListener(new ActionListener()
243     {
244       public void actionPerformed(ActionEvent e)
245       {
246         moveWsUrlUp_actionPerformed(e);
247       }
248     });
249     moveWsUrlDown.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
250     moveWsUrlDown.setText(MessageManager.getString("action.move_down"));
251     moveWsUrlDown.setToolTipText(MessageManager
252             .getString("label.move_url_down"));
253     moveWsUrlDown.addActionListener(new ActionListener()
254     {
255       public void actionPerformed(ActionEvent e)
256       {
257         moveWsUrlDown_actionPerformed(e);
258       }
259     });
260     newSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
261     newSbrsUrl.setText(MessageManager
262             .getString("label.add_sbrs_definition"));
263     newSbrsUrl.addActionListener(new ActionListener()
264     {
265       public void actionPerformed(ActionEvent e)
266       {
267         newSbrsUrl_actionPerformed(e);
268       }
269     });
270     editSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
271     editSbrsUrl.setText(MessageManager
272             .getString("label.edit_sbrs_definition"));
273     editSbrsUrl.addActionListener(new ActionListener()
274     {
275       public void actionPerformed(ActionEvent e)
276       {
277         editSbrsUrl_actionPerformed(e);
278       }
279     });
280
281     deleteSbrsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
282     deleteSbrsUrl.setText(MessageManager
283             .getString("label.delete_sbrs_definition"));
284     deleteSbrsUrl.addActionListener(new ActionListener()
285     {
286       public void actionPerformed(ActionEvent e)
287       {
288         deleteSbrsUrl_actionPerformed(e);
289       }
290     });
291
292     setLayout(myBorderlayout);
293     setPreferredSize(new Dimension(500, 400));
294     progressBar.setPreferredSize(new Dimension(450, 20));
295     progressBar.setString("");
296     wsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
297     wsListUrlPanel.setLayout(new BorderLayout());
298     wsListPane.setBorder(BorderFactory.createEtchedBorder());
299     wsListPane.getViewport().add(wsList);
300     wsList.setPreferredSize(new Dimension(482, 202));
301     wsListPane.setPreferredSize(new Dimension(380, 80));
302     wsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
303     wsList.setColumnSelectionAllowed(false);
304     wsList.addMouseListener(new MouseListener()
305     {
306
307       public void mouseClicked(MouseEvent e)
308       {
309         if (e.getClickCount() > 1)
310         {
311           editWsUrl_actionPerformed(null);
312         }
313
314       }
315
316       public void mouseEntered(MouseEvent e)
317       {
318
319       }
320
321       public void mouseExited(MouseEvent e)
322       {
323       }
324
325       public void mousePressed(MouseEvent e)
326       {
327
328       }
329
330       public void mouseReleased(MouseEvent e)
331       {
332
333       }
334
335     });
336     wsListButtons.setLayout(new FlowLayout());
337     wsListButtons.add(newWsUrl);
338     wsListButtons.add(editWsUrl);
339     wsListButtons.add(deleteWsUrl);
340     wsListButtons.setMinimumSize(new Dimension(350, 80));
341     wsListNavButs.setSize(new Dimension(80, 80));
342     wsListNavButs.setPreferredSize(new Dimension(80, 80));
343     wsListNavButs.setLayout(new FlowLayout());
344     wsListNavButs.add(moveWsUrlUp);
345     wsListNavButs.add(moveWsUrlDown);
346     wsListUrlPanel.add(wsListPane, BorderLayout.CENTER);
347     wsListUrlPanel.add(wsListNavButs, BorderLayout.WEST);
348     wsListPanel.setBorder(wsListTitleBorder);
349     wsListPanel.setLayout(new BorderLayout());
350     wsListPanel.add(wsListUrlPanel, BorderLayout.NORTH);
351     wsListPanel.add(wsListButtons, BorderLayout.SOUTH);
352
353     srbsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
354     srbsListUrlPanel.setLayout(new BorderLayout());
355     srbsListPane.setBorder(BorderFactory.createEtchedBorder());
356     srbsListPane.getViewport().add(sbrsList);
357     sbrsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
358     sbrsList.addMouseListener(new MouseListener()
359     {
360
361       public void mouseClicked(MouseEvent e)
362       {
363         if (e.getClickCount() > 1)
364         {
365           editSbrsUrl_actionPerformed(null);
366         }
367
368       }
369
370       public void mouseEntered(MouseEvent e)
371       {
372
373       }
374
375       public void mouseExited(MouseEvent e)
376       {
377       }
378
379       public void mousePressed(MouseEvent e)
380       {
381
382       }
383
384       public void mouseReleased(MouseEvent e)
385       {
386
387       }
388
389     });
390     srbsListButtons.setLayout(new FlowLayout());
391     srbsListButtons.add(newSbrsUrl);
392     srbsListButtons.add(editSbrsUrl);
393     srbsListButtons.add(deleteSbrsUrl);
394     srbsListUrlPanel.add(srbsListPane, BorderLayout.CENTER);
395     srbsListPanel.setBorder(sbrsListTitleBorder);
396     srbsListPanel.setLayout(new BorderLayout());
397     srbsListPanel.add(srbsListUrlPanel, BorderLayout.NORTH);
398     srbsListPanel.add(srbsListButtons, BorderLayout.CENTER);
399
400     wsMenuButtons.setLayout(new GridLayout(2, 3));
401     wsMenuButtons.add(indexByHost);
402     wsMenuButtons.add(indexByType);
403     wsMenuButtons.add(enableJws2Services);
404     wsMenuButtons.add(displayWsWarning);
405     wsMenuRefreshButs.setLayout(new FlowLayout());
406     wsMenuRefreshButs.setPreferredSize(new Dimension(480, 30));
407     wsMenuRefreshButs.setSize(new Dimension(480, 30));
408     wsMenuRefreshButs.add(refreshWs, null);
409     wsMenuRefreshButs.add(resetWs, null);
410     wsMenuRefreshButs.add(progressBar, null);
411     myBorderlayout.setHgap(3);
412     if (jalview.bin.Cache.getDefault("ENABLE_RSBS_EDITOR", false))
413     {
414       JTabbedPane listPanels = new JTabbedPane();
415       listPanels.addTab("JABAWS Servers", wsListPanel);
416       listPanels.addTab("RSB Services", srbsListPanel);
417       add(listPanels, BorderLayout.NORTH);
418     }
419     else
420     {
421       add(wsListPanel, BorderLayout.NORTH);
422     }
423     add(wsMenuButtons, BorderLayout.CENTER);
424     add(wsMenuRefreshButs, BorderLayout.SOUTH);
425   }
426
427   protected void deleteSbrsUrl_actionPerformed(ActionEvent e)
428   {
429     // TODO Auto-generated method stub
430
431   }
432
433   protected void editSbrsUrl_actionPerformed(ActionEvent e)
434   {
435     // TODO Auto-generated method stub
436
437   }
438
439   protected void newSbrsUrl_actionPerformed(ActionEvent e)
440   {
441     // TODO Auto-generated method stub
442
443   }
444
445   protected void displayWsWarning_actionPerformed(ActionEvent e)
446   {
447     // TODO Auto-generated method stub
448
449   }
450
451   protected void resetWs_actionPerformed(ActionEvent e)
452   {
453
454   }
455
456   protected void indexByType_actionPerformed(ActionEvent e)
457   {
458
459   }
460
461   protected void indexByHost_actionPerformed(ActionEvent e)
462   {
463
464   }
465
466   protected void newWsUrl_actionPerformed(ActionEvent e)
467   {
468
469   }
470
471   protected void editWsUrl_actionPerformed(ActionEvent e)
472   {
473
474   }
475
476   protected void deleteWsUrl_actionPerformed(ActionEvent e)
477   {
478
479   }
480
481   protected void moveWsUrlUp_actionPerformed(ActionEvent e)
482   {
483
484   }
485
486   protected void moveWsUrlDown_actionPerformed(ActionEvent e)
487   {
488
489   }
490
491   protected void enableEnfinServices_actionPerformed(ActionEvent e)
492   {
493
494   }
495
496   protected void enableJws2Services_actionPerformed(ActionEvent e)
497   {
498
499   }
500
501   protected void refreshWs_actionPerformed(ActionEvent e)
502   {
503
504   }
505
506 }