1 56 package org.objectstyle.cayenne.modeler.editor.datanode; 57 58 import org.objectstyle.cayenne.access.DataNode; 59 import org.objectstyle.cayenne.modeler.ProjectController; 60 import org.objectstyle.cayenne.modeler.util.CayenneController; 61 import org.objectstyle.cayenne.swing.BindingBuilder; 62 import org.objectstyle.cayenne.swing.BindingDelegate; 63 import org.objectstyle.cayenne.swing.ObjectBinding; 64 import org.objectstyle.cayenne.util.Util; 65 66 69 public abstract class DataSourceEditor extends CayenneController { 70 71 protected ObjectBinding[] fieldAdapters; 72 protected DataNode node; 73 protected BindingDelegate nodeChangeProcessor; 74 75 public DataSourceEditor(ProjectController controller, 76 BindingDelegate nodeChangeProcessor) { 77 super(controller); 78 this.nodeChangeProcessor = nodeChangeProcessor; 79 initBindings(); 80 } 81 82 public DataNode getNode() { 83 return node; 84 } 85 86 public void setNode(DataNode node) { 87 if (!Util.nullSafeEquals(this.node, node)) { 88 this.node = node; 89 90 for (int i = 0; i < fieldAdapters.length; i++) { 91 fieldAdapters[i].updateView(); 92 } 93 } 94 } 95 96 protected void initBindings() { 97 BindingBuilder builder = new BindingBuilder( 98 getApplication().getBindingFactory(), 99 this); 100 builder.setDelegate(nodeChangeProcessor); 101 prepareBindings(builder); 102 } 103 104 protected abstract void prepareBindings(BindingBuilder builder); 105 106 protected void refreshView() { 107 for (int i = 0; i < fieldAdapters.length; i++) { 108 fieldAdapters[i].updateView(); 109 } 110 } 111 } | Popular Tags |