gave the "top" page the makeover it so richly deserved - now, instead of an
array of content panels, we have a big content panel (use to come later) plus a set of configurable "sideboxes" that look kind of like Slashboxes...
This commit is contained in:
@@ -76,7 +76,7 @@ public class Top extends VeniceServlet
|
||||
|
||||
try
|
||||
{ // attempt to get the user content
|
||||
return new TopContent(user);
|
||||
return new TopDisplay(getServletContext(),user);
|
||||
|
||||
} // end try
|
||||
catch (DataException de)
|
||||
@@ -84,6 +84,11 @@ public class Top extends VeniceServlet
|
||||
return new ErrorBox("Database Error","Error loading front page: " + de.getMessage(),null);
|
||||
|
||||
} // end catch
|
||||
catch (AccessError ae)
|
||||
{ // there was an access error, whoops!
|
||||
return new ErrorBox("Access Error",ae.getMessage(),null);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end doVeniceGet
|
||||
|
||||
|
||||
@@ -311,28 +311,6 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
|
||||
} // end isImageButtonClicked
|
||||
|
||||
/*
|
||||
protected static final VeniceEngine getVeniceEngine(ServletContext ctxt) throws ServletException
|
||||
{
|
||||
return Variables.getVeniceEngine(ctxt);
|
||||
|
||||
} // end getVeniceEngine
|
||||
|
||||
protected final VeniceEngine getVeniceEngine() throws ServletException
|
||||
{
|
||||
return Variables.getVeniceEngine(getServletContext());
|
||||
|
||||
} // end getVeniceEngine
|
||||
*/
|
||||
|
||||
/*
|
||||
protected final UserContext getUserContext(HttpServletRequest request) throws ServletException
|
||||
{
|
||||
return Variables.getUserContext(getServletContext(),request,request.getSession(true));
|
||||
|
||||
} // end getUserContext
|
||||
*/
|
||||
|
||||
protected final void putUserContext(HttpServletRequest request, UserContext ctxt)
|
||||
{
|
||||
Variables.putUserContext(request.getSession(true),ctxt);
|
||||
@@ -387,15 +365,6 @@ public abstract class VeniceServlet extends HttpServlet
|
||||
|
||||
} // end clearMenu
|
||||
|
||||
/*
|
||||
protected final RenderData createRenderData(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException
|
||||
{
|
||||
return RenderConfig.createRenderData(getServletContext(),request,response);
|
||||
|
||||
} // end createRenderData
|
||||
*/
|
||||
|
||||
protected final String getStandardCommandParam(ServletRequest request)
|
||||
{
|
||||
String foo = request.getParameter("cmd");
|
||||
|
||||
@@ -252,6 +252,12 @@ public class RenderData
|
||||
|
||||
} // end storeJSPRender
|
||||
|
||||
public void setRequestAttribute(String name, Object value)
|
||||
{
|
||||
request.setAttribute(name,value);
|
||||
|
||||
} // end setRequestAttribute
|
||||
|
||||
public void forwardDispatch(RequestDispatcher dispatcher) throws IOException, ServletException
|
||||
{
|
||||
dispatcher.forward(request,response);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class SideBoxConferences implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private UserContext uc;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SideBoxConferences(UserContext uc, String parameter)
|
||||
{
|
||||
this.uc = uc;
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
if (uc.isLoggedIn())
|
||||
return "Your Conference Hotlist:";
|
||||
else
|
||||
return "Featured Conferences:";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
/* BEGIN TEMP */
|
||||
out.write("<FONT FACE=\"Arial, Helvetica\" SIZE=2><UL>\n");
|
||||
out.write("<LI>BOFH (Benevolent Dictators)</LI>\n");
|
||||
out.write("<LI>Playground (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Commons (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Top Ten Lists (Pamela's Lounge)</LI>\n");
|
||||
out.write("</UL></FONT>\n");
|
||||
/* END TEMP */
|
||||
|
||||
// write the link at the end
|
||||
out.write("<P>" + rdat.getStdFontTag(null,1) + "<B>[ <A HREF=\"" + rdat.getEncodedServletPath("TODO")
|
||||
+ "\">Manage</A> ]</B></FONT>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class SideBoxConferences
|
||||
103
src/com/silverwrist/venice/servlets/format/SideBoxSIGs.java
Normal file
103
src/com/silverwrist/venice/servlets/format/SideBoxSIGs.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class SideBoxSIGs implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private UserContext uc;
|
||||
private List sig_list;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public SideBoxSIGs(UserContext uc, String parameter) throws DataException
|
||||
{
|
||||
this.uc = uc;
|
||||
this.sig_list = uc.getMemberSIGs();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
if (uc.isLoggedIn())
|
||||
return "Your SIGs:";
|
||||
else
|
||||
return "Featured SIGs:";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write(rdat.getStdFontTag(null,2) + "\n");
|
||||
if (sig_list.size()>0)
|
||||
{ // display the list of available SIGs
|
||||
out.write("<TABLE ALIGN=CENTER BORDER=0 CELLPADDING=0 CELLSPACING=2>\n");
|
||||
Iterator it = sig_list.iterator();
|
||||
while (it.hasNext())
|
||||
{ // display the names of the SIGs one by one
|
||||
SIGContext sig = (SIGContext)(it.next());
|
||||
out.write("<TR VALIGN=MIDDLE>\n<TD ALIGN=CENTER WIDTH=14><IMG SRC=\""
|
||||
+ rdat.getFullImagePath("purple-ball.gif")
|
||||
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0></TD>\n");
|
||||
out.write("<TD ALIGN=LEFT>\n" + rdat.getStdFontTag(null,2) + "<B><A HREF=\""
|
||||
+ rdat.getEncodedServletPath("sig/" + sig.getAlias()) + "\">"
|
||||
+ StringUtil.encodeHTML(sig.getName()) + "</A></B></FONT>\n");
|
||||
if (sig.isAdmin())
|
||||
out.write(" <IMG SRC=\"" + rdat.getFullImagePath("tag_host.gif")
|
||||
+ "\" ALT=\"Host!\" BORDER=0 WIDTH=40 HEIGHT=20>\n");
|
||||
out.write("</TD>\n</TR>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
|
||||
} // end if
|
||||
else
|
||||
out.write(rdat.getStdFontTag(null,2) + "<EM>You are not a member of any SIGs.</EM></FONT>\n");
|
||||
|
||||
// write the two links at the end
|
||||
out.write("<P>" + rdat.getStdFontTag(null,1) + "<B>[ <A HREF=\"" + rdat.getEncodedServletPath("TODO")
|
||||
+ "\">Manage</A> | <A HREF=\"" + rdat.getEncodedServletPath("sigops?cmd=C")
|
||||
+ "\">Create New</A> ]</B></FONT>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class SideBoxSIGs
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* 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 Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public class TCPanelConferences extends TCStandardPanel
|
||||
{
|
||||
public TCPanelConferences()
|
||||
{
|
||||
super("Your Favorite Conferences:",null);
|
||||
addButton("bn_manage.gif","Manage",null,true,80,24);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public TCPanelConferences(TCPanelConferences other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderContent(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
/* BEGIN TEMP */
|
||||
out.write("<FONT FACE=\"Arial, Helvetica\" SIZE=2><UL>\n");
|
||||
out.write("<LI>BOFH (Benevolent Dictators)</LI>\n");
|
||||
out.write("<LI>Playground (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Commons (Electric Minds)</LI>\n");
|
||||
out.write("<LI>Top Ten Lists (Pamela's Lounge)</LI>\n");
|
||||
out.write("</UL></FONT>\n");
|
||||
/* END TEMP */
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{ // TEMP - do nothing
|
||||
super.configure(uc,parameter);
|
||||
if (!(uc.isLoggedIn()))
|
||||
setTitle("Featured Conferences:");
|
||||
|
||||
} // end configure
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new TCPanelConferences(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* 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 Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import com.silverwrist.venice.core.SIGContext;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public class TCPanelSIGs extends TCStandardPanel
|
||||
{
|
||||
private List my_sigs = null;
|
||||
|
||||
public TCPanelSIGs()
|
||||
{
|
||||
super("Your SIGs:",null);
|
||||
addButton("bn_manage.gif","Manage",null,true,80,24);
|
||||
addButton("bn_create_new.gif","Create New","sigops?cmd=C",true,80,24);
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected TCPanelSIGs(TCPanelSIGs other)
|
||||
{
|
||||
super(other);
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderContent(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write(rdat.getStdFontTag(null,2) + "\n");
|
||||
if (my_sigs.size()>0)
|
||||
{ // display the list of available SIGs
|
||||
out.write("<UL>\n");
|
||||
|
||||
Iterator it = my_sigs.iterator();
|
||||
while (it.hasNext())
|
||||
{ // display the names of the SIGs one by one
|
||||
SIGContext sig = (SIGContext)(it.next());
|
||||
// TODO: make this fancier than just an unordered list
|
||||
out.write("<LI><B><A HREF=\"" + rdat.getEncodedServletPath("sig/" + sig.getAlias())
|
||||
+ "\">" + sig.getName() + "</A></B>");
|
||||
if (sig.isAdmin())
|
||||
out.write(" <IMG SRC=\"" + rdat.getFullImagePath("tag_host.gif")
|
||||
+ "\" ALT=\"Host!\" BORDER=0 WIDTH=40 HEIGHT=20>");
|
||||
out.write("</LI>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</UL>\n");
|
||||
|
||||
} // end if
|
||||
else
|
||||
out.write("<EM>You are not a member of any SIGs.</EM>\n");
|
||||
|
||||
out.write("</FONT>\n");
|
||||
|
||||
} // end renderContent
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{
|
||||
super.configure(uc,parameter);
|
||||
if (!(uc.isLoggedIn()))
|
||||
setTitle("Featured SIGs:");
|
||||
my_sigs = uc.getMemberSIGs();
|
||||
|
||||
} // end configure
|
||||
|
||||
public Object clone()
|
||||
{
|
||||
return new TCPanelSIGs(this);
|
||||
|
||||
} // end clone
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
@@ -1,184 +0,0 @@
|
||||
/*
|
||||
* 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 Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public abstract class TCStandardPanel extends TopContentPanel
|
||||
{
|
||||
class TCButton implements ComponentRender
|
||||
{
|
||||
private String image;
|
||||
private String alt_text;
|
||||
private String url;
|
||||
private boolean login_only;
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public TCButton(String image, String alt_text, String url, boolean login_only, int width, int height)
|
||||
{
|
||||
this.image = image;
|
||||
this.alt_text = alt_text;
|
||||
this.url = url;
|
||||
this.login_only = login_only;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
} // end constructor
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
if (url!=null)
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath(url) + "\">");
|
||||
out.write("<IMG SRC=\"" + rdat.getFullImagePath(image) + "\" ALT=\"" + alt_text);
|
||||
out.write("\" BORDER=0 WIDTH=" + String.valueOf(width) + " HEIGHT=" + String.valueOf(height) + ">");
|
||||
if (url!=null)
|
||||
out.write("</A>");
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public boolean isLoginOnly()
|
||||
{
|
||||
return login_only;
|
||||
|
||||
} // end isLoginOnly
|
||||
|
||||
} // end class TCButton
|
||||
|
||||
// Attributes
|
||||
private String title;
|
||||
private String subtitle;
|
||||
private Vector buttons;
|
||||
|
||||
private String real_title;
|
||||
private String real_subtitle;
|
||||
private boolean logged_in;
|
||||
|
||||
protected TCStandardPanel(String title, String subtitle)
|
||||
{
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.buttons = new Vector();
|
||||
this.real_title = title;
|
||||
this.real_subtitle = subtitle;
|
||||
|
||||
} // end constructor
|
||||
|
||||
protected TCStandardPanel(TCStandardPanel other)
|
||||
{
|
||||
super(other);
|
||||
this.title = other.title;
|
||||
this.subtitle = other.subtitle;
|
||||
this.buttons = other.buttons;
|
||||
this.real_title = other.title;
|
||||
this.real_subtitle = other.subtitle;
|
||||
|
||||
} // end constructor
|
||||
|
||||
private boolean displayButtons()
|
||||
{
|
||||
if (buttons.size()==0)
|
||||
return false;
|
||||
else if (logged_in)
|
||||
return true;
|
||||
|
||||
boolean login_only = true;
|
||||
Enumeration enum = buttons.elements();
|
||||
while (login_only && enum.hasMoreElements())
|
||||
{ // attempt to determine if there are any non-"login only" buttons
|
||||
TCButton bn = (TCButton)(enum.nextElement());
|
||||
login_only = bn.isLoginOnly();
|
||||
|
||||
} // end while
|
||||
|
||||
return !login_only;
|
||||
|
||||
} // end displayButtons
|
||||
|
||||
protected void addButton(String image, String alt_text, String url, boolean login_only, int width,
|
||||
int height)
|
||||
{
|
||||
buttons.addElement(new TCButton(image,alt_text,url,login_only,width,height));
|
||||
|
||||
} // end addButton
|
||||
|
||||
protected abstract void renderContent(Writer out, RenderData rdat) throws IOException;
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
rdat.writeContentHeader(out,real_title,real_subtitle);
|
||||
|
||||
if (displayButtons())
|
||||
{ // want to print the buttons
|
||||
out.write("<DIV ALIGN=\"LEFT\">\n");
|
||||
Enumeration enum = buttons.elements();
|
||||
|
||||
boolean first_post = true;
|
||||
while (enum.hasMoreElements())
|
||||
{ // figure out whether to display this button
|
||||
TCButton bn = (TCButton)(enum.nextElement());
|
||||
boolean display_me = logged_in;
|
||||
if (logged_in)
|
||||
display_me = true;
|
||||
else
|
||||
display_me = !(bn.isLoginOnly());
|
||||
|
||||
if (display_me)
|
||||
{ // display this button
|
||||
if (first_post)
|
||||
first_post = false;
|
||||
else
|
||||
out.write(" ");
|
||||
bn.renderHere(out,rdat);
|
||||
|
||||
} // end if
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("\n</DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
renderContent(out,rdat);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
public void configure(UserContext uc, String parameter) throws DataException
|
||||
{
|
||||
logged_in = uc.isLoggedIn();
|
||||
|
||||
} // end configure
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.real_title = title;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
public void setSubtitle(String title)
|
||||
{
|
||||
this.real_subtitle = subtitle;
|
||||
|
||||
} // end setTitle
|
||||
|
||||
} // end class TCPanelSIGs
|
||||
@@ -1,142 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class TopContent implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data members
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static final int MAX_COLS = 2;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private int actual_cols = MAX_COLS;
|
||||
private int[] col_sizes;
|
||||
private Vector panels = new Vector();
|
||||
private boolean display_configure;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public TopContent(UserContext uc) throws DataException
|
||||
{
|
||||
int i; // loop counter
|
||||
|
||||
// get the current view configuration
|
||||
FrontPageViewConfig vconfig = uc.getFrontPageViewConfig(MAX_COLS);
|
||||
if (vconfig.getNumColumns()<MAX_COLS)
|
||||
actual_cols = vconfig.getNumColumns();
|
||||
|
||||
// compute the column sizes in percentages
|
||||
col_sizes = new int[actual_cols];
|
||||
int base_amt = 100 / actual_cols;
|
||||
int rem_amt = 100 % actual_cols;
|
||||
for (i=0; i<actual_cols; i++)
|
||||
{ // initialize the column sizes
|
||||
col_sizes[i] = base_amt;
|
||||
if (i<rem_amt)
|
||||
col_sizes[i]++;
|
||||
|
||||
} // end for
|
||||
|
||||
// load the top content
|
||||
TopContentPanel parray[];
|
||||
for (i=0; i<vconfig.getNumRows(); i++)
|
||||
{ // create array and load it with panels
|
||||
parray = new TopContentPanel[actual_cols];
|
||||
for (int j=0; j<actual_cols; j++)
|
||||
{ // create and configure the parts in this row
|
||||
parray[j] = TopContentPanel.create(vconfig.getPartID(i,j));
|
||||
parray[j].configure(uc,vconfig.getParameter(i,j));
|
||||
|
||||
} // end for
|
||||
|
||||
panels.addElement(parray);
|
||||
|
||||
} // end for
|
||||
|
||||
display_configure = uc.isLoggedIn();
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
return "My Front Page";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0>\n");
|
||||
|
||||
Enumeration enum = panels.elements();
|
||||
while (enum.hasMoreElements())
|
||||
{ // output each row in turn
|
||||
TopContentPanel[] rowarray = (TopContentPanel[])(enum.nextElement());
|
||||
out.write("<TR VALIGN=TOP>\n");
|
||||
|
||||
for (int i=0; i<actual_cols; i++)
|
||||
{ // write the table data header and then render the content
|
||||
out.write("<TD ALIGN=LEFT WIDTH=\"" + String.valueOf(col_sizes[i]) + "%\">\n");
|
||||
rowarray[i].renderHere(out,rdat);
|
||||
out.write("</TD>\n");
|
||||
|
||||
} // end for
|
||||
|
||||
out.write("</TR>\n");
|
||||
|
||||
} // end while
|
||||
|
||||
out.write("</TABLE>\n");
|
||||
|
||||
if (display_configure)
|
||||
{ // display the Configure button
|
||||
out.write("<HR WIDTH=\"80%\"><DIV ALIGN=\"LEFT\">\n<A HREF=\"\"><IMG SRC=\"");
|
||||
out.write(rdat.getFullImagePath("bn_configure.gif"));
|
||||
out.write("\" ALT=\"Configure\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n</DIV>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class TopContent
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* 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 Community System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import com.silverwrist.venice.core.UserContext;
|
||||
import com.silverwrist.venice.core.DataException;
|
||||
|
||||
public abstract class TopContentPanel implements ComponentRender, Cloneable
|
||||
{
|
||||
protected TopContentPanel()
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
protected TopContentPanel(TopContentPanel other)
|
||||
{ // do nothing
|
||||
} // end constructor
|
||||
|
||||
public abstract void renderHere(Writer out, RenderData rdat) throws IOException;
|
||||
|
||||
public abstract void configure(UserContext uc, String parameter) throws DataException;
|
||||
|
||||
public static TopContentPanel create(String partid)
|
||||
{
|
||||
if (partid.equals("SIGS"))
|
||||
return new TCPanelSIGs();
|
||||
if (partid.equals("CONF"))
|
||||
return new TCPanelConferences();
|
||||
return null;
|
||||
|
||||
} // end create
|
||||
|
||||
} // end class TopContentPanel
|
||||
|
||||
245
src/com/silverwrist/venice/servlets/format/TopDisplay.java
Normal file
245
src/com/silverwrist/venice/servlets/format/TopDisplay.java
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
||||
* (the "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
|
||||
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
|
||||
* language governing rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Venice Web Communities System.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
|
||||
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
|
||||
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
package com.silverwrist.venice.servlets.format;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.*;
|
||||
import com.silverwrist.util.StringUtil;
|
||||
import com.silverwrist.venice.core.*;
|
||||
|
||||
public class TopDisplay implements ContentRender
|
||||
{
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Static data values
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private static final String ATTR_NAME = "com.silverwrist.venice.TopDisplay";
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Attributes
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
private ServletContext ctxt;
|
||||
private UserContext uc;
|
||||
private List descrs;
|
||||
private VeniceContent[] sideboxes;
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Constructor
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public TopDisplay(ServletContext ctxt, UserContext uc) throws DataException, AccessError, ErrorBox
|
||||
{
|
||||
// Stash some basic information.
|
||||
this.ctxt = ctxt;
|
||||
this.uc = uc;
|
||||
this.descrs = uc.getSideBoxList();
|
||||
|
||||
// Create the arrays used to construct sideboxes.
|
||||
Class[] ctor_argtypes = new Class[2];
|
||||
ctor_argtypes[0] = UserContext.class;
|
||||
ctor_argtypes[1] = String.class;
|
||||
Object[] ctor_args = new Object[2];
|
||||
ctor_args[0] = uc;
|
||||
|
||||
// Create the actual sideboxes.
|
||||
sideboxes = new VeniceContent[descrs.size()];
|
||||
for (int i=0; i<descrs.size(); i++)
|
||||
{ // create each sidebox in turn...
|
||||
SideBoxDescriptor d = (SideBoxDescriptor)(descrs.get(i));
|
||||
String cn = "com.silverwrist.venice.servlets.format." + d.getClassname();
|
||||
|
||||
try
|
||||
{ // get the class name and the constructor pointer
|
||||
Class sb_class = Class.forName(cn);
|
||||
if (!(VeniceContent.class.isAssignableFrom(sb_class)))
|
||||
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
|
||||
java.lang.reflect.Constructor ctor = sb_class.getDeclaredConstructor(ctor_argtypes);
|
||||
|
||||
// create the side box!
|
||||
ctor_args[1] = d.getParameter();
|
||||
sideboxes[i] = (VeniceContent)(ctor.newInstance(ctor_args));
|
||||
|
||||
} // end try
|
||||
catch (ClassNotFoundException cnfe)
|
||||
{ // Class.forName didn't work? yIkes!
|
||||
throw new ErrorBox(null,"Cannot find sidebox class: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (NoSuchMethodException nsme)
|
||||
{ // no constructor matching the prototype? yIkes!
|
||||
throw new ErrorBox(null,"Cannot find sidebox class constructor: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (SecurityException se)
|
||||
{ // how'd we trip the security manager? oh well...
|
||||
throw new ErrorBox(null,"Security violation on class: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (InstantiationException ie)
|
||||
{ // the target class is an abstract class - oh, that's not right!
|
||||
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (IllegalAccessException iae1)
|
||||
{ // the constructor isn't public - oh, that's not right!
|
||||
throw new ErrorBox(null,"Invalid sidebox class: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (IllegalArgumentException iae2)
|
||||
{ // the arguments to the constructor are wrong - we should've caught this!
|
||||
throw new ErrorBox(null,"Invalid constructor call: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
catch (java.lang.reflect.InvocationTargetException ite)
|
||||
{ // the constructor itself threw an exception
|
||||
Throwable sub_e = ite.getTargetException();
|
||||
if (sub_e instanceof DataException)
|
||||
throw (DataException)sub_e;
|
||||
if (sub_e instanceof AccessError)
|
||||
throw (AccessError)sub_e;
|
||||
throw new ErrorBox(null,"Unknown exception creating: " + cn,null);
|
||||
|
||||
} // end catch
|
||||
|
||||
} // end for
|
||||
|
||||
} // end constructor
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* External static operations
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public static TopDisplay retrieve(ServletRequest request)
|
||||
{
|
||||
return (TopDisplay)(request.getAttribute(ATTR_NAME));
|
||||
|
||||
} // end retrieve
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface VeniceContent
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public String getPageTitle(RenderData rdat)
|
||||
{
|
||||
return "My Front Page";
|
||||
|
||||
} // end getPageTitle
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
* Implementations from interface ContentRender
|
||||
*--------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
public void renderHere(Writer out, RenderData rdat) throws IOException
|
||||
{
|
||||
// Write out the start of the content structure.
|
||||
out.write("<TABLE BORDER=0 ALIGN=CENTER WIDTH=\"100%\" CELLPADDING=4 CELLSPACING=0><TR VALIGN=TOP>\n");
|
||||
out.write("<TD ALIGN=LEFT>\n");
|
||||
|
||||
// The top content is a JSP page, so include it here.
|
||||
rdat.setRequestAttribute(ATTR_NAME,this);
|
||||
RequestDispatcher dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath("top_content.jsp"));
|
||||
out.flush();
|
||||
rdat.flushOutput(); // make sure the stuff to be output first is output
|
||||
try
|
||||
{ // include me!
|
||||
rdat.includeDispatch(dispatcher);
|
||||
|
||||
} // end try
|
||||
catch (ServletException se)
|
||||
{ // since we can't throw ServletException, we throw IOException
|
||||
throw new IOException("Failure including top_content.jsp");
|
||||
|
||||
} // end catch
|
||||
|
||||
rdat.flushOutput(); // now make sure the included page is properly flushed
|
||||
|
||||
out.write("</TD>\n<TD ALIGN=CENTER WIDTH=210>\n"); // break to the sidebox column
|
||||
|
||||
for (int i=0; i<sideboxes.length; i++)
|
||||
{ // draw in the outer framework of the sidebox
|
||||
out.write("<TABLE ALIGN=CENTER WIDTH=200 BORDER=0 CELLPADDING=2 CELLSPACING=0>"
|
||||
+ "<TR VALIGN=MIDDLE BGCOLOR=\"#6666CC\"><TD ALIGN=LEFT>\n");
|
||||
out.write(rdat.getStdFontTag("white",3) + "<B>" + StringUtil.encodeHTML(sideboxes[i].getPageTitle(rdat))
|
||||
+ "</B></FONT>\n");
|
||||
out.write("</TD></TR><TR VALIGN=TOP BGCOLOR=\"#9999FF\"><TD ALIGN=LEFT>\n");
|
||||
|
||||
// Fill in the sidebox by calling down to the base.
|
||||
if (sideboxes[i] instanceof ContentRender)
|
||||
{ // we have a direct-rendering component here - do it
|
||||
ContentRender cr = (ContentRender)(sideboxes[i]);
|
||||
cr.renderHere(out,rdat);
|
||||
|
||||
} // end if
|
||||
else if (sideboxes[i] instanceof JSPRender)
|
||||
{ // we have a JSP rendering component here - bounce to the appropriate JSP file
|
||||
JSPRender jr = (JSPRender)(sideboxes[i]);
|
||||
rdat.storeJSPRender(jr);
|
||||
dispatcher = ctxt.getRequestDispatcher(rdat.getFormatJSPPath(jr.getTargetJSPName()));
|
||||
out.flush();
|
||||
rdat.flushOutput(); // make sure the stuff to be output first is output
|
||||
try
|
||||
{ // include me!
|
||||
rdat.includeDispatch(dispatcher);
|
||||
|
||||
} // end try
|
||||
catch (ServletException se)
|
||||
{ // since we can't throw ServletException, we throw IOException
|
||||
out.write(rdat.getStdFontTag(null,2) + "<EM>failure rendering class "
|
||||
+ sideboxes[i].getClass().getName() + ": " + StringUtil.encodeHTML(se.getMessage())
|
||||
+ "</EM></FONT>\n");
|
||||
out.flush();
|
||||
|
||||
} // end catch
|
||||
|
||||
rdat.flushOutput(); // now make sure the included page is properly flushed
|
||||
|
||||
} // end else if
|
||||
else // this is bogus - just display a little error here
|
||||
out.write(rdat.getStdFontTag(null,2) + "<EM>cannot display sidebox of class: "
|
||||
+ sideboxes[i].getClass().getName() + "</EM></FONT>\n");
|
||||
|
||||
// close up the framework of this sidebox
|
||||
out.write("</TD></TR></TABLE><P>\n");
|
||||
|
||||
} // end for
|
||||
|
||||
if (uc.isLoggedIn())
|
||||
{ // write the Configure button below the sideboxes
|
||||
out.write("<A HREF=\"" + rdat.getEncodedServletPath("TODO") + "\"><IMG SRC=\""
|
||||
+ rdat.getFullImagePath("bn_configure.gif")
|
||||
+ "\" ALT=\"Configure\" WIDTH=80 HEIGHT=24 BORDER=0></A>\n");
|
||||
|
||||
} // end if
|
||||
|
||||
// Finish up.
|
||||
out.write("</TD>\n</TR></TABLE>");
|
||||
rdat.writeFooter(out);
|
||||
|
||||
} // end renderHere
|
||||
|
||||
} // end class TopDisplay
|
||||
Reference in New Issue
Block a user