From: gmungoc Date: Tue, 2 May 2017 13:07:49 +0000 (+0100) Subject: JAL-2447 EXPERIMENTAL preference (option in Tools menu) X-Git-Tag: Release_2_10_2~3^2~82^2 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=124aa4823768a2c745a5e41f2ebfe13ab77bbea4 JAL-2447 EXPERIMENTAL preference (option in Tools menu) --- diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 915ef6f..354dc93 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -1300,3 +1300,5 @@ warn.name_cannot_be_duplicate = User-defined URL names must be unique and cannot label.invalid_name = Invalid Name ! label.output_seq_details = Output Sequence Details to list all database references label.urllinks = Links +label.show_experimental = Enable experimental features +label.show_experimental_tip = Enable any new and currently 'experimental' features (see Latest Release Notes for details) \ No newline at end of file diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index ec9feb7..ab6f6c8 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -100,35 +100,41 @@ public class ChimeraViewFrame extends StructureViewerBase savemenu.setVisible(false); // not yet implemented viewMenu.add(fitToWindow); - JMenuItem writeFeatures = new JMenuItem( - MessageManager.getString("label.create_chimera_attributes")); - writeFeatures.setToolTipText(MessageManager - .getString("label.create_chimera_attributes_tip")); - writeFeatures.addActionListener(new ActionListener() + /* + * exchange of Jalview features and Chimera attributes is for now + * an optionally enabled experimental feature + */ + if (Desktop.instance.showExperimental()) { - @Override - public void actionPerformed(ActionEvent e) + JMenuItem writeFeatures = new JMenuItem( + MessageManager.getString("label.create_chimera_attributes")); + writeFeatures.setToolTipText(MessageManager + .getString("label.create_chimera_attributes_tip")); + writeFeatures.addActionListener(new ActionListener() { - sendFeaturesToChimera(); - } - }); - viewerActionMenu.add(writeFeatures); - - final JMenu fetchAttributes = new JMenu( - MessageManager.getString("label.fetch_chimera_attributes")); - fetchAttributes.setToolTipText(MessageManager - .getString("label.fetch_chimera_attributes_tip")); - fetchAttributes.addMouseListener(new MouseAdapter() - { - - @Override - public void mouseEntered(MouseEvent e) + @Override + public void actionPerformed(ActionEvent e) + { + sendFeaturesToChimera(); + } + }); + viewerActionMenu.add(writeFeatures); + + final JMenu fetchAttributes = new JMenu( + MessageManager.getString("label.fetch_chimera_attributes")); + fetchAttributes.setToolTipText(MessageManager + .getString("label.fetch_chimera_attributes_tip")); + fetchAttributes.addMouseListener(new MouseAdapter() { - buildAttributesMenu(fetchAttributes); - } - }); - viewerActionMenu.add(fetchAttributes); + @Override + public void mouseEntered(MouseEvent e) + { + buildAttributesMenu(fetchAttributes); + } + }); + viewerActionMenu.add(fetchAttributes); + } } /** diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 7d0eb7f..b8f8399 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -129,6 +129,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements DropTargetListener, ClipboardOwner, IProgressIndicator, jalview.api.StructureSelectionManagerProvider { + private static final String EXPERIMENTAL_FEATURES = "EXPERIMENTAL_FEATURES"; private JalviewChangeSupport changeSupport = new JalviewChangeSupport(); @@ -327,19 +328,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements instance = this; doVamsasClientCheck(); - groovyShell = new JMenuItem(); - groovyShell.setText(MessageManager.getString("label.groovy_console")); - groovyShell.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - groovyShell_actionPerformed(); - } - }); - toolsMenu.add(groovyShell); - groovyShell.setVisible(true); - doConfigureStructurePrefs(); setTitle("Jalview " + jalview.bin.Cache.getProperty("VERSION")); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -394,6 +382,8 @@ public class Desktop extends jalview.jbgui.GDesktop implements showConsole(showjconsole); showNews.setVisible(false); + + experimentalFeatures.setSelected(showExperimental()); getIdentifiersOrgData(); @@ -490,6 +480,19 @@ public class Desktop extends jalview.jbgui.GDesktop implements }); } + /** + * Answers true if user preferences to enable experimental features is True + * (on), else false + * + * @return + */ + public boolean showExperimental() + { + String experimental = Cache.getDefault(EXPERIMENTAL_FEATURES, + Boolean.FALSE.toString()); + return Boolean.valueOf(experimental).booleanValue(); + } + public void doConfigureStructurePrefs() { // configure services @@ -2492,8 +2495,6 @@ public class Desktop extends jalview.jbgui.GDesktop implements } - protected JMenuItem groovyShell; - /** * Accessor method to quickly get all the AlignmentFrames loaded. * @@ -2579,6 +2580,7 @@ public class Desktop extends jalview.jbgui.GDesktop implements /** * Add Groovy Support to Jalview */ + @Override public void groovyShell_actionPerformed() { try @@ -3393,4 +3395,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements } } } + + /** + * Sets the Preferences property for experimental features to True or False + * depending on the state of the controlling menu item + */ + @Override + protected void showExperimental_actionPerformed(boolean selected) + { + Cache.setProperty(EXPERIMENTAL_FEATURES, Boolean.toString(selected)); + } } diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index 63ecdaf..3e3691c 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -23,6 +23,7 @@ package jalview.jbgui; import jalview.api.AlignmentViewPanel; import jalview.io.FileFormatException; import jalview.util.MessageManager; +import jalview.util.Platform; import java.awt.FlowLayout; import java.awt.Toolkit; @@ -99,6 +100,10 @@ public class GDesktop extends JFrame JMenuItem garbageCollect = new JMenuItem(); + protected JMenuItem groovyShell; + + protected JCheckBoxMenuItem experimentalFeatures; + protected JCheckBoxMenuItem showConsole = new JCheckBoxMenuItem(); protected JCheckBoxMenuItem showNews = new JCheckBoxMenuItem(); @@ -119,7 +124,7 @@ public class GDesktop extends JFrame e.printStackTrace(); } - if (!new jalview.util.Platform().isAMac()) + if (!Platform.isAMac()) { FileMenu.setMnemonic('F'); inputLocalFileMenuItem.setMnemonic('L'); @@ -374,6 +379,30 @@ public class GDesktop extends JFrame showNews_actionPerformed(e); } }); + groovyShell = new JMenuItem(); + groovyShell.setText(MessageManager.getString("label.groovy_console")); + groovyShell.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + groovyShell_actionPerformed(); + } + }); + experimentalFeatures = new JCheckBoxMenuItem(); + experimentalFeatures.setText(MessageManager + .getString("label.show_experimental")); + experimentalFeatures.setToolTipText(MessageManager + .getString("label.show_experimental_tip")); + experimentalFeatures.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + showExperimental_actionPerformed(experimentalFeatures.isSelected()); + } + }); + snapShotWindow.setText(MessageManager.getString("label.take_snapshot")); snapShotWindow.addActionListener(new ActionListener() { @@ -410,6 +439,8 @@ public class GDesktop extends JFrame toolsMenu.add(showConsole); toolsMenu.add(showNews); toolsMenu.add(garbageCollect); + toolsMenu.add(groovyShell); + toolsMenu.add(experimentalFeatures); // toolsMenu.add(snapShotWindow); inputMenu.add(inputLocalFileMenuItem); inputMenu.add(inputURLMenuItem); @@ -421,6 +452,14 @@ public class GDesktop extends JFrame // inputMenu.add(vamsasLoad); } + protected void showExperimental_actionPerformed(boolean selected) + { + } + + protected void groovyShell_actionPerformed() + { + } + protected void snapShotWindow_actionPerformed(ActionEvent e) { // TODO Auto-generated method stub