revamped menu HTML generation by making it template-driven; excised the old
menu rendering code
This commit is contained in:
parent
ad3af636d7
commit
156511e747
|
@ -455,6 +455,57 @@ Text of this agreement is TBD.
|
||||||
|
|
||||||
</menu-definitions>
|
</menu-definitions>
|
||||||
|
|
||||||
|
<!-- Definitions for menu templates -->
|
||||||
|
<menu-template-definitions>
|
||||||
|
|
||||||
|
<!-- "Normal" menu rendering -->
|
||||||
|
<menu-template id="normal">
|
||||||
|
<title type="single"><![CDATA[
|
||||||
|
<font class="chead1" face="${font}" color="${color.content.header}" size="${size.header}"><b>${title}</b></font>
|
||||||
|
]]></title>
|
||||||
|
<title type="double"><![CDATA[
|
||||||
|
<font class="chead1" face="${font}" color="${color.content.header}" size="${size.header}"><b>${title}</b></font>
|
||||||
|
|
||||||
|
<font class="chead2" face="${font}" color="${color.content.header}" size="${size.subhead}"><b>${subtitle}</b></font>
|
||||||
|
]]></title>
|
||||||
|
<block id="title-post"><![CDATA[<hr align="left" size="2" width="90%" noshade="noshade" />]]></block>
|
||||||
|
<block id="items-pre"><![CDATA[
|
||||||
|
<font class="content" face="${font}" color="${color.content.fg}" size="${size.content}">
|
||||||
|
]]></block>
|
||||||
|
<block id="link-indent"><![CDATA[ ]]></block>
|
||||||
|
<item type="*">${text}</item>
|
||||||
|
<item type="header"><![CDATA[<font size="+1"><b>${text}</b></font><br />]]></item>
|
||||||
|
<item type="separator"><![CDATA[${text}<br />]]></item>
|
||||||
|
<block id="items-post"><![CDATA[</font>]]></block>
|
||||||
|
<link type="*"><![CDATA[${stdbullet} <a href="${link}"${xattr}>${item}</a><br />]]></link>
|
||||||
|
<link type="disabled"><![CDATA[${stdbullet} <font color="${color.disabled}">${item}</font><br />]]></link>
|
||||||
|
<block id="pre-comm"><![CDATA[
|
||||||
|
<table border="0" cellpadding="2" cellspacing="0"><tr valign="bottom"><td align="left" width="110">
|
||||||
|
]]></block>
|
||||||
|
<block id="title-pre-comm"><![CDATA[</td>\n<td align="left">]]></block>
|
||||||
|
<block id="title-post-comm"><![CDATA[</td></tr></table><br />]]></block>
|
||||||
|
<block id="unjoin-break"><![CDATA[<p />]]></block>
|
||||||
|
</menu-template>
|
||||||
|
|
||||||
|
<!-- Left menu bar menu rendering -->
|
||||||
|
<menu-template id="left">
|
||||||
|
<title type="single"><![CDATA[<b>${title}</b><br />]]></title>
|
||||||
|
<title type="double"><![CDATA[<b>${title}</b><br />${subtitle}<br />]]></title>
|
||||||
|
<block id="link-indent"><![CDATA[ ]]></block>
|
||||||
|
<item type="*">${text}</item>
|
||||||
|
<item type="header"><![CDATA[<b>${text}</b><br />]]></item>
|
||||||
|
<item type="separator"><![CDATA[${text}<br />]]></item>
|
||||||
|
<link type="*"><![CDATA[
|
||||||
|
<a href="${link}" class="lbar"${xattr}><font color="${color.left.link}">${item}</font></a><br />
|
||||||
|
]]></link>
|
||||||
|
<link type="disabled"><![CDATA[<font color="${color.disabled}">${item}</font><br />]]></link>
|
||||||
|
<block id="pre-comm"><![CDATA[<div align="left">]]></block>
|
||||||
|
<block id="title-pre-comm"><![CDATA[</div>]]></block>
|
||||||
|
<block id="unjoin-break"><![CDATA[<br />]]></block>
|
||||||
|
</menu-template>
|
||||||
|
|
||||||
|
</menu-template-definitions>
|
||||||
|
|
||||||
<!-- Definitions for dialog boxes -->
|
<!-- Definitions for dialog boxes -->
|
||||||
<dialog-definitions>
|
<dialog-definitions>
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -90,7 +90,7 @@ public final class DOMElementHelper
|
||||||
if (b==null)
|
if (b==null)
|
||||||
return null; // no TEXT nodes
|
return null; // no TEXT nodes
|
||||||
else
|
else
|
||||||
return b.toString(); // return the concatenation
|
return b.toString().trim(); // return the concatenation
|
||||||
|
|
||||||
} // end getTextOfElement
|
} // end getTextOfElement
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.silverwrist.venice.ui.menus.CommunityMenu;
|
||||||
import com.silverwrist.venice.ui.menus.CommunityMenuFactory;
|
import com.silverwrist.venice.ui.menus.CommunityMenuFactory;
|
||||||
import com.silverwrist.venice.ui.menus.Menu;
|
import com.silverwrist.venice.ui.menus.Menu;
|
||||||
import com.silverwrist.venice.ui.menus.MenuComponent;
|
import com.silverwrist.venice.ui.menus.MenuComponent;
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
import com.silverwrist.venice.ui.rpc.XmlRpcMethod;
|
import com.silverwrist.venice.ui.rpc.XmlRpcMethod;
|
||||||
import com.silverwrist.venice.util.*;
|
import com.silverwrist.venice.util.*;
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
private static final int VENICE_IMAGE_HEIGHT = 103;
|
private static final int VENICE_IMAGE_HEIGHT = 103;
|
||||||
private static final String VENICE_ALT = "Powered By Venice";
|
private static final String VENICE_ALT = "Powered By Venice";
|
||||||
|
|
||||||
private static Category logger = Category.getInstance(RootConfig.class);
|
private static Logger logger = Logger.getLogger(RootConfig.class);
|
||||||
|
|
||||||
private static final Map link_types;
|
private static final Map link_types;
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
private String page_icon_tags = null; // the HTML snippet containing the page icons
|
private String page_icon_tags = null; // the HTML snippet containing the page icons
|
||||||
private String font_face; // the default font face name
|
private String font_face; // the default font face name
|
||||||
private String base_font; // the default <BASEFONT> tag
|
private String base_font; // the default <BASEFONT> tag
|
||||||
private Map font_sizes; // the stock font sizes
|
private Map m_font_sizes; // the stock font sizes
|
||||||
private ColorPalette colors; // all the colors
|
private ColorPalette colors; // all the colors
|
||||||
private boolean html_comments; // do we want to embed HTML comments?
|
private boolean html_comments; // do we want to embed HTML comments?
|
||||||
private ButtonHolder buttons; // the button definitions
|
private ButtonHolder buttons; // the button definitions
|
||||||
|
@ -86,6 +87,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
private List xmlrpc_methods; // the list of XML-RPC methods
|
private List xmlrpc_methods; // the list of XML-RPC methods
|
||||||
private StockMessages stock_messages; // the stock messages
|
private StockMessages stock_messages; // the stock messages
|
||||||
private Map menus; // the menus
|
private Map menus; // the menus
|
||||||
|
private Map m_menu_templates; // the menu templates
|
||||||
private DialogManager dialogs; // the dialog manager
|
private DialogManager dialogs; // the dialog manager
|
||||||
private SideBoxManager sideboxes; // the sidebox manager
|
private SideBoxManager sideboxes; // the sidebox manager
|
||||||
private CommunityMenuFactory comm_menu_fact; // the community menu factory
|
private CommunityMenuFactory comm_menu_fact; // the community menu factory
|
||||||
|
@ -393,13 +395,13 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
|
|
||||||
// save off the returned sizes
|
// save off the returned sizes
|
||||||
if (tmap.isEmpty())
|
if (tmap.isEmpty())
|
||||||
font_sizes = Collections.EMPTY_MAP;
|
m_font_sizes = Collections.EMPTY_MAP;
|
||||||
else
|
else
|
||||||
font_sizes = Collections.unmodifiableMap(tmap);
|
m_font_sizes = Collections.unmodifiableMap(tmap);
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
else // no font sizes - just leave this empty
|
else // no font sizes - just leave this empty
|
||||||
font_sizes = Collections.EMPTY_MAP;
|
m_font_sizes = Collections.EMPTY_MAP;
|
||||||
|
|
||||||
// Load all the colors.
|
// Load all the colors.
|
||||||
colors = new ColorPalette(loader.configGetSubSection(sect_h,"colors"));
|
colors = new ColorPalette(loader.configGetSubSection(sect_h,"colors"));
|
||||||
|
@ -497,6 +499,31 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
else
|
else
|
||||||
menus = Collections.unmodifiableMap(tmap);
|
menus = Collections.unmodifiableMap(tmap);
|
||||||
|
|
||||||
|
// Get the <menu-template-definitions/> section.
|
||||||
|
sect = loader.configGetSubSection(root_h,"menu-template-definitions");
|
||||||
|
|
||||||
|
tmap = new HashMap();
|
||||||
|
nl = sect.getChildNodes();
|
||||||
|
for (i=0; i<nl.getLength(); i++)
|
||||||
|
{ // look for <menudef> subnodes and use them to initialize menu templates
|
||||||
|
Node n = nl.item(i);
|
||||||
|
if (n.getNodeType()==Node.ELEMENT_NODE)
|
||||||
|
{ // verify that it's a menu template definition, then get its ID and build a menu
|
||||||
|
loader.configVerifyNodeName(n,"menu-template");
|
||||||
|
String menuid = loader.configGetAttribute((Element)n,"id");
|
||||||
|
MenuTemplate m = new MenuTemplate((Element)n,this,menuid);
|
||||||
|
tmap.put(menuid,m);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
// else just ignore it
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
if (tmap.isEmpty())
|
||||||
|
m_menu_templates = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
m_menu_templates = Collections.unmodifiableMap(tmap);
|
||||||
|
|
||||||
// Get the <dialog-definitions/> section.
|
// Get the <dialog-definitions/> section.
|
||||||
sect = loader.configGetSubSection(root_h,"dialog-definitions");
|
sect = loader.configGetSubSection(root_h,"dialog-definitions");
|
||||||
|
|
||||||
|
@ -529,7 +556,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
|
|
||||||
private final String mapFontSize(String sz)
|
private final String mapFontSize(String sz)
|
||||||
{
|
{
|
||||||
String rc = (String)(font_sizes.get(sz));
|
String rc = (String)(m_font_sizes.get(sz));
|
||||||
return ((rc==null) ? sz : rc);
|
return ((rc==null) ? sz : rc);
|
||||||
|
|
||||||
} // end mapFontSize
|
} // end mapFontSize
|
||||||
|
@ -781,6 +808,12 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
|
|
||||||
} // end getMenu
|
} // end getMenu
|
||||||
|
|
||||||
|
public final MenuTemplate getMenuTemplate(String name)
|
||||||
|
{
|
||||||
|
return (MenuTemplate)(m_menu_templates.get(name));
|
||||||
|
|
||||||
|
} // end getMenuTemplate
|
||||||
|
|
||||||
public final String getButtonVisual(String id)
|
public final String getButtonVisual(String id)
|
||||||
{
|
{
|
||||||
return buttons.getButtonVisual(id);
|
return buttons.getButtonVisual(id);
|
||||||
|
@ -847,6 +880,22 @@ public class RootConfig implements LinkTypes, ColorSelectors
|
||||||
|
|
||||||
} // end getXmlRpcMethods
|
} // end getXmlRpcMethods
|
||||||
|
|
||||||
|
public final void addFormatParams(Map map)
|
||||||
|
{
|
||||||
|
// add font and colors first
|
||||||
|
map.put("font",font_face);
|
||||||
|
colors.fillParameterMap("color.",map);
|
||||||
|
|
||||||
|
// now add font sizes
|
||||||
|
for (Iterator it=m_font_sizes.entrySet().iterator(); it.hasNext(); )
|
||||||
|
{ // add the size parameters
|
||||||
|
Map.Entry ntry = (Map.Entry)(it.next());
|
||||||
|
map.put("size." + ntry.getKey().toString(),ntry.getValue());
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
} // end addFormatParams
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Static initializer
|
* Static initializer
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
|
|
26
src/com/silverwrist/venice/ui/helpers/ResourceLoader.java
Normal file
26
src/com/silverwrist/venice/ui/helpers/ResourceLoader.java
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* 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@ricochet.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.venice.ui.helpers;
|
||||||
|
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
|
|
||||||
|
public interface ResourceLoader
|
||||||
|
{
|
||||||
|
public MenuTemplate getMenuTemplate(String name);
|
||||||
|
|
||||||
|
} // end interface ResourceLoader
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,9 @@ import java.io.IOException;
|
||||||
import javax.servlet.jsp.*;
|
import javax.servlet.jsp.*;
|
||||||
import javax.servlet.jsp.tagext.*;
|
import javax.servlet.jsp.tagext.*;
|
||||||
import com.silverwrist.venice.ui.*;
|
import com.silverwrist.venice.ui.*;
|
||||||
|
import com.silverwrist.venice.ui.helpers.ResourceLoader;
|
||||||
import com.silverwrist.venice.ui.menus.MenuComponent;
|
import com.silverwrist.venice.ui.menus.MenuComponent;
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
|
|
||||||
public class FrameCurrentMenuTag extends VeniceTagSupport
|
public class FrameCurrentMenuTag extends VeniceTagSupport
|
||||||
{
|
{
|
||||||
|
@ -32,15 +34,21 @@ public class FrameCurrentMenuTag extends VeniceTagSupport
|
||||||
|
|
||||||
public int doStartTag() throws JspException
|
public int doStartTag() throws JspException
|
||||||
{
|
{
|
||||||
|
RequestInput ri = getRequestInput();
|
||||||
MenuComponent mc =
|
MenuComponent mc =
|
||||||
(MenuComponent)(getRequestInput().getSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR));
|
(MenuComponent)(ri.getSessionAttribute(RequestInput.LEFT_MENU_SESSION_ATTR));
|
||||||
if (mc==null)
|
if (mc==null)
|
||||||
throw new JspTagException("<frame:currentmenu/> menu not defined!");
|
throw new JspTagException("<frame:currentmenu/> menu not defined!");
|
||||||
|
|
||||||
|
ResourceLoader rload = (ResourceLoader)(ri.queryService(ResourceLoader.class));
|
||||||
|
MenuTemplate templ = rload.getMenuTemplate("left");
|
||||||
|
if (templ==null)
|
||||||
|
throw new JspTagException("internal error: \"left\" menu template not defined!");
|
||||||
|
|
||||||
try
|
try
|
||||||
{ // write out what we came here to accomplish
|
{ // write out what we came here to accomplish
|
||||||
JspWriter out = pageContext.getOut();
|
JspWriter out = pageContext.getOut();
|
||||||
mc.renderOnLeft(getRequestOutput(),out);
|
mc.render(getRequestOutput(),out,templ);
|
||||||
|
|
||||||
} // end try
|
} // end try
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,9 @@ import java.io.IOException;
|
||||||
import javax.servlet.jsp.*;
|
import javax.servlet.jsp.*;
|
||||||
import javax.servlet.jsp.tagext.*;
|
import javax.servlet.jsp.tagext.*;
|
||||||
import com.silverwrist.venice.ui.*;
|
import com.silverwrist.venice.ui.*;
|
||||||
|
import com.silverwrist.venice.ui.helpers.ResourceLoader;
|
||||||
import com.silverwrist.venice.ui.menus.MenuComponent;
|
import com.silverwrist.venice.ui.menus.MenuComponent;
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
|
|
||||||
public class FrameLeftMenuTag extends VeniceTagSupport
|
public class FrameLeftMenuTag extends VeniceTagSupport
|
||||||
{
|
{
|
||||||
|
@ -30,7 +32,7 @@ public class FrameLeftMenuTag extends VeniceTagSupport
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String name = null;
|
private String m_name = null;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Overrides from class TagSupport
|
* Overrides from class TagSupport
|
||||||
|
@ -39,16 +41,22 @@ public class FrameLeftMenuTag extends VeniceTagSupport
|
||||||
|
|
||||||
public int doStartTag() throws JspException
|
public int doStartTag() throws JspException
|
||||||
{
|
{
|
||||||
if (name==null)
|
if (m_name==null)
|
||||||
throw new JspTagException("<frame:leftmenu/> tag without name= attribute!");
|
throw new JspTagException("<frame:leftmenu/> tag without name= attribute!");
|
||||||
MenuComponent mc = getRequestInput().getMenu(name);
|
RequestInput ri = getRequestInput();
|
||||||
|
MenuComponent mc = ri.getMenu(m_name);
|
||||||
if (mc==null)
|
if (mc==null)
|
||||||
throw new JspTagException("<frame:leftmenu/> menu name= not defined!");
|
throw new JspTagException("<frame:leftmenu/> menu name= not defined!");
|
||||||
|
|
||||||
|
ResourceLoader rload = (ResourceLoader)(ri.queryService(ResourceLoader.class));
|
||||||
|
MenuTemplate templ = rload.getMenuTemplate("left");
|
||||||
|
if (templ==null)
|
||||||
|
throw new JspTagException("internal error: \"left\" menu template not defined!");
|
||||||
|
|
||||||
try
|
try
|
||||||
{ // write out what we came here to accomplish
|
{ // write out what we came here to accomplish
|
||||||
JspWriter out = pageContext.getOut();
|
JspWriter out = pageContext.getOut();
|
||||||
mc.renderOnLeft(getRequestOutput(),out);
|
mc.render(getRequestOutput(),out,templ);
|
||||||
|
|
||||||
} // end try
|
} // end try
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
@ -64,7 +72,7 @@ public class FrameLeftMenuTag extends VeniceTagSupport
|
||||||
public void release()
|
public void release()
|
||||||
{
|
{
|
||||||
super.release();
|
super.release();
|
||||||
name = null;
|
m_name = null;
|
||||||
|
|
||||||
} // end release
|
} // end release
|
||||||
|
|
||||||
|
@ -75,7 +83,7 @@ public class FrameLeftMenuTag extends VeniceTagSupport
|
||||||
|
|
||||||
public void setName(String s)
|
public void setName(String s)
|
||||||
{
|
{
|
||||||
name = s;
|
m_name = s;
|
||||||
|
|
||||||
} // end setName
|
} // end setName
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -28,16 +28,24 @@ import com.silverwrist.venice.ui.helpers.HTMLRendering;
|
||||||
|
|
||||||
public class CommunityMenu implements MenuComponent
|
public class CommunityMenu implements MenuComponent
|
||||||
{
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Static data members
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private static final TextItem s_unjoin = new TextItem("Unjoin");
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Attributes
|
* Attributes
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String image_url; // path to actual image
|
private String m_image_url; // path to actual image
|
||||||
private String title; // title for menu
|
private String m_title; // title for menu
|
||||||
private List items_list; // list of menu items
|
private List m_items_list; // list of menu items
|
||||||
private int cid; // community ID
|
private int m_cid; // community ID
|
||||||
private boolean show_unjoin; // show the "Unjoin" menu choice?
|
private boolean m_show_unjoin; // show the "Unjoin" menu choice?
|
||||||
|
private MenuComponent m_unjoin = null; // "unjoin" menu choice, or null
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -49,19 +57,21 @@ public class CommunityMenu implements MenuComponent
|
||||||
try
|
try
|
||||||
{ // retrieve the contact info for this puppy
|
{ // retrieve the contact info for this puppy
|
||||||
ContactInfo ci = ctxt.getContactInfo();
|
ContactInfo ci = ctxt.getContactInfo();
|
||||||
image_url = ci.getPhotoURL();
|
m_image_url = ci.getPhotoURL();
|
||||||
|
|
||||||
} // end try
|
} // end try
|
||||||
catch (DataException e)
|
catch (DataException e)
|
||||||
{ // if we couldn't get the contact info, screw it
|
{ // if we couldn't get the contact info, screw it
|
||||||
image_url = null;
|
m_image_url = null;
|
||||||
|
|
||||||
} // end catch
|
} // end catch
|
||||||
|
|
||||||
title = StringUtil.encodeHTML(ctxt.getName());
|
m_title = ctxt.getName();
|
||||||
items_list = items;
|
m_items_list = items;
|
||||||
cid = ctxt.getCommunityID();
|
m_cid = ctxt.getCommunityID();
|
||||||
show_unjoin = ctxt.canUnjoin();
|
m_show_unjoin = ctxt.canUnjoin();
|
||||||
|
if (ctxt.canUnjoin())
|
||||||
|
m_unjoin = new LinkItem("comm/unjoin.js.vs?cc=" + ctxt.getCommunityID(),LinkTypes.SERVLET,s_unjoin);
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -70,82 +80,52 @@ public class CommunityMenu implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,Collections.EMPTY_SET);
|
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
||||||
|
if (wr==null)
|
||||||
|
wr = out.getWriter();
|
||||||
|
template.writeBlock(wr,"pre-comm");
|
||||||
|
wr.write(html.getCommunityLogoTag(m_image_url));
|
||||||
|
template.writeBlock(wr,"title-pre-comm");
|
||||||
|
template.renderTitle(wr,m_title,null);
|
||||||
|
template.writeBlock(wr,"title-post-comm");
|
||||||
|
|
||||||
|
if ((m_items_list.size()>0) || m_show_unjoin)
|
||||||
|
{ // write the items list
|
||||||
|
template.writeBlock(wr,"items-pre-comm");
|
||||||
|
for (Iterator it=m_items_list.iterator(); it.hasNext(); )
|
||||||
|
{ // display each menu item in turn
|
||||||
|
MenuComponent mc = (MenuComponent)(it.next());
|
||||||
|
mc.render(out,wr,template,defines);
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
if (m_show_unjoin)
|
||||||
|
{ // write the "Unjoin" link
|
||||||
|
if (m_items_list.size()>0)
|
||||||
|
template.writeBlock(wr,"unjoin-break");
|
||||||
|
m_unjoin.render(out,wr,template,defines);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
template.writeBlock(wr,"items-post-comm");
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
template.writeBlock(wr,"post-comm");
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
this.render(out,wr,template,Collections.EMPTY_SET);
|
||||||
|
|
||||||
if (wr==null)
|
|
||||||
wr = out.getWriter();
|
|
||||||
|
|
||||||
wr.write("<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0><TR VALIGN=BOTTOM>\n<TD ALIGN=LEFT WIDTH=110>"
|
|
||||||
+ html.getCommunityLogoTag(image_url) + "</TD>\n<TD ALIGN=LEFT>\n");
|
|
||||||
|
|
||||||
// display the title
|
|
||||||
out.writeContentHeader(wr,title,null);
|
|
||||||
wr.write("</TD>\n</TR></TABLE><BR>\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("<P><IMG SRC=\"" + html.getImagePath("purple-ball.gif")
|
|
||||||
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0><A HREF=\""
|
|
||||||
+ html.formatURL("comm/unjoin.js.vs?cc=" + cid,html.SERVLET) + "\">Unjoin</A><BR>\n");
|
|
||||||
|
|
||||||
wr.write("\n"); // all done...
|
|
||||||
|
|
||||||
} // end render
|
} // 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("<DIV ALIGN=\"LEFT\">" + html.getCommunityLogoTag(image_url) + "</DIV>\n<B>"
|
|
||||||
+ StringUtil.encodeHTML(title) + "</B><BR>\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("<BR>\n<A CLASS=\"lbar\" HREF=\"" + html.formatURL("comm/unjoin.js.vs?cc=" + cid,html.SERVLET)
|
|
||||||
+ "\">" + hilite + "Unjoin</FONT></A>\n");
|
|
||||||
|
|
||||||
wr.write("\n"); // all done...
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
return title;
|
return m_title;
|
||||||
|
|
||||||
} // end getTitle
|
} // end getTitle
|
||||||
|
|
||||||
|
@ -156,7 +136,7 @@ public class CommunityMenu implements MenuComponent
|
||||||
|
|
||||||
public final int getID()
|
public final int getID()
|
||||||
{
|
{
|
||||||
return cid;
|
return m_cid;
|
||||||
|
|
||||||
} // end getID
|
} // end getID
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,15 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
package com.silverwrist.venice.ui.menus;
|
package com.silverwrist.venice.ui.menus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.w3c.dom.*;
|
import org.w3c.dom.*;
|
||||||
import com.silverwrist.util.DOMElementHelper;
|
import com.silverwrist.util.DOMElementHelper;
|
||||||
|
@ -31,7 +30,7 @@ class HeaderItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private TextItem subitem;
|
private TextItem m_subitem;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -41,7 +40,7 @@ class HeaderItem implements MenuComponent
|
||||||
HeaderItem(Element elt)
|
HeaderItem(Element elt)
|
||||||
{
|
{
|
||||||
DOMElementHelper h = new DOMElementHelper(elt);
|
DOMElementHelper h = new DOMElementHelper(elt);
|
||||||
subitem = new TextItem(h.getElementText());
|
m_subitem = new TextItem(h.getElementText());
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -50,38 +49,26 @@ class HeaderItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
// Render the subitem first.
|
||||||
|
StringWriter subwr = new StringWriter();
|
||||||
|
m_subitem.render(out,subwr,template,defines);
|
||||||
|
subwr.flush();
|
||||||
|
|
||||||
|
// Now render this as a header.
|
||||||
|
if (wr==null)
|
||||||
|
wr = out.getWriter();
|
||||||
|
template.renderItem(wr,"header",subwr.toString(),null);
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
if (wr==null)
|
this.render(out,wr,template,java.util.Collections.EMPTY_SET);
|
||||||
wr = out.getWriter();
|
|
||||||
wr.write("<FONT SIZE=+1><B>");
|
|
||||||
subitem.render(out,wr,defines);
|
|
||||||
wr.write("</B></FONT><BR>\n");
|
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
|
|
||||||
{
|
|
||||||
this.renderOnLeft(out,wr,java.util.Collections.EMPTY_SET);
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
if (wr==null)
|
|
||||||
wr = out.getWriter();
|
|
||||||
wr.write("<B>");
|
|
||||||
subitem.renderOnLeft(out,wr,defines);
|
|
||||||
wr.write("</B><BR>\n");
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -34,12 +34,12 @@ class ImageItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String src; // image source URL
|
private String m_src; // image source URL
|
||||||
private String alt = null; // image alternate text
|
private String m_alt = null; // image alternate text
|
||||||
private String name = null; // image NAME= attribute
|
private String m_name = null; // image NAME= attribute
|
||||||
private int width; // width of image in pixels
|
private int m_width; // width of image in pixels
|
||||||
private int height; // height of image in pixels
|
private int m_height; // height of image in pixels
|
||||||
private boolean fixup; // does image source URL need fixing up?
|
private boolean m_fixup; // does image source URL need fixing up?
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -53,65 +53,65 @@ class ImageItem implements MenuComponent
|
||||||
loader.configVerifyNodeName(elt,"image");
|
loader.configVerifyNodeName(elt,"image");
|
||||||
|
|
||||||
// get image source & dimensions
|
// get image source & dimensions
|
||||||
src = loader.configGetAttribute(elt,"src");
|
m_src = loader.configGetAttribute(elt,"src");
|
||||||
width = loader.configGetAttributeInt(elt,"width");
|
m_width = loader.configGetAttributeInt(elt,"width");
|
||||||
height = loader.configGetAttributeInt(elt,"height");
|
m_height = loader.configGetAttributeInt(elt,"height");
|
||||||
|
|
||||||
// get the rest of the attributes
|
// get the rest of the attributes
|
||||||
DOMElementHelper h = new DOMElementHelper(elt);
|
DOMElementHelper h = new DOMElementHelper(elt);
|
||||||
if (h.hasAttribute("alt"))
|
if (h.hasAttribute("alt"))
|
||||||
alt = elt.getAttribute("alt");
|
m_alt = elt.getAttribute("alt");
|
||||||
if (h.hasAttribute("name"))
|
if (h.hasAttribute("name"))
|
||||||
name = elt.getAttribute("name");
|
m_name = elt.getAttribute("name");
|
||||||
if (h.hasAttribute("fixup"))
|
if (h.hasAttribute("fixup"))
|
||||||
fixup = true;
|
m_fixup = true;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Internal operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private final String getImageTag(RequestOutput out)
|
||||||
|
{
|
||||||
|
StringBuffer buf = new StringBuffer("<img src=\"");
|
||||||
|
if (m_fixup)
|
||||||
|
{ // fix up the image path
|
||||||
|
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
||||||
|
m_src = html.getImagePath(m_src);
|
||||||
|
m_fixup = false;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
buf.append(m_src).append("\" width=\"").append(m_width).append("\" height=\"").append(m_height).append("\"");
|
||||||
|
if (m_alt!=null)
|
||||||
|
buf.append(" alt=\"").append(m_alt).append("\" title=\"").append(m_alt).append("\"");
|
||||||
|
if (m_name!=null)
|
||||||
|
buf.append(" name=\"").append(m_name).append("\"");
|
||||||
|
buf.append(" border=\"0\" />");
|
||||||
|
return buf.toString();
|
||||||
|
|
||||||
|
} // end getImageTag
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Implementations from interface MenuComponent
|
* Implementations from interface MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
|
||||||
|
|
||||||
} // end render
|
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
{
|
||||||
if (wr==null)
|
if (wr==null)
|
||||||
wr = out.getWriter();
|
wr = out.getWriter();
|
||||||
wr.write("<IMG SRC=\"");
|
template.renderItem(wr,"image",getImageTag(out),null);
|
||||||
if (fixup)
|
|
||||||
{ // fix up the image path
|
|
||||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
|
||||||
src = html.getImagePath(src);
|
|
||||||
fixup = false;
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
wr.write(src + "\" WIDTH=" + width + " HEIGHT=" + height);
|
|
||||||
if (alt!=null)
|
|
||||||
wr.write(" ALT=\"" + alt + "\"");
|
|
||||||
if (name!=null)
|
|
||||||
wr.write(" NAME=\"" + name + "\"");
|
|
||||||
wr.write(" BORDER=0>");
|
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
this.render(out,wr,template,java.util.Collections.EMPTY_SET);
|
||||||
|
|
||||||
} // end renderOnLeft
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
this.render(out,wr,defines);
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,18 +9,16 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
package com.silverwrist.venice.ui.menus;
|
package com.silverwrist.venice.ui.menus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.Writer;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import org.apache.log4j.*;
|
import org.apache.log4j.*;
|
||||||
import org.w3c.dom.*;
|
import org.w3c.dom.*;
|
||||||
import com.silverwrist.util.*;
|
import com.silverwrist.util.*;
|
||||||
|
@ -37,23 +35,23 @@ class LinkItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static Category logger = Category.getInstance(LinkItem.class);
|
private static Logger logger = Logger.getLogger(LinkItem.class);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Attributes
|
* Attributes
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String href; // what we actually link to
|
private String m_href; // what we actually link to
|
||||||
private int type; // the type of item we specify
|
private int m_type; // the type of item we specify
|
||||||
private boolean enabled = true; // is this item enabled?
|
private boolean m_enabled = true; // is this item enabled?
|
||||||
private String target = null; // target window for the link
|
private String m_target = null; // target window for the link
|
||||||
private String title = null; // title (tooltip) for the link
|
private String m_title = null; // title (tooltip) for the link
|
||||||
private String on_click = null; // onClick JavaScript for the link
|
private String m_on_click = null; // onClick JavaScript for the link
|
||||||
private String ifdef_sym = null; // include only if defined
|
private String m_ifdef_sym = null; // include only if defined
|
||||||
private String ifndef_sym = null; // include only if NOT defined
|
private String m_ifndef_sym = null; // include only if NOT defined
|
||||||
private int indent = 0; // how many spaces do we indent this link?
|
private int m_indent = 0; // how many spaces do we indent this link?
|
||||||
private MenuComponent contents; // what does this link contain? (image vs. text)
|
private MenuComponent m_contents; // what does this link contain? (image vs. text)
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -66,47 +64,47 @@ class LinkItem implements MenuComponent
|
||||||
|
|
||||||
loader.configVerifyNodeName(elt,"link");
|
loader.configVerifyNodeName(elt,"link");
|
||||||
|
|
||||||
href = loader.configGetAttribute(elt,"href");
|
m_href = loader.configGetAttribute(elt,"href");
|
||||||
|
|
||||||
DOMElementHelper h = new DOMElementHelper(elt);
|
DOMElementHelper h = new DOMElementHelper(elt);
|
||||||
if (h.hasAttribute("type"))
|
if (h.hasAttribute("type"))
|
||||||
{ // convert link type to an index
|
{ // convert link type to an index
|
||||||
type = rconf.convertLinkType(elt.getAttribute("type"));
|
m_type = rconf.convertLinkType(elt.getAttribute("type"));
|
||||||
if (type<0) // the type is not valid
|
if (m_type<0) // the type is not valid
|
||||||
throw new ConfigException("invalid type= attribute of <link/>");
|
throw new ConfigException("invalid type= attribute of <link/>");
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
else // default to "absolute"
|
else // default to "absolute"
|
||||||
type = LinkTypes.ABSOLUTE;
|
m_type = LinkTypes.ABSOLUTE;
|
||||||
|
|
||||||
// load the "target"
|
// load the "target"
|
||||||
if (h.hasAttribute("target"))
|
if (h.hasAttribute("target"))
|
||||||
target = elt.getAttribute("target");
|
m_target = elt.getAttribute("target");
|
||||||
|
|
||||||
// load the "title"
|
// load the "title"
|
||||||
if (h.hasAttribute("title"))
|
if (h.hasAttribute("title"))
|
||||||
title = elt.getAttribute("title");
|
m_title = elt.getAttribute("title");
|
||||||
|
|
||||||
// load the "onClick" script code
|
// load the "onClick" script code
|
||||||
if (h.hasAttribute("onClick"))
|
if (h.hasAttribute("onClick"))
|
||||||
on_click = elt.getAttribute("onClick");
|
m_on_click = elt.getAttribute("onClick");
|
||||||
|
|
||||||
// load the "ifdef" and "ifndef" symbols
|
// load the "ifdef" and "ifndef" symbols
|
||||||
if (h.hasAttribute("ifdef"))
|
if (h.hasAttribute("ifdef"))
|
||||||
ifdef_sym = elt.getAttribute("ifdef");
|
m_ifdef_sym = elt.getAttribute("ifdef");
|
||||||
if (h.hasAttribute("ifndef"))
|
if (h.hasAttribute("ifndef"))
|
||||||
ifndef_sym = elt.getAttribute("ifndef");
|
m_ifndef_sym = elt.getAttribute("ifndef");
|
||||||
|
|
||||||
// load the "disabled" attribute
|
// load the "disabled" attribute
|
||||||
if (h.hasAttribute("disabled"))
|
if (h.hasAttribute("disabled"))
|
||||||
enabled = false;
|
m_enabled = false;
|
||||||
|
|
||||||
if (h.hasAttribute("indent"))
|
if (h.hasAttribute("indent"))
|
||||||
{ // load the "indent" attribute, make sure it's not less than 0
|
{ // load the "indent" attribute, make sure it's not less than 0
|
||||||
indent = loader.configGetAttributeInt(elt,"indent");
|
m_indent = loader.configGetAttributeInt(elt,"indent");
|
||||||
if (indent<0)
|
if (m_indent<0)
|
||||||
{ // whoops - this is an error!
|
{ // whoops - this is an error!
|
||||||
logger.fatal("indent=\"" + indent + "\" is not a valid value");
|
logger.fatal("indent=\"" + m_indent + "\" is not a valid value");
|
||||||
throw new ConfigException("invalid indent= attribute of <link/>");
|
throw new ConfigException("invalid indent= attribute of <link/>");
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
@ -116,24 +114,32 @@ class LinkItem implements MenuComponent
|
||||||
// load the contents
|
// load the contents
|
||||||
Element x = h.getSubElement("image");
|
Element x = h.getSubElement("image");
|
||||||
if (x!=null)
|
if (x!=null)
|
||||||
contents = new ImageItem(x);
|
m_contents = new ImageItem(x);
|
||||||
else
|
else
|
||||||
contents = new TextItem(h.getElementText());
|
m_contents = new TextItem(h.getElementText());
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
LinkItem(String href, int type, MenuComponent contents)
|
||||||
|
{
|
||||||
|
m_href = href;
|
||||||
|
m_type = type;
|
||||||
|
m_contents = contents;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
LinkItem(LinkItem other, Map vars)
|
LinkItem(LinkItem other, Map vars)
|
||||||
{
|
{
|
||||||
this.href = StringUtil.replaceAllVariables(other.href,vars);
|
m_href = StringUtil.replaceAllVariables(other.m_href,vars);
|
||||||
this.type = other.type;
|
m_type = other.m_type;
|
||||||
this.enabled = other.enabled;
|
m_enabled = other.m_enabled;
|
||||||
this.target = other.target;
|
m_target = other.m_target;
|
||||||
this.title = other.title;
|
m_title = other.m_title;
|
||||||
this.on_click = StringUtil.replaceAllVariables(other.on_click,vars);
|
m_on_click = StringUtil.replaceAllVariables(other.m_on_click,vars);
|
||||||
this.ifdef_sym = other.ifdef_sym;
|
m_ifdef_sym = other.m_ifdef_sym;
|
||||||
this.ifndef_sym = other.ifndef_sym;
|
m_ifndef_sym = other.m_ifndef_sym;
|
||||||
this.indent = other.indent;
|
m_indent = other.m_indent;
|
||||||
this.contents = other.contents;
|
m_contents = other.m_contents;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -144,100 +150,67 @@ class LinkItem implements MenuComponent
|
||||||
|
|
||||||
private final String getAddress(HTMLRendering html, Map vars)
|
private final String getAddress(HTMLRendering html, Map vars)
|
||||||
{
|
{
|
||||||
String s = StringUtil.replaceAllVariables(href,vars);
|
String s = StringUtil.replaceAllVariables(m_href,vars);
|
||||||
return html.formatURL(s,type);
|
return html.formatURL(s,m_type);
|
||||||
|
|
||||||
} // end getAddress
|
} // end getAddress
|
||||||
|
|
||||||
|
private final String getExtraAttributes()
|
||||||
|
{
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
if (m_target!=null)
|
||||||
|
buf.append(" target=\"").append(m_target).append("\"");
|
||||||
|
if (m_title!=null)
|
||||||
|
buf.append(" title=\"").append(m_title).append("\"");
|
||||||
|
if (m_on_click!=null)
|
||||||
|
buf.append(" onClick=\"").append(m_on_click).append("\"");
|
||||||
|
return buf.toString();
|
||||||
|
|
||||||
|
} // end getExtraAttributes
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Implementations from interface MenuComponent
|
* Implementations from interface MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
if ((m_ifdef_sym!=null) && !(defines.contains(m_ifdef_sym)))
|
||||||
|
|
||||||
} // end render
|
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
if ((ifdef_sym!=null) && !(defines.contains(ifdef_sym)))
|
|
||||||
return;
|
return;
|
||||||
if ((ifndef_sym!=null) && defines.contains(ifndef_sym))
|
if ((m_ifndef_sym!=null) && defines.contains(m_ifndef_sym))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
||||||
|
|
||||||
|
// Build up the parms map.
|
||||||
|
HashMap parms = new HashMap();
|
||||||
|
parms.put("xattr",getExtraAttributes());
|
||||||
|
parms.put("stdbullet","<img src=\"" + html.getImagePath("purple-ball.gif")
|
||||||
|
+ "\" alt=\"*\" width=\"14\" height=\"14\" border=\"0\" />");
|
||||||
|
|
||||||
|
// Format the item text to a StringWriter.
|
||||||
|
StringWriter subwr = new StringWriter();
|
||||||
|
m_contents.render(out,subwr,template,defines);
|
||||||
|
subwr.flush();
|
||||||
|
|
||||||
if (wr==null)
|
if (wr==null)
|
||||||
wr = out.getWriter();
|
wr = out.getWriter();
|
||||||
for (int i=0; i<indent; i++)
|
|
||||||
wr.write(" "); // do indent
|
|
||||||
wr.write("<IMG SRC=\"" + html.getImagePath("purple-ball.gif")
|
|
||||||
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0> ");
|
|
||||||
if (enabled)
|
|
||||||
{ // render the URL as an <A> tag
|
|
||||||
wr.write("<A HREF=\"" + html.formatURL(href,type) + "\"");
|
|
||||||
if (target!=null)
|
|
||||||
wr.write(" TARGET=\"" + target + "\"");
|
|
||||||
if (title!=null)
|
|
||||||
wr.write(" TITLE=\"" + title + "\"");
|
|
||||||
if (on_click!=null)
|
|
||||||
wr.write(" onClick=\"" + on_click + "\"");
|
|
||||||
wr.write(">");
|
|
||||||
|
|
||||||
} // end if
|
// output the indenting
|
||||||
else // just disable the color
|
String nstr = template.getBlock("link-indent");
|
||||||
wr.write(html.getFontTag(html.CONTENT_DISABLED,null));
|
for (int i=0; i<m_indent; i++)
|
||||||
contents.render(out,wr,defines);
|
wr.write(nstr);
|
||||||
if (enabled)
|
|
||||||
wr.write("</A>");
|
// output the actual item
|
||||||
else
|
template.renderItem(wr,(m_enabled ? "normal" : "disabled"),subwr.toString(),html.formatURL(m_href,m_type),parms);
|
||||||
wr.write("</FONT>");
|
|
||||||
wr.write("<BR>\n");
|
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
this.renderOnLeft(out,wr,java.util.Collections.EMPTY_SET);
|
this.render(out,wr,template,java.util.Collections.EMPTY_SET);
|
||||||
|
|
||||||
} // end renderOnLeft
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
if ((ifdef_sym!=null) && !(defines.contains(ifdef_sym)))
|
|
||||||
return;
|
|
||||||
if ((ifndef_sym!=null) && defines.contains(ifndef_sym))
|
|
||||||
return;
|
|
||||||
|
|
||||||
HTMLRendering html = (HTMLRendering)(out.queryService(HTMLRendering.class));
|
|
||||||
|
|
||||||
if (wr==null)
|
|
||||||
wr = out.getWriter();
|
|
||||||
for (int i=0; i<indent; i++)
|
|
||||||
wr.write(" "); // do indent
|
|
||||||
if (enabled)
|
|
||||||
{ // write the opening <A> and <FONT> tags
|
|
||||||
wr.write("<A HREF=\"" + html.formatURL(href,type) + "\" CLASS=\"lbar\"");
|
|
||||||
if (target!=null)
|
|
||||||
wr.write(" TARGET=\"" + target + "\"");
|
|
||||||
if (title!=null)
|
|
||||||
wr.write(" TITLE=\"" + title + "\"");
|
|
||||||
if (on_click!=null)
|
|
||||||
wr.write(" onClick=\"" + on_click + "\"");
|
|
||||||
wr.write(">" + html.getFontTag(html.LEFT_LINK,null));
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
else
|
|
||||||
wr.write(html.getFontTag(html.CONTENT_DISABLED,null));
|
|
||||||
contents.renderOnLeft(out,wr,defines);
|
|
||||||
wr.write("</FONT>");
|
|
||||||
if (enabled)
|
|
||||||
wr.write("</A>");
|
|
||||||
wr.write("<BR>\n");
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -33,7 +33,7 @@ import com.silverwrist.venice.util.XMLLoader;
|
||||||
public class Menu implements MenuComponent
|
public class Menu implements MenuComponent
|
||||||
{
|
{
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Attributes
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -137,80 +137,42 @@ public class Menu implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) 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 (title!=null)
|
|
||||||
{ // write the header
|
|
||||||
if (wr==null)
|
|
||||||
out.writeContentHeader(title,subtitle);
|
|
||||||
else
|
|
||||||
out.writeContentHeader(wr,title,subtitle);
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
if (wr!=null)
|
|
||||||
{ // write using specified writer
|
|
||||||
wr.write(html.getFontTag(html.CONTENT_FOREGROUND,"content") + "\n");
|
|
||||||
wr.flush();
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
else
|
|
||||||
out.write(html.getFontTag(html.CONTENT_FOREGROUND,"content") + "\n");
|
|
||||||
|
|
||||||
Iterator it = menu_items.iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{ // render each menu item in turn
|
|
||||||
MenuComponent mc = (MenuComponent)(it.next());
|
|
||||||
mc.render(out,wr,defines);
|
|
||||||
|
|
||||||
} // end while
|
|
||||||
|
|
||||||
if (wr!=null)
|
|
||||||
{ // write using specified writer
|
|
||||||
wr.write("</FONT>\n");
|
|
||||||
wr.flush();
|
|
||||||
|
|
||||||
} // end if
|
|
||||||
else
|
|
||||||
out.write("</FONT>\n");
|
|
||||||
|
|
||||||
} // 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
|
|
||||||
{
|
{
|
||||||
if (wr==null)
|
if (wr==null)
|
||||||
wr = out.getWriter();
|
wr = out.getWriter();
|
||||||
|
template.writeBlock(wr,"pre");
|
||||||
if (title!=null)
|
if (title!=null)
|
||||||
{ // write the title and subtitle
|
{ // render the title
|
||||||
wr.write("<B>" + StringUtil.encodeHTML(title) + "</B><BR>\n");
|
template.writeBlock(wr,"title-pre");
|
||||||
if (subtitle!=null)
|
template.renderTitle(wr,title,subtitle);
|
||||||
wr.write(StringUtil.encodeHTML(subtitle) + "<BR>\n");
|
template.writeBlock(wr,"title-post");
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
Iterator it = menu_items.iterator();
|
if (menu_items.size()>0)
|
||||||
while (it.hasNext())
|
{ // write the menu items
|
||||||
{ // render each menu item in turn
|
template.writeBlock(wr,"items-pre");
|
||||||
MenuComponent mc = (MenuComponent)(it.next());
|
for (Iterator it=menu_items.iterator(); it.hasNext(); )
|
||||||
mc.renderOnLeft(out,wr,defines);
|
{ // render the menu items
|
||||||
|
MenuComponent mc = (MenuComponent)(it.next());
|
||||||
|
mc.render(out,wr,template,defines);
|
||||||
|
|
||||||
} // end while
|
} // end for
|
||||||
|
|
||||||
} // end renderOnLeft
|
template.writeBlock(wr,"items-post");
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
template.writeBlock(wr,"post");
|
||||||
|
|
||||||
|
} // end render
|
||||||
|
|
||||||
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
|
{
|
||||||
|
this.render(out,wr,template,Collections.EMPTY_SET);
|
||||||
|
|
||||||
|
} // end render
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -24,14 +24,10 @@ import com.silverwrist.venice.ui.RequestOutput;
|
||||||
|
|
||||||
public interface MenuComponent
|
public interface MenuComponent
|
||||||
{
|
{
|
||||||
public abstract void render(RequestOutput out, Writer wr) throws IOException;
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException;
|
||||||
|
|
||||||
public abstract void render(RequestOutput out, Writer wr, Set defines) throws IOException;
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException;
|
||||||
|
|
||||||
public abstract void renderOnLeft(RequestOutput out, Writer wr) throws IOException;
|
public String getTitle(RequestOutput out);
|
||||||
|
|
||||||
public abstract void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException;
|
|
||||||
|
|
||||||
public abstract String getTitle(RequestOutput out);
|
|
||||||
|
|
||||||
} // end interface MenuComponent
|
} // end interface MenuComponent
|
||||||
|
|
243
src/com/silverwrist/venice/ui/menus/MenuTemplate.java
Normal file
243
src/com/silverwrist/venice/ui/menus/MenuTemplate.java
Normal file
|
@ -0,0 +1,243 @@
|
||||||
|
/*
|
||||||
|
* 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@ricochet.com>,
|
||||||
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
|
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
*/
|
||||||
|
package com.silverwrist.venice.ui.menus;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.w3c.dom.*;
|
||||||
|
import com.silverwrist.util.*;
|
||||||
|
import com.silverwrist.venice.except.*;
|
||||||
|
import com.silverwrist.venice.ui.*;
|
||||||
|
import com.silverwrist.venice.ui.config.RootConfig;
|
||||||
|
import com.silverwrist.venice.util.XMLLoader;
|
||||||
|
|
||||||
|
public class MenuTemplate
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private String m_identifier; // menu template identifier
|
||||||
|
private RootConfig m_rootconf; // backreference to root configuration
|
||||||
|
private Map m_blocks; // blocks defined in menu template
|
||||||
|
private String m_title_single; // single title block
|
||||||
|
private String m_title_double; // double title block
|
||||||
|
private Map m_items; // item templates defined in menu template
|
||||||
|
private Map m_links; // link templates defined in menu template
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public MenuTemplate(Element elt, RootConfig rootconf, String identifier) throws ConfigException
|
||||||
|
{
|
||||||
|
XMLLoader loader = XMLLoader.get();
|
||||||
|
|
||||||
|
loader.configVerifyNodeName(elt,"menu-template"); // verify the name of the root node
|
||||||
|
m_identifier = identifier;
|
||||||
|
m_rootconf = rootconf;
|
||||||
|
|
||||||
|
// load the contents of the menu template
|
||||||
|
HashMap tmp_blocks = new HashMap();
|
||||||
|
HashMap tmp_items = new HashMap();
|
||||||
|
HashMap tmp_links = new HashMap();
|
||||||
|
NodeList nl = elt.getChildNodes();
|
||||||
|
for (int i=0; i<nl.getLength(); i++)
|
||||||
|
{ // examine each child node
|
||||||
|
Node n = nl.item(i);
|
||||||
|
if (n.getNodeType()==Node.ELEMENT_NODE)
|
||||||
|
{ // look at the node name
|
||||||
|
Element ne = (Element)n;
|
||||||
|
String nn = n.getNodeName();
|
||||||
|
if (nn.equals("block"))
|
||||||
|
{ // get block by ID and save it off
|
||||||
|
String id = ne.getAttribute("id");
|
||||||
|
if (StringUtil.isStringEmpty(id))
|
||||||
|
throw new ConfigException("menu template \"" + identifier + "\" has a <block/> with no id",ne);
|
||||||
|
DOMElementHelper h = new DOMElementHelper(ne);
|
||||||
|
tmp_blocks.put(id,h.getElementText());
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else if (nn.equals("title"))
|
||||||
|
{ // get title type and save it off
|
||||||
|
String typ = ne.getAttribute("type");
|
||||||
|
if ((typ==null) || !(typ.equalsIgnoreCase("single") || typ.equalsIgnoreCase("double")))
|
||||||
|
throw new ConfigException("menu template \"" + identifier + "\" has a <title/> with bad type \""
|
||||||
|
+ typ + "\"",ne);
|
||||||
|
DOMElementHelper h = new DOMElementHelper(ne);
|
||||||
|
if (typ.equalsIgnoreCase("single"))
|
||||||
|
m_title_single = h.getElementText();
|
||||||
|
else
|
||||||
|
m_title_double = h.getElementText();
|
||||||
|
|
||||||
|
} // end else if
|
||||||
|
else if (nn.equals("item"))
|
||||||
|
{ // save off item template
|
||||||
|
String typ = ne.getAttribute("type");
|
||||||
|
if (StringUtil.isStringEmpty(typ))
|
||||||
|
throw new ConfigException("menu template \"" + identifier + "\" has an <item/> with no type",ne);
|
||||||
|
DOMElementHelper h = new DOMElementHelper(ne);
|
||||||
|
tmp_items.put(typ,h.getElementText());
|
||||||
|
|
||||||
|
} // end else if
|
||||||
|
else if (nn.equals("link"))
|
||||||
|
{ // save off the link template
|
||||||
|
String typ = ne.getAttribute("type");
|
||||||
|
if (StringUtil.isStringEmpty(typ))
|
||||||
|
throw new ConfigException("menu template \"" + identifier + "\" has a <link/> with no type",ne);
|
||||||
|
DOMElementHelper h = new DOMElementHelper(ne);
|
||||||
|
tmp_links.put(typ,h.getElementText());
|
||||||
|
|
||||||
|
} // end else if
|
||||||
|
else // unknown item
|
||||||
|
throw new ConfigException("unknown element <" + nn + "/> inside <menu-template/>",ne);
|
||||||
|
|
||||||
|
} // end if (element found)
|
||||||
|
// else ignore this node
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
|
if (tmp_blocks.isEmpty())
|
||||||
|
m_blocks = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
m_blocks = Collections.unmodifiableMap(tmp_blocks);
|
||||||
|
if (tmp_items.isEmpty())
|
||||||
|
m_items = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
m_items = Collections.unmodifiableMap(tmp_items);
|
||||||
|
if (tmp_links.isEmpty())
|
||||||
|
m_links = Collections.EMPTY_MAP;
|
||||||
|
else
|
||||||
|
m_links = Collections.unmodifiableMap(tmp_links);
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* External operations
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public String getIdentifier()
|
||||||
|
{
|
||||||
|
return m_identifier;
|
||||||
|
|
||||||
|
} // end getIdentifier
|
||||||
|
|
||||||
|
public String getBlock(String id)
|
||||||
|
{
|
||||||
|
String bk = (String)(m_blocks.get(id));
|
||||||
|
if (StringUtil.isStringEmpty(bk))
|
||||||
|
return "";
|
||||||
|
HashMap parms = new HashMap();
|
||||||
|
m_rootconf.addFormatParams(parms);
|
||||||
|
String rc = StringUtil.replaceAllVariables(bk,parms);
|
||||||
|
return (rc==null) ? "" : rc;
|
||||||
|
|
||||||
|
} // end getBlock
|
||||||
|
|
||||||
|
public void writeBlock(Writer wr, String id) throws IOException
|
||||||
|
{
|
||||||
|
String bk = (String)(m_blocks.get(id));
|
||||||
|
if (StringUtil.isStringEmpty(bk))
|
||||||
|
return;
|
||||||
|
|
||||||
|
HashMap parms = new HashMap();
|
||||||
|
m_rootconf.addFormatParams(parms);
|
||||||
|
String out = StringUtil.replaceAllVariables(bk,parms);
|
||||||
|
if (!(StringUtil.isStringEmpty(out)))
|
||||||
|
wr.write(out);
|
||||||
|
|
||||||
|
} // end writeBlock
|
||||||
|
|
||||||
|
public void renderTitle(Writer wr, String title, String subtitle) throws IOException
|
||||||
|
{
|
||||||
|
if (StringUtil.isStringEmpty(title))
|
||||||
|
throw new IllegalArgumentException("title should not be empty!");
|
||||||
|
String templ = m_title_single;
|
||||||
|
HashMap parms = new HashMap();
|
||||||
|
parms.put("title",StringUtil.encodeHTML(title));
|
||||||
|
if (!(StringUtil.isStringEmpty(subtitle)))
|
||||||
|
{ // shift to "double" template
|
||||||
|
templ = m_title_double;
|
||||||
|
parms.put("subtitle",StringUtil.encodeHTML(subtitle));
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
m_rootconf.addFormatParams(parms);
|
||||||
|
String out = StringUtil.replaceAllVariables(templ,parms);
|
||||||
|
if (!(StringUtil.isStringEmpty(out)))
|
||||||
|
wr.write(out);
|
||||||
|
|
||||||
|
} // end renderTitle
|
||||||
|
|
||||||
|
public void renderItem(Writer wr, String type, String text, String link, Map params) throws IOException
|
||||||
|
{
|
||||||
|
String out = text;
|
||||||
|
HashMap myparms = new HashMap();
|
||||||
|
String templ = (String)(m_items.get(type));
|
||||||
|
if (templ==null)
|
||||||
|
templ = (String)(m_items.get("*"));
|
||||||
|
if (templ!=null)
|
||||||
|
{ // format the item template
|
||||||
|
if (text!=null)
|
||||||
|
{ // format the text
|
||||||
|
m_rootconf.addFormatParams(myparms);
|
||||||
|
myparms.putAll(params);
|
||||||
|
myparms.put("text",text);
|
||||||
|
out = StringUtil.replaceAllVariables(templ,myparms);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
else // just use the template as the output text
|
||||||
|
out = templ;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
if (link!=null)
|
||||||
|
{ // there's a link - need to look for a link template
|
||||||
|
templ = (String)(m_links.get(type));
|
||||||
|
if (templ==null)
|
||||||
|
templ = (String)(m_links.get("*"));
|
||||||
|
if (templ!=null)
|
||||||
|
{ // format the link
|
||||||
|
myparms.clear();
|
||||||
|
m_rootconf.addFormatParams(myparms);
|
||||||
|
myparms.putAll(params);
|
||||||
|
myparms.put("link",link);
|
||||||
|
myparms.put("item",out);
|
||||||
|
if (text!=null)
|
||||||
|
myparms.put("text",text);
|
||||||
|
out = StringUtil.replaceAllVariables(templ,myparms);
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
if (!(StringUtil.isStringEmpty(out)))
|
||||||
|
wr.write(out); // write it!
|
||||||
|
|
||||||
|
} // end renderItem
|
||||||
|
|
||||||
|
public void renderItem(Writer wr, String type, String text, String link) throws IOException
|
||||||
|
{
|
||||||
|
this.renderItem(wr,type,text,link,Collections.EMPTY_MAP);
|
||||||
|
|
||||||
|
} // end renderItem
|
||||||
|
|
||||||
|
} // end class MenuTemplate
|
|
@ -9,16 +9,15 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
package com.silverwrist.venice.ui.menus;
|
package com.silverwrist.venice.ui.menus;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import com.silverwrist.venice.ui.RequestOutput;
|
import com.silverwrist.venice.ui.RequestOutput;
|
||||||
|
|
||||||
|
@ -29,14 +28,14 @@ class SeparatorItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private static SeparatorItem the_blank = new SeparatorItem(null);
|
private static SeparatorItem s_blank = new SeparatorItem(null);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Attributes
|
* Attributes
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private MenuComponent subitem;
|
private MenuComponent m_subitem;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -45,7 +44,7 @@ class SeparatorItem implements MenuComponent
|
||||||
|
|
||||||
SeparatorItem(MenuComponent subitem)
|
SeparatorItem(MenuComponent subitem)
|
||||||
{
|
{
|
||||||
this.subitem = subitem;
|
m_subitem = subitem;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -54,38 +53,30 @@ class SeparatorItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
String text = "";
|
||||||
|
if (m_subitem!=null)
|
||||||
|
{ // render the subitem
|
||||||
|
StringWriter subwr = new StringWriter();
|
||||||
|
m_subitem.render(out,subwr,template,defines);
|
||||||
|
subwr.flush();
|
||||||
|
text = subwr.toString();
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
if (wr==null)
|
||||||
|
wr = out.getWriter();
|
||||||
|
template.renderItem(wr,"separator",text,null);
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
if (subitem!=null)
|
this.render(out,wr,template,java.util.Collections.EMPTY_SET);
|
||||||
subitem.render(out,wr,defines);
|
|
||||||
if (wr==null)
|
|
||||||
wr = out.getWriter();
|
|
||||||
wr.write("<BR>\n");
|
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
|
|
||||||
{
|
|
||||||
this.renderOnLeft(out,wr,java.util.Collections.EMPTY_SET);
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
if (subitem!=null)
|
|
||||||
subitem.renderOnLeft(out,wr,defines);
|
|
||||||
if (wr==null)
|
|
||||||
wr = out.getWriter();
|
|
||||||
wr.write("<BR>\n");
|
|
||||||
|
|
||||||
} // end renderHere
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -99,7 +90,7 @@ class SeparatorItem implements MenuComponent
|
||||||
|
|
||||||
static SeparatorItem getBlank()
|
static SeparatorItem getBlank()
|
||||||
{
|
{
|
||||||
return the_blank;
|
return s_blank;
|
||||||
|
|
||||||
} // end getBlank
|
} // end getBlank
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +30,7 @@ class TextItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private String contents;
|
private String m_contents;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -39,7 +39,7 @@ class TextItem implements MenuComponent
|
||||||
|
|
||||||
TextItem(String contents)
|
TextItem(String contents)
|
||||||
{
|
{
|
||||||
this.contents = StringUtil.encodeHTML(contents);
|
m_contents = StringUtil.encodeHTML(contents);
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -48,32 +48,19 @@ class TextItem implements MenuComponent
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template, Set defines) throws IOException
|
||||||
{
|
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
|
||||||
|
|
||||||
} // end render
|
|
||||||
|
|
||||||
public void render(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
{
|
||||||
if (wr==null)
|
if (wr==null)
|
||||||
out.write(contents);
|
wr = out.getWriter();
|
||||||
else
|
template.renderItem(wr,"text",m_contents,null);
|
||||||
wr.write(contents);
|
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr) throws IOException
|
public void render(RequestOutput out, Writer wr, MenuTemplate template) throws IOException
|
||||||
{
|
{
|
||||||
this.render(out,wr,java.util.Collections.EMPTY_SET);
|
this.render(out,wr,template,java.util.Collections.EMPTY_SET);
|
||||||
|
|
||||||
} // end renderOnLeft
|
} // end render
|
||||||
|
|
||||||
public void renderOnLeft(RequestOutput out, Writer wr, Set defines) throws IOException
|
|
||||||
{
|
|
||||||
this.render(out,wr,defines);
|
|
||||||
|
|
||||||
} // end renderOnLeft
|
|
||||||
|
|
||||||
public String getTitle(RequestOutput out)
|
public String getTitle(RequestOutput out)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,6 +38,7 @@ import com.silverwrist.venice.ui.helpers.*;
|
||||||
import com.silverwrist.venice.ui.menus.CommunityMenu;
|
import com.silverwrist.venice.ui.menus.CommunityMenu;
|
||||||
import com.silverwrist.venice.ui.menus.Menu;
|
import com.silverwrist.venice.ui.menus.Menu;
|
||||||
import com.silverwrist.venice.ui.menus.MenuComponent;
|
import com.silverwrist.venice.ui.menus.MenuComponent;
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
import com.silverwrist.venice.ui.script.*;
|
import com.silverwrist.venice.ui.script.*;
|
||||||
import com.silverwrist.venice.util.XMLLoader;
|
import com.silverwrist.venice.util.XMLLoader;
|
||||||
|
|
||||||
|
@ -75,6 +76,8 @@ public class RequestImpl implements RequestInput
|
||||||
{
|
{
|
||||||
if (klass==HTMLRendering.class)
|
if (klass==HTMLRendering.class)
|
||||||
return RequestImpl.this.queryService(klass);
|
return RequestImpl.this.queryService(klass);
|
||||||
|
if (klass==ResourceLoader.class)
|
||||||
|
return RequestImpl.this.queryService(klass);
|
||||||
throw new NoSuchServiceException("RequestOutput",klass);
|
throw new NoSuchServiceException("RequestOutput",klass);
|
||||||
|
|
||||||
} // end queryService
|
} // end queryService
|
||||||
|
@ -553,6 +556,7 @@ public class RequestImpl implements RequestInput
|
||||||
private CookieControlImpl cookie_control = null; // cookie control interface
|
private CookieControlImpl cookie_control = null; // cookie control interface
|
||||||
private HTMLRenderingImpl html_rendering = null; // HTML rendering interface
|
private HTMLRenderingImpl html_rendering = null; // HTML rendering interface
|
||||||
private ScriptSupportImpl script_support = null; // script support interface
|
private ScriptSupportImpl script_support = null; // script support interface
|
||||||
|
private ResourceLoaderImpl m_resource_loader = null; // resource loader interface
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -902,6 +906,14 @@ public class RequestImpl implements RequestInput
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
|
if (klass==ResourceLoader.class)
|
||||||
|
{ // create script support object and return it
|
||||||
|
if (m_resource_loader==null)
|
||||||
|
m_resource_loader = new ResourceLoaderImpl(config);
|
||||||
|
return m_resource_loader;
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
throw new NoSuchServiceException("RequestInput",klass);
|
throw new NoSuchServiceException("RequestInput",klass);
|
||||||
|
|
||||||
} // end queryService
|
} // end queryService
|
||||||
|
@ -2272,8 +2284,8 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private RequestImpl req; // request we're attached to
|
private RequestImpl m_req; // request we're attached to
|
||||||
private RootConfig config; // configuration data
|
private RootConfig m_config; // configuration data
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -2282,8 +2294,8 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
|
|
||||||
ScriptSupportImpl(RequestImpl req, RootConfig config)
|
ScriptSupportImpl(RequestImpl req, RootConfig config)
|
||||||
{
|
{
|
||||||
this.req = req;
|
m_req = req;
|
||||||
this.config = config;
|
m_config = config;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -2329,13 +2341,13 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
|
|
||||||
public String getScriptName(String raw_name)
|
public String getScriptName(String raw_name)
|
||||||
{
|
{
|
||||||
return config.getScriptPath(raw_name);
|
return m_config.getScriptPath(raw_name);
|
||||||
|
|
||||||
} // end getScriptName
|
} // end getScriptName
|
||||||
|
|
||||||
public String getScriptName(boolean strip_ext)
|
public String getScriptName(boolean strip_ext)
|
||||||
{
|
{
|
||||||
String script = req.getServletPath();
|
String script = m_req.getServletPath();
|
||||||
if (script.charAt(0)=='/')
|
if (script.charAt(0)=='/')
|
||||||
script = script.substring(1);
|
script = script.substring(1);
|
||||||
|
|
||||||
|
@ -2348,7 +2360,7 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
|
|
||||||
} // end if
|
} // end if
|
||||||
|
|
||||||
return config.getScriptPath(script);
|
return m_config.getScriptPath(script);
|
||||||
|
|
||||||
} // end getScriptName
|
} // end getScriptName
|
||||||
|
|
||||||
|
@ -2360,7 +2372,7 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
|
|
||||||
public String getScriptLoggerName()
|
public String getScriptLoggerName()
|
||||||
{
|
{
|
||||||
String script = req.getServletPath();
|
String script = m_req.getServletPath();
|
||||||
if (script.charAt(0)=='/')
|
if (script.charAt(0)=='/')
|
||||||
script = script.substring(1);
|
script = script.substring(1);
|
||||||
|
|
||||||
|
@ -2370,7 +2382,7 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
|
|
||||||
public String getRPCScriptName(String raw_name)
|
public String getRPCScriptName(String raw_name)
|
||||||
{
|
{
|
||||||
return config.getRPCScriptPath(raw_name);
|
return m_config.getRPCScriptPath(raw_name);
|
||||||
|
|
||||||
} // end getScriptName
|
} // end getScriptName
|
||||||
|
|
||||||
|
@ -2381,3 +2393,36 @@ class ScriptSupportImpl implements ScriptSupport
|
||||||
} // end getScriptLoggerName
|
} // end getScriptLoggerName
|
||||||
|
|
||||||
} // end class ScriptSupportImpl
|
} // end class ScriptSupportImpl
|
||||||
|
|
||||||
|
class ResourceLoaderImpl implements ResourceLoader
|
||||||
|
{
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Attributes
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
private RootConfig m_config; // configuration data
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Constructor
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
ResourceLoaderImpl(RootConfig config)
|
||||||
|
{
|
||||||
|
m_config = config;
|
||||||
|
|
||||||
|
} // end constructor
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------
|
||||||
|
* Implementations from interface ResourceLoader
|
||||||
|
*--------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
public MenuTemplate getMenuTemplate(String name)
|
||||||
|
{
|
||||||
|
return m_config.getMenuTemplate(name);
|
||||||
|
|
||||||
|
} // end getMenuTemplate
|
||||||
|
|
||||||
|
} // end class ResourceLoader
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
*
|
*
|
||||||
* The Original Code is the Venice Web Communities System.
|
* The Original Code is the Venice Web Communities System.
|
||||||
*
|
*
|
||||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
|
||||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||||
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Contributor(s):
|
* Contributor(s):
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,9 @@ import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import com.silverwrist.util.StringUtil;
|
import com.silverwrist.util.StringUtil;
|
||||||
import com.silverwrist.venice.ui.*;
|
import com.silverwrist.venice.ui.*;
|
||||||
|
import com.silverwrist.venice.ui.helpers.ResourceLoader;
|
||||||
import com.silverwrist.venice.ui.menus.MenuComponent;
|
import com.silverwrist.venice.ui.menus.MenuComponent;
|
||||||
|
import com.silverwrist.venice.ui.menus.MenuTemplate;
|
||||||
|
|
||||||
public class MenuView implements ContentDirect
|
public class MenuView implements ContentDirect
|
||||||
{
|
{
|
||||||
|
@ -30,10 +32,10 @@ public class MenuView implements ContentDirect
|
||||||
*--------------------------------------------------------------------------------
|
*--------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private int menu_selector = MENU_SELECTOR_NOCHANGE;
|
private int m_menu_selector = MENU_SELECTOR_NOCHANGE;
|
||||||
private String qid = null;
|
private String m_qid = null;
|
||||||
private MenuComponent component;
|
private MenuComponent m_component;
|
||||||
private Set defines = Collections.EMPTY_SET;
|
private Set m_defines = Collections.EMPTY_SET;
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------------
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -42,7 +44,7 @@ public class MenuView implements ContentDirect
|
||||||
|
|
||||||
public MenuView(MenuComponent component)
|
public MenuView(MenuComponent component)
|
||||||
{
|
{
|
||||||
this.component = component;
|
m_component = component;
|
||||||
|
|
||||||
} // end constructor
|
} // end constructor
|
||||||
|
|
||||||
|
@ -59,19 +61,19 @@ public class MenuView implements ContentDirect
|
||||||
|
|
||||||
public int getMenuSelector()
|
public int getMenuSelector()
|
||||||
{
|
{
|
||||||
return menu_selector;
|
return m_menu_selector;
|
||||||
|
|
||||||
} // end getMenuSelector
|
} // end getMenuSelector
|
||||||
|
|
||||||
public String getPageTitle(RequestOutput ro)
|
public String getPageTitle(RequestOutput ro)
|
||||||
{
|
{
|
||||||
return component.getTitle(ro);
|
return m_component.getTitle(ro);
|
||||||
|
|
||||||
} // end getPageTitle
|
} // end getPageTitle
|
||||||
|
|
||||||
public String getPageQID()
|
public String getPageQID()
|
||||||
{
|
{
|
||||||
return qid;
|
return m_qid;
|
||||||
|
|
||||||
} // end getPageQID
|
} // end getPageQID
|
||||||
|
|
||||||
|
@ -82,7 +84,9 @@ public class MenuView implements ContentDirect
|
||||||
|
|
||||||
public void render(RequestOutput out) throws IOException
|
public void render(RequestOutput out) throws IOException
|
||||||
{
|
{
|
||||||
component.render(out,null,defines);
|
ResourceLoader rload = (ResourceLoader)(out.queryService(ResourceLoader.class));
|
||||||
|
MenuTemplate templ = rload.getMenuTemplate("normal");
|
||||||
|
m_component.render(out,null,templ,m_defines);
|
||||||
|
|
||||||
} // end render
|
} // end render
|
||||||
|
|
||||||
|
@ -93,21 +97,21 @@ public class MenuView implements ContentDirect
|
||||||
|
|
||||||
public final void setMenuSelector(int sel)
|
public final void setMenuSelector(int sel)
|
||||||
{
|
{
|
||||||
menu_selector = sel;
|
m_menu_selector = sel;
|
||||||
|
|
||||||
} // end setMenuSelector
|
} // end setMenuSelector
|
||||||
|
|
||||||
public final void setPageQID(String s)
|
public final void setPageQID(String s)
|
||||||
{
|
{
|
||||||
qid = s;
|
m_qid = s;
|
||||||
|
|
||||||
} // end setPageQID
|
} // end setPageQID
|
||||||
|
|
||||||
public final void define(String symbol)
|
public final void define(String symbol)
|
||||||
{
|
{
|
||||||
if (defines==Collections.EMPTY_SET)
|
if (m_defines==Collections.EMPTY_SET)
|
||||||
defines = new HashSet();
|
m_defines = new HashSet();
|
||||||
defines.add(symbol);
|
m_defines.add(symbol);
|
||||||
|
|
||||||
} // end define
|
} // end define
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user