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