,
* 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.menus;
import java.io.Writer;
import java.io.IOException;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.helpers.HTMLRendering;
public class CommunityMenu implements MenuComponent
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String image_url; // path to actual image
private String title; // title for menu
private List items_list; // list of menu items
private int cid; // community ID
private boolean show_unjoin; // show the "Unjoin" menu choice?
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
CommunityMenu(CommunityContext ctxt, List items)
{
try
{ // retrieve the contact info for this puppy
ContactInfo ci = ctxt.getContactInfo();
image_url = ci.getPhotoURL();
} // end try
catch (DataException e)
{ // if we couldn't get the contact info, screw it
image_url = null;
} // end catch
title = StringUtil.encodeHTML(ctxt.getName());
items_list = items;
cid = ctxt.getCommunityID();
show_unjoin = ctxt.canUnjoin();
} // end constructor
/*--------------------------------------------------------------------------------
* Implementations from interface MenuComponent
*--------------------------------------------------------------------------------
*/
public void render(RequestOutput out, Writer wr) throws IOException
{
this.render(out,wr,Collections.EMPTY_SET);
} // end render
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
{
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
if (wr==null)
wr = out.getWriter();
wr.write("\n"
+ html.getCommunityLogoTag(image_url) + " | \n\n");
// display the title
out.writeContentHeader(wr,title,null);
wr.write(" | \n
\n");
// display the menu items
Iterator it = items_list.iterator();
while (it.hasNext())
{ // display each menu item in turn
MenuComponent mc = (MenuComponent)(it.next());
mc.render(out,wr,defines);
} // end while
if (show_unjoin) // display the "Unjoin" link
wr.write("
Unjoin
\n");
wr.write("\n"); // all done...
} // end render
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
{
this.renderOnLeft(out,wr,Collections.EMPTY_SET);
} // end renderOnLeft
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
{
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
if (wr==null)
wr = out.getWriter();
String hilite = html.getFontTag(html.LEFT_LINK,null);
// display the image URL and title
wr.write("
" + html.getCommunityLogoTag(image_url) + "
\n"
+ StringUtil.encodeHTML(title) + "
\n");
// display the menu items
Iterator it = items_list.iterator();
while (it.hasNext())
{ // display each menu item in turn
MenuComponent mc = (MenuComponent)(it.next());
mc.renderOnLeft(out,wr,defines);
} // end while
if (show_unjoin)
wr.write("
\n" + hilite + "Unjoin\n");
wr.write("\n"); // all done...
} // end renderOnLeft
public String getTitle(RequestOutput out)
{
return title;
} // end getTitle
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
*/
public final int getID()
{
return cid;
} // end getID
} // end class CommunityMenu