From 67fe33692d163752fd467468b18ace4a9b4eac7d Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Fri, 20 May 2005 13:30:06 +0000 Subject: [PATCH] startup file added --- src/jalview/gui/Preferences.java | 40 ++++++++++++++++++++++++++++++-- src/jalview/jbgui/GPreferences.java | 43 +++++++++++++++++++++++++++++++++-- 2 files changed, 79 insertions(+), 4 deletions(-) diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 075065e..1553de5 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -2,12 +2,14 @@ package jalview.gui; import jalview.jbgui.*; import jalview.schemes.*; +import jalview.io.*; import jalview.bin.Cache; import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.*; + public class Preferences extends GPreferences { static boolean preferencesLoaded=false; @@ -23,6 +25,8 @@ public class Preferences extends GPreferences public static String fontStyle; public static char gapSymbol='-'; public static String defaultColour=null; + public static boolean showStartupFile=true; + public static String startupFile = "http://www.compbio.dundee.ac.uk/~andrew/jalviewTEST/fasta"; JInternalFrame frame; @@ -36,7 +40,6 @@ public class Preferences extends GPreferences if(string!=null) showFullscreen = Boolean.valueOf(string).booleanValue(); - string = Cache.getProperty("SHOW_ANNOTATIONS"); if(string!=null) showAnnotation = Boolean.valueOf(string).booleanValue(); @@ -67,6 +70,13 @@ public class Preferences extends GPreferences if(string!=null) defaultColour = string; + string = Cache.getProperty("STARTUP_FILE"); + if(string!=null) + startupFile = string; + + string = Cache.getProperty("SHOW_STARTUP_FILE"); + if(string!=null) + showStartupFile = Boolean.valueOf(string).booleanValue(); preferencesLoaded = true; } @@ -78,7 +88,7 @@ public class Preferences extends GPreferences frame = new JInternalFrame(); frame.setContentPane(this); - Desktop.addInternalFrame(frame, "Preferences", 480,350 ); + Desktop.addInternalFrame(frame, "Preferences", 480,390 ); fullID.setSelected(showFullId); String string = Cache.getProperty("SHOW_FULLSCREEN"); @@ -126,6 +136,9 @@ public class Preferences extends GPreferences gapSymbolCB.setSelectedItem( gapSymbol+"" ); + startupCheckbox.setSelected(showStartupFile); + startupFileTextfield.setText(startupFile); + } public void ok_actionPerformed(ActionEvent e) @@ -141,6 +154,8 @@ public class Preferences extends GPreferences fontName = fontNameCB.getSelectedItem().toString(); fontSize = fontSizeCB.getSelectedItem().toString(); fontStyle = fontStyleCB.getSelectedItem().toString(); + startupFile = startupFileTextfield.getText(); + showStartupFile = startupCheckbox.isSelected(); Cache.setProperty("SHOW_FULL_ID", Boolean.toString(showFullId)); Cache.setProperty("SHOW_FULLSCREEN", Boolean.toString( showFullscreen ) ); @@ -157,12 +172,33 @@ public class Preferences extends GPreferences Cache.setProperty("FONT_STYLE", fontStyle); Cache.setProperty("FONT_SIZE", fontSize); + Cache.setProperty("STARTUP_FILE", startupFile); + Cache.setProperty("SHOW_STARTUP_FILE", Boolean.toString(showStartupFile)); + + + try { frame.setClosed(true); } catch (Exception ex) {} } + public void startupFileTextfield_mouseClicked() + { + JalviewFileChooser chooser = new JalviewFileChooser(jalview.bin.Cache.getProperty("LAST_DIRECTORY"), + new String[]{"fa, fasta, fastq", "aln", "pfam", "msf", "pir","blc","jar"}, + new String[]{"Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "Jalview"} + ,null); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Select startup file"); + int value = chooser.showOpenDialog(this); + if(value == JalviewFileChooser.APPROVE_OPTION) + { + startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() ); + } + } + + public void cancel_actionPerformed(ActionEvent e) { try{ diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index a3091e4..d4929b4 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -5,6 +5,8 @@ import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import javax.swing.border.TitledBorder; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; public class GPreferences extends JPanel @@ -50,7 +52,7 @@ public class GPreferences quality.setText("Quality"); quality.setBounds(new Rectangle(248, 53, 81, 23)); jPanel2.setBorder(titledBorder1); - jPanel2.setBounds(new Rectangle(9, 20, 442, 206)); + jPanel2.setBounds(new Rectangle(9, 20, 442, 241)); jPanel2.setLayout(null); fullID.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); fullID.setHorizontalAlignment(SwingConstants.RIGHT); @@ -111,6 +113,29 @@ public class GPreferences fontNameCB.setBounds(new Rectangle(121, 109, 183, 21)); gapSymbolCB.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); gapSymbolCB.setBounds(new Rectangle(121, 140, 67, 21)); + startupCheckbox.setText("Open file"); + startupCheckbox.setBounds(new Rectangle(4, 200, 115, 23)); + startupCheckbox.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) + { + jCheckBox1_actionPerformed(e); + } + }); + startupCheckbox.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT); + startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT); + startupCheckbox.setSelected(true); + startupFileTextfield.setFont(new java.awt.Font("Verdana", Font.PLAIN, 11)); + startupFileTextfield.setBounds(new Rectangle(122, 202, 309, 20)); + startupFileTextfield.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + startupFileTextfield_mouseClicked(); + } + }); + jPanel2.add(annotations); jPanel2.add(conservation); jPanel2.add(quality); @@ -125,13 +150,14 @@ public class GPreferences jPanel2.add(fontStyleCB); jPanel2.add(identity); jPanel2.add(fullScreen); + jPanel2.add(startupCheckbox); + jPanel2.add(startupFileTextfield); jPanel1.add(ok); jPanel1.add(cancel); this.add(visaulTab, java.awt.BorderLayout.CENTER); visaulTab.add(visual, "visual"); visual.add(jPanel2); this.add(jPanel1, java.awt.BorderLayout.SOUTH); - DefaultListCellRenderer dlcr = new DefaultListCellRenderer(); dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER); gapSymbolCB.setRenderer(dlcr); @@ -160,6 +186,8 @@ public class GPreferences protected JComboBox fontStyleCB = new JComboBox(); protected JComboBox fontNameCB = new JComboBox(); protected JComboBox gapSymbolCB = new JComboBox(); + protected JCheckBox startupCheckbox = new JCheckBox(); + protected JTextField startupFileTextfield = new JTextField(); public void ok_actionPerformed(ActionEvent e) { @@ -175,4 +203,15 @@ public class GPreferences } + public void jCheckBox1_actionPerformed(ActionEvent e) + { + + } + + + public void startupFileTextfield_mouseClicked() + { + + } + } -- 1.7.10.2