JAL-1807 explicit imports (jalview.jbgui)
[jalview.git] / src / jalview / jbgui / GDasSourceBrowser.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.util.BrowserLauncher;
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.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.Insets;
33 import java.awt.event.ActionEvent;
34 import java.awt.event.ActionListener;
35
36 import javax.swing.BorderFactory;
37 import javax.swing.JButton;
38 import javax.swing.JEditorPane;
39 import javax.swing.JLabel;
40 import javax.swing.JList;
41 import javax.swing.JPanel;
42 import javax.swing.JProgressBar;
43 import javax.swing.JScrollPane;
44 import javax.swing.JTable;
45 import javax.swing.JTextField;
46 import javax.swing.SwingConstants;
47 import javax.swing.border.TitledBorder;
48 import javax.swing.event.HyperlinkEvent;
49 import javax.swing.event.HyperlinkListener;
50
51 public class GDasSourceBrowser extends JPanel
52 {
53   public GDasSourceBrowser()
54   {
55     try
56     {
57       jbInit();
58     } catch (Exception ex)
59     {
60       ex.printStackTrace();
61     }
62   }
63
64   private void jbInit() throws Exception
65   {
66     this.setLayout(gridBagLayout1);
67     refresh.setText(MessageManager
68             .getString("label.refresh_available_sources"));
69     refresh.addActionListener(new ActionListener()
70     {
71       public void actionPerformed(ActionEvent e)
72       {
73         refresh_actionPerformed(e);
74       }
75     });
76     progressBar.setPreferredSize(new Dimension(450, 20));
77     progressBar.setString("");
78     scrollPane.setBorder(titledBorder1);
79     scrollPane.setBorder(BorderFactory.createEtchedBorder());
80     fullDetailsScrollpane.setBorder(BorderFactory.createEtchedBorder());
81     fullDetails.addHyperlinkListener(new HyperlinkListener()
82     {
83       public void hyperlinkUpdate(HyperlinkEvent e)
84       {
85         fullDetails_hyperlinkUpdate(e);
86       }
87     });
88     fullDetails.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
89     fullDetails.setEditable(false);
90     registryLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
91     registryLabel.setHorizontalAlignment(SwingConstants.TRAILING);
92     registryLabel.setText(MessageManager.getString("label.use_registry"));
93     addLocal.setText(MessageManager.getString("label.add_local_source"));
94     addLocal.addActionListener(new ActionListener()
95     {
96       public void actionPerformed(ActionEvent e)
97       {
98         amendLocal(true);
99       }
100     });
101     jPanel1.setLayout(flowLayout1);
102     jPanel1.setMinimumSize(new Dimension(596, 30));
103     jPanel1.setPreferredSize(new Dimension(596, 30));
104     jScrollPane2.setBorder(titledBorder3);
105     jScrollPane3.setBorder(titledBorder4);
106     jScrollPane4.setBorder(titledBorder5);
107     titledBorder2
108             .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
109     titledBorder3
110             .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
111     titledBorder4
112             .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
113     filter1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
114     filter2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
115     filter3.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
116     table.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
117     reset.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
118     reset.setMargin(new Insets(2, 2, 2, 2));
119     reset.setText(MessageManager.getString("action.reset"));
120     reset.addActionListener(new ActionListener()
121     {
122       public void actionPerformed(ActionEvent e)
123       {
124         reset_actionPerformed(e);
125       }
126     });
127     jPanel2.setLayout(borderLayout1);
128     borderLayout1.setHgap(5);
129     registryURL.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10));
130     scrollPane.getViewport().add(table);
131     fullDetailsScrollpane.getViewport().add(fullDetails);
132     jScrollPane3.getViewport().add(filter2);
133     jScrollPane4.getViewport().add(filter3);
134     jPanel1.add(refresh, null);
135     jPanel1.add(addLocal, null);
136     jPanel1.add(progressBar, null);
137     jScrollPane2.getViewport().add(filter1);
138     this.add(jPanel1, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0,
139             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
140             new Insets(0, 0, 0, 0), 0, 0));
141     this.add(fullDetailsScrollpane, new GridBagConstraints(1, 0, 2, 1, 1.0,
142             1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
143             new Insets(3, 0, 0, 3), 240, 130));
144     this.add(scrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
145             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
146                     3, 2, 0, 0), 150, 130));
147     jPanel2.add(registryLabel, java.awt.BorderLayout.WEST);
148     jPanel2.add(registryURL, java.awt.BorderLayout.CENTER);
149     jPanel2.add(reset, java.awt.BorderLayout.EAST);
150     this.add(jPanel2, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
151             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
152             new Insets(5, 10, 0, 10), 339, 0));
153     this.add(jScrollPane2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
154             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
155                     0, 0, 0, 60), 80, 60));
156     this.add(jScrollPane4, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0,
157             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
158                     0, -80, 0, 0), 80, 60));
159     this.add(jScrollPane3, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
160             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
161                     0, -60, 0, 80), 80, 60));
162   }
163
164   protected JTable table = new JTable();
165
166   protected JEditorPane fullDetails = new JEditorPane("text/html", "");
167
168   TitledBorder titledBorder1 = new TitledBorder(
169           MessageManager.getString("label.available_das_sources"));
170
171   protected JButton refresh = new JButton();
172
173   protected JProgressBar progressBar = new JProgressBar();
174
175   protected JScrollPane scrollPane = new JScrollPane();
176
177   TitledBorder titledBorder2 = new TitledBorder(
178           MessageManager.getString("label.full_details"));
179
180   protected JScrollPane fullDetailsScrollpane = new JScrollPane();
181
182   protected JList filter1 = new JList();
183
184   protected JList filter2 = new JList();
185
186   protected JList filter3 = new JList();
187
188   JScrollPane jScrollPane2 = new JScrollPane();
189
190   JScrollPane jScrollPane3 = new JScrollPane();
191
192   JScrollPane jScrollPane4 = new JScrollPane();
193
194   protected JTextField registryURL = new JTextField();
195
196   protected JLabel registryLabel = new JLabel();
197
198   protected JButton addLocal = new JButton();
199
200   JPanel jPanel1 = new JPanel();
201
202   FlowLayout flowLayout1 = new FlowLayout();
203
204   GridBagLayout gridBagLayout1 = new GridBagLayout();
205
206   TitledBorder titledBorder3 = new TitledBorder(
207           MessageManager.getString("label.authority") + ":");
208
209   TitledBorder titledBorder4 = new TitledBorder(
210           MessageManager.getString("label.type") + ":");
211
212   TitledBorder titledBorder5 = new TitledBorder(
213           MessageManager.getString("label.label") + ":");
214
215   JButton reset = new JButton();
216
217   JPanel jPanel2 = new JPanel();
218
219   BorderLayout borderLayout1 = new BorderLayout();
220
221   public void refresh_actionPerformed(ActionEvent e)
222   {
223
224   }
225
226   public void fullDetails_hyperlinkUpdate(HyperlinkEvent e)
227   {
228     try
229     {
230
231       if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
232       {
233         BrowserLauncher.openURL(e.getURL().toString());
234       }
235     } catch (Exception ex)
236     {
237       System.out.println(e.getURL());
238       ex.printStackTrace();
239     }
240   }
241
242   public void amendLocal(boolean newSource)
243   {
244
245   }
246
247   public void reset_actionPerformed(ActionEvent e)
248   {
249
250   }
251
252 }