2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\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
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
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
19 package jalview.gui;
\r
21 import jalview.io.*;
\r
23 import jalview.jbgui.*;
\r
25 import jalview.schemes.*;
\r
28 import java.awt.event.*;
\r
30 import javax.swing.*;
\r
34 import jalview.bin.Cache;
\r
41 * @version $Revision$
\r
43 public class Preferences extends GPreferences
\r
45 /** Holds name and link separated with | character. Sequence ID must be $SEQUENCE_ID$ */
\r
46 public static Vector sequenceURLLinks;
\r
49 String string = Cache.getDefault("SEQUENCE_LINKS",
\r
50 "SRS|http://srs.ebi.ac.uk/srs7bin/cgi-bin/wgetz?-e+[uniprot-all:$SEQUENCE_ID$]+-vn+2");
\r
51 sequenceURLLinks = new Vector();
\r
55 StringTokenizer st = new StringTokenizer(string, "|");
\r
56 while (st.hasMoreElements())
\r
58 sequenceURLLinks.addElement(st.nextToken() + "|" + st.nextToken());
\r
61 catch (Exception ex)
\r
63 System.out.println(ex + "\nError parsing sequence links");
\r
66 Vector nameLinks, urlLinks;
\r
68 JInternalFrame frame;
\r
70 DasSourceBrowser dasSource;
\r
74 * Creates a new Preferences object.
\r
76 public Preferences()
\r
79 frame = new JInternalFrame();
\r
80 frame.setContentPane(this);
\r
81 dasSource = new DasSourceBrowser();
\r
82 dasPanel.add(dasSource, BorderLayout.CENTER);
\r
84 int width = 500, height = 420;
\r
85 if(System.getProperty("os.name").startsWith("Mac"))
\r
91 Desktop.addInternalFrame(frame, "Preferences", width, height);
\r
92 frame.setMinimumSize(new Dimension(width, height));
\r
94 seqLimit.setSelected( Cache.getDefault("SHOW_JVSUFFIX", true));
\r
95 fullScreen.setSelected( Cache.getDefault("SHOW_FULLSCREEN", false));
\r
96 annotations.setSelected( Cache.getDefault("SHOW_ANNOTATIONS", true));
\r
98 conservation.setEnabled( Cache.getDefault("SHOW_ANNOTATIONS", true));
\r
99 quality.setEnabled(Cache.getDefault("SHOW_ANNOTATIONS", true));
\r
100 identity.setEnabled(Cache.getDefault("SHOW_ANNOTATIONS", true));
\r
102 conservation.setSelected(Cache.getDefault("SHOW_CONSERVATION", true));
\r
103 quality.setSelected(Cache.getDefault("SHOW_QUALITY", true));
\r
104 identity.setSelected(Cache.getDefault("SHOW_IDENTITY", true));
\r
106 for (int i = 0; i < 13; i++)
\r
108 colour.addItem(ColourSchemeProperty.getColourName(i));
\r
111 String string = Cache.getDefault("DEFAULT_COLOUR", "None");
\r
113 colour.setSelectedItem(string);
\r
115 String[] fonts = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment()
\r
116 .getAvailableFontFamilyNames();
\r
118 for (int i = 0; i < fonts.length; i++)
\r
120 fontNameCB.addItem(fonts[i]);
\r
123 for (int i = 1; i < 31; i++)
\r
125 fontSizeCB.addItem(i + "");
\r
128 fontStyleCB.addItem("plain");
\r
129 fontStyleCB.addItem("bold");
\r
130 fontStyleCB.addItem("italic");
\r
132 fontNameCB.setSelectedItem(Cache.getDefault("FONT_NAME", "SansSerif"));
\r
133 fontSizeCB.setSelectedItem(Cache.getDefault("FONT_SIZE", "10"));
\r
134 fontStyleCB.setSelectedItem(Cache.getDefault("FONT_STYLE", Font.PLAIN + "") );
\r
136 smoothFont.setSelected(Cache.getDefault("ANTI_ALIAS", false));
\r
138 wrap.setSelected(Cache.getDefault("WRAP_ALIGNMENT", false));
\r
140 gapSymbolCB.addItem("-");
\r
141 gapSymbolCB.addItem(".");
\r
143 gapSymbolCB.setSelectedItem( Cache.getDefault("GAP_SYMBOL", "-"));
\r
145 startupCheckbox.setSelected( Cache.getDefault("SHOW_STARTUP_FILE", true) );
\r
146 startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE",
\r
147 "http://www.jalview.org/examples/exampleFile.jar"));
\r
149 sortby.addItem("No sort");
\r
150 sortby.addItem("Id");
\r
151 sortby.addItem("Pairwise Identity");
\r
152 sortby.setSelectedItem( Cache.getDefault("SORT_ALIGNMENT", "No sort") );
\r
154 epsRendering.addItem("Prompt each time");
\r
155 epsRendering.addItem("Lineart");
\r
156 epsRendering.addItem("Text");
\r
157 epsRendering.setSelectedItem( Cache.getDefault("EPS_RENDERING", "Prompt each time"));
\r
159 blcjv.setSelected( Cache.getDefault("BLC_JVSUFFIX", true) );
\r
160 clustaljv.setSelected( Cache.getDefault("CLUSTAL_JVSUFFIX", true) );
\r
161 fastajv.setSelected( Cache.getDefault("FASTA_JVSUFFIX", true) );
\r
162 msfjv.setSelected( Cache.getDefault("MSF_JVSUFFIX", true) );
\r
163 pfamjv.setSelected( Cache.getDefault("PFAM_JVSUFFIX", true) );
\r
164 pileupjv.setSelected( Cache.getDefault("PILEUP_JVSUFFIX", true) );
\r
165 pirjv.setSelected( Cache.getDefault("PIR_JVSUFFIX", true) );
\r
167 modellerOutput.setSelected( Cache.getDefault("PIR_MODELLER", false));
\r
169 autoCalculateConsCheck.setSelected( Cache.getDefault("AUTO_CALC_CONSENSUS", true));
\r
170 padGaps.setSelected( Cache.getDefault("PAD_GAPS", false));
\r
172 /****************************************************
\r
173 * Set up Connections
\r
175 nameLinks = new Vector();
\r
176 urlLinks = new Vector();
\r
177 for(int i=0; i<sequenceURLLinks.size(); i++)
\r
179 String link = sequenceURLLinks.elementAt(i).toString();
\r
180 nameLinks.addElement(link.substring(0, link.indexOf("|")) );
\r
181 urlLinks.addElement(link.substring(link.indexOf("|")+1));
\r
186 useProxy.setSelected( Cache.getDefault("USE_PROXY", false));
\r
187 proxyServerTB.setEnabled(useProxy.isSelected());
\r
188 proxyPortTB.setEnabled(useProxy.isSelected());
\r
189 proxyServerTB.setText( Cache.getDefault("PROXY_SERVER", ""));
\r
190 proxyPortTB.setText(Cache.getDefault("PROXY_PORT", ""));
\r
192 defaultBrowser.setText( Cache.getDefault("DEFAULT_BROWSER",""));
\r
197 catch (Exception ex)
\r
199 ex.printStackTrace();
\r
208 * @param e DOCUMENT ME!
\r
210 public void ok_actionPerformed(ActionEvent e)
\r
213 Cache.applicationProperties.setProperty("SHOW_JVSUFFIX", Boolean.toString(seqLimit.isSelected()));
\r
214 Cache.applicationProperties.setProperty("SHOW_FULLSCREEN", Boolean.toString(fullScreen.isSelected()));
\r
216 Cache.applicationProperties.setProperty("SHOW_ANNOTATIONS", Boolean.toString(annotations.isSelected()));
\r
217 Cache.applicationProperties.setProperty("SHOW_CONSERVATION", Boolean.toString(conservation.isSelected()));
\r
218 Cache.applicationProperties.setProperty("SHOW_QUALITY", Boolean.toString(quality.isSelected()));
\r
219 Cache.applicationProperties.setProperty("SHOW_IDENTITY", Boolean.toString(identity.isSelected()));
\r
221 Cache.applicationProperties.setProperty("DEFAULT_COLOUR", colour.getSelectedItem().toString());
\r
222 Cache.applicationProperties.setProperty("GAP_SYMBOL", gapSymbolCB.getSelectedItem().toString());
\r
224 Cache.applicationProperties.setProperty("FONT_NAME", fontNameCB.getSelectedItem().toString());
\r
225 Cache.applicationProperties.setProperty("FONT_STYLE", fontStyleCB.getSelectedItem().toString());
\r
226 Cache.applicationProperties.setProperty("FONT_SIZE", fontSizeCB.getSelectedItem().toString());
\r
228 Cache.applicationProperties.setProperty("ANTI_ALIAS", Boolean.toString(smoothFont.isSelected()));
\r
230 Cache.applicationProperties.setProperty("WRAP_ALIGNMENT", Boolean.toString(wrap.isSelected()));
\r
232 Cache.applicationProperties.setProperty("STARTUP_FILE", startupFileTextfield.getText());
\r
233 Cache.applicationProperties.setProperty("SHOW_STARTUP_FILE", Boolean.toString(startupCheckbox.isSelected()));
\r
235 Cache.applicationProperties.setProperty("SORT_ALIGNMENT", sortby.getSelectedItem().toString() );
\r
237 if(epsRendering.getSelectedItem().equals("Prompt each time"))
\r
238 Cache.applicationProperties.remove("EPS_RENDERING");
\r
240 Cache.applicationProperties.setProperty("EPS_RENDERING", epsRendering.getSelectedItem().toString());
\r
242 if(defaultBrowser.getText().trim().length()<1)
\r
243 Cache.applicationProperties.remove("DEFAULT_BROWSER");
\r
245 Cache.applicationProperties.setProperty("DEFAULT_BROWSER",
\r
246 defaultBrowser.getText());
\r
248 jalview.util.BrowserLauncher.resetBrowser();
\r
250 if(nameLinks.size()>0)
\r
252 StringBuffer links = new StringBuffer();
\r
253 sequenceURLLinks = new Vector();
\r
254 for (int i = 0; i < nameLinks.size(); i++)
\r
256 sequenceURLLinks.addElement(nameLinks.elementAt(i)+"|"+urlLinks.elementAt(i));
\r
257 links.append(sequenceURLLinks.elementAt(i).toString());
\r
261 links.setLength( links.length()-1 );
\r
262 Cache.applicationProperties.setProperty("SEQUENCE_LINKS", links.toString());
\r
265 Cache.applicationProperties.remove("SEQUENCE_LINKS");
\r
268 Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected()));
\r
270 if (proxyServerTB.getText().trim().length() < 1)
\r
271 Cache.applicationProperties.remove("PROXY_SERVER");
\r
273 Cache.applicationProperties.setProperty("PROXY_SERVER",
\r
274 proxyServerTB.getText());
\r
276 if (proxyPortTB.getText().trim().length() < 1)
\r
277 Cache.applicationProperties.remove("PROXY_PORT");
\r
279 Cache.applicationProperties.setProperty("PROXY_PORT", proxyPortTB.getText());
\r
281 if(useProxy.isSelected())
\r
283 System.setProperty("http.proxyHost", proxyServerTB.getText());
\r
284 System.setProperty("http.proxyPort", proxyPortTB.getText());
\r
288 System.setProperty("http.proxyHost","");
\r
289 System.setProperty("http.proxyPort","");
\r
293 Cache.applicationProperties.setProperty("BLC_JVSUFFIX", Boolean.toString(blcjv.isSelected()) );
\r
294 Cache.applicationProperties.setProperty("CLUSTAL_JVSUFFIX", Boolean.toString(clustaljv.isSelected()) );
\r
295 Cache.applicationProperties.setProperty("FASTA_JVSUFFIX", Boolean.toString(fastajv.isSelected()) );
\r
296 Cache.applicationProperties.setProperty("MSF_JVSUFFIX", Boolean.toString(msfjv.isSelected()) );
\r
297 Cache.applicationProperties.setProperty("PFAM_JVSUFFIX", Boolean.toString(pfamjv.isSelected()) );
\r
298 Cache.applicationProperties.setProperty("PILEUP_JVSUFFIX", Boolean.toString(pileupjv.isSelected()) );
\r
299 Cache.applicationProperties.setProperty("PIR_JVSUFFIX", Boolean.toString(pirjv.isSelected()) );
\r
300 Cache.applicationProperties.setProperty("PIR_MODELLER", Boolean.toString(modellerOutput.isSelected()) );
\r
301 jalview.io.PIRFile.useModellerOutput = modellerOutput.isSelected();
\r
303 Cache.applicationProperties.setProperty("AUTO_CALC_CONSENSUS",
\r
304 Boolean.toString(autoCalculateConsCheck.isSelected()));
\r
305 Cache.applicationProperties.setProperty("PAD_GAPS",
\r
306 Boolean.toString(padGaps.isSelected()));
\r
308 dasSource.saveProperties(Cache.applicationProperties);
\r
310 Cache.saveProperties();
\r
313 frame.setClosed(true);
\r
315 catch (Exception ex)
\r
323 public void startupFileTextfield_mouseClicked()
\r
325 JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty(
\r
329 "fa, fasta, fastq", "aln", "pfam", "msf", "pir", "blc",
\r
334 "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"
\r
335 }, jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT"));
\r
336 chooser.setFileView(new JalviewFileView());
\r
337 chooser.setDialogTitle("Select startup file");
\r
339 int value = chooser.showOpenDialog(this);
\r
341 if (value == JalviewFileChooser.APPROVE_OPTION)
\r
343 jalview.bin.Cache.applicationProperties.setProperty("DEFAULT_FILE_FORMAT",
\r
344 chooser.getSelectedFormat());
\r
345 startupFileTextfield.setText(chooser.getSelectedFile()
\r
346 .getAbsolutePath());
\r
353 * @param e DOCUMENT ME!
\r
355 public void cancel_actionPerformed(ActionEvent e)
\r
359 frame.setClosed(true);
\r
361 catch (Exception ex)
\r
369 * @param e DOCUMENT ME!
\r
371 public void annotations_actionPerformed(ActionEvent e)
\r
373 conservation.setEnabled(annotations.isSelected());
\r
374 quality.setEnabled(annotations.isSelected());
\r
375 identity.setEnabled(annotations.isSelected());
\r
379 public void newLink_actionPerformed(ActionEvent e) {
\r
381 GSequenceLink link = new GSequenceLink();
\r
382 boolean valid = false;
\r
385 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
\r
386 "New sequence URL link",
\r
387 JOptionPane.OK_CANCEL_OPTION
\r
389 == JOptionPane.OK_OPTION)
\r
391 if (link.checkValid())
\r
393 nameLinks.addElement(link.getName());
\r
394 urlLinks.addElement(link.getURL());
\r
404 public void editLink_actionPerformed(ActionEvent e) {
\r
405 GSequenceLink link = new GSequenceLink();
\r
407 int index = linkNameList.getSelectedIndex();
\r
410 JOptionPane.showInternalMessageDialog(Desktop.desktop, "No link selected!"
\r
411 ,"No link selected", JOptionPane.WARNING_MESSAGE);
\r
415 link.setName( nameLinks.elementAt(index).toString() );
\r
416 link.setURL( urlLinks.elementAt(index).toString() );
\r
418 boolean valid = false;
\r
422 if (JOptionPane.showInternalConfirmDialog(Desktop.desktop, link,
\r
423 "New sequence URL link",
\r
424 JOptionPane.OK_CANCEL_OPTION
\r
426 == JOptionPane.OK_OPTION)
\r
428 if (link.checkValid())
\r
430 nameLinks.setElementAt(link.getName(), index);
\r
431 urlLinks.setElementAt(link.getURL(), index);
\r
442 public void deleteLink_actionPerformed(ActionEvent e) {
\r
443 int index = linkNameList.getSelectedIndex();
\r
446 JOptionPane.showInternalMessageDialog(Desktop.desktop, "No link selected!"
\r
447 ,"No link selected", JOptionPane.WARNING_MESSAGE);
\r
450 nameLinks.removeElementAt(index);
\r
451 urlLinks.removeElementAt(index);
\r
455 void updateLinkData()
\r
457 linkNameList.setListData(nameLinks);
\r
458 linkURLList.setListData(urlLinks);
\r
461 public void defaultBrowser_mouseClicked(MouseEvent e)
\r
463 JFileChooser chooser = new JFileChooser(".");
\r
464 chooser.setDialogTitle("Select default web browser");
\r
466 int value = chooser.showOpenDialog(this);
\r
468 if (value == JFileChooser.APPROVE_OPTION)
\r
470 defaultBrowser.setText(chooser.getSelectedFile().getAbsolutePath());
\r
475 private void jbInit()
\r