NEW FILES
[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     jLabel1.setText("<html><p align=\"right\">Show sources serving</p></html>");\r
72     jLabel2.setText("and");\r
73     jLabel3.setHorizontalAlignment(SwingConstants.RIGHT);\r
74     jLabel3.setText("<html><p align=\"right\">using coordinates</p></html>");\r
75     registryLabel.setHorizontalAlignment(SwingConstants.TRAILING);\r
76     registryLabel.setText("Use Registry");\r
77     addLocal.setText("Add Local Source");\r
78     addLocal.addActionListener(new ActionListener()\r
79     {\r
80       public void actionPerformed(ActionEvent e)\r
81       {\r
82         amendLocal(true);\r
83       }\r
84     });\r
85     jPanel1.setLayout(flowLayout1);\r
86     jPanel1.setMinimumSize(new Dimension(596, 30));\r
87     jPanel1.setPreferredSize(new Dimension(596, 30));\r
88     scrollPane.getViewport().add(table);\r
89     fullDetailsScrollpane.getViewport().add(fullDetails);\r
90     jScrollPane3.getViewport().add(coords1);\r
91     jScrollPane2.getViewport().add(capabilities);\r
92     jScrollPane4.getViewport().add(coords2);\r
93     jPanel1.add(refresh, null);\r
94     jPanel1.add(addLocal, null);\r
95     jPanel1.add(progressBar, null);\r
96     this.add(registryLabel, new GridBagConstraints(0, 2, 2, 1, 0.0, 0.0\r
97         , GridBagConstraints.WEST, GridBagConstraints.NONE,\r
98         new Insets(11, 2, 0, 0), 9, 2));\r
99     this.add(registryURL, new GridBagConstraints(2, 2, 5, 1, 1.0, 0.0\r
100                                                  , GridBagConstraints.WEST,\r
101                                                  GridBagConstraints.HORIZONTAL,\r
102                                                  new Insets(6, 7, 0, 10), 393,\r
103                                                  3));\r
104     this.add(jLabel2, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0\r
105                                              , GridBagConstraints.WEST,\r
106                                              GridBagConstraints.NONE,\r
107                                              new Insets(36, 7, 35, 0), 5, 21));\r
108     this.add(jLabel3, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0\r
109                                              , GridBagConstraints.WEST,\r
110                                              GridBagConstraints.NONE,\r
111                                              new Insets(33, 0, 29, 0), 5, 16));\r
112     this.add(jLabel1,\r
113              new GridBagConstraints(0, 1, 1, GridBagConstraints.REMAINDER, 0.0,\r
114                                     0.0\r
115                                     , GridBagConstraints.WEST,\r
116                                     GridBagConstraints.NONE,\r
117                                     new Insets( -60, 2, 0, 0), 5, 20));\r
118     this.add(jPanel1, new GridBagConstraints(0, 3, 7, 1, 1.0, 1.0\r
119                                              , GridBagConstraints.CENTER,\r
120                                              GridBagConstraints.HORIZONTAL,\r
121                                              new Insets(0, 0, 0, 0), 0, 0));\r
122     this.add(fullDetailsScrollpane, new GridBagConstraints(3, 0, 4, 1, 1.0, 1.0\r
123         , GridBagConstraints.CENTER, GridBagConstraints.BOTH,\r
124         new Insets(3, 0, 0, 3), 240, 130));\r
125     this.add(scrollPane, new GridBagConstraints(0, 0, 3, 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     this.add(jScrollPane3, new GridBagConstraints(4, 1, 1, 1, 1.0, 1.0\r
131                                                   , GridBagConstraints.CENTER,\r
132                                                   GridBagConstraints.BOTH,\r
133                                                   new Insets(9, 0, 0, 0), 80, 0));\r
134     this.add(jScrollPane2, new GridBagConstraints(1, 1, 2, 1, 1.0, 1.0\r
135                                                   , GridBagConstraints.CENTER,\r
136                                                   GridBagConstraints.BOTH,\r
137                                                   new Insets(9, 0, 0, 0), 80, 0));\r
138     this.add(jScrollPane4, new GridBagConstraints(6, 1, 1, 1, 1.0, 1.0\r
139                                                   , GridBagConstraints.CENTER,\r
140                                                   GridBagConstraints.BOTH,\r
141                                                   new Insets(9, 0, 0, 9), 80, 0));\r
142   }\r
143 \r
144   protected JTable table = new JTable();\r
145   protected JEditorPane fullDetails = new JEditorPane("text/html", "");\r
146   TitledBorder titledBorder1 = new TitledBorder("Available DAS Sources");\r
147   protected JButton refresh = new JButton();\r
148   protected JProgressBar progressBar = new JProgressBar();\r
149   protected JScrollPane scrollPane = new JScrollPane();\r
150   TitledBorder titledBorder2 = new TitledBorder("Full Details");\r
151   protected JScrollPane fullDetailsScrollpane = new JScrollPane();\r
152   protected JList capabilities = new JList();\r
153   protected JList coords1 = new JList();\r
154   protected JList coords2 = new JList();\r
155   JLabel jLabel1 = new JLabel();\r
156   JLabel jLabel2 = new JLabel();\r
157   JLabel jLabel3 = new JLabel();\r
158   JScrollPane jScrollPane2 = new JScrollPane();\r
159   JScrollPane jScrollPane3 = new JScrollPane();\r
160   JScrollPane jScrollPane4 = new JScrollPane();\r
161   protected JTextField registryURL = new JTextField();\r
162   protected JLabel registryLabel = new JLabel();\r
163   protected JButton addLocal = new JButton();\r
164   JPanel jPanel1 = new JPanel();\r
165   FlowLayout flowLayout1 = new FlowLayout();\r
166   GridBagLayout gridBagLayout1 = new GridBagLayout();\r
167   public void refresh_actionPerformed(ActionEvent e)\r
168   {\r
169 \r
170   }\r
171 \r
172   public void fullDetails_hyperlinkUpdate(HyperlinkEvent e)\r
173   {\r
174     try{\r
175 \r
176       if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)\r
177         jalview.util.BrowserLauncher.openURL(e.getURL().toString());\r
178     }\r
179     catch(Exception ex)\r
180     {\r
181       System.out.println(e.getURL());\r
182       ex.printStackTrace();\r
183     }\r
184   }\r
185 \r
186   public void amendLocal(boolean newSource)\r
187   {\r
188 \r
189   }\r
190 \r
191 }\r