[Dirconsole-cvs] dirconsole/Snapins/CosinSchema/src/dirconsole/snapin/cosin/editor SOAForm.java,NONE
Brought to you by:
bavodr
|
From: Bavo De R. <ba...@us...> - 2004-07-25 15:45:45
|
Update of /cvsroot/dirconsole/dirconsole/Snapins/CosinSchema/src/dirconsole/snapin/cosin/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1181/Snapins/CosinSchema/src/dirconsole/snapin/cosin/editor Added Files: SOAForm.java SOAFormModel.java Log Message: Initial version of a form to edit the SOA values --- NEW FILE: SOAForm.java --- /* * Copyright 2001 - 2004, Bavo De Ridder * * This file is part of Directory Console. * * Directory Console is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * * Directory Console is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * Directory Console; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston * * http://www.gnu.org/licenses/gpl.html */ package dirconsole.snapin.cosin.editor; import dirconsole.editor.api.EditorException; import portal.comp.CheckBox; import portal.comp.PanelDelegator; import portal.comp.TextInput; import portal.comp.TextInputModel; import portal.core.render.VelocityLayout; public class SOAForm extends PanelDelegator { public SOAForm(SOAFormModel soaModel) { super(soaModel); createUI(); } public SOAFormModel getSOAFormModel() { return (SOAFormModel) getModel(); } public void beforeApply() throws EditorException { getSOAFormModel().updateAttribute(); } private void createUI() { getContentPanel().setLayout( new VelocityLayout("snapin/cosin/editor/DNSZoneSOAPanel.vm")); serialSOAInput = new TextInput(new TextInputModel(getSOAFormModel() .getSerial())); refreshSOAInput = new TextInput(new TextInputModel(getSOAFormModel() .getRefreshTime())); retrySOAInput = new TextInput(new TextInputModel(getSOAFormModel() .getRetryTime())); expireSOAInput = new TextInput(new TextInputModel(getSOAFormModel() .getExpireTime())); ttlSOAInput = new TextInput(new TextInputModel(getSOAFormModel() .getTTL())); getContentPanel().add(serialSOAInput, "serialSOA"); getContentPanel().add(refreshSOAInput, "refreshSOA"); getContentPanel().add(retrySOAInput, "retrySOA"); getContentPanel().add(expireSOAInput, "expireSOA"); getContentPanel().add(ttlSOAInput, "ttlSOA"); serialAutoUpdate = new CheckBox(); serialAutoUpdate.getCheckBoxModel().setCaption("Auto update"); serialAutoUpdate.getCheckBoxModel().setValue(true); getContentPanel().add(serialAutoUpdate, "serialSOAAutoUpdate"); } TextInput serialSOAInput; TextInput refreshSOAInput; TextInput retrySOAInput; TextInput expireSOAInput; TextInput ttlSOAInput; CheckBox serialAutoUpdate; } --- NEW FILE: SOAFormModel.java --- /* * Copyright 2001 - 2004, Bavo De Ridder * * This file is part of Directory Console. * * Directory Console is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) any * later version. * * Directory Console is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * Directory Console; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston * * http://www.gnu.org/licenses/gpl.html */ package dirconsole.snapin.cosin.editor; import java.util.StringTokenizer; import portal.comp.form.FormModel; import portal.core.model.SimpleStringModel; import portal.core.model.StringModel; import dirconsole.editor.api.EditorException; import dirconsole.editor.api.LdapAttributeModel; public class SOAFormModel extends FormModel { public SOAFormModel(LdapAttributeModel soaAttributeModel) throws EditorException { this.soaAttribute = soaAttributeModel; serialModel = new SimpleStringModel(); refreshTimeModel = new SimpleStringModel(); retryTimeModel = new SimpleStringModel(); expireTimeModel = new SimpleStringModel(); ttlModel = new SimpleStringModel(); populateModels(); } public StringModel getSerial() { return serialModel; } public StringModel getRefreshTime() { return refreshTimeModel; } public StringModel getRetryTime() { return retryTimeModel; } public StringModel getExpireTime() { return expireTimeModel; } public StringModel getTTL() { return ttlModel; } public void updateAttribute() throws EditorException { StringBuffer buffer = new StringBuffer(); buffer.append(serialModel.getString()); buffer.append(" "); buffer.append(refreshTimeModel.getString()); buffer.append(" "); buffer.append(retryTimeModel.getString()); buffer.append(" "); buffer.append(expireTimeModel.getString()); buffer.append(" "); buffer.append(ttlModel.getString()); soaAttribute.removeAllValues(); soaAttribute.addValue(buffer.toString()); } private void populateModels() throws EditorException { if (soaAttribute.getSize() != 1) { return; } String soaValue = (String) soaAttribute.getValue(0); if (soaValue != null && soaValue.length() != 0) { StringTokenizer tokenizer = new StringTokenizer(soaValue); if (tokenizer.countTokens() != 5) { return; } serialModel.setString(tokenizer.nextToken()); refreshTimeModel.setString(tokenizer.nextToken()); retryTimeModel.setString(tokenizer.nextToken()); expireTimeModel.setString(tokenizer.nextToken()); ttlModel.setString(tokenizer.nextToken()); } } private LdapAttributeModel soaAttribute; private SimpleStringModel serialModel; private SimpleStringModel refreshTimeModel; private SimpleStringModel retryTimeModel; private SimpleStringModel expireTimeModel; private SimpleStringModel ttlModel; } |