/* * Jalview - A Sequence Alignment Editor and Viewer * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ package jalview.appletgui; import java.awt.*; import java.awt.event.*; import jalview.datamodel.*; import jalview.io.*; import jalview.jbappletgui.*; public class CutAndPasteTransfer extends GCutAndPasteTransfer { public CutAndPasteTransfer(boolean forImport) { super(); if (!forImport) { buttonPanel.setVisible(false); } } public String getText() { return textarea.getText(); } public void setText(String text) { textarea.setText(text); } protected void ok_actionPerformed(ActionEvent e) { String text = getText(); int length = text.length(); textarea.append("\n"); if(textarea.getText().length()==length) { String warning = "\n\n#################################################\n" +"WARNING!! THIS IS THE MAXIMUM SIZE OF TEXTAREA!!\n" +"\nCAN'T INPUT FULL ALIGNMENT" +"\n\nYOU MUST DELETE THIS WARNING TO CONTINUE" +"\n\nMAKE SURE LAST SEQUENCE PASTED IS COMPLETE" +"\n#################################################\n"; textarea.setText(text.substring(0, text.length()-warning.length()) +warning); textarea.setCaretPosition(text.length()); return; } SequenceI[] sequences = null; String format = IdentifyFile.Identify(text, "Paste"); sequences = FormatAdapter.readFile(text, "Paste", format); if (sequences != null) { AlignFrame af = new AlignFrame(new Alignment(sequences)); jalview.bin.JalviewLite.addFrame(af, "Cut & Paste input - " + format, AlignFrame.NEW_WINDOW_WIDTH, AlignFrame.NEW_WINDOW_HEIGHT); af.statusBar.setText("Successfully pasted alignment file"); } Frame frame = (Frame)this.getParent(); frame.setVisible(false); } protected void cancel_actionPerformed(ActionEvent e) { Frame frame = (Frame)this.getParent(); frame.setVisible(false); } }