/*
* 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 .
*
* 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 ,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.menu;
import java.io.*;
import java.util.*;
import com.silverwrist.util.*;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.security.SecurityReferenceMonitor;
import com.silverwrist.venice.iface.*;
class LeftMenuRendering implements MenuRenderObject, SelfRenderable
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private MenuDefinition m_menudef;
private boolean[] m_showitem;
private HashMap m_local_vars;
private int m_selected_index = -1;
/*--------------------------------------------------------------------------------
* Constructor
*--------------------------------------------------------------------------------
*/
LeftMenuRendering(DynamoUser caller, MenuDefinition def, SecurityReferenceMonitor srm, int[] acl_ids)
throws DatabaseException
{
m_menudef = def;
int count = def.getItemCount();
m_showitem = new boolean[count];
for (int i=0; i");
else if (item.isEnabled() && (item.getLink()!=null))
{ // write the link
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
wr.write("");
} // end if
else // just disable the text
wr.write("");
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
if (selected)
wr.write("");
else if (item.isEnabled())
wr.write("");
else
wr.write("");
wr.write("
\n");
} // end renderTextItem
private final void renderHeaderItem(TextRenderControl control, MenuItemDefinition item, boolean selected)
throws IOException, RenderingException
{
PrintWriter wr = control.getWriter();
for (int i=0; i");
if (!selected)
{ // write the opening sequence
if (item.isEnabled() && (item.getLink()!=null))
{ // write the link
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
wr.write("");
} // end if
else // just disable the text
wr.write("");
} // end if
wr.write(StringUtils.encodeHTML(StringUtils.replaceAllVariables(item.getText(),m_local_vars)));
if (!selected)
{ // write the closing sequence
if (item.isEnabled())
wr.write("");
else
wr.write("");
} // end if
wr.write("
\n");
} // end renderHeaderItem
private final void renderImageItem(TextRenderControl control, MenuItemDefinition item, boolean selected)
throws IOException, RenderingException
{
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
String s;
PrintWriter wr = control.getWriter();
for (int i=0; i");
} // end if
else // just disable the text
wr.write("");
} // end if
String[] data = StringUtils.split(item.getText(),",",4);
wr.write("
");
if (!selected)
{ // write the closing sequence
if (item.isEnabled())
wr.write("");
else
wr.write("");
} // end if
wr.write("
\n");
} // end renderImageItem
private final void renderSeparatorItem(TextRenderControl control, MenuItemDefinition item)
throws IOException, RenderingException
{
PrintWriter wr = control.getWriter();
wr.write("
\n");
} // end renderSeparatorItem
/*--------------------------------------------------------------------------------
* Implementations from interface MenuRenderObject
*--------------------------------------------------------------------------------
*/
public int getItemCount()
{
return m_menudef.getItemCount();
} // end getItemCount
public void setVariable(String name, String value)
{
if (m_menudef.isVariable(name))
m_local_vars.put(name,value);
} // end setVariable
public void setSelectedIndex(int index)
{
m_selected_index = index;
} // end setSelectedIndex
/*--------------------------------------------------------------------------------
* Implementations from interface SelfRenderable
*--------------------------------------------------------------------------------
*/
public void render(SelfRenderControl control) throws IOException, RenderingException
{
TextRenderControl tctrl = control.getTextRender();
PrintWriter wr = tctrl.getWriter();
if (m_menudef.getTitle()!=null)
{ // write the title and subtitle
wr.write("" + StringUtils.encodeHTML(m_menudef.getTitle()) + "
\n");
if (m_menudef.getSubtitle()!=null)
wr.write(StringUtils.encodeHTML(m_menudef.getSubtitle()) + "
\n");
} // end if
for (int i=0; i