/* * 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) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ package com.silverwrist.venice.servlets.format; import java.util.*; import com.silverwrist.util.StringUtil; import com.silverwrist.venice.ValidationException; import com.silverwrist.venice.security.Role; import com.silverwrist.venice.core.*; public class EditConferenceDialog extends ContentDialog { /*-------------------------------------------------------------------------------- * Constructors *-------------------------------------------------------------------------------- */ public EditConferenceDialog() { super("Edit Conference:",null,"editconfform","confops"); setHiddenField("cmd","E"); setHiddenField("sig",""); setHiddenField("conf",""); addFormField(new CDFormCategoryHeader("Basic Information")); addFormField(new CDTextFormField("name","Conference Name",null,true,32,128)); addFormField(new CDTextFormField("descr","Description",null,false,32,255)); addFormField(new CDCheckBoxFormField("hide","Hide conference in the SIG's conference list",null,"Y")); addFormField(new CDFormCategoryHeader("Security Information")); addFormField(new CDRoleListFormField("read_lvl","Security level required to read conference",null,true, Role.getConferenceReadList())); addFormField(new CDRoleListFormField("post_lvl","Security level required to post to conference",null,true, Role.getConferencePostList())); addFormField(new CDRoleListFormField("create_lvl", "Security level required to create new topics in conference",null, true,Role.getConferenceCreateList())); addFormField(new CDRoleListFormField("hide_lvl", "Security level required to archive or freeze topics", "(or to hide posts of which you are not the owner)",true, Role.getConferenceHideList())); addFormField(new CDRoleListFormField("nuke_lvl", "Security level required to delete topics or nuke posts", "(or to scribble posts of which you are not the owner)",true, Role.getConferenceNukeList())); addFormField(new CDRoleListFormField("change_lvl", "Security level required to change conference attributes",null,true, Role.getConferenceChangeList())); addFormField(new CDRoleListFormField("delete_lvl", "Security level required to delete conference",null,true, Role.getConferenceDeleteList())); addCommandButton(new CDImageButton("update","bn_update.gif","Update",80,24)); addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24)); } // end constructor protected EditConferenceDialog(EditConferenceDialog other) { super(other); } // end constructor /*-------------------------------------------------------------------------------- * External operations *-------------------------------------------------------------------------------- */ public void setupDialog(SIGContext sig, ConferenceContext conf) throws DataException, AccessError { setHiddenField("sig",String.valueOf(sig.getSIGID())); setHiddenField("conf",String.valueOf(conf.getConfID())); setTitle("Edit Conference: " + conf.getName()); setFieldValue("name",conf.getName()); setFieldValue("descr",conf.getDescription()); if (conf.getHideList()) setFieldValue("hide","Y"); else setFieldValue("hide",""); setFieldValue("read_lvl",String.valueOf(conf.getReadLevel())); setFieldValue("post_lvl",String.valueOf(conf.getPostLevel())); setFieldValue("create_lvl",String.valueOf(conf.getCreateLevel())); setFieldValue("hide_lvl",String.valueOf(conf.getHideLevel())); setFieldValue("nuke_lvl",String.valueOf(conf.getNukeLevel())); setFieldValue("change_lvl",String.valueOf(conf.getChangeLevel())); setFieldValue("delete_lvl",String.valueOf(conf.getDeleteLevel())); } // end setupDialog public void doDialog(ConferenceContext conf) throws ValidationException, DataException, AccessError { final String yes = "Y"; // the "yes" string validate(); // validate the dialog entries int read_lvl, post_lvl, create_lvl, hide_lvl, nuke_lvl, change_lvl, delete_lvl; try { // get all the security levels out of their form fields read_lvl = Integer.parseInt(getFieldValue("read_lvl")); post_lvl = Integer.parseInt(getFieldValue("post_lvl")); create_lvl = Integer.parseInt(getFieldValue("create_lvl")); hide_lvl = Integer.parseInt(getFieldValue("hide_lvl")); nuke_lvl = Integer.parseInt(getFieldValue("nuke_lvl")); change_lvl = Integer.parseInt(getFieldValue("change_lvl")); delete_lvl = Integer.parseInt(getFieldValue("delete_lvl")); } // end try catch (NumberFormatException nfe) { // how rude! throw new InternalStateError("somehow we got a non-numeric result from a numeric dropdown list!"); } // end catch // sweep through the conference and set the appropriate changes conf.setName(getFieldValue("name")); conf.setDescription(getFieldValue("descr")); conf.setHideList(yes.equals(getFieldValue("hide"))); conf.setSecurityLevels(read_lvl,post_lvl,create_lvl,hide_lvl,nuke_lvl,change_lvl,delete_lvl); } // end doDialog public void resetOnError(SIGContext sig, ConferenceContext conf, String message) { setHiddenField("sig",String.valueOf(sig.getSIGID())); setHiddenField("conf",String.valueOf(conf.getConfID())); setTitle("Edit Conference: " + conf.getName()); setErrorMessage(message); } // end resetOnError public Object clone() { return new EditConferenceDialog(this); } // end clone } // end class EditConferenceDialog