1 /** 2 * Jin - a chess client for internet chess servers. 3 * More information is available at http://www.jinchess.com/. 4 * Copyright (C) 2002 Alexander Maryanovsky. 5 * All rights reserved. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 package free.jin.console.icc; 23 24 import javax.swing.text.BadLocationException; 25 26 import free.jin.console.Console; 27 import free.jin.console.ConsoleTextField; 28 import free.jin.console.ConsoleTextPane; 29 30 31 /** 32 * An extension of free.jin.console.Console which adds some ICC specific 33 * features. 34 */ 35 36 public class ChessclubConsole extends Console{ 37 38 39 40 /** 41 * Creates a new <code>ChessclubConsole</code> to be used with the specified 42 * <code>ChessclubConsoleManager</code>. 43 */ 44 ChessclubConsole(ChessclubConsoleManager consoleManager)45 public ChessclubConsole(ChessclubConsoleManager consoleManager){ 46 super(consoleManager); 47 } 48 49 50 51 /** 52 * Creates the <code>ConsoleTextField</code> in which the user can input 53 * commands to be sent to the server. Overrides 54 * <code>Console.createInputComponent()</code> since we need a 55 * special <code>ConsoleTextField</code> for ICC. 56 */ 57 createInputComponent()58 protected ConsoleTextField createInputComponent(){ 59 return new ChessclubConsoleTextField(this); 60 } 61 62 63 64 65 /** 66 * Overrides <code>Console.createOutputComponent()</code> since we need a 67 * special <code>ConsoleTextPane</code> for ICC. 68 */ 69 createOutputComponent()70 protected ConsoleTextPane createOutputComponent(){ 71 return new ChessclubConsoleTextPane(this); 72 } 73 74 75 76 /** 77 * Works around the issue with specially layed out finger noted, such as 78 * "finger Live" by splitting lines with lots of spaces followed by a ':'. 79 * See http://sourceforge.net/tracker/index.php?func=detail&aid=675197&group_id=50386&atid=459537 80 * for more information. 81 */ 82 addToOutputImpl(String text, String textType)83 protected void addToOutputImpl(String text, String textType) throws BadLocationException{ 84 // As of 02.06.2005, the ICC server does the wrapping thing itself 85 // String delim = " :"; 86 // int index; 87 // while ((index = text.indexOf(delim)) != -1){ 88 // String line = TextUtilities.trimRight(text.substring(0, index)); 89 // super.addToOutputImpl(line, textType); 90 // text = text.substring(index + delim.length() - 3); 91 // } 92 93 super.addToOutputImpl(text, textType); 94 } 95 96 97 98 } 99