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