From: gmungoc Date: Thu, 13 Nov 2014 12:40:33 +0000 (+0000) Subject: JAL-1528 new Preference CHIMERA_PATH (Preferences | Structure) X-Git-Tag: Release_2_8_2b1^2~33^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=739296345a62ffba3edcd23c1213d60db89e7c7e;p=jalview.git JAL-1528 new Preference CHIMERA_PATH (Preferences | Structure) --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 9eee9cc..511e5e9 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -248,6 +248,9 @@ label.use_rnaview = Use RNAView for secondary structure label.autoadd_secstr = Add secondary structure annotation to alignment label.autoadd_temp = Add Temperature Factor annotation to alignment label.structure_viewer = Default structure viewer +label.chimera_path = Path to Chimera program +label.chimera_path_tip = Jalview will try standard locations, plus any path entered here. +label.invalid_path = File not found or not executable label.min_colour = Minimum Colour label.max_colour = Maximum Colour label.use_original_colours = Use Original Colours diff --git a/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java b/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java index ec956d7..1208638 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java @@ -1,12 +1,14 @@ package ext.edu.ucsf.rbvi.strucviz2; +import jalview.bin.Cache; +import jalview.gui.Preferences; + import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Properties; @@ -32,10 +34,6 @@ public class StructureManager static final String[] defaultResidueKeys = { "FunctionalResidues", "ResidueList", "Residues" }; - private final String chimeraPropertyName = "chimera"; - - private final String chimeraPathPropertyKey = "LastChimeraPath"; - public enum ModelType { PDB_MODEL, MODBASE_MODEL, SMILES @@ -494,7 +492,9 @@ public class StructureManager // we do not care about the model anymore selSpec = selSpec.concat(nodeInfo.toSpec()); if (i < chimSelectionList.size() - 1) + { selSpec.concat("|"); + } } if (selSpec.length() > 0) { @@ -665,7 +665,9 @@ public class StructureManager for (ChimeraStructuralObject cso : chimSelectionList) { if (cso != null) + { cso.setSelected(false); + } } chimSelectionList.clear(); } @@ -879,17 +881,16 @@ public class StructureManager } } - // if no network settings, check if the last chimera path is saved in the - // session - // String lastPath = CytoUtils.getDefaultChimeraPath(registrar, - // chimeraPropertyName, - // chimeraPathPropertyKey); - // if (lastPath != null && !lastPath.equals("")) { - // pathList.add(lastPath); - // return pathList; - // } + /* + * Jalview addition: check if path set in user preferences. + */ + String userPath = Cache.getDefault(Preferences.CHIMERA_PATH, null); + if (userPath != null) + { + pathList.add(userPath); + } - // if no user settings and no last path, get default system's settings + // Add default installation paths String os = System.getProperty("os.name"); if (os.startsWith("Linux")) { diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index a48b750..24ed1b4 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -173,6 +173,7 @@ import org.apache.log4j.SimpleLayout; * display *
  • STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure * display
  • + *
  • CHIMERA_PATH specify full path to Chimera program (if non-standard)
  • * * * Deprecated settings: @@ -906,4 +907,27 @@ public class Cache } return sourceRegistry; } + + /** + * Set the specified value, or remove it if null or empty. Does not save the + * properties file. + * + * @param propName + * @param value + */ + public static void setOrRemove(String propName, String value) + { + if (propName == null) + { + return; + } + if (value == null || value.trim().length() < 1) + { + Cache.applicationProperties.remove(propName); + } + else + { + Cache.applicationProperties.setProperty(propName, value); + } + } } diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 2e8aa89..ab4f94f 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -35,7 +35,9 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.io.File; import java.util.Collection; import java.util.StringTokenizer; import java.util.Vector; @@ -65,6 +67,8 @@ public class Preferences extends GPreferences public static final String STRUCTURE_DISPLAY = "STRUCTURE_DISPLAY"; + public static final String CHIMERA_PATH = "CHIMERA_PATH"; + public static final String SORT_ANNOTATIONS = "SORT_ANNOTATIONS"; public static final String SHOW_AUTOCALC_ABOVE = "SHOW_AUTOCALC_ABOVE"; @@ -281,6 +285,25 @@ public class Preferences extends GPreferences addTempFactor.setEnabled(structSelected); structViewer.setSelectedItem(Cache.getDefault(STRUCTURE_DISPLAY, Viewer.JMOL.name())); + chimeraPath.setText(Cache.getDefault(CHIMERA_PATH, "")); + chimeraPath.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + if (chimeraPath.getText().trim().length() > 0) + { + File f = new File(chimeraPath.getText()); + if (!f.canExecute()) + { + JOptionPane.showInternalMessageDialog(Desktop.desktop, + MessageManager.getString("label.invalid_path"), + MessageManager.getString("label.invalid_name"), + JOptionPane.ERROR_MESSAGE); + } + } + } + }); /* * Set Connections tab defaults @@ -449,6 +472,7 @@ public class Preferences extends GPreferences Boolean.toString(structFromPdb.isSelected())); Cache.applicationProperties.setProperty(STRUCTURE_DISPLAY, structViewer .getSelectedItem().toString()); + Cache.setOrRemove(CHIMERA_PATH, chimeraPath.getText()); /* * Save Output settings @@ -466,15 +490,7 @@ public class Preferences extends GPreferences /* * Save Connections settings */ - if (defaultBrowser.getText().trim().length() < 1) - { - Cache.applicationProperties.remove("DEFAULT_BROWSER"); - } - else - { - Cache.applicationProperties.setProperty("DEFAULT_BROWSER", - defaultBrowser.getText()); - } + Cache.setOrRemove("DEFAULT_BROWSER", defaultBrowser.getText()); jalview.util.BrowserLauncher.resetBrowser(); @@ -502,25 +518,9 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("USE_PROXY", Boolean.toString(useProxy.isSelected())); - if (proxyServerTB.getText().trim().length() < 1) - { - Cache.applicationProperties.remove("PROXY_SERVER"); - } - else - { - Cache.applicationProperties.setProperty("PROXY_SERVER", - proxyServerTB.getText()); - } + Cache.setOrRemove("PROXY_SERVER", proxyServerTB.getText()); - if (proxyPortTB.getText().trim().length() < 1) - { - Cache.applicationProperties.remove("PROXY_PORT"); - } - else - { - Cache.applicationProperties.setProperty("PROXY_PORT", - proxyPortTB.getText()); - } + Cache.setOrRemove("PROXY_PORT", proxyPortTB.getText()); if (useProxy.isSelected()) { diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index cd3064e..a232377 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -140,6 +140,8 @@ public class GPreferences extends JPanel protected JComboBox structViewer = new JComboBox(); + protected JTextField chimeraPath = new JTextField(); + /* * Colours tab components */ @@ -744,11 +746,26 @@ public class GPreferences extends JPanel structureTab.add(viewerLabel); structViewer.setFont(verdana11); - structViewer.setBounds(new Rectangle(150, ypos, 120, height)); + structViewer.setBounds(new Rectangle(160, ypos, 120, height)); structViewer.addItem(Viewer.JMOL.name()); structViewer.addItem(Viewer.CHIMERA.name()); structureTab.add(structViewer); + ypos += lineSpacing; + JLabel pathLabel = new JLabel(); + pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11)); + pathLabel.setHorizontalAlignment(SwingConstants.LEFT); + pathLabel.setText(MessageManager.getString("label.chimera_path")); + pathLabel.setToolTipText(MessageManager + .getString("label.chimera_path_tip")); + pathLabel.setBounds(new Rectangle(10, ypos, 140, height)); + structureTab.add(pathLabel); + + chimeraPath.setFont(verdana11); + chimeraPath.setText(""); + chimeraPath.setBounds(new Rectangle(160, ypos, 300, height)); + structureTab.add(chimeraPath); + return structureTab; }