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