added initial implementation of Edit Community Profile dialog; added additional

fields needed to implement the dialog; changed build script to keep from
recompiling the JavaCC-compiled parser stuff needlessly
This commit is contained in:
Eric J. Bowersox
2003-06-16 21:11:59 +00:00
parent eb32d42bd7
commit f8ddd74223
11 changed files with 495 additions and 12 deletions

View File

@@ -174,7 +174,9 @@ 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("languagelist",fact);
m_factory_data.put("linktypelist",fact);
m_factory_data.put("list",fact);
m_factory_data.put("localelist",fact);
m_factory_data.put("password",fact);
m_factory_data.put("text",fact);

View File

@@ -30,3 +30,5 @@ 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}
picklist.choices=Error parsing the pick list choices for field "{0}": {1}.
picklist.noChoice=No choices present for static pick list "{0}."

View File

@@ -0,0 +1,123 @@
/*
* 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.util.*;
import org.w3c.dom.Element;
import com.silverwrist.util.*;
import com.silverwrist.dynamo.except.DialogException;
class LanguageListField extends PickListField
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Language UNKNOWN_LANGUAGE = International.get().getLanguageForCode("i-default");
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
LanguageListField(Element elt) throws DialogException
{
super(elt);
} // end constructor
protected LanguageListField(LanguageListField other)
{
super(other);
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract implementations from class BaseDialogField
*--------------------------------------------------------------------------------
*/
public Object clone()
{
return new LanguageListField(this);
} // end clone
/*--------------------------------------------------------------------------------
* Overrides from class BaseDialogField
*--------------------------------------------------------------------------------
*/
protected boolean isNull(Object value)
{
return ((value==null) || UNKNOWN_LANGUAGE.equals(value));
} // end isNull
/*--------------------------------------------------------------------------------
* Abstract implementations from class PickListField
*--------------------------------------------------------------------------------
*/
protected Iterator getChoices()
{
return International.get().getLanguageList().iterator();
} // end getChoices
protected String getChoiceName(Object choice)
{
return ((Language)choice).getCode();
} // end getChoiceName
protected String getChoiceDisplay(Object choice)
{
return ((Language)choice).getName();
} // end getChoiceDisplay
protected Object getChoiceForName(String name)
{
return International.get().getLanguageForCode(name);
} // end getChoiceForName
protected boolean isValidChoice(Object choice)
{
if (!(choice instanceof Language))
return false;
Language x = International.get().getLanguageForCode(((Language)choice).getCode());
return x.equals(choice);
} // end isValidChoice
/*--------------------------------------------------------------------------------
* Overrides from class PickListField
*--------------------------------------------------------------------------------
*/
public boolean containsValue()
{
Object v = getValue();
return ((v!=null) && !UNKNOWN_LANGUAGE.equals(v));
} // end containsValue
} // end class LanguageListField

View File

@@ -0,0 +1,138 @@
/*
* 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.util.*;
import org.w3c.dom.*;
import com.silverwrist.util.xml.*;
import com.silverwrist.dynamo.except.DialogException;
class StaticPickListField extends PickListField
{
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
private List m_choices; // our list of choices
private Map m_name_map; // mapping from names to text
/*--------------------------------------------------------------------------------
* Constructors
*--------------------------------------------------------------------------------
*/
StaticPickListField(Element elt) throws DialogException
{
super(elt);
XMLLoader loader = XMLLoader.get();
try
{ // get the <choice/> sub-elements of the main element
List l = loader.getMatchingSubElements(elt,"choice");
Iterator it = l.iterator();
ArrayList choice_list = new ArrayList();
HashMap choice_map = new HashMap();
while (it.hasNext())
{ // load the various choices
Element n = (Element)(it.next());
String name = loader.getAttribute(n,"id");
String value = loader.getText(n);
choice_list.add(name);
choice_map.put(name,value);
} // end while
if (choice_list.isEmpty())
{ // no choices specified - throw an error!
DialogException de = new DialogException(StaticPickListField.class,"DialogMessages","picklist.noChoice");
de.setParameter(0,super.getName());
throw de;
} // end if
choice_list.trimToSize();
m_choices = Collections.unmodifiableList(choice_list);
m_name_map = Collections.unmodifiableMap(choice_map);
} // end try
catch (XMLLoadException e)
{ // XML load failure - throw an error
DialogException de = new DialogException(StaticPickListField.class,"DialogMessages","picklist.choices",e);
de.setParameter(0,super.getName());
de.setParameter(1,e.getMessage());
throw de;
} // end catch
} // end constructor
protected StaticPickListField(StaticPickListField other)
{
super(other);
m_choices = other.m_choices;
m_name_map = other.m_name_map;
} // end constructor
/*--------------------------------------------------------------------------------
* Abstract implementations from class BaseDialogField
*--------------------------------------------------------------------------------
*/
public Object clone()
{
return new StaticPickListField(this);
} // end clone
/*--------------------------------------------------------------------------------
* Abstract implementations from class PickListField
*--------------------------------------------------------------------------------
*/
protected Iterator getChoices()
{
return m_choices.iterator();
} // end getChoices
protected String getChoiceName(Object choice)
{
return choice.toString();
} // end getChoiceName
protected String getChoiceDisplay(Object choice)
{
return m_name_map.get(choice).toString();
} // end getChoiceDisplay
protected Object getChoiceForName(String name)
{
return m_name_map.containsKey(name) ? name : null;
} // end getChoiceForName
protected boolean isValidChoice(Object choice)
{
return (choice!=null) && m_name_map.containsKey(choice);
} // end isValidChoice
} // end class StaticPickListField

View File

@@ -64,8 +64,12 @@ class StdItemFactory implements DialogItemFactory
return new HiddenField(elt);
if (tagname.equals("int"))
return new IntegerField(elt);
if (tagname.equals("languagelist"))
return new LanguageListField(elt);
if (tagname.equals("linktypelist"))
return new LinkTypeField(elt);
if (tagname.equals("list"))
return new StaticPickListField(elt);
if (tagname.equals("localelist"))
return new LocaleListField(elt);
if (tagname.equals("password"))