added initial sysadmin menu items and dialogs, fixed a few things about dialog

operation here and there
This commit is contained in:
Eric J. Bowersox
2003-05-25 09:11:12 +00:00
parent 0c7f518f3e
commit cbae9cdd8e
17 changed files with 698 additions and 28 deletions

View File

@@ -11,7 +11,7 @@
*
* 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) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -109,7 +109,7 @@ abstract class CommonTextField extends BaseDialogField
protected boolean isNull(Object value)
{
return StringUtils.isEmpty((String)value);
return ((value==null) || StringUtils.isEmpty(value.toString()));
} // end isNull

View File

@@ -580,7 +580,19 @@ class DialogImpl implements Dialog
while (it.hasNext())
{ // call reset on each field
DialogField fld = (DialogField)(it.next());
fld.validate(r);
try
{ // perform validation
fld.validate(r);
} // end try
catch (RuntimeException e)
{ // safety in case RuntimeException is thrown
ValidationException ve = new ValidationException(DialogImpl.class,"DialogMessages","valid.except",e);
ve.setParameter(0,fld.getName());
ve.setParameter(1,e.getMessage());
throw ve;
} // end catch
} // end while

View File

@@ -174,9 +174,11 @@ public class DialogManager
m_factory_data.put("header",fact);
m_factory_data.put("hidden",fact);
m_factory_data.put("int",fact);
m_factory_data.put("linktypelist",fact);
m_factory_data.put("localelist",fact);
m_factory_data.put("password",fact);
m_factory_data.put("text",fact);
m_factory_data.put("textbox",fact);
m_factory_data.put("tzlist",fact);
// Get the service provider hooks interface.

View File

@@ -10,7 +10,7 @@
#
# 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) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
# Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
#
# Contributor(s):
# ---------------------------------------------------------------------------------
@@ -29,3 +29,4 @@ bad.email=The value in the "{0}" field is not a valid E-mail address.
text.notInteger=Invalid non-numeric character in the "{0}" field.
int.tooSmall=The value of the "{0}" field must be greater than or equal to {1}.
int.tooLarge=The value of the "{0}" field must be less than or equal to {1}.
valid.except=Exception generated while validating "{0}": {1}

View File

@@ -0,0 +1,175 @@
/*
* 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) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.dynamo.dialog;
import java.io.*;
import java.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.*;
import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.util.*;
public class MultiLineTextField extends BaseDialogField
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
public static final int DEFAULT_ROWS = 4;
public static final int DEFAULT_COLS = 40;
public static final int DEFAULT_MAXLENGTH = -1;
public static final String DEFAULT_WRAP = "soft";
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private String m_value = null;
private int m_rows;
private int m_cols;
private int m_maxlength;
private String m_wraptype;
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
public MultiLineTextField(Element elt) throws DialogException
{
super(false,elt);
XMLLoader loader = XMLLoader.get();
try
{ // load the attributes specific to a multiline field
m_rows = loader.getAttributeInt(elt,"rows",DEFAULT_ROWS);
m_cols = loader.getAttributeInt(elt,"cols",DEFAULT_COLS);
m_maxlength = loader.getAttributeInt(elt,"maxlength",DEFAULT_MAXLENGTH);
m_wraptype = loader.getAttribute(elt,"wrap",DEFAULT_WRAP);
} // end try
catch (XMLLoadException e)
{ // translate exception before returning
throw new DialogException(e);
} // end catch
} // end constructor
protected MultiLineTextField(MultiLineTextField other)
{
super(other);
m_rows = other.m_rows;
m_cols = other.m_cols;
m_maxlength = other.m_maxlength;
m_wraptype = other.m_wraptype;
} // end constructor
/*--------------------------------------------------------------------------------
* Overrides from class BaseDialogField
*--------------------------------------------------------------------------------
*/
protected boolean isNull(Object value)
{
return StringUtils.isEmpty((String)value);
} // end isNull
/*--------------------------------------------------------------------------------
* Abstract implementations from class BaseDialogField
*--------------------------------------------------------------------------------
*/
protected void renderField(TextRenderControl control, Map render_params)
throws IOException, RenderingException
{
PrintWriter wr = control.getWriter();
wr.write("<textarea class=\"content\" name=\"" + getName() + "\" rows=\"" + m_rows + "\" cols=\"" + m_cols
+ "\" wrap = \"" + m_wraptype + "\"");
if (!isEnabled())
wr.write(" disabled=\"disabled\"");
wr.write(">");
if (m_value!=null)
wr.write(StringUtils.encodeHTML(m_value));
wr.write("</textarea>");
} // end renderField
protected void validateContents(Request r, Object data) throws ValidationException
{
if ((data!=null) && (m_maxlength>0) && (data.toString().length()>m_maxlength))
{ // this value is too long
ValidationException ve = new ValidationException(CommonTextField.class,"DialogMessages","text.tooLong");
ve.setParameter(0,getCaption());
ve.setParameter(1,String.valueOf(m_maxlength));
throw ve;
} // end if
} // end validateContents
public Object getValue()
{
return m_value;
} // end getValue
public boolean containsValue()
{
return StringUtils.isNotEmpty(m_value);
} // end containsValue
public void setValue(Object obj)
{
if (obj==null)
m_value = null;
else
m_value = obj.toString();
if ((m_value!=null) && StringUtils.isEmpty(m_value))
m_value = null;
} // end setValue
public void setValueFrom(Request r)
{
RequestHelper rh = new RequestHelper(r);
m_value = rh.getParameterString(getName());
if ((m_value!=null) && StringUtils.isEmpty(m_value))
m_value = null;
} // end setValueFrom
public void reset()
{
m_value = null;
} // end reset
public Object clone()
{
return new MultiLineTextField(this);
} // end clone
} // end class MultiLineTextField

View File

@@ -72,6 +72,8 @@ class StdItemFactory implements DialogItemFactory
return new PasswordField(elt);
if (tagname.equals("text"))
return new TextField(elt);
if (tagname.equals("textbox"))
return new MultiLineTextField(elt);
if (tagname.equals("tzlist"))
return new TimeZoneListField(elt);

View File

@@ -313,8 +313,6 @@ public class BufferTextRenderControl extends BaseDelegatingServiceProvider imple
{
if (m_type==null)
m_type = type;
else
throw new RenderingException(BufferTextRenderControl.class,"UtilityMessages","buffer.setMime2X");
} // end setContentType
@@ -322,8 +320,6 @@ public class BufferTextRenderControl extends BaseDelegatingServiceProvider imple
{
if (m_length<0)
m_length = length;
else
throw new RenderingException(BufferTextRenderControl.class,"UtilityMessages","buffer.setLength2X");
} // end setContentLength