Eric J. Bowersox e4e0223452 the erbo_reorg_04202002 branch is no more...development continues on the
trunk while the stable_branch_04202002 branch takes the 'stable' role
2002-04-24 06:39:29 +00:00

206 lines
5.2 KiB
Java

/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui.view;
import java.io.IOException;
import java.util.*;
import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.helpers.HTMLRendering;
public class TextMessage implements ContentDirect
{
/*--------------------------------------------------------------------------------
* Internal class that holds button details
*--------------------------------------------------------------------------------
*/
class Button
{
private int linktype;
private String link;
private String id;
Button(int linktype, String link, String id)
{
this.linktype = linktype;
this.link = link;
this.id = id;
} // end constructor
public final String getEquivalent(HTMLRendering html)
{
return "<A HREF=\"" + html.formatURL(link,linktype) + "\">" + html.getButtonVisual(id) + "</A>";
} // end getEquivalent
} // end class Button
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private int menu_selector = Content.MENU_SELECTOR_NOCHANGE;
private String title;
private String subtitle;
private String text = null;
private ArrayList buttons = new ArrayList();
private String[] render_buttons = null;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public TextMessage(String title)
{
this.title = title;
this.subtitle = null;
} // end constructor
public TextMessage(String title, String subtitle)
{
this.title = title;
this.subtitle = subtitle;
} // end constructor
public TextMessage(int msel, String title, String subtitle)
{
this.menu_selector = msel;
this.title = title;
this.subtitle = subtitle;
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface Content
*--------------------------------------------------------------------------------
*/
public boolean needFrame()
{
return true;
} // end needFrame
public int getMenuSelector()
{
return menu_selector;
} // end getMenuSelector
public String getPageTitle(RequestOutput ro)
{
return title;
} // end getPageTitle
public String getPageQID()
{
return null;
} // end getPageQID
/*--------------------------------------------------------------------------------
* Implementations from interface ContentDirect
*--------------------------------------------------------------------------------
*/
public void render(RequestOutput out) throws IOException
{
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
if (render_buttons==null)
{ // pre-render the buttons
render_buttons = new String[buttons.size()];
for (int i=0; i<render_buttons.length; i++)
{ // pre-render the buttons into an array
Button b = (Button)(buttons.get(i));
render_buttons[i] = b.getEquivalent(html);
} // end for
} // end if
out.writeContentHeader(title,subtitle);
out.write(html.getFontTag(html.CONTENT_FOREGROUND,"content") + "\n" + text
+ "</FONT><P>\n<DIV ALIGN=\"center\">\n" + StringUtil.join((Object[])render_buttons,"&nbsp;\n")
+ "</DIV>\n");
} // end render
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final void setMenuSelector(int sel)
{
menu_selector = sel;
} // end setMenuSelector
public final String getTitle()
{
return title;
} // end getTitle
public final void setTitle(String s)
{
title = s;
} // end setTitle
public final String getSubTitle()
{
return subtitle;
} // end getSubTitle
public final void setSubTitle(String s)
{
subtitle = s;
} // end setSubTitle
public final String getText()
{
return text;
} // end getText
public final void setText(String s)
{
text = s;
} // end setText
public final void addButton(int linktype, String link, String id)
{
buttons.add(new Button(linktype,link,id));
render_buttons = null;
} // end addButton
} // end class TextMessage