+ /**
+ * Returns true if chimera path is to a valid executable, else show an error
+ * dialog.
+ */
+ private boolean validateChimeraPath()
+ {
+ if (chimeraPath.getText().trim().length() > 0)
+ {
+ File f = new File(chimeraPath.getText());
+ if (!f.canExecute())
+ {
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.invalid_chimera_path"),
+ MessageManager.getString("label.invalid_name"),
+ JOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ }
+ 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(ViewerType.CHIMERA.name()))
+ {
+ return;
+ }
+ boolean found = false;
+
+ /*
+ * Try user-specified and standard paths for Chimera executable.
+ */
+ List<String> 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();
+ }
+ }
+ }
+ }
+
+ public class OptionsParam
+ {
+ private String name;
+
+ private String code;
+
+ public OptionsParam(String name, String code)
+ {
+ this.name = name;
+ this.code = code;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getCode()
+ {
+ return code;
+ }
+
+ public void setCode(String code)
+ {
+ this.code = code;
+ }
+
+ @Override
+ public String toString()
+ {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object that)
+ {
+ if (!(that instanceof OptionsParam))
+ {
+ return false;
+ }
+ return this.code.equalsIgnoreCase(((OptionsParam) that).code);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return name.hashCode() + code.hashCode();
+ }
+ }