From: amwaterhouse Date: Thu, 16 Mar 2006 15:16:45 +0000 (+0000) Subject: Cut and paste may be inserted into Dialog frame X-Git-Tag: Root_VamJalview_2_07b+~57 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a6ae2ce881e99308d02a04941943ad94bd26e084;p=jalview.git Cut and paste may be inserted into Dialog frame --- diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index 173b031..4b890bb 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -27,13 +27,12 @@ import jalview.io.*; public class CutAndPasteTransfer extends Panel implements ActionListener, MouseListener { - jalview.bin.JalviewLite applet; - boolean pdbImport = false; + boolean treeImport = false; Sequence seq; - SeqCanvas seqcanvas; + AlignFrame alignFrame; - public CutAndPasteTransfer(boolean forImport, jalview.bin.JalviewLite mainApplet) + public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame) { try { jbInit(); @@ -41,7 +40,7 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, MouseL e.printStackTrace(); } - applet = mainApplet; + this.alignFrame = alignFrame; if (!forImport) { @@ -49,14 +48,6 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, MouseL } } - public void setPDBImport(Sequence seq, SeqCanvas seqcanvas) - { - this.seq = seq; - this.seqcanvas = seqcanvas; - pdbImport = true; - } - - public String getText() { return textarea.getText(); @@ -67,6 +58,13 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, MouseL textarea.setText(text); } + public void setPDBImport(Sequence seq) + { + this.seq = seq; + pdbImport = true; + } + + public void actionPerformed(ActionEvent evt) { if(evt.getSource()==ok) @@ -96,9 +94,28 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, MouseL if(pdbImport) { - new MCview.AppletPDBViewer(text, AppletFormatAdapter.PASTE, seq, seqcanvas); + new MCview.AppletPDBViewer(text, AppletFormatAdapter.PASTE, + seq, + alignFrame.getSeqcanvas()); } - else + else if(treeImport) + { + try{ + jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea.getText(), + "Paste"); + + fin.parse(); + if(fin.getTree()!=null) + alignFrame.loadTree(fin, "Pasted tree file"); + + } + catch (Exception ex) + { + textarea.setText("Could not parse Newick file!\n" + ex); + return; + } + } + else if(alignFrame!=null) { SequenceI[] sequences = null; @@ -111,18 +128,26 @@ public class CutAndPasteTransfer extends Panel implements ActionListener, MouseL } if (sequences != null) { - AlignFrame af = new AlignFrame(new Alignment(sequences), applet, - "Cut & Paste input - " + format); + AlignFrame af = new AlignFrame(new Alignment(sequences), alignFrame.applet, + "Cut & Paste input - " + format, + false); af.statusBar.setText("Successfully pasted alignment file"); } } + if(this.getParent() instanceof Frame) ((Frame)this.getParent()).setVisible(false); + else + ((Dialog)this.getParent()).setVisible(false); } protected void cancel_actionPerformed() { - ((Frame)this.getParent()).setVisible(false); + textarea.setText(""); + if(this.getParent() instanceof Frame) + ((Frame)this.getParent()).setVisible(false); + else + ((Dialog)this.getParent()).setVisible(false); } protected TextArea textarea = new TextArea();