01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui.action;
19:
20: import de.finix.contelligent.client.gui.AbstractGUI;
21: import de.finix.contelligent.client.gui.ComponentEditor;
22: import de.finix.contelligent.client.gui.ComponentRenderer;
23: import de.finix.contelligent.client.gui.UnsupportedGUIException;
24: import de.finix.contelligent.client.gui.property.PropertyEditor;
25: import de.finix.contelligent.client.i18n.Resources;
26:
27: public class ParameterGUI extends AbstractGUI {
28:
29: private ParameterEditor parameterEditor = null;
30:
31: private PropertyEditor propertyEditor = null;
32:
33: private void assureParameterEditorCreated(boolean editable) {
34: if (parameterEditor == null) {
35: parameterEditor = new ParameterEditor();
36: parameterEditor.setComponent(getComponent());
37: parameterEditor.setView(getView());
38: parameterEditor.setEditable(editable);
39: parameterEditor.init();
40: } else if (parameterEditor.isEditable() != editable) {
41: // only change this, if neccessary as it may take quite some time...
42: parameterEditor.setEditable(editable);
43: }
44: }
45:
46: private void assurePropertyEditorCreated(boolean editable) {
47: if (propertyEditor == null) {
48: propertyEditor = new PropertyEditor();
49: propertyEditor.setComponent(getComponent());
50: propertyEditor.setView(getView());
51: propertyEditor.setEditable(editable);
52: propertyEditor.setVisibleGroup(PropertyEditor.EDIT);
53: propertyEditor.init();
54: } else if (propertyEditor.isEditable() != editable) {
55: // only change this, if neccessary as it may take quite some time...
56: propertyEditor.setEditable(editable);
57: }
58: }
59:
60: public boolean isSupported(int type) {
61: return (type == DEFAULT || type == TABLE);
62: }
63:
64: public ComponentEditor getEditor(int type)
65: throws UnsupportedGUIException {
66: if (!isSupported(type)) {
67: throw new UnsupportedGUIException(getComponent());
68: }
69: if (type == TABLE) {
70: assureParameterEditorCreated(true);
71: return parameterEditor;
72: } else {
73: assurePropertyEditorCreated(true);
74: return propertyEditor;
75: }
76: }
77:
78: public ComponentRenderer getRenderer(int type)
79: throws UnsupportedGUIException {
80: if (!isSupported(type)) {
81: throw new UnsupportedGUIException(getComponent());
82: }
83: if (type == TABLE) {
84: assureParameterEditorCreated(false);
85: return parameterEditor;
86: } else {
87: assurePropertyEditorCreated(false);
88: return propertyEditor;
89: }
90: }
91:
92: public String getName() {
93: return Resources.getLocalString("action_parameter_gui");
94: }
95: }
|