1 56 57 package org.objectstyle.cayenne.modeler.dialog.validator; 58 59 import javax.swing.JFrame ; 60 61 import org.objectstyle.cayenne.access.DataDomain; 62 import org.objectstyle.cayenne.map.DataMap; 63 import org.objectstyle.cayenne.map.DbEntity; 64 import org.objectstyle.cayenne.map.Entity; 65 import org.objectstyle.cayenne.map.ObjEntity; 66 import org.objectstyle.cayenne.map.Relationship; 67 import org.objectstyle.cayenne.modeler.ProjectController; 68 import org.objectstyle.cayenne.modeler.event.RelationshipDisplayEvent; 69 import org.objectstyle.cayenne.project.validator.ValidationInfo; 70 71 77 public class RelationshipErrorMsg extends ValidationDisplayHandler { 78 79 protected DataMap map; 80 protected Entity entity; 81 protected Relationship rel; 82 83 88 public RelationshipErrorMsg(ValidationInfo result) { 89 super(result); 90 Object [] path = result.getPath().getPath(); 91 int len = path.length; 92 93 if (len >= 1) { 94 rel = (Relationship) path[len - 1]; 95 } 96 97 if (len >= 2) { 98 entity = (Entity) path[len - 2]; 99 } 100 101 if (len >= 3) { 102 map = (DataMap) path[len - 3]; 103 } 104 105 if (len >= 4) { 106 domain = (DataDomain) path[len - 4]; 107 } 108 } 109 110 public void displayField(ProjectController mediator, JFrame frame) { 111 RelationshipDisplayEvent event = new RelationshipDisplayEvent( 112 frame, 113 rel, 114 entity, 115 map, 116 domain); 117 118 if (entity instanceof ObjEntity) { 121 mediator.fireObjEntityDisplayEvent(event); 122 mediator.fireObjRelationshipDisplayEvent(event); 123 } 124 else if (entity instanceof DbEntity) { 125 mediator.fireDbEntityDisplayEvent(event); 126 mediator.fireDbRelationshipDisplayEvent(event); 127 } 128 } 129 } | Popular Tags |