01: /*
02: * SwingML Copyright (C) 2002 Robert J. Morris.
03: *
04: * This library is free software; you can redistribute it and/or modify it under
05: * the terms of the GNU Lesser General Public License as published by the Free
06: * Software Foundation; either version 2 of the License, or (at your option) any
07: * later version.
08: *
09: * This library is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12: * details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with this library; if not, write to the Free Software Foundation, Inc.,
16: * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: * Authors: Adi Rosenblum <arosenblum@crosslogic.com>
19: */
20:
21: package org.swingml.view.renderer;
22:
23: import java.awt.*;
24: import java.util.*;
25: import java.util.List;
26:
27: import org.swingml.*;
28: import org.swingml.errors.handlers.*;
29: import org.swingml.model.*;
30: import org.swingml.view.*;
31:
32: public class ErrorHandlerRenderer extends RendererUtil implements
33: Renderer {
34:
35: public Container render(AbstractSwingMLModel aModel,
36: Container aParent) {
37: ErrorHandlerModel theModel = (ErrorHandlerModel) aModel;
38: if (theModel.getParent() instanceof ISwingMLErrorHandlerContainer) {
39: // Create new Error handler from factory
40: ISwingMLErrorHandler handler = ErrorHandlerFactory
41: .getErrorHandler(theModel);
42:
43: // iterate children, creating name/value parameters
44: List children = theModel.getChildren();
45: SwingMLModel child;
46: Iterator schmiterator = children.iterator();
47: while (schmiterator.hasNext()) {
48: child = (SwingMLModel) schmiterator.next();
49: if (child instanceof ParameterModel) {
50: ParameterModel parameter = (ParameterModel) child;
51: handler.addParameter(parameter.getName(), parameter
52: .getValue());
53: }
54: }
55:
56: // set on parent
57: ((ISwingMLErrorHandlerContainer) theModel.getParent())
58: .addHandler(theModel.getErrorType(), handler);
59: }
60: return null;
61: }
62: }
|