a2612e81d29f66ff740c486925e62f8085599417
[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(MessageManager
67             .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, new GridBagConstraints(1, 0, 2, 1, 1.0,
141             1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
142             new Insets(3, 0, 0, 3), 240, 130));
143     this.add(scrollPane, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
144             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
145                     3, 2, 0, 0), 150, 130));
146     jPanel2.add(registryLabel, java.awt.BorderLayout.WEST);
147     jPanel2.add(registryURL, java.awt.BorderLayout.CENTER);
148     jPanel2.add(reset, java.awt.BorderLayout.EAST);
149     this.add(jPanel2, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0,
150             GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
151             new Insets(5, 10, 0, 10), 339, 0));
152     this.add(jScrollPane2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0,
153             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
154                     0, 0, 0, 60), 80, 60));
155     this.add(jScrollPane4, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0,
156             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
157                     0, -80, 0, 0), 80, 60));
158     this.add(jScrollPane3, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,
159             GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
160                     0, -60, 0, 80), 80, 60));
161   }
162
163   protected JTable table = new JTable();
164
165   protected JEditorPane fullDetails = new JEditorPane("text/html", "");
166
167   TitledBorder titledBorder1 = new TitledBorder(
168           MessageManager.getString("label.available_das_sources"));
169
170   protected JButton refresh = new JButton();
171
172   protected JProgressBar progressBar = new JProgressBar();
173
174   protected JScrollPane scrollPane = new JScrollPane();
175
176   TitledBorder titledBorder2 = new TitledBorder(
177           MessageManager.getString("label.full_details"));
178
179   protected JScrollPane fullDetailsScrollpane = new JScrollPane();
180
181   protected JList filter1 = new JList();
182
183   protected JList filter2 = new JList();
184
185   protected JList filter3 = new JList();
186
187   JScrollPane jScrollPane2 = new JScrollPane();
188
189   JScrollPane jScrollPane3 = new JScrollPane();
190
191   JScrollPane jScrollPane4 = new JScrollPane();
192
193   protected JTextField registryURL = new JTextField();
194
195   protected JLabel registryLabel = new JLabel();
196
197   protected JButton addLocal = new JButton();
198
199   JPanel jPanel1 = new JPanel();
200
201   FlowLayout flowLayout1 = new FlowLayout();
202
203   GridBagLayout gridBagLayout1 = new GridBagLayout();
204
205   TitledBorder titledBorder3 = new TitledBorder(
206           MessageManager.getString("label.authority") + ":");
207
208   TitledBorder titledBorder4 = new TitledBorder(
209           MessageManager.getString("label.type") + ":");
210
211   TitledBorder titledBorder5 = new TitledBorder(
212           MessageManager.getString("label.label") + ":");
213
214   JButton reset = new JButton();
215
216   JPanel jPanel2 = new JPanel();
217
218   BorderLayout borderLayout1 = new BorderLayout();
219
220   public void refresh_actionPerformed(ActionEvent e)
221   {
222
223   }
224
225   public void fullDetails_hyperlinkUpdate(HyperlinkEvent e)
226   {
227     try
228     {
229
230       if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
231       {
232         jalview.util.BrowserLauncher.openURL(e.getURL().toString());
233       }
234     } catch (Exception ex)
235     {
236       System.out.println(e.getURL());
237       ex.printStackTrace();
238     }
239   }
240
241   public void amendLocal(boolean newSource)
242   {
243
244   }
245
246   public void reset_actionPerformed(ActionEvent e)
247   {
248
249   }
250
251 }