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
22 import java.awt.datatransfer.*;
\r
23 import java.awt.event.*;
\r
24 import javax.swing.*;
\r
26 import jalview.datamodel.*;
\r
27 import jalview.io.*;
\r
28 import jalview.jbgui.*;
\r
30 public class CutAndPasteTransfer
\r
31 extends GCutAndPasteTransfer
\r
33 public void setForInput()
\r
35 getContentPane().add(inputButtonPanel, java.awt.BorderLayout.SOUTH);
\r
38 public String getText()
\r
40 return textarea.getText();
\r
43 public void setText(String text)
\r
45 textarea.setText(text);
\r
48 public void copyItem_actionPerformed(ActionEvent e)
\r
50 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
\r
51 c.setContents(new StringSelection(textarea.getText()), null);
\r
54 public void pasteMenu_actionPerformed(ActionEvent e)
\r
56 Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
\r
57 Transferable contents = c.getContents(this);
\r
59 if (contents == null)
\r
66 textarea.setText( (String) contents.getTransferData(
\r
67 DataFlavor.stringFlavor));
\r
69 catch (Exception ex)
\r
74 public void ok_actionPerformed(ActionEvent e)
\r
76 String format = IdentifyFile.Identify(getText(), "Paste");
\r
77 SequenceI[] sequences = null;
\r
79 if (FormatAdapter.formats.contains(format))
\r
81 sequences = FormatAdapter.readFile(getText(), "Paste", format);
\r
84 if (sequences != null)
\r
86 AlignFrame af = new AlignFrame(new Alignment(sequences));
\r
87 af.currentFileFormat = format;
\r
88 Desktop.addInternalFrame(af, "Cut & Paste input - " + format,
\r
89 AlignFrame.NEW_WINDOW_WIDTH,
\r
90 AlignFrame.NEW_WINDOW_HEIGHT);
\r
91 af.statusBar.setText("Successfully pasted alignment file");
\r
95 af.setMaximum(Preferences.showFullscreen);
\r
97 catch (Exception ex)
\r
103 this.setClosed(true);
\r
105 catch (Exception ex)
\r
111 JOptionPane.showInternalMessageDialog(Desktop.desktop,
\r
112 "Couldn't read the pasted text.\n" +
\r
113 "Formats currently supported are\n" +
\r
114 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM",
\r
115 "Error parsing text",
\r
116 JOptionPane.WARNING_MESSAGE);
\r
120 public void cancel_actionPerformed(ActionEvent e)
\r
124 this.setClosed(true);
\r
126 catch (Exception ex)
\r