1 4 package org.oddjob.designer.view; 5 6 import java.awt.Component ; 7 import java.awt.Container ; 8 import java.awt.GridBagLayout ; 9 import java.util.ArrayList ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 13 import javax.swing.JPanel ; 14 15 import org.oddjob.designer.Looks; 16 import org.oddjob.designer.model.DesignDefinition; 17 import org.oddjob.designer.model.FieldGroup; 18 19 22 public class FieldGroupView implements ViewProducer { 23 24 private final List childViews = new ArrayList (); 25 26 private final FieldGroup fieldGroup; 27 28 public FieldGroupView(FieldGroup fieldGroup) { 29 this.fieldGroup = fieldGroup; 30 } 31 32 35 public Component dialog() { 36 return group(); 37 } 38 39 42 public Component group() { 43 JPanel form = new JPanel (); 44 form.setLayout(new GridBagLayout ()); 45 form.setBorder(Looks.groupBorder(fieldGroup.getTitle())); 46 47 inline(form, 0, 0, fieldGroup.isContainsSelection()); 48 49 return form; 50 } 51 52 55 public Component detailEdit() { 56 return ViewHelper.createDetailButton(fieldGroup); 57 } 58 59 62 public Component cell() { 63 return ViewHelper.createDetailButton(fieldGroup); 64 } 65 66 69 public int inline(Container 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 84 public void setEnabled(boolean enabled) { 85 for (Iterator it = childViews.iterator(); it.hasNext(); ) { 86 ((ViewProducer) it.next()).setEnabled(enabled); 87 } 88 } 89 90 } 91 | Popular Tags |