X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=398c5bed6d1ee1201fcfae0b5e65bc2e9792f068;hb=8f2acf658e855209c6db6b68d5cc0779733c3d7e;hp=264ef03930c55736f6df5cabe9a81cb4e52c92ac;hpb=62fcb83be442a0d2bbce77423a6bfed2303f6959;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 264ef03..398c5be 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; @@ -18,11 +20,13 @@ public class Preferences extends GPreferences public static boolean showConservation=true; public static boolean showQuality=true; public static boolean showIdentity=true; - public static String fontName; - public static String fontSize; - public static String fontStyle; + public static String fontName="SansSerif"; + public static String fontSize="10"; + public static String fontStyle=Font.PLAIN+""; 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(); @@ -51,25 +54,49 @@ public class Preferences extends GPreferences if(string!=null) showIdentity = Boolean.valueOf(string).booleanValue(); + string = Cache.getProperty("GAP_SYMBOL"); + if(string!=null) + gapSymbol = string.charAt(0); + string = Cache.getProperty("SHOW_FULL_ID"); if(string!=null) showFullId = Boolean.valueOf(string).booleanValue(); - fontName = Cache.getProperty("FONT_NAME"); - fontStyle = Cache.getProperty("FONT_STYLE"); - fontSize = Cache.getProperty("FONT_SIZE"); + string = Cache.getProperty("FONT_NAME"); + if (string != null) + fontName = string; + + string = Cache.getProperty("FONT_STYLE"); + if (string != null) + fontStyle = string; + + string = Cache.getProperty("FONT_SIZE"); + if (string != null) + fontSize = string; + + + string = Cache.getProperty("DEFAULT_COLOUR"); + 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; } public Preferences() { - if(!preferencesLoaded) - initPreferences(); + initPreferences(); 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"); @@ -117,6 +144,9 @@ public class Preferences extends GPreferences gapSymbolCB.setSelectedItem( gapSymbol+"" ); + startupCheckbox.setSelected(showStartupFile); + startupFileTextfield.setText(startupFile); + } public void ok_actionPerformed(ActionEvent e) @@ -132,6 +162,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 ) ); @@ -148,12 +180,34 @@ 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"} + ,jalview.bin.Cache.getProperty("DEFAULT_FILE_FORMAT")); + chooser.setFileView(new JalviewFileView()); + chooser.setDialogTitle("Select startup file"); + int value = chooser.showOpenDialog(this); + if(value == JalviewFileChooser.APPROVE_OPTION) + { + jalview.bin.Cache.setProperty("DEFAULT_FILE_FORMAT", chooser.getSelectedFormat()); + startupFileTextfield.setText( chooser.getSelectedFile().getAbsolutePath() ); + } + } + + public void cancel_actionPerformed(ActionEvent e) { try{