KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > designer > view > FieldGroupView


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.designer.view;
5
6 import java.awt.Component JavaDoc;
7 import java.awt.Container JavaDoc;
8 import java.awt.GridBagLayout JavaDoc;
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12
13 import javax.swing.JPanel JavaDoc;
14
15 import org.oddjob.designer.Looks;
16 import org.oddjob.designer.model.DesignDefinition;
17 import org.oddjob.designer.model.FieldGroup;
18
19 /**
20  *
21  */

22 public class FieldGroupView implements ViewProducer {
23
24     private final List JavaDoc childViews = new ArrayList JavaDoc();
25     
26     private final FieldGroup fieldGroup;
27     
28     public FieldGroupView(FieldGroup fieldGroup) {
29         this.fieldGroup = fieldGroup;
30     }
31
32     /* (non-Javadoc)
33      * @see org.oddjob.designer.view.ViewProducer#dialog()
34      */

35     public Component JavaDoc dialog() {
36         return group();
37     }
38     
39     /* (non-Javadoc)
40      * @see org.oddjob.designer.view.ViewProducer#form()
41      */

42     public Component JavaDoc group() {
43         JPanel JavaDoc form = new JPanel JavaDoc();
44         form.setLayout(new GridBagLayout JavaDoc());
45         form.setBorder(Looks.groupBorder(fieldGroup.getTitle()));
46         
47         inline(form, 0, 0, fieldGroup.isContainsSelection());
48         
49         return form;
50     }
51
52     /* (non-Javadoc)
53      * @see org.oddjob.designer.view.ViewProducer#detailEdit(org.oddjob.designer.view.ActionWrapper)
54      */

55     public Component JavaDoc detailEdit() {
56         return ViewHelper.createDetailButton(fieldGroup);
57     }
58     
59     /* (non-Javadoc)
60      * @see org.oddjob.designer.view.ViewProducer#cell()
61      */

62     public Component JavaDoc cell() {
63         return ViewHelper.createDetailButton(fieldGroup);
64     }
65     
66     /* (non-Javadoc)
67      * @see org.oddjob.designer.view.ViewProducer#inline(java.awt.Container, int, int, boolean)
68      */

69     public int inline(Container JavaDoc container, int row, int column,
70             boolean selectionInGroup) {
71         for (int i = 0; i < fieldGroup.size(); ++i) {
72             DesignDefinition designDefinition = fieldGroup.get(i);
73             ViewProducer viewProducer = ViewFactory.create(designDefinition);
74             row = viewProducer.inline(container, row, column,
75                     fieldGroup.isContainsSelection());
76             childViews.add(viewProducer);
77         }
78         return row + 1;
79     }
80
81     /* (non-Javadoc)
82      * @see org.oddjob.designer.view.ViewProducer#setEnabled(boolean)
83      */

84     public void setEnabled(boolean enabled) {
85         for (Iterator JavaDoc it = childViews.iterator(); it.hasNext(); ) {
86             ((ViewProducer) it.next()).setEnabled(enabled);
87         }
88     }
89             
90 }
91
Popular Tags