1 56 package org.objectstyle.cayenne.modeler.editor; 57 58 import java.awt.BorderLayout ; 59 import java.awt.event.ActionEvent ; 60 import java.awt.event.ActionListener ; 61 62 import javax.swing.JCheckBox ; 63 64 import org.objectstyle.cayenne.modeler.ProjectController; 65 import org.objectstyle.cayenne.query.GenericSelectQuery; 66 67 import com.jgoodies.forms.builder.PanelBuilder; 68 import com.jgoodies.forms.layout.CellConstraints; 69 import com.jgoodies.forms.layout.FormLayout; 70 71 76 public class ObjectQueryPropertiesPanel extends SelectPropertiesPanel { 77 78 protected JCheckBox dataRows; 79 80 public ObjectQueryPropertiesPanel(ProjectController mediator) { 81 super(mediator); 82 } 83 84 protected void initView() { 85 super.initView(); 86 88 dataRows = new JCheckBox (); 89 90 CellConstraints cc = new CellConstraints(); 92 FormLayout layout = new FormLayout( 93 "right:max(80dlu;pref), 3dlu, left:max(50dlu;pref), fill:max(150dlu;pref)", 94 "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p"); 95 PanelBuilder builder = new PanelBuilder(layout); 96 builder.setDefaultDialogBorder(); 97 98 builder.addSeparator("", cc.xywh(1, 1, 4, 1)); 99 100 builder.addLabel("Result Caching:", cc.xy(1, 3)); 101 builder.add(cachePolicy, cc.xywh(3, 3, 2, 1)); 102 builder.addLabel("Fetch Data Rows:", cc.xy(1, 7)); 103 builder.add(dataRows, cc.xy(3, 7)); 104 builder.addLabel("Refresh Results:", cc.xy(1, 9)); 105 builder.add(refreshesResults, cc.xy(3, 9)); 106 builder.addLabel("Fetch Limit, Rows:", cc.xy(1, 11)); 107 builder.add(fetchLimit.getComponent(), cc.xy(3, 11)); 108 builder.addLabel("Page Size:", cc.xy(1, 13)); 109 builder.add(pageSize.getComponent(), cc.xy(3, 13)); 110 111 this.setLayout(new BorderLayout ()); 112 this.add(builder.getPanel(), BorderLayout.CENTER); 113 } 114 115 protected void initController() { 116 super.initController(); 117 118 dataRows.addActionListener(new ActionListener () { 119 120 public void actionPerformed(ActionEvent event) { 121 Boolean b = dataRows.isSelected() ? Boolean.TRUE : Boolean.FALSE; 122 setQueryProperty("fetchingDataRows", b); 123 } 124 }); 125 } 126 127 131 public void initFromModel(GenericSelectQuery query) { 132 super.initFromModel(query); 133 134 dataRows.setSelected(query.isFetchingDataRows()); 135 } 136 } | Popular Tags |