1 /* 2 * Created on 12 Apr 2008 3 * Created by Allan Crooks 4 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 package org.gudy.azureus2.pluginsimpl.local.ui; 19 20 import org.gudy.azureus2.core3.internat.MessageText; 21 import org.gudy.azureus2.plugins.ui.UIMessage; 22 23 /** 24 * @author Allan Crooks 25 * 26 */ 27 public abstract class AbstractUIMessage implements UIMessage { 28 29 protected int message_type = MSG_NONE; 30 protected int input_type = INPUT_OK; 31 protected String title = ""; 32 protected String[] messages = new String[0]; 33 setInputType(int input_type)34 public void setInputType(int input_type) {this.input_type = input_type;} setMessageType(int msg_type)35 public void setMessageType(int msg_type) {this.message_type = msg_type;} setLocalisedTitle(String title)36 public void setLocalisedTitle(String title) {this.title = title;} setLocalisedMessage(String message)37 public void setLocalisedMessage(String message) {setLocalisedMessages(new String[] {message});} setLocalisedMessages(String[] messages)38 public void setLocalisedMessages(String[] messages) {this.messages = messages;} setMessage(String message)39 public void setMessage(String message) {setLocalisedMessage(localise(message));} setTitle(String title)40 public void setTitle(String title) {setLocalisedTitle(localise(title));} 41 messagesAsString()42 protected final String messagesAsString() { 43 if (messages.length == 0) { 44 return ""; 45 } 46 StringBuffer sb = new StringBuffer(messages[0]); 47 for (int i=1; i<messages.length; i++) { 48 sb.append("\n"); 49 sb.append(messages[i]); 50 } 51 return sb.toString(); 52 } 53 setMessages(String[] messages)54 public void setMessages(String[] messages) { 55 String[] new_messages = new String[messages.length]; 56 for (int i=0; i<new_messages.length; i++) { 57 new_messages[i] = this.localise(messages[i]); 58 } 59 this.setLocalisedMessages(new_messages); 60 } 61 localise(String key)62 private final String localise(String key) { 63 return MessageText.getString(key); 64 } 65 ask()66 public int ask() { 67 return 0; 68 } 69 70 } 71