001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.unifiedGui.wizard.validation;
032:
033: import java.util.*;
034:
035: import de.ug2t.kernel.*;
036: import de.ug2t.unifiedGui.*;
037: import de.ug2t.unifiedGui.wizard.*;
038:
039: public class FieldValidationCheck implements IWizardPrePostAction {
040: public boolean pcmf_doPrePost(WizardPlugin xPl, int xPrePost,
041: int xDirection) {
042: boolean l_error = false;
043: String l_pMess = xPl.pcmf_getMessages();
044:
045: if (xPrePost == IWizardPrePostAction.CSC_WIZ_POSTACTION
046: && xDirection == IWizardPrePostAction.CSC_WIZ_NEXT) {
047: ArrayList l_list = xPl.pcmf_getAllValidations();
048: if (l_list == null)
049: return (true);
050:
051: Iterator l_it = l_list.iterator();
052: while (l_it.hasNext()) {
053: ADialogPlugin.ValidationPair l_pair = (ADialogPlugin.ValidationPair) l_it
054: .next();
055: if (l_pair.pcm_toValidate.pcmf_isHidden() == false
056: && l_pair.pcm_toValidate.pcmf_isDisabled() == false
057: && l_pair.pcm_toValidate.pcmf_isParentHidden() == false
058: && l_pair.pcm_toValidate
059: .pcmf_isParentDisabled() == false) {
060: String l_vRes = l_pair.pcm_validator
061: .pcmf_validate(l_pair.pcm_toValidate);
062: if (l_vRes == null) {
063: l_pair.pcm_toValidate.pcmf_setToolTip(null);
064: if (xPl
065: .pcmf_isMandatory(xPl
066: .pcmf_getLocalName(l_pair.pcm_toValidate)))
067: l_pair.pcm_toValidate
068: .pcmf_setBorder(
069: UnComponent.LINE_BORDER,
070: "black", 1);
071: else
072: l_pair.pcm_toValidate.pcmf_reset();
073:
074: continue;
075: }
076: l_pair.pcm_toValidate.pcmf_setBorder(
077: UnComponent.LINE_BORDER, "red", 1);
078: l_pair.pcm_toValidate.pcmf_setToolTip(l_vRes);
079: xPl.pcmf_addMessage(KeTools.pcmf_deRef(l_vRes));
080: l_error = true;
081: }
082: }
083: }
084: if (!l_error)
085: xPl.pcmf_setMessage(l_pMess);
086:
087: return (!l_error);
088: }
089:
090: public static void pcmf_setError(WizardPlugin xPl,
091: UnComponent xToValidate, String l_vRes) {
092: if (l_vRes == null) {
093: xToValidate.pcmf_setToolTip(null);
094: if (xPl
095: .pcmf_isMandatory(xPl
096: .pcmf_getLocalName(xToValidate)))
097: xToValidate.pcmf_setBorder(UnComponent.LINE_BORDER,
098: "black", 1);
099: else
100: xToValidate.pcmf_reset();
101:
102: } else {
103: xToValidate.pcmf_setBorder(UnComponent.LINE_BORDER, "red",
104: 1);
105: xToValidate.pcmf_setToolTip(l_vRes);
106: xPl.pcmf_addMessage(KeTools.pcmf_deRef(l_vRes));
107: }
108: }
109: }
|