X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fappletgui%2FCutAndPasteTransfer.java;h=f8c3756b2f3d6aff93c20663aec017846aaecfcf;hb=b03ab64755cdfd11f8d1f2c93d01f276d121e6d7;hp=e4b8c9b03c166e8e5ade2cf3215632e9c65dbab1;hpb=ec955aa655d8320258b91eb079bc57f688cd0a07;p=jalview.git diff --git a/src/jalview/appletgui/CutAndPasteTransfer.java b/src/jalview/appletgui/CutAndPasteTransfer.java index e4b8c9b..f8c3756 100755 --- a/src/jalview/appletgui/CutAndPasteTransfer.java +++ b/src/jalview/appletgui/CutAndPasteTransfer.java @@ -1,32 +1,46 @@ -/******************** - * 2004 Jalview Reengineered - * Barton Group - * Dundee University +/* + * Jalview - A Sequence Alignment Editor and Viewer + * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * - * AM Waterhouse - *******************/ + * 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 jalview.jbappletgui.GCutAndPasteTransfer; -import jalview.datamodel.*; -import jalview.io.*; import java.awt.*; import java.awt.event.*; -public class CutAndPasteTransfer extends GCutAndPasteTransfer +import jalview.datamodel.*; +import jalview.io.*; +import jalview.jbappletgui.*; + +public class CutAndPasteTransfer + extends GCutAndPasteTransfer { - public CutAndPasteTransfer(boolean forImport) + jalview.bin.JalviewLite applet; + public CutAndPasteTransfer(boolean forImport, jalview.bin.JalviewLite mainApplet) { super(); + applet = mainApplet; - if(!forImport) + if (!forImport) { buttonPanel.setVisible(false); } } - public String getText() { return textarea.getText(); @@ -37,36 +51,48 @@ public class CutAndPasteTransfer extends GCutAndPasteTransfer textarea.setText(text); } - protected void ok_actionPerformed(ActionEvent e) { String text = getText(); - SequenceI [] sequences = null; - - String format = IdentifyFile.Identify(text, "Paste"); - - // if (FormatProperties.contains( format )) - 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"); - } + 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; + } - Frame frame = (Frame)this.getParent(); - frame.setVisible(false); - } + SequenceI[] sequences = null; - protected void cancel_actionPerformed(ActionEvent e) { - Frame frame = (Frame)this.getParent(); - frame.setVisible(false); - } + String format = IdentifyFile.Identify(text, "Paste"); + sequences = FormatAdapter.readFile(text, "Paste", format); + if (sequences != null) + { + AlignFrame af = new AlignFrame(new Alignment(sequences), applet); + 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); + } }