X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FCutAndPasteTransfer.java;h=7b3e43874319ede3697f6b17f27b1fca6d88e6a2;hb=ee198b3ca3687f18a2ee186f4e7c7330f4ea30f0;hp=acc71f306db90e9e4fc3930de20837b5535f79e5;hpb=4513bd826c54623c14aa8946a51a2382f64e98f3;p=jalview.git diff --git a/src/jalview/gui/CutAndPasteTransfer.java b/src/jalview/gui/CutAndPasteTransfer.java index acc71f3..7b3e438 100644 --- a/src/jalview/gui/CutAndPasteTransfer.java +++ b/src/jalview/gui/CutAndPasteTransfer.java @@ -23,12 +23,16 @@ package jalview.gui; import jalview.api.AlignViewportI; import jalview.api.AlignmentViewPanel; import jalview.api.ComplexAlignFile; +import jalview.api.FeatureSettingsModelI; import jalview.api.FeaturesDisplayedI; +import jalview.api.FeaturesSourceI; import jalview.bin.Jalview; import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.SequenceI; import jalview.io.AppletFormatAdapter; +import jalview.io.DataSourceType; +import jalview.io.FileFormatI; import jalview.io.FileParse; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -72,6 +76,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { textarea.requestFocus(); @@ -124,6 +129,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer textarea.append(text); } + @Override public void save_actionPerformed(ActionEvent e) { JalviewFileChooser chooser = new JalviewFileChooser( @@ -160,6 +166,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer * @param e * DOCUMENT ME! */ + @Override public void copyItem_actionPerformed(ActionEvent e) { textarea.getSelectedText(); @@ -173,6 +180,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer * @param e * DOCUMENT ME! */ + @Override public void pasteMenu_actionPerformed(ActionEvent e) { Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); @@ -198,6 +206,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer * @param e * DOCUMENT ME! */ + @Override public void ok_actionPerformed(ActionEvent e) { String text = getText(); @@ -206,14 +215,15 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer return; } - String format = new IdentifyFile().Identify(text, "Paste"); - if (format == null || format.equalsIgnoreCase("EMPTY DATA FILE")) + FileFormatI format = new IdentifyFile().identify(text, + DataSourceType.PASTE); + if (format == null) { System.err.println(MessageManager .getString("label.couldnt_read_data")); if (!Jalview.isHeadlessMode()) { - javax.swing.JOptionPane.showInternalMessageDialog(Desktop.desktop, + JOptionPane.showInternalMessageDialog(Desktop.desktop, AppletFormatAdapter.SUPPORTED_FORMATS, MessageManager.getString("label.couldnt_read_data"), JOptionPane.WARNING_MESSAGE); @@ -229,7 +239,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer try { FormatAdapter fa = new FormatAdapter(alignpanel); - al = fa.readFile(getText(), "Paste", format); + al = fa.readFile(getText(), DataSourceType.PASTE, format); source = fa.getAlignFile(); } catch (java.io.IOException ex) @@ -247,8 +257,19 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer { String title = MessageManager.formatMessage( "label.input_cut_paste_params", new String[] { format }); - if (viewport != null) + FeatureSettingsModelI proxyColourScheme = source + .getFeatureColourScheme(); + + /* + * if the view panel was closed its alignment is nulled + * and this is an orphaned cut and paste window + */ + if (viewport != null && viewport.getAlignment() != null) { + if (proxyColourScheme != null) + { + viewport.applyFeaturesStyle(proxyColourScheme); + } ((AlignViewport) viewport).addAlignment(al, title); } else @@ -273,14 +294,24 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer af.getViewport().setFeaturesDisplayed(fd); ColourSchemeI cs = ColourSchemeMapper.getJalviewColourScheme( colourSchemeName, al); - af.changeColour(cs); + if (cs != null) + { + af.changeColour(cs); + } } else { af = new AlignFrame(al, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); + if (source instanceof FeaturesSourceI) + { + af.getViewport().setShowSequenceFeatures(true); + } + } + if (proxyColourScheme != null) + { + af.getViewport().applyFeaturesStyle(proxyColourScheme); } - af.currentFileFormat = format; Desktop.addInternalFrame(af, title, AlignFrame.DEFAULT_WIDTH, AlignFrame.DEFAULT_HEIGHT); @@ -316,6 +347,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer * @param e * DOCUMENT ME! */ + @Override public void cancel_actionPerformed(ActionEvent e) { try @@ -326,9 +358,10 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer } } + @Override public void textarea_mousePressed(MouseEvent e) { - if (SwingUtilities.isRightMouseButton(e)) + if (e.isPopupTrigger()) { JPopupMenu popup = new JPopupMenu( MessageManager.getString("action.edit")); @@ -336,6 +369,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer MessageManager.getString("action.copy")); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { copyItem_actionPerformed(e); @@ -345,6 +379,7 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer item = new JMenuItem(MessageManager.getString("action.paste")); item.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { pasteMenu_actionPerformed(e);