01: /*
02: * Copyright (C) 2005 Jeff Tassin
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package com.jeta.swingbuilder.codegen.builder.properties;
20:
21: import java.util.Collection;
22: import java.util.Iterator;
23:
24: import com.jeta.forms.gui.beans.JETAPropertyDescriptor;
25: import com.jeta.forms.store.properties.TabProperty;
26: import com.jeta.forms.store.properties.TabbedPaneProperties;
27: import com.jeta.swingbuilder.codegen.builder.BeanWriter;
28: import com.jeta.swingbuilder.codegen.builder.DeclarationManager;
29: import com.jeta.swingbuilder.codegen.builder.IconExpression;
30: import com.jeta.swingbuilder.codegen.builder.MethodExpression;
31: import com.jeta.swingbuilder.codegen.builder.MethodStatement;
32: import com.jeta.swingbuilder.codegen.builder.MethodWriter;
33: import com.jeta.swingbuilder.codegen.builder.PanelWriter;
34: import com.jeta.swingbuilder.codegen.builder.PropertyWriter;
35: import com.jeta.swingbuilder.codegen.builder.StringExpression;
36:
37: public class TabbedPanePropertyWriter implements PropertyWriter {
38: /**
39: * PropertyWriter implementation
40: */
41: public void writeProperty(DeclarationManager declMgr,
42: BeanWriter writer, JETAPropertyDescriptor pd, Object value) {
43: try {
44: if (value instanceof TabbedPaneProperties) {
45: TabbedPaneProperties tpp = (TabbedPaneProperties) value;
46: Collection tabs = tpp.getTabs();
47: Iterator iter = tabs.iterator();
48: while (iter.hasNext()) {
49: TabProperty tp = (TabProperty) iter.next();
50: MethodStatement ss = new MethodStatement(writer
51: .getBeanVariable(), "addTab");
52: ss
53: .addParameter(new StringExpression(tp
54: .getTitle()));
55: ss.addParameter(new IconExpression(declMgr, tp
56: .getIconProperty()));
57: PanelWriter pw = new PanelWriter();
58: MethodWriter mw = pw.createPanel(declMgr, tp
59: .getFormMemento());
60: ss.addParameter(new MethodExpression(mw
61: .getMethodName()));
62: writer.addStatement(ss);
63: }
64: }
65: } catch (Exception e) {
66: e.printStackTrace();
67: }
68: }
69:
70: }
|