use of org.apache.cayenne.map.Embeddable in project cayenne by apache.
the class CreateAttributeAction method performAction.
/**
* Creates ObjAttribute, DbAttribute depending on context.
*/
@Override
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
if (getProjectController().getCurrentEmbeddable() != null) {
Embeddable embeddable = mediator.getCurrentEmbeddable();
EmbeddableAttribute attr = new EmbeddableAttribute();
attr.setName(NameBuilder.builder(attr, embeddable).name());
createEmbAttribute(embeddable, attr);
application.getUndoManager().addEdit(new CreateEmbAttributeUndoableEdit(embeddable, new EmbeddableAttribute[] { attr }));
}
if (getProjectController().getCurrentObjEntity() != null) {
ObjEntity objEntity = mediator.getCurrentObjEntity();
ObjAttribute attr = new ObjAttribute();
attr.setName(NameBuilder.builder(attr, objEntity).name());
createObjAttribute(mediator.getCurrentDataMap(), objEntity, attr);
application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), objEntity, attr));
} else if (getProjectController().getCurrentDbEntity() != null) {
DbEntity dbEntity = getProjectController().getCurrentDbEntity();
DbAttribute attr = new DbAttribute();
attr.setName(NameBuilder.builder(attr, dbEntity).name());
attr.setType(TypesMapping.NOT_DEFINED);
attr.setEntity(dbEntity);
createDbAttribute(mediator.getCurrentDataMap(), dbEntity, attr);
application.getUndoManager().addEdit(new CreateAttributeUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), dbEntity, attr));
}
}
use of org.apache.cayenne.map.Embeddable in project cayenne by apache.
the class FindAction method jumpToResult.
/**
* Navigate to search result
* Used also in {@link org.apache.cayenne.modeler.graph.action.EntityDisplayAction}
*/
public static void jumpToResult(FindAction.SearchResultEntry searchResultEntry) {
EditorView editor = ((CayenneModelerFrame) Application.getInstance().getFrameController().getView()).getView();
DataChannelDescriptor domain = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
if (searchResultEntry.getObject() instanceof Entity) {
jumpToEntityResult((Entity) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof QueryDescriptor) {
jumpToQueryResult((QueryDescriptor) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Embeddable) {
jumpToEmbeddableResult((Embeddable) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof EmbeddableAttribute) {
jumpToEmbeddableAttributeResult((EmbeddableAttribute) searchResultEntry.getObject(), editor, domain);
} else if (searchResultEntry.getObject() instanceof Attribute || searchResultEntry.getObject() instanceof Relationship) {
jumpToAttributeResult(searchResultEntry, editor, domain);
}
}
use of org.apache.cayenne.map.Embeddable in project cayenne by apache.
the class RemoveAction method removeLastPathComponent.
/**
* Removes an object, depending on its type
*/
private UndoableEdit removeLastPathComponent(ConfigurationNode object, ConfigurationNode parentObject) {
UndoableEdit undo = null;
if (object instanceof DataMap) {
if (parentObject != null && parentObject instanceof DataNodeDescriptor) {
undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) parentObject, (DataMap) object);
removeDataMapFromDataNode((DataNodeDescriptor) parentObject, (DataMap) object);
} else {
// Not under Data Node, remove completely
undo = new RemoveUndoableEdit(application, (DataMap) object);
removeDataMap((DataMap) object);
}
} else if (object instanceof DataNodeDescriptor) {
undo = new RemoveUndoableEdit(application, (DataNodeDescriptor) object);
removeDataNode((DataNodeDescriptor) object);
} else if (object instanceof DbEntity) {
undo = new RemoveUndoableEdit(((DbEntity) object).getDataMap(), (DbEntity) object);
removeDbEntity(((DbEntity) object).getDataMap(), (DbEntity) object);
} else if (object instanceof ObjEntity) {
undo = new RemoveUndoableEdit(((ObjEntity) object).getDataMap(), (ObjEntity) object);
removeObjEntity(((ObjEntity) object).getDataMap(), (ObjEntity) object);
} else if (object instanceof QueryDescriptor) {
undo = new RemoveUndoableEdit(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
removeQuery(((QueryDescriptor) object).getDataMap(), (QueryDescriptor) object);
} else if (object instanceof Procedure) {
undo = new RemoveUndoableEdit(((Procedure) object).getDataMap(), (Procedure) object);
removeProcedure(((Procedure) object).getDataMap(), (Procedure) object);
} else if (object instanceof Embeddable) {
undo = new RemoveUndoableEdit(((Embeddable) object).getDataMap(), (Embeddable) object);
removeEmbeddable(((Embeddable) object).getDataMap(), (Embeddable) object);
}
return undo;
}
use of org.apache.cayenne.map.Embeddable in project cayenne by apache.
the class CodeGeneratorControllerBase method getItemName.
public JLabel getItemName(Object obj) {
String className;
Icon icon = null;
if (obj instanceof Embeddable) {
className = ((Embeddable) obj).getClassName();
icon = CellRenderers.iconForObject(new Embeddable());
} else {
className = ((ObjEntity) obj).getName();
icon = CellRenderers.iconForObject(new ObjEntity());
}
JLabel labelIcon = new JLabel();
labelIcon.setIcon(icon);
labelIcon.setVisible(true);
labelIcon.setText(className);
return labelIcon;
}
use of org.apache.cayenne.map.Embeddable in project cayenne by apache.
the class EmbeddableDisplayEventType method fireLastDisplayEvent.
@Override
public void fireLastDisplayEvent() {
DataChannelDescriptor dataChannel = (DataChannelDescriptor) controller.getProject().getRootNode();
if (!dataChannel.getName().equals(preferences.getDomain())) {
return;
}
DataMap dataMap = dataChannel.getDataMap(preferences.getDataMap());
if (dataMap == null) {
return;
}
Embeddable embeddable = dataMap.getEmbeddable(preferences.getEmbeddable());
if (embeddable == null) {
return;
}
EmbeddableDisplayEvent embeddableDisplayEvent = new EmbeddableDisplayEvent(this, embeddable, dataMap, dataChannel);
controller.fireEmbeddableDisplayEvent(embeddableDisplayEvent);
}
Aggregations