import jalview.jbgui.GCutAndPasteTransfer;
import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.datatransfer.*;
+import jalview.datamodel.Alignment;
+import jalview.io.FormatAdapter;
+import jalview.datamodel.SequenceI;
+import javax.swing.JOptionPane;
+import jalview.io.IdentifyFile;
public class CutAndPasteTransfer extends GCutAndPasteTransfer
{
+ public void setForInput()
+ {
+ getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH);
+ }
public String getText()
{
{
textarea.setText(text);
}
+
+ public void copyItem_actionPerformed(ActionEvent e)
+ {
+ Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
+ c.setContents( new StringSelection( textarea.getText()) , null ) ;
+ }
+
+ public void pasteMenu_actionPerformed(ActionEvent e)
+ {
+ Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
+ Transferable contents = c.getContents(this);
+ if (contents == null)
+ return;
+ try{
+ textarea.setText( (String) contents.getTransferData(DataFlavor.
+ stringFlavor));
+ }catch(Exception ex){}
+ }
+
+ public void ok_actionPerformed(ActionEvent e)
+ {
+ String format = IdentifyFile.Identify(getText(), "Paste");
+ SequenceI [] sequences = null;
+
+ if (FormatAdapter.formats.contains( format ))
+ sequences = FormatAdapter.readFile(getText(), "Paste", format);
+
+
+ if(sequences!=null)
+ {
+ AlignFrame af = new AlignFrame(new Alignment(sequences));
+ af.currentFileFormat = format;
+ Desktop.addInternalFrame(af, "Cut & Paste input - "+format,
+ AlignFrame.NEW_WINDOW_WIDTH,
+ AlignFrame.NEW_WINDOW_HEIGHT);
+ af.statusBar.setText("Successfully pasted alignment file");
+ }
+ else
+ JOptionPane.showInternalMessageDialog(Desktop.desktop, "Couldn't read the pasted text.\n"
+ +"Formats currently supported are\n"
+ +"Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",
+ "Error parsing text", JOptionPane.WARNING_MESSAGE);
+
+ }
+
+ public void cancel_actionPerformed(ActionEvent e)
+ {
+ try{
+ this.setClosed(true);
+ }catch(Exception ex){}
+ }
+
+
}