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