001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (C) Alkacon Software (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.gwt.client.ui.input.form; 029 030/** 031 * Abstract handler superclass for forms which have their own dialog.<p> 032 */ 033public class CmsDialogFormHandler implements I_CmsFormHandler { 034 035 /** The form dialog. */ 036 protected CmsFormDialog m_dialog; 037 038 /** The form submit handler. */ 039 protected I_CmsFormSubmitHandler m_submitHandler; 040 041 /** Flag indicating whether we are currently submitting the form results. */ 042 private boolean m_submitting = false; 043 044 /** 045 * Creates a new instance.<p> 046 */ 047 public CmsDialogFormHandler() { 048 // empty default constructor 049 } 050 051 /** 052 * Returns true if the form results are currently being submitted.<p> 053 * 054 * @return true if the form results are submitted 055 */ 056 public boolean isSubmitting() { 057 058 return m_submitting; 059 } 060 061 /** 062 * @see org.opencms.gwt.client.ui.input.form.I_CmsFormHandler#onSubmitValidationResult(org.opencms.gwt.client.ui.input.form.CmsForm, boolean) 063 */ 064 public void onSubmitValidationResult(CmsForm form, boolean ok) { 065 066 if (ok) { 067 m_submitting = true; 068 m_dialog.hide(); 069 form.handleSubmit(m_submitHandler); 070 } else { 071 m_dialog.setOkButtonEnabled(form.noFieldsInvalid()); 072 } 073 } 074 075 /** 076 * @see org.opencms.gwt.client.ui.input.form.I_CmsFormHandler#onValidationResult(org.opencms.gwt.client.ui.input.form.CmsForm, boolean) 077 */ 078 public void onValidationResult(CmsForm form, boolean ok) { 079 080 m_dialog.setOkButtonEnabled(ok); 081 } 082 083 /** 084 * Sets the dialog.<p> 085 * 086 * @param dialog the form dialog 087 */ 088 public void setDialog(CmsFormDialog dialog) { 089 090 m_dialog = dialog; 091 } 092 093 /** 094 * Sets the form submit handler.<p> 095 * 096 * @param submitHandler the new form submit handler 097 */ 098 public void setSubmitHandler(I_CmsFormSubmitHandler submitHandler) { 099 100 m_submitHandler = submitHandler; 101 } 102}