2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 import jalview.jbgui.GCutAndPasteTransfer;
24 import java.awt.event.ActionEvent;
25 import java.awt.datatransfer.*;
26 import jalview.datamodel.Alignment;
27 import jalview.io.FormatAdapter;
28 import jalview.datamodel.SequenceI;
29 import javax.swing.JOptionPane;
30 import jalview.io.IdentifyFile;
32 public class CutAndPasteTransfer extends GCutAndPasteTransfer
34 public void setForInput()
36 getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH);
39 public String getText()
41 return textarea.getText();
44 public void setText(String text)
46 textarea.setText(text);
49 public void copyItem_actionPerformed(ActionEvent e)
51 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
52 c.setContents( new StringSelection( textarea.getText()) , null ) ;
55 public void pasteMenu_actionPerformed(ActionEvent e)
57 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
58 Transferable contents = c.getContents(this);
62 textarea.setText( (String) contents.getTransferData(DataFlavor.
64 }catch(Exception ex){}
67 public void ok_actionPerformed(ActionEvent e)
69 String format = IdentifyFile.Identify(getText(), "Paste");
70 SequenceI [] sequences = null;
72 if (FormatAdapter.formats.contains( format ))
73 sequences = FormatAdapter.readFile(getText(), "Paste", format);
78 AlignFrame af = new AlignFrame(new Alignment(sequences));
79 af.currentFileFormat = format;
80 Desktop.addInternalFrame(af, "Cut & Paste input - " + format,
81 AlignFrame.NEW_WINDOW_WIDTH,
82 AlignFrame.NEW_WINDOW_HEIGHT);
83 af.statusBar.setText("Successfully pasted alignment file");
85 { af.setMaximum(Preferences.showFullscreen); }
98 JOptionPane.showInternalMessageDialog(Desktop.desktop,
99 "Couldn't read the pasted text.\n"
100 + "Formats currently supported are\n"
102 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",
103 "Error parsing text",
104 JOptionPane.WARNING_MESSAGE);
107 public void cancel_actionPerformed(ActionEvent e)
110 this.setClosed(true);
111 }catch(Exception ex){}