+ JalviewColourChooser.showColourChooser(this,
+ MessageManager.getString("label.select_colour_minimum_value"),
+ panel);
+ }
+
+ @Override
+ public void maxColour_actionPerformed(JPanel panel)
+ {
+ JalviewColourChooser.showColourChooser(this,
+ MessageManager.getString("label.select_colour_maximum_value"),
+ panel);
+ }
+
+ @Override
+ public void gapColour_actionPerformed(JPanel gap)
+ {
+ if (!useLegacyGap.isSelected())
+ {
+ JalviewColourChooser.showColourChooser(this,
+ MessageManager.getString("label.select_gap_colour"), gap);
+ }
+ }
+
+ @Override
+ public void hiddenColour_actionPerformed(JPanel hidden)
+ {
+ JalviewColourChooser.showColourChooser(this,
+ MessageManager.getString("label.select_hidden_colour"), hidden);
+ }
+
+ @Override
+ protected void useLegacyGaps_actionPerformed(ActionEvent e)
+ {
+ boolean enabled = useLegacyGap.isSelected();
+ if (enabled)
+ {
+ gapColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_LEGACY_GAP);
+ }
+ else
+ {
+ gapColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_GAP);
+ }
+ gapColour.setEnabled(!enabled);
+ gapLabel.setEnabled(!enabled);
+ }
+
+ @Override
+ protected void resetOvDefaults_actionPerformed(ActionEvent e)
+ {
+ useLegacyGap.setSelected(false);
+ useLegacyGaps_actionPerformed(null);
+ showHiddenAtStart.setSelected(false);
+ hiddenColour.setBackground(
+ jalview.renderer.OverviewResColourFinder.OVERVIEW_DEFAULT_HIDDEN);
+ }
+
+ @Override
+ protected void userIdWidth_actionPerformed()
+ {
+ try
+ {
+ String val = userIdWidth.getText().trim();
+ if (val.length() > 0)
+ {
+ Integer iw = Integer.parseInt(val);
+ if (iw.intValue() < 12)
+ {
+ throw new NumberFormatException();
+ }
+ userIdWidth.setText(iw.toString());
+ }
+ } catch (NumberFormatException x)
+ {
+ userIdWidth.setText("");
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager
+ .getString("warn.user_defined_width_requirements"),
+ MessageManager.getString("label.invalid_id_column_width"),
+ JvOptionPane.WARNING_MESSAGE);
+ }
+ }
+
+ @Override
+ protected void autoIdWidth_actionPerformed()
+ {
+ userIdWidth.setEnabled(!autoIdWidth.isSelected());
+ userIdWidthlabel.setEnabled(!autoIdWidth.isSelected());
+ }
+
+ /**
+ * Returns true if structure viewer path is to a valid executable, else shows
+ * an error dialog. Does nothing if the path is empty, as is the case for Jmol
+ * (built in to Jalview) or when Jalview is left to try default paths.
+ */
+ private boolean validateViewerPath()
+ {
+ if (structureViewerPath.getText().trim().length() > 0)
+ {
+ File f = new File(structureViewerPath.getText());
+ if (!f.canExecute())
+ {
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ MessageManager.getString("label.invalid_viewer_path"),
+ MessageManager.getString("label.invalid_viewer_path"),
+ JvOptionPane.ERROR_MESSAGE);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * If Chimera or ChimeraX or Pymol 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.JMOL.name()))
+ {
+ structureViewerPath.setEnabled(false);
+ structureViewerPathLabel.setEnabled(false);
+ return;
+ }
+ boolean found = false;
+ structureViewerPath.setEnabled(true);
+ structureViewerPathLabel.setEnabled(true);
+ structureViewerPathLabel.setText(MessageManager
+ .formatMessage("label.viewer_path", selectedItem));
+
+ /*
+ * Try user-specified and standard paths for structure viewer executable
+ */
+ String viewerPath = "";
+ List<String> paths = null;
+ try
+ {
+ ViewerType viewerType = ViewerType.valueOf(selectedItem);
+ switch (viewerType)
+ {
+ case JMOL:
+ // dealt with above
+ break;
+ case CHIMERA:
+ viewerPath = Cache.getDefault(CHIMERA_PATH, "");
+ paths = StructureManager.getChimeraPaths(false);
+ break;
+ case CHIMERAX:
+ viewerPath = Cache.getDefault(CHIMERAX_PATH, "");
+ paths = StructureManager.getChimeraPaths(true);
+ break;
+ case PYMOL:
+ viewerPath = Cache.getDefault(PYMOL_PATH, "");
+ paths = PymolManager.getPymolPaths();
+ break;
+ }
+ } catch (IllegalArgumentException e)
+ {
+ // only valid entries should be in the drop-down
+ }
+ structureViewerPath.setText(viewerPath);
+
+ paths.add(0, structureViewerPath.getText());
+ for (String path : paths)
+ {
+ if (new File(path.trim()).canExecute())
+ {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ String[] options = { "OK", "Help" };
+ int showHelp = JvOptionPane.showInternalOptionDialog(Desktop.desktop,
+ JvSwingUtils.wrapTooltip(true,
+ MessageManager.getString("label.viewer_missing")),
+ "", JvOptionPane.YES_NO_OPTION, JvOptionPane.WARNING_MESSAGE,
+ null, options, options[0]);
+
+ if (showHelp == JvOptionPane.NO_OPTION)
+ {
+ this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
+ try
+ {
+ Help.showHelpWindow(HelpId.StructureViewer);
+ } catch (HelpSetException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else if (showHelp == JvOptionPane.OK_OPTION)
+ {
+ this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null);
+ CompletableFuture<Void> cf = CompletableFuture.runAsync(() -> {
+ try
+ {
+ for (int i = 0; i < 3; i++)
+ {
+ structureViewerPath.setBackground(Color.PINK);
+ Thread.sleep(500);
+ structureViewerPath.setBackground(Color.WHITE);
+ Thread.sleep(500);
+ }
+ } catch (InterruptedException e)
+ {
+ }
+ });
+ }
+ }
+ }
+
+ 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();
+ }
+ }
+
+ private class UrlListSelectionHandler implements ListSelectionListener
+ {
+
+ @Override
+ public void valueChanged(ListSelectionEvent e)
+ {
+ ListSelectionModel lsm = (ListSelectionModel) e.getSource();
+
+ int index = lsm.getMinSelectionIndex();
+ if (index == -1)
+ {
+ // no selection, so disable delete/edit buttons
+ editLink.setEnabled(false);
+ deleteLink.setEnabled(false);
+ return;
+ }
+ int modelIndex = linkUrlTable.convertRowIndexToModel(index);
+
+ // enable/disable edit and delete link buttons
+ if (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isRowDeletable(modelIndex))
+ {
+ deleteLink.setEnabled(true);
+ }
+ else
+ {
+ deleteLink.setEnabled(false);
+ }
+
+ if (((UrlLinkTableModel) linkUrlTable.getModel())
+ .isRowEditable(modelIndex))
+ {
+ editLink.setEnabled(true);
+ }
+ else
+ {
+ editLink.setEnabled(false);
+ }
+ }