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