/*
* 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.dialog;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.Namespaces;
import com.silverwrist.dynamo.dialog.BaseDialogField;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.iface.*;
class CommunityLogoField extends BaseDialogField
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String m_logo_url = null;
private String m_link_url;
private String m_link_type;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
CommunityLogoField(Element elt) throws DialogException
{
super(false,elt);
XMLLoader loader = XMLLoader.get();
try
{ // get link URL and link type
m_link_url = loader.getAttribute(elt,"link");
m_link_type = loader.getAttribute(elt,"type");
} // end try
catch (XMLLoadException e)
{ // translate to DialogException
throw new DialogException(e);
} // end catch
// Load caption 2 from messages
ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.dialog.VeniceDialogMessages",
Locale.getDefault());
setCaption2(b.getString("communitylogo.caption2"));
} // end constructor
protected CommunityLogoField(CommunityLogoField other)
{
super(other);
m_logo_url = null;
m_link_url = other.m_link_url;
m_link_type = other.m_link_type;
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract implementations from class BaseDialogField
*--------------------------------------------------------------------------------
*/
protected void renderField(TextRenderControl control, Map render_params)
throws IOException, RenderingException
{
PrintWriter wr = control.getWriter();
if (isEnabled())
{ // write the opening tag
URLRewriter rewriter = (URLRewriter)(control.queryService(URLRewriter.class));
wr.write("");
} // end if
// write the
tag by running it through the standard communtiy logo renderer
ObjectProvider oprov = (ObjectProvider)(control.queryService(ObjectProvider.class));
ServiceProvider sp = (ServiceProvider)(oprov.getObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,
"venice-communitylogo"));
RenderImage rimg = (RenderImage)(sp.queryService(RenderImage.class));
rimg.renderImageTag(control,m_logo_url);
// write the tag
if (isEnabled())
wr.write("");
} // end renderField
protected void validateContents(Request r, Object data) throws ValidationException
{ // do nothing
} // end validateContents
public Object clone()
{
return new CommunityLogoField(this);
} // end clone
public Object getValue()
{
return m_logo_url;
} // end getValue
public boolean containsValue()
{
return (m_logo_url!=null);
} // end containsValue
public void setValue(Object obj)
{
m_logo_url = ((obj==null) ? null : obj.toString());
} // end setValue
public void setValueFrom(Request r)
{ // do nothing - this doesn't get handled in the usual way
} // end setValueFrom
public void reset()
{ // do nothing
} // end reset
/*--------------------------------------------------------------------------------
* Overrides from class BaseDialogField
*--------------------------------------------------------------------------------
*/
protected boolean isNull(Object value)
{
return false;
} // end isNull
public int getFlags()
{
return 0;
} // end getFlags
} // end class CommunityLogoField