Put DBRefFether in a new thread
[jalview.git] / src / jalview / jbgui / GDasSourceBrowser.java
1 /*\r
2  * Jalview - A Sequence Alignment Editor and Viewer\r
3  * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
4  *\r
5  * This program is free software; you can redistribute it and/or\r
6  * modify it under the terms of the GNU General Public License\r
7  * as published by the Free Software Foundation; either version 2\r
8  * of the License, or (at your option) any later version.\r
9  *\r
10  * This program is distributed in the hope that it will be useful,\r
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13  * GNU General Public License for more details.\r
14  *\r
15  * You should have received a copy of the GNU General Public License\r
16  * along with this program; if not, write to the Free Software\r
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
18  */\r
19 package jalview.jbgui;\r
20 \r
21 import javax.swing.*;\r
22 import javax.swing.border.TitledBorder;\r
23 import java.awt.event.ActionListener;\r
24 import java.awt.event.ActionEvent;\r
25 import java.awt.*;\r
26 import javax.swing.BorderFactory;\r
27 import javax.swing.event.HyperlinkListener;\r
28 import javax.swing.event.HyperlinkEvent;\r
29 import java.awt.Dimension;\r
30 \r
31 public class GDasSourceBrowser\r
32     extends JPanel\r
33 {\r
34   public GDasSourceBrowser()\r
35   {\r
36     try\r
37     {\r
38       jbInit();\r
39     }\r
40     catch (Exception ex)\r
41     {\r
42       ex.printStackTrace();\r
43     }\r
44   }\r
45 \r
46   private void jbInit()\r
47       throws Exception\r
48   {\r
49     this.setLayout(gridBagLayout1);\r
50     refresh.setText("Refresh Available Sources");\r
51     refresh.addActionListener(new ActionListener()\r
52     {\r
53       public void actionPerformed(ActionEvent e)\r
54       {\r
55         refresh_actionPerformed(e);\r
56       }\r
57     });\r
58     progressBar.setPreferredSize(new Dimension(450, 20));\r
59     progressBar.setString("");\r
60     scrollPane.setBorder(titledBorder1);\r
61     scrollPane.setBorder(BorderFactory.createEtchedBorder());\r
62     fullDetailsScrollpane.setBorder(BorderFactory.createEtchedBorder());\r
63     fullDetails.addHyperlinkListener(new HyperlinkListener()\r
64     {\r
65       public void hyperlinkUpdate(HyperlinkEvent e)\r
66       {\r
67         fullDetails_hyperlinkUpdate(e);\r
68       }\r
69     });\r
70     fullDetails.setEditable(false);\r
71     registryLabel.setHorizontalAlignment(SwingConstants.TRAILING);\r
72     registryLabel.setText("Use Registry");\r
73     addLocal.setText("Add Local Source");\r
74     addLocal.addActionListener(new ActionListener()\r
75     {\r
76       public void actionPerformed(ActionEvent e)\r
77       {\r
78         amendLocal(true);\r
79       }\r
80     });\r
81     jPanel1.setLayout(flowLayout1);\r
82     jPanel1.setMinimumSize(new Dimension(596, 30));\r
83     jPanel1.setPreferredSize(new Dimension(596, 30));\r
84     jScrollPane2.setBorder(titledBorder3);\r
85     jScrollPane3.setBorder(titledBorder4);\r
86     jScrollPane4.setBorder(titledBorder5);\r
87     scrollPane.getViewport().add(table);\r
88     fullDetailsScrollpane.getViewport().add(fullDetails);\r
89     jScrollPane3.getViewport().add(filter2);\r
90     jScrollPane4.getViewport().add(filter3);\r
91     jPanel1.add(refresh, null);\r
92     jPanel1.add(addLocal, null);\r
93     jPanel1.add(progressBar, null);\r
94     jScrollPane2.getViewport().add(filter1);\r
95     this.add(registryLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0\r
96         , GridBagConstraints.WEST, GridBagConstraints.NONE,\r
97         new Insets(11, 2, 0, 0), 9, 2));\r
98     this.add(registryURL, new GridBagConstraints(1, 2, 4, 1, 1.0, 0.0\r
99                                                  , GridBagConstraints.WEST,\r
100                                                  GridBagConstraints.HORIZONTAL,\r
101                                                  new Insets(6, 7, 0, 10), 393,\r
102                                                  3));\r
103     this.add(jPanel1, new GridBagConstraints(0, 3, 5, 1, 1.0, 1.0\r
104                                              , GridBagConstraints.CENTER,\r
105                                              GridBagConstraints.HORIZONTAL,\r
106                                              new Insets(0, 0, 0, 0), 0, 0));\r
107     this.add(fullDetailsScrollpane, new GridBagConstraints(2, 0, 3, 1, 1.0, 1.0\r
108         , GridBagConstraints.CENTER, GridBagConstraints.BOTH,\r
109         new Insets(3, 0, 0, 3), 240, 130));\r
110     this.add(jScrollPane3, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0\r
111                                                   , GridBagConstraints.CENTER,\r
112                                                   GridBagConstraints.BOTH,\r
113                                                   new Insets(0, 0, 0, 0), 80,\r
114                                                   60));\r
115     this.add(jScrollPane4, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0\r
116                                                   , GridBagConstraints.CENTER,\r
117                                                   GridBagConstraints.BOTH,\r
118                                                   new Insets(0, 0, 0, 0), 80,\r
119                                                   60));\r
120     this.add(jScrollPane2, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0\r
121                                                   , GridBagConstraints.CENTER,\r
122                                                   GridBagConstraints.BOTH,\r
123                                                   new Insets(0, 0, 0, 0), 80,\r
124                                                   60));\r
125     this.add(scrollPane, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0\r
126                                                 , GridBagConstraints.CENTER,\r
127                                                 GridBagConstraints.BOTH,\r
128                                                 new Insets(3, 2, 0, 0), 150,\r
129                                                 130));\r
130   }\r
131 \r
132   protected JTable table = new JTable();\r
133   protected JEditorPane fullDetails = new JEditorPane("text/html", "");\r
134   TitledBorder titledBorder1 = new TitledBorder("Available DAS Sources");\r
135   protected JButton refresh = new JButton();\r
136   protected JProgressBar progressBar = new JProgressBar();\r
137   protected JScrollPane scrollPane = new JScrollPane();\r
138   TitledBorder titledBorder2 = new TitledBorder("Full Details");\r
139   protected JScrollPane fullDetailsScrollpane = new JScrollPane();\r
140   protected JList filter1 = new JList();\r
141   protected JList filter2 = new JList();\r
142   protected JList filter3 = new JList();\r
143   JScrollPane jScrollPane2 = new JScrollPane();\r
144   JScrollPane jScrollPane3 = new JScrollPane();\r
145   JScrollPane jScrollPane4 = new JScrollPane();\r
146   protected JTextField registryURL = new JTextField();\r
147   protected JLabel registryLabel = new JLabel();\r
148   protected JButton addLocal = new JButton();\r
149   JPanel jPanel1 = new JPanel();\r
150   FlowLayout flowLayout1 = new FlowLayout();\r
151   GridBagLayout gridBagLayout1 = new GridBagLayout();\r
152   TitledBorder titledBorder3 = new TitledBorder("Authority:");\r
153   TitledBorder titledBorder4 = new TitledBorder("Type:");\r
154   TitledBorder titledBorder5 = new TitledBorder("Label:");\r
155   public void refresh_actionPerformed(ActionEvent e)\r
156   {\r
157 \r
158   }\r
159 \r
160   public void fullDetails_hyperlinkUpdate(HyperlinkEvent e)\r
161   {\r
162     try{\r
163 \r
164       if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)\r
165         jalview.util.BrowserLauncher.openURL(e.getURL().toString());\r
166     }\r
167     catch(Exception ex)\r
168     {\r
169       System.out.println(e.getURL());\r
170       ex.printStackTrace();\r
171     }\r
172   }\r
173 \r
174   public void amendLocal(boolean newSource)\r
175   {\r
176 \r
177   }\r
178 \r
179 }\r