2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
19 package jalview.gui;
\r
21 import jalview.datamodel.*;
\r
23 import jalview.io.*;
\r
25 import jalview.jbgui.*;
\r
28 import java.awt.datatransfer.*;
\r
29 import java.awt.event.*;
\r
31 import javax.swing.*;
\r
38 * @version $Revision$
\r
40 public class CutAndPasteTransfer extends GCutAndPasteTransfer
\r
45 public void setForInput()
\r
47 getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH);
\r
53 * @return DOCUMENT ME!
\r
55 public String getText()
\r
57 return textarea.getText();
\r
63 * @param text DOCUMENT ME!
\r
65 public void setText(String text)
\r
67 textarea.setText(text);
\r
73 * @param e DOCUMENT ME!
\r
75 public void copyItem_actionPerformed(ActionEvent e)
\r
77 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
\r
78 c.setContents(new StringSelection(textarea.getText()), null);
\r
84 * @param e DOCUMENT ME!
\r
86 public void pasteMenu_actionPerformed(ActionEvent e)
\r
88 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
\r
89 Transferable contents = c.getContents(this);
\r
91 if (contents == null)
\r
98 textarea.setText((String) contents.getTransferData(
\r
99 DataFlavor.stringFlavor));
\r
101 catch (Exception ex)
\r
109 * @param e DOCUMENT ME!
\r
111 public void ok_actionPerformed(ActionEvent e)
\r
113 String format = IdentifyFile.Identify(getText(), "Paste");
\r
114 SequenceI[] sequences = null;
\r
116 if (FormatAdapter.formats.contains(format))
\r
118 sequences = FormatAdapter.readFile(getText(), "Paste", format);
\r
121 if (sequences != null)
\r
123 AlignFrame af = new AlignFrame(new Alignment(sequences));
\r
124 af.currentFileFormat = format;
\r
125 Desktop.addInternalFrame(af, "Cut & Paste input - " + format,
\r
126 AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT);
\r
127 af.statusBar.setText("Successfully pasted alignment file");
\r
131 af.setMaximum(Preferences.showFullscreen);
\r
133 catch (Exception ex)
\r
139 this.setClosed(true);
\r
141 catch (Exception ex)
\r
147 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
148 "Couldn't read the pasted text.\n" +
\r
149 "Formats currently supported are\n" +
\r
150 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",
\r
151 "Error parsing text", JOptionPane.WARNING_MESSAGE);
\r
158 * @param e DOCUMENT ME!
\r
160 public void cancel_actionPerformed(ActionEvent e)
\r
164 this.setClosed(true);
\r
166 catch (Exception ex)
\r