/** * Returns <code>true</code> if path contains a DataMap object. */ public boolean enableForPath(ConfigurationNode object) { if (object == null) { return false; } return ((Entity) object).getDataMap() != null; } }
public Object getParent() { return getDataMap(); }
public Object getParent() { return getDataMap(); }
@Override public String quotedIdentifier(Entity entity, String... identifierParts) { return quotedIdentifier(entity.getDataMap(), identifierParts); }
final MappingNamespace getNonNullNamespace() { MappingNamespace parent = getDataMap(); if (parent == null) { throw new CayenneRuntimeException("Entity '%s' has no parent MappingNamespace (such as DataMap)", getName()); } return parent; } }
final MappingNamespace getNonNullNamespace() { MappingNamespace parent = getDataMap(); if (parent == null) { throw new CayenneRuntimeException("Entity '" + getName() + "' has no parent MappingNamespace (such as DataMap)"); } return parent; } }
/** * Converts non-String Object used in renderers (currently CayenneMapEntry * instances only) to String * * @param obj Object to be converted * @param namespace the current namespace */ public static String asString(Object obj, MappingNamespace namespace) { if (obj instanceof CayenneMapEntry) { CayenneMapEntry mapObject = (CayenneMapEntry) obj; String label = mapObject.getName(); if (mapObject instanceof Entity) { Entity entity = (Entity) mapObject; // for different namespace display its name DataMap dataMap = entity.getDataMap(); if (dataMap != null && dataMap != namespace) { label += " (" + dataMap.getName() + ")"; } } return label; } else if (obj instanceof DataMap) { return ((DataMap) obj).getName(); } return obj == null ? null : String.valueOf(obj); }
/** * Returns a collection of DbRelationships that use this attribute as a source. */ public static Collection<DbRelationship> getRelationshipsUsingAttributeAsTarget( DbAttribute attribute) { Entity parent = attribute.getEntity(); if (parent == null) { return Collections.EMPTY_LIST; } DataMap map = parent.getDataMap(); if (map == null) { return Collections.EMPTY_LIST; } Collection<DbRelationship> relationships = new ArrayList<DbRelationship>(); for (Entity entity : map.getDbEntities()) { if (entity == parent) { continue; } Collection<DbRelationship> entityRelationships = (Collection<DbRelationship>) entity .getRelationships(); for (DbRelationship relationship : entityRelationships) { if (ProjectUtil.containsTargetAttribute(relationship, attribute)) { relationships.add(relationship); } } } return relationships; }
/** * Constructor for EntityErrorMsg. * * @param result */ public EntityErrorMsg(ValidationFailure result) { super(result); Object object = result.getSource(); entity = (Entity) object; map = entity.getDataMap(); domain = (DataChannelDescriptor) Application .getInstance() .getProject() .getRootNode(); }
@Override public void performAction(ActionEvent e, boolean allowAsking) { ConfirmRemoveDialog dialog = getConfirmDeleteDialog(allowAsking); Entity entity = builder.getSelectedEntity(); if (entity == null) { return; } if (entity instanceof ObjEntity) { if (dialog.shouldDelete("ObjEntity", entity.getName())) { application.getUndoManager().addEdit( new RemoveUndoableEdit(entity.getDataMap(), (ObjEntity) entity)); removeObjEntity(entity.getDataMap(), (ObjEntity) entity); } } else { if (dialog.shouldDelete("DbEntity", entity.getName())) { application.getUndoManager().addEdit( new RemoveUndoableEdit(entity.getDataMap(), (DbEntity) entity)); removeDbEntity(entity.getDataMap(), (DbEntity) entity); } } } }
/** * Constructor for AttributeErrorMsg. * * @param result */ public AttributeErrorMsg(ValidationFailure result) { super(result); Object object = result.getSource(); attribute = (Attribute) object; entity = attribute.getEntity(); map = entity.getDataMap(); domain = (DataChannelDescriptor) Application .getInstance() .getProject() .getRootNode(); }
/** * Constructor for RelationshipErrorMsg. * * @param result */ public RelationshipErrorMsg(ValidationFailure result) { super(result); Object object = result.getSource(); rel = (Relationship) object; entity = rel.getSourceEntity(); map = entity.getDataMap(); domain = (DataChannelDescriptor) Application .getInstance() .getProject() .getRootNode(); }
private static void jumpToEntityResult(Entity entity, EditorView editor, DataChannelDescriptor domain) { DataMap map = entity.getDataMap(); buildAndSelectTreePath(map, entity, editor); EntityDisplayEvent event = new EntityDisplayEvent(editor.getProjectTreeView(), entity, map, domain); event.setMainTabFocus(true); if (entity instanceof ObjEntity) { editor.getObjDetailView().currentObjEntityChanged(event); } else if (entity instanceof DbEntity) { editor.getDbDetailView().currentDbEntityChanged(event); } }
/** * Informs all listeners of the EntityEvent. Does not send the event to its * originator. */ public void fireObjEntityEvent(EntityEvent e) { setDirty(true); if (e.getEntity().getDataMap() != null && e.getId() == MapEvent.CHANGE) { e.getEntity().getDataMap().objEntityChanged(e); } if (e.getId() == MapEvent.REMOVE) { removeFromHistory(e); } for (EventListener listener : listenerList.getListeners(ObjEntityListener.class)) { ObjEntityListener temp = (ObjEntityListener) listener; switch (e.getId()) { case MapEvent.ADD: temp.objEntityAdded(e); break; case MapEvent.CHANGE: temp.objEntityChanged(e); break; case MapEvent.REMOVE: temp.objEntityRemoved(e); break; default: throw new IllegalArgumentException("Invalid EntityEvent type: " + e.getId()); } } }
/** * Event handler for ObjEntity and DbEntity removals. Removes a tree node for the * entity and selects its sibling. */ protected void entityRemoved(EntityEvent e) { if (e.getSource() == this) { return; } // remove from DataMap tree removeNode(new Object[] { e.getDomain() != null ? e.getDomain() : (DataChannelDescriptor) mediator .getProject() .getRootNode(), e.getEntity().getDataMap(), e.getEntity() }); }
/** * Event handler for ObjEntity and DbEntity additions. Adds a tree node for the entity * and make it selected. */ protected void entityAdded(EntityEvent e) { Entity entity = e.getEntity(); DefaultMutableTreeNode mapNode = getProjectModel().getNodeForObjectPath( new Object[] { e.getDomain() != null ? e.getDomain() : (DataChannelDescriptor) mediator .getProject() .getRootNode(), e.getEntity().getDataMap() }); if (mapNode == null) { return; } DefaultMutableTreeNode currentNode = new DefaultMutableTreeNode(entity, false); positionNode(mapNode, currentNode, Comparators.getDataMapChildrenComparator()); showNode(currentNode); }
.getRootNode(); Object[] path = new Object[] {domain, entity.getDataMap(), entity};
/** * Makes Entity visible and selected. * <ul> * <li>If entity is from the current node, refreshes the node making sure changes in * the entity name are reflected.</li> * <li>If entity is in a different node, makes that node visible and selected.</li> * </ul> */ protected void entityChanged(EntityEvent e) { if (e.isNameChange()) { Object[] path = new Object[] { e.getDomain() != null ? e.getDomain() : (DataChannelDescriptor) mediator.getProject().getRootNode(), e.getEntity().getDataMap(), e.getEntity() }; updateNode(path); positionNode(path, Comparators.getDataMapChildrenComparator()); showNode(path); } }
public void navigateToEntity(Entity entity) { TreePath path = buildTreePath(entity); editor().getProjectTreeView().getSelectionModel().setSelectionPath(path); EntityDisplayEvent event = new EntityDisplayEvent( editor().getProjectTreeView(), entity, entity.getDataMap(), (DataChannelDescriptor) getProjectController().getProject().getRootNode()); if (entity instanceof DbEntity) { getProjectController().fireDbEntityDisplayEvent(event); } else if (entity instanceof ObjEntity){ getProjectController().fireObjEntityDisplayEvent(event); } } }
void showEntity(Entity entity) { // we're always in same domain EditorView editor = ((CayenneModelerFrame) Application .getInstance() .getFrameController() .getView()).getView(); editor.getProjectTreeView().getSelectionModel().setSelectionPath( editor .getProjectTreeView() .getSelectionPath() .getParentPath() .getParentPath()); DomainDisplayEvent event = new EntityDisplayEvent( editor.getProjectTreeView(), entity, entity.getDataMap(), (DataChannelDescriptor) getProjectController().getProject().getRootNode()); getProjectController().fireDomainDisplayEvent(event); } }