\r
public class CutAndPasteTransfer extends Panel implements ActionListener, MouseListener\r
{\r
- jalview.bin.JalviewLite applet;\r
-\r
boolean pdbImport = false;\r
+ boolean treeImport = false;\r
Sequence seq;\r
- SeqCanvas seqcanvas;\r
+ AlignFrame alignFrame;\r
\r
- public CutAndPasteTransfer(boolean forImport, jalview.bin.JalviewLite mainApplet)\r
+ public CutAndPasteTransfer(boolean forImport, AlignFrame alignFrame)\r
{\r
try {\r
jbInit();\r
e.printStackTrace();\r
}\r
\r
- applet = mainApplet;\r
+ this.alignFrame = alignFrame;\r
\r
if (!forImport)\r
{\r
}\r
}\r
\r
- public void setPDBImport(Sequence seq, SeqCanvas seqcanvas)\r
- {\r
- this.seq = seq;\r
- this.seqcanvas = seqcanvas;\r
- pdbImport = true;\r
- }\r
-\r
-\r
public String getText()\r
{\r
return textarea.getText();\r
textarea.setText(text);\r
}\r
\r
+ public void setPDBImport(Sequence seq)\r
+ {\r
+ this.seq = seq;\r
+ pdbImport = true;\r
+ }\r
+\r
+\r
public void actionPerformed(ActionEvent evt)\r
{\r
if(evt.getSource()==ok)\r
\r
if(pdbImport)\r
{\r
- new MCview.AppletPDBViewer(text, AppletFormatAdapter.PASTE, seq, seqcanvas);\r
+ new MCview.AppletPDBViewer(text, AppletFormatAdapter.PASTE,\r
+ seq,\r
+ alignFrame.getSeqcanvas());\r
}\r
- else\r
+ else if(treeImport)\r
+ {\r
+ try{\r
+ jalview.io.NewickFile fin = new jalview.io.NewickFile(textarea.getText(),\r
+ "Paste");\r
+\r
+ fin.parse();\r
+ if(fin.getTree()!=null)\r
+ alignFrame.loadTree(fin, "Pasted tree file");\r
+\r
+ }\r
+ catch (Exception ex)\r
+ {\r
+ textarea.setText("Could not parse Newick file!\n" + ex);\r
+ return;\r
+ }\r
+ }\r
+ else if(alignFrame!=null)\r
{\r
SequenceI[] sequences = null;\r
\r
}\r
if (sequences != null)\r
{\r
- AlignFrame af = new AlignFrame(new Alignment(sequences), applet,\r
- "Cut & Paste input - " + format);\r
+ AlignFrame af = new AlignFrame(new Alignment(sequences), alignFrame.applet,\r
+ "Cut & Paste input - " + format,\r
+ false);\r
af.statusBar.setText("Successfully pasted alignment file");\r
}\r
}\r
\r
+ if(this.getParent() instanceof Frame)\r
((Frame)this.getParent()).setVisible(false);\r
+ else\r
+ ((Dialog)this.getParent()).setVisible(false);\r
}\r
\r
protected void cancel_actionPerformed()\r
{\r
- ((Frame)this.getParent()).setVisible(false);\r
+ textarea.setText("");\r
+ if(this.getParent() instanceof Frame)\r
+ ((Frame)this.getParent()).setVisible(false);\r
+ else\r
+ ((Dialog)this.getParent()).setVisible(false);\r
}\r
\r
protected TextArea textarea = new TextArea();\r