2 * 2004 Jalview Reengineered
11 import jalview.jbgui.GCutAndPasteTransfer;
13 import java.awt.event.ActionEvent;
14 import java.awt.datatransfer.*;
15 import jalview.datamodel.Alignment;
16 import jalview.io.FormatAdapter;
17 import jalview.datamodel.SequenceI;
18 import javax.swing.JOptionPane;
19 import jalview.io.IdentifyFile;
21 public class CutAndPasteTransfer extends GCutAndPasteTransfer
23 public void setForInput()
25 getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH);
28 public String getText()
30 return textarea.getText();
33 public void setText(String text)
35 textarea.setText(text);
38 public void copyItem_actionPerformed(ActionEvent e)
40 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
41 c.setContents( new StringSelection( textarea.getText()) , null ) ;
44 public void pasteMenu_actionPerformed(ActionEvent e)
46 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
47 Transferable contents = c.getContents(this);
51 textarea.setText( (String) contents.getTransferData(DataFlavor.
53 }catch(Exception ex){}
56 public void ok_actionPerformed(ActionEvent e)
58 String format = IdentifyFile.Identify(getText(), "Paste");
59 SequenceI [] sequences = null;
61 if (FormatAdapter.formats.contains( format ))
62 sequences = FormatAdapter.readFile(getText(), "Paste", format);
67 AlignFrame af = new AlignFrame(new Alignment(sequences));
68 af.currentFileFormat = format;
69 Desktop.addInternalFrame(af, "Cut & Paste input - "+format,
70 AlignFrame.NEW_WINDOW_WIDTH,
71 AlignFrame.NEW_WINDOW_HEIGHT);
72 af.statusBar.setText("Successfully pasted alignment file");
75 JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't read the pasted text.\n"
76 +"Formats currently supported are\n"
77 +"Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",
78 "Error parsing text", JOptionPane.WARNING_MESSAGE);
82 public void cancel_actionPerformed(ActionEvent e)
86 }catch(Exception ex){}