X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FPreferences.java;h=b9f30e35e7dfeeefdb419c28d84517bc0ff67ee1;hb=cb8e52fbbc5f725e3f7f48c672cdddb0690bd978;hp=8eb066473448966a41b5c0aeba8704b308614271;hpb=726bda0e9aea2d68b90803e142346cc46c8d4772;p=jalview.git diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 8eb0664..b9f30e3 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -31,6 +31,7 @@ import java.awt.event.MouseEvent; import java.io.File; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.CompletableFuture; import javax.help.HelpSetException; import javax.swing.JComboBox; @@ -53,6 +54,7 @@ import javax.swing.table.TableRowSorter; import ext.edu.ucsf.rbvi.strucviz2.StructureManager; import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; import jalview.bin.Cache; +import jalview.bin.Console; import jalview.bin.MemorySetting; import jalview.ext.pymol.PymolManager; import jalview.gui.Help.HelpId; @@ -146,10 +148,10 @@ public class Preferences extends GPreferences /** * Holds name and link separated with | character. Sequence IDS and Sequences - * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and - * $SEQUENCES$ or $SEQUENCES=/.possible | chars ./=$ and separation character - * for first and second token specified after a pipe character at end |,|. - * (TODO: proper escape for using | to separate ids or sequences + * must be $SEQUENCEIDS$ or $SEQUENCEIDS=/.possible | chars ./=$ and $SEQUENCES$ + * or $SEQUENCES=/.possible | chars ./=$ and separation character for first and + * second token specified after a pipe character at end |,|. (TODO: proper + * escape for using | to separate ids or sequences */ public static List groupURLLinks; @@ -220,19 +222,27 @@ public class Preferences extends GPreferences public static void openPreferences() { - openPreferences(0, null); + openPreferences(null, null); } - public static void openPreferences(int selectTab, String message) + public static void openPreferences(TabRef selectTab, String message) { Preferences p = getInstance(); - p.selectTab(selectTab); - p.setMessage(message); + if (selectTab != null) + p.selectTab(selectTab, message); p.frame.show(); p.frame.moveToFront(); p.frame.grabFocus(); } + public void selectTab(TabRef selectTab, String message) + { + this.selectTab(selectTab); + if (message != null) + this.setMessage(message); + this.frame.show(); + } + /** * Creates a new Preferences object. */ @@ -347,8 +357,8 @@ public class Preferences extends GPreferences startupCheckbox .setSelected(Cache.getDefault("SHOW_STARTUP_FILE", true)); startupFileTextfield.setText(Cache.getDefault("STARTUP_FILE", - Cache.getDefault("www.jalview.org", "http://www.jalview.org") - + "/examples/exampleFile_2_3.jar")); + Cache.getDefault("www.jalview.org", "https://www.jalview.org") + + "/examples/exampleFile_2_7.jvp")); /* * Set Colours tab defaults @@ -388,13 +398,11 @@ public class Preferences extends GPreferences /* * Set Structure tab defaults */ - final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, false); + final boolean structSelected = Cache.getDefault(STRUCT_FROM_PDB, true); structFromPdb.setSelected(structSelected); - useRnaView.setSelected(Cache.getDefault(USE_RNAVIEW, false)); - useRnaView.setEnabled(structSelected); - addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, false)); + addSecondaryStructure.setSelected(Cache.getDefault(ADD_SS_ANN, true)); addSecondaryStructure.setEnabled(structSelected); - addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, false)); + addTempFactor.setSelected(Cache.getDefault(ADD_TEMPFACT_ANN, true)); addTempFactor.setEnabled(structSelected); /* @@ -425,7 +433,7 @@ public class Preferences extends GPreferences } } catch (IllegalArgumentException e) { - Cache.log.error("Unknown structure viewer type: " + viewerType + Console.error("Unknown structure viewer type: " + viewerType + ", defaulting to Jmol"); type = ViewerType.JMOL; } @@ -438,11 +446,27 @@ public class Preferences extends GPreferences { if (validateViewerPath()) { - Cache.setProperty( - structViewer.getSelectedItem().equals( - ViewerType.CHIMERAX.name()) ? CHIMERAX_PATH - : CHIMERA_PATH, - structureViewerPath.getText()); + String path = structureViewerPath.getText(); + try { + ViewerType type = ViewerType.valueOf(viewerType); + switch (type) + { + case JMOL: + break; + case CHIMERA: + Cache.setProperty(CHIMERA_PATH, path); + break; + case CHIMERAX: + Cache.setProperty(CHIMERAX_PATH, path); + break; + case PYMOL: + Cache.setProperty(PYMOL_PATH, path); + break; + } + } catch (IllegalArgumentException x) + { + Console.error("Failed to set path - unknown viewer type",x); + } } } }); @@ -597,7 +621,7 @@ public class Preferences extends GPreferences proxyType.setSelected(customProxy.getModel(), true); break; default: - Cache.log.warn( + Console.warn( "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): " + proxyTypeString); } @@ -826,8 +850,6 @@ public class Preferences extends GPreferences Boolean.toString(addTempFactor.isSelected())); Cache.applicationProperties.setProperty(ADD_SS_ANN, Boolean.toString(addSecondaryStructure.isSelected())); - Cache.applicationProperties.setProperty(USE_RNAVIEW, - Boolean.toString(useRnaView.isSelected())); Cache.applicationProperties.setProperty(STRUCT_FROM_PDB, Boolean.toString(structFromPdb.isSelected())); String viewer = structViewer.getSelectedItem().toString(); @@ -1030,8 +1052,8 @@ public class Preferences extends GPreferences } /** - * Do any necessary validation before saving settings. Return focus to the - * first tab which fails validation. + * Do any necessary validation before saving settings. Return focus to the first + * tab which fails validation. * * @return */ @@ -1085,7 +1107,7 @@ public class Preferences extends GPreferences * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ @Override public void cancel_actionPerformed(ActionEvent e) @@ -1107,7 +1129,7 @@ public class Preferences extends GPreferences * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ @Override public void annotations_actionPerformed(ActionEvent e) @@ -1168,7 +1190,7 @@ public class Preferences extends GPreferences if (index == -1) { // button no longer enabled if row is not selected - Cache.log.debug("Edit with no row selected in linkUrlTable"); + Console.debug("Edit with no row selected in linkUrlTable"); return; } @@ -1220,7 +1242,7 @@ public class Preferences extends GPreferences if (index == -1) { // button no longer enabled if row is not selected - Cache.log.debug("Delete with no row selected in linkUrlTable"); + Console.debug("Delete with no row selected in linkUrlTable"); return; } else @@ -1370,8 +1392,8 @@ public class Preferences extends GPreferences } /** - * 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 + * 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() @@ -1392,8 +1414,8 @@ public class Preferences extends GPreferences } /** - * 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 + * 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) @@ -1460,8 +1482,10 @@ public class Preferences extends GPreferences 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); @@ -1470,6 +1494,24 @@ public class Preferences extends GPreferences e.printStackTrace(); } } + else if (showHelp == JvOptionPane.OK_OPTION) + { + this.selectTab(Preferences.TabRef.STRUCTURE_TAB, null); + CompletableFuture 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) + { + } + }); + } } }