da9322c7fe248cd0a73c169f27054b87697254ac
[jalview.git] / src / jalview / jbgui / GWsPreferences.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3  * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
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  */
18 package jalview.jbgui;
19
20 import java.awt.BorderLayout;
21 import java.awt.Dimension;
22 import java.awt.FlowLayout;
23 import java.awt.Font;
24 import java.awt.GridBagLayout;
25 import java.awt.GridLayout;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.awt.event.MouseEvent;
29 import java.awt.event.MouseListener;
30
31 import javax.swing.BorderFactory;
32 import javax.swing.JButton;
33 import javax.swing.JCheckBox;
34 import javax.swing.JList;
35 import javax.swing.JPanel;
36 import javax.swing.JProgressBar;
37 import javax.swing.JScrollPane;
38 import javax.swing.ListSelectionModel;
39 import javax.swing.SwingConstants;
40 import javax.swing.border.TitledBorder;
41
42 /**
43  * Preference dialog for jalview web services
44  * 
45  * @author JimP
46  */
47 public class GWsPreferences extends JPanel
48 {
49   protected JList wsList = new JList();
50
51   protected TitledBorder wsListTitleBorder = new TitledBorder(
52           "Web Service Discovery URLS");
53
54   protected JButton newWsUrl = new JButton();
55
56   protected JButton editWsUrl = new JButton();
57
58   protected JButton deleteWsUrl = new JButton();
59
60   protected JButton moveWsUrlUp = new JButton();
61
62   protected JButton moveWsUrlDown = new JButton();
63
64   protected JCheckBox indexByHost = new JCheckBox();
65
66   protected JCheckBox indexByType = new JCheckBox();
67
68   protected JCheckBox enableJws1Services = new JCheckBox();
69
70   protected JCheckBox enableJws2Services = new JCheckBox();
71
72   protected JCheckBox enableEnfinServices = new JCheckBox();
73
74   protected JCheckBox displayWsWarning = new JCheckBox();
75
76   protected JButton refreshWs = new JButton();
77
78   protected JButton resetWs = new JButton();
79
80   protected JProgressBar progressBar = new JProgressBar();
81
82   JScrollPane wsListPane = new JScrollPane();
83
84   JPanel wsListUrlPanel = new JPanel();
85
86   JPanel wsListPanel = new JPanel();
87
88   JPanel wsListButtons = new JPanel();
89
90   JPanel wsListNavButs = new JPanel();
91
92   BorderLayout myBorderlayout = new BorderLayout();
93
94   BorderLayout wsListBorderlayout = new BorderLayout();
95
96   GridBagLayout wsPrefLayout = new GridBagLayout();
97
98   GridBagLayout wsListLayout = new GridBagLayout();
99
100   GridBagLayout wsMenuLayout = new GridBagLayout();
101
102   JPanel wsMenuButtons = new JPanel();
103
104   JPanel wsMenuRefreshButs = new JPanel();
105
106   public GWsPreferences()
107   {
108     jbInit();
109   }
110
111   private void jbInit()
112   {
113
114     refreshWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
115     refreshWs.setText("Refresh Services");
116     refreshWs.addActionListener(new ActionListener()
117     {
118       public void actionPerformed(ActionEvent e)
119       {
120         refreshWs_actionPerformed(e);
121       }
122     });
123     resetWs.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
124     resetWs.setText("Reset Services");
125
126     resetWs.addActionListener(new ActionListener()
127     {
128       public void actionPerformed(ActionEvent e)
129       {
130         resetWs_actionPerformed(e);
131       }
132     });
133     indexByHost.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
134     indexByHost.setText("Index by host");
135     indexByHost
136             .setToolTipText("Index web services in menu by the host site.");
137     indexByHost.addActionListener(new ActionListener()
138     {
139       public void actionPerformed(ActionEvent e)
140       {
141         indexByHost_actionPerformed(e);
142       }
143     });
144     indexByType.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
145     indexByType.setText("Index by type");
146     indexByType.addActionListener(new ActionListener()
147     {
148       public void actionPerformed(ActionEvent e)
149       {
150         indexByType_actionPerformed(e);
151       }
152     });
153     enableEnfinServices
154             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
155     enableEnfinServices.setText("Enable Enfin Services");
156     enableEnfinServices.addActionListener(new ActionListener()
157     {
158       public void actionPerformed(ActionEvent e)
159       {
160         enableEnfinServices_actionPerformed(e);
161       }
162     });
163     enableJws2Services
164             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
165     enableJws2Services.setText("Enable JABAWS Services");
166     enableJws2Services.addActionListener(new ActionListener()
167     {
168       public void actionPerformed(ActionEvent e)
169       {
170         enableJws2Services_actionPerformed(e);
171       }
172     });
173     enableJws1Services
174             .setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
175     enableJws1Services.setText("Enable Legacy Services");
176     enableJws1Services.addActionListener(new ActionListener()
177     {
178       public void actionPerformed(ActionEvent e)
179       {
180         enableJws1Services_actionPerformed(e);
181       }
182     });
183     displayWsWarning.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
184     displayWsWarning.setText("Display warnings");
185     displayWsWarning
186             .setToolTipText("<html>Check this option if you want to be informed<br>when a web service URL cannot be accessed by Jalview<br>when it starts up");
187     displayWsWarning.addActionListener(new ActionListener()
188     {
189       public void actionPerformed(ActionEvent e)
190       {
191         displayWsWarning_actionPerformed(e);
192       }
193     });
194     newWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
195     newWsUrl.setText("New Service URL");
196     newWsUrl.addActionListener(new ActionListener()
197     {
198       public void actionPerformed(ActionEvent e)
199       {
200         newWsUrl_actionPerformed(e);
201       }
202     });
203     editWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
204     editWsUrl.setText("Edit Service URL");
205     editWsUrl.addActionListener(new ActionListener()
206     {
207       public void actionPerformed(ActionEvent e)
208       {
209         editWsUrl_actionPerformed(e);
210       }
211     });
212
213     deleteWsUrl.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
214     deleteWsUrl.setText("Delete Service URL");
215     deleteWsUrl.addActionListener(new ActionListener()
216     {
217       public void actionPerformed(ActionEvent e)
218       {
219         deleteWsUrl_actionPerformed(e);
220       }
221     });
222     moveWsUrlUp.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
223     moveWsUrlUp.setText("Up");
224     moveWsUrlUp.setToolTipText("Move URL up");
225     moveWsUrlUp.addActionListener(new ActionListener()
226     {
227       public void actionPerformed(ActionEvent e)
228       {
229         moveWsUrlUp_actionPerformed(e);
230       }
231     });
232     moveWsUrlDown.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
233     moveWsUrlDown.setText("Down");
234     moveWsUrlDown.setToolTipText("Move URL Down");
235     moveWsUrlDown.addActionListener(new ActionListener()
236     {
237       public void actionPerformed(ActionEvent e)
238       {
239         moveWsUrlDown_actionPerformed(e);
240       }
241     });
242
243     setLayout(myBorderlayout);
244     setPreferredSize(new Dimension(500, 400));
245     progressBar.setPreferredSize(new Dimension(450, 20));
246     progressBar.setString("");
247     wsListUrlPanel.setBorder(BorderFactory.createEtchedBorder());
248     wsListUrlPanel.setLayout(new BorderLayout());
249     // wsListUrlPanel.setPreferredSize(new Dimension(482,202));
250     wsListPane.setBorder(BorderFactory.createEtchedBorder());
251     wsListPane.getViewport().add(wsList);
252     wsListPane.setPreferredSize(new Dimension(380, 200));
253     wsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
254     wsList.addMouseListener(new MouseListener()
255     {
256
257       public void mouseClicked(MouseEvent e)
258       {
259         if (e.getClickCount() > 1)
260         {
261           editWsUrl_actionPerformed(null);
262         }
263
264       }
265
266       public void mouseEntered(MouseEvent e)
267       {
268
269       }
270
271       public void mouseExited(MouseEvent e)
272       {
273       }
274
275       public void mousePressed(MouseEvent e)
276       {
277
278       }
279
280       public void mouseReleased(MouseEvent e)
281       {
282
283       }
284
285     });
286     // wsListButtons.setPreferredSize(new Dimension(480, 60));
287     wsListButtons.setLayout(new FlowLayout());
288     // wsListButtons.add(moveWsUrlUp);
289     // wsListButtons.add(moveWsUrlDown);
290     wsListButtons.add(newWsUrl);
291     wsListButtons.add(editWsUrl);
292     wsListButtons.add(deleteWsUrl);
293     wsListNavButs.setSize(new Dimension(80, 80));
294     wsListNavButs.setPreferredSize(new Dimension(80, 80));
295     wsListNavButs.setLayout(new FlowLayout());
296     wsListNavButs.add(moveWsUrlUp);
297     wsListNavButs.add(moveWsUrlDown);
298     wsListUrlPanel.add(wsListPane, BorderLayout.EAST);
299     wsListUrlPanel.add(wsListNavButs, BorderLayout.WEST);
300     wsListPanel.setBorder(wsListTitleBorder);
301     wsListPanel.setLayout(new BorderLayout());
302     wsListPanel.add(wsListUrlPanel, BorderLayout.NORTH);
303     wsListPanel.add(wsListButtons, BorderLayout.SOUTH);
304     wsMenuButtons.setLayout(new GridLayout(2, 3));
305     wsMenuButtons.add(indexByHost);
306     wsMenuButtons.add(indexByType);
307     wsMenuButtons.add(enableJws1Services);
308     wsMenuButtons.add(enableJws2Services);
309     wsMenuButtons.add(enableEnfinServices);
310     wsMenuButtons.add(displayWsWarning);
311     wsMenuRefreshButs.setLayout(new FlowLayout());
312     wsMenuRefreshButs.setPreferredSize(new Dimension(480, 30));
313     wsMenuRefreshButs.setSize(new Dimension(480, 30));
314     wsMenuRefreshButs.add(refreshWs, null);
315     wsMenuRefreshButs.add(resetWs, null);
316     wsMenuRefreshButs.add(progressBar, null);
317     myBorderlayout.setHgap(3);
318     add(wsListPanel, BorderLayout.NORTH);
319     add(wsMenuButtons, BorderLayout.CENTER);
320     add(wsMenuRefreshButs, BorderLayout.SOUTH);
321   }
322
323   protected void displayWsWarning_actionPerformed(ActionEvent e)
324   {
325     // TODO Auto-generated method stub
326     
327   }
328
329   protected void resetWs_actionPerformed(ActionEvent e)
330   {
331
332   }
333
334   protected void indexByType_actionPerformed(ActionEvent e)
335   {
336
337   }
338
339   protected void indexByHost_actionPerformed(ActionEvent e)
340   {
341
342   }
343
344   protected void newWsUrl_actionPerformed(ActionEvent e)
345   {
346
347   }
348
349   protected void editWsUrl_actionPerformed(ActionEvent e)
350   {
351
352   }
353
354   protected void deleteWsUrl_actionPerformed(ActionEvent e)
355   {
356
357   }
358
359   protected void moveWsUrlUp_actionPerformed(ActionEvent e)
360   {
361
362   }
363
364   protected void moveWsUrlDown_actionPerformed(ActionEvent e)
365   {
366
367   }
368
369   protected void enableEnfinServices_actionPerformed(ActionEvent e)
370   {
371
372   }
373
374   protected void enableJws2Services_actionPerformed(ActionEvent e)
375   {
376
377   }
378
379   protected void enableJws1Services_actionPerformed(ActionEvent e)
380   {
381
382   }
383
384   protected void refreshWs_actionPerformed(ActionEvent e)
385   {
386
387   }
388
389 }