From cf64def09a8b741483854ddd8c034d0aefff15b4 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 18 Sep 2018 16:03:09 +0100 Subject: [PATCH] JAL-3063 temporary extra menu option to save/load project as JAXB --- src/jalview/gui/AlignFrame.java | 4 +++- src/jalview/gui/Desktop.java | 41 +++++++++++++++++++++++++++++---------- src/jalview/jbgui/GDesktop.java | 28 ++++++++++++++++++++++---- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index a2336a0..1f1fac0 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -5399,7 +5399,9 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ public List getAlignPanels() { - return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels; + // alignPanels is never null + // return alignPanels == null ? Arrays.asList(alignPanel) : alignPanels; + return alignPanels; } /** diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 8d9e366..bbdddbb 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -1605,9 +1605,10 @@ public class Desktop extends jalview.jbgui.GDesktop * DOCUMENT ME! */ @Override - public void saveState_actionPerformed(ActionEvent e) + public void saveState_actionPerformed(boolean asCastor) { - JalviewFileChooser chooser = new JalviewFileChooser("jvp", + JalviewFileChooser chooser = new JalviewFileChooser( + asCastor ? "jvp" : "jvx", "Jalview Project"); chooser.setFileView(new JalviewFileView()); @@ -1636,7 +1637,14 @@ public class Desktop extends jalview.jbgui.GDesktop // TODO prevent user from messing with the Desktop whilst we're saving try { - new Jalview2XML().saveState(choice); + if (asCastor) + { + new Jalview2XML().saveState(choice); + } + else + { + new jalview.project.Jalview2XML().saveState(choice); + } } catch (OutOfMemoryError oom) { new OOMWarning( @@ -1678,13 +1686,19 @@ public class Desktop extends jalview.jbgui.GDesktop * DOCUMENT ME! */ @Override - public void loadState_actionPerformed(ActionEvent e) - { + public void loadState_actionPerformed(boolean asCastor) + { + final String[] suffix = asCastor ? new String[] { "jvp", "jar" } + : new String[] + { "jvx" }; + final String[] desc = asCastor + ? new String[] + { "Jalview Project", "Jalview Project (old)" } + : new String[] + { "Jalview Project" }; JalviewFileChooser chooser = new JalviewFileChooser( - Cache.getProperty("LAST_DIRECTORY"), new String[] - { "jvp", "jar" }, - new String[] - { "Jalview Project", "Jalview Project (old)" }, + Cache.getProperty("LAST_DIRECTORY"), suffix, + desc, "Jalview Project"); chooser.setFileView(new JalviewFileView()); chooser.setDialogTitle(MessageManager.getString("label.restore_state")); @@ -1707,7 +1721,14 @@ public class Desktop extends jalview.jbgui.GDesktop { choice }), choice.hashCode()); try { - new Jalview2XML().loadJalviewAlign(choice); + if (asCastor) + { + new Jalview2XML().loadJalviewAlign(choice); + } + else + { + new jalview.project.Jalview2XML().loadJalviewAlign(choice); + } } catch (OutOfMemoryError oom) { new OOMWarning("Whilst loading project from " + choice, oom); diff --git a/src/jalview/jbgui/GDesktop.java b/src/jalview/jbgui/GDesktop.java index a4afb74..290c4a4 100755 --- a/src/jalview/jbgui/GDesktop.java +++ b/src/jalview/jbgui/GDesktop.java @@ -245,7 +245,16 @@ public class GDesktop extends JFrame @Override public void actionPerformed(ActionEvent e) { - saveState_actionPerformed(e); + saveState_actionPerformed(true); + } + }); + JMenuItem saveAsJaxb = new JMenuItem("Save Project as JAXB"); + saveAsJaxb.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + saveState_actionPerformed(false); } }); loadState.setText(MessageManager.getString("action.load_project")); @@ -254,7 +263,16 @@ public class GDesktop extends JFrame @Override public void actionPerformed(ActionEvent e) { - loadState_actionPerformed(e); + loadState_actionPerformed(true); + } + }); + JMenuItem loadAsJaxb = new JMenuItem("Load Project as JAXB"); + loadAsJaxb.addActionListener(new ActionListener() + { + @Override + public void actionPerformed(ActionEvent e) + { + loadState_actionPerformed(false); } }); inputMenu.setText(MessageManager.getString("label.input_alignment")); @@ -424,7 +442,9 @@ public class GDesktop extends JFrame FileMenu.add(inputSequence); FileMenu.addSeparator(); FileMenu.add(saveState); + FileMenu.add(saveAsJaxb); FileMenu.add(loadState); + FileMenu.add(loadAsJaxb); FileMenu.addSeparator(); FileMenu.add(quit); HelpMenu.add(aboutMenuItem); @@ -586,7 +606,7 @@ public class GDesktop extends JFrame * @param e * DOCUMENT ME! */ - public void saveState_actionPerformed(ActionEvent e) + public void saveState_actionPerformed(boolean asCastor) { } @@ -596,7 +616,7 @@ public class GDesktop extends JFrame * @param e * DOCUMENT ME! */ - public void loadState_actionPerformed(ActionEvent e) + public void loadState_actionPerformed(boolean asCastor) { } -- 1.7.10.2