From e8479b912a9f5caf2e86d2dee10f153955522e33 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 27 Nov 2014 11:56:25 +0000 Subject: [PATCH] JAL-1603 if Chimera selected in Preferences, warn if not installed/found --- help/html/features/chimera.html | 5 +- help/html/features/viewingpdbs.html | 3 +- resources/lang/Messages.properties | 1 + .../edu/ucsf/rbvi/strucviz2/StructureManager.java | 24 +++++---- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 6 +-- src/jalview/gui/Help.java | 3 +- src/jalview/gui/Preferences.java | 57 +++++++++++++++++++- src/jalview/jbgui/GPreferences.java | 18 +++++++ 8 files changed, 97 insertions(+), 20 deletions(-) diff --git a/help/html/features/chimera.html b/help/html/features/chimera.html index 236701a..dbaad73 100644 --- a/help/html/features/chimera.html +++ b/help/html/features/chimera.html @@ -24,7 +24,7 @@

The Chimera Viewer

-

Since Jalview 2.8.2, Chimera +

Since Jalview 2.8.2, Chimera (http://www.cgl.ucsf.edu/chimera/) has been integrated into Jalview for interactively viewing structures opened by entries in the "Structure" submenu in the sequence id pop-up menu (if you can't see this, then you need to -

Basic screen operations (see Chimera help for full details). +

Basic screen operations (see Chimera help +(http://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/mouse.html) for full details). diff --git a/help/html/features/viewingpdbs.html b/help/html/features/viewingpdbs.html index 75a5c9c..99f17fe 100755 --- a/help/html/features/viewingpdbs.html +++ b/help/html/features/viewingpdbs.html @@ -31,8 +31,7 @@

The Jmol viewer has been included since Jalview - 2.3. Jalview 2.8.2 included support for - Chimera, provided it is + 2.3. Jalview 2.8.2 included support for Chimera, provided it is installed and can be launched by Jalview. The default viewer can be configured in the Structure tab in the diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index cabee76..795dfa0 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -251,6 +251,7 @@ label.structure_viewer = Default structure viewer label.chimera_path = Path to Chimera program label.chimera_path_tip = Jalview will first try any path entered here, else standard installation locations.
Double-click to browse for file. label.invalid_chimera_path = Chimera path not found or not executable +label.chimera_missing = Chimera structure viewer not found.
Please enter the path to Chimera (if installed),
or download and install UCSF Chimera. 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 1208638..4797b37 100644 --- a/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java +++ b/src/ext/edu/ucsf/rbvi/strucviz2/StructureManager.java @@ -864,22 +864,24 @@ public class StructureManager StructureSettings defaultSettings = null; // TODO: [Optional] Change priority of Chimera paths - public List getChimeraPaths() + public static List getChimeraPaths() { List pathList = new ArrayList(); // if no network is available and the settings have been modified by the // user, check for a // path to chimera - if (defaultSettings != null) - { - String defaultPath = defaultSettings.getChimeraPath(); - if (defaultPath != null && !defaultPath.equals("")) - { - pathList.add(defaultPath); - return pathList; - } - } + // + // For Jalview, Preferences/Cache plays this role instead + // if (defaultSettings != null) + // { + // String defaultPath = defaultSettings.getChimeraPath(); + // if (defaultPath != null && !defaultPath.equals("")) + // { + // pathList.add(defaultPath); + // return pathList; + // } + // } /* * Jalview addition: check if path set in user preferences. @@ -887,7 +889,7 @@ public class StructureManager String userPath = Cache.getDefault(Preferences.CHIMERA_PATH, null); if (userPath != null) { - pathList.add(userPath); + pathList.add(0, userPath); } // Add default installation paths diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 0042041..82f5e5c 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -954,7 +954,7 @@ public abstract class JalviewChimeraBinding extends } } - boolean debug = true; + boolean debug = false; private void log(String message) { @@ -963,8 +963,8 @@ public abstract class JalviewChimeraBinding extends private void viewerCommandHistory(boolean enable) { - log("(Not yet implemented) History " - + ((debug || enable) ? "on" : "off")); + // log("(Not yet implemented) History " + // + ((debug || enable) ? "on" : "off")); } public void loadInline(String string) diff --git a/src/jalview/gui/Help.java b/src/jalview/gui/Help.java index ae3f457..b07cc4e 100644 --- a/src/jalview/gui/Help.java +++ b/src/jalview/gui/Help.java @@ -17,7 +17,8 @@ public class Help { public enum HelpId { - Home("home"), SequenceFeatureSettings("seqfeatures.settings"); + Home("home"), SequenceFeatureSettings("seqfeatures.settings"), StructureViewer( + "viewingpdbs"); private String id; diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index b082bc6..bdc83e5 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -22,6 +22,7 @@ package jalview.gui; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; +import jalview.gui.Help.HelpId; import jalview.gui.StructureViewer.Viewer; import jalview.io.JalviewFileChooser; import jalview.io.JalviewFileView; @@ -39,15 +40,19 @@ import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.io.File; import java.util.Collection; +import java.util.List; import java.util.StringTokenizer; import java.util.Vector; +import javax.help.HelpSetException; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JInternalFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; +import ext.edu.ucsf.rbvi.strucviz2.StructureManager; + /** * DOCUMENT ME! * @@ -596,7 +601,8 @@ public class Preferences extends GPreferences } /** - * Do any necessary validation before saving settings. + * Do any necessary validation before saving settings. Return focus to the + * first tab which fails validation. * * @return */ @@ -879,4 +885,53 @@ public class Preferences extends GPreferences return true; } + /** + * If Chimera is selected, check it can be found on default or user-specified + * path, if not show a warning/help dialog. + */ + @Override + protected void structureViewer_actionPerformed(String selectedItem) + { + if (!selectedItem.equals(Viewer.CHIMERA.name())) + { + return; + } + boolean found = false; + + /* + * Try user-specified and standard paths for Chimera executable. + */ + List paths = StructureManager.getChimeraPaths(); + paths.add(0, chimeraPath.getText()); + for (String path : paths) + { + if (new File(path.trim()).canExecute()) + { + found = true; + break; + } + } + if (!found) + { + String[] options = + { "OK", "Help" }; + int showHelp = JOptionPane.showInternalOptionDialog( + Desktop.desktop, + JvSwingUtils.wrapTooltip(true, + MessageManager.getString("label.chimera_missing")), + "", JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE, null, options, options[0]); + if (showHelp == JOptionPane.NO_OPTION) + { + try + { + Help.showHelpWindow(HelpId.StructureViewer); + } catch (HelpSetException e) + { + e.printStackTrace(); + } + } + } + } + } diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index 5569c24..610f32e 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -782,6 +782,15 @@ public class GPreferences extends JPanel structViewer.setBounds(new Rectangle(160, ypos, 120, height)); structViewer.addItem(Viewer.JMOL.name()); structViewer.addItem(Viewer.CHIMERA.name()); + structViewer.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + structureViewer_actionPerformed((String) structViewer + .getSelectedItem()); + } + }); structureTab.add(structViewer); ypos += lineSpacing; @@ -819,6 +828,15 @@ public class GPreferences extends JPanel } /** + * Action on choosing a structure viewer from combobox options. + * + * @param selectedItem + */ + protected void structureViewer_actionPerformed(String selectedItem) + { + } + + /** * Show a dialog for the user to choose a file. Returns the chosen path, or * null on Cancel. * -- 1.7.10.2
Action