use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class CreateObjEntityAction method createObjEntity.
protected void createObjEntity() {
ProjectController mediator = getProjectController();
DataMap dataMap = mediator.getCurrentDataMap();
ObjEntity entity = new ObjEntity();
entity.setName(NameBuilder.builder(entity, dataMap).name());
// init defaults
entity.setSuperClassName(dataMap.getDefaultSuperclass());
entity.setDeclaredLockType(dataMap.getDefaultLockType());
DbEntity dbEntity = mediator.getCurrentDbEntity();
if (dbEntity != null) {
entity.setDbEntity(dbEntity);
// TODO: use injectable name generator
String baseName = new DefaultObjectNameGenerator(NoStemStemmer.getInstance()).objEntityName(dbEntity);
entity.setName(NameBuilder.builder(entity, dbEntity.getDataMap()).baseName(baseName).name());
}
entity.setClassName(dataMap.getNameWithDefaultPackage(entity.getName()));
if (dataMap.isClientSupported()) {
entity.setClientClassName(dataMap.getNameWithDefaultClientPackage(entity.getName()));
entity.setClientSuperClassName(dataMap.getDefaultClientSuperclass());
}
dataMap.addObjEntity(entity);
// TODO: Modeler-controlled defaults for all the hardcoded boolean flags here.
EntityMergeSupport merger = new EntityMergeSupport(new DefaultObjectNameGenerator(NoStemStemmer.getInstance()), NamePatternMatcher.EXCLUDE_ALL, true, true, false);
merger.setNameGenerator(new DbEntitySyncAction.PreserveRelationshipNameGenerator());
merger.addEntityMergeListener(DeleteRuleUpdater.getEntityMergeListener());
merger.synchronizeWithDbEntity(entity);
fireObjEntityEvent(this, mediator, dataMap, entity);
application.getUndoManager().addEdit(new CreateObjEntityUndoableEdit(dataMap, entity));
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class CreateObjEntityAction method createObjEntity.
public void createObjEntity(DataMap dataMap, ObjEntity entity) {
ProjectController mediator = getProjectController();
dataMap.addObjEntity(entity);
fireObjEntityEvent(this, mediator, dataMap, entity);
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class CreateProcedureParameterAction method performAction.
/**
* Creates ProcedureParameter depending on context.
*/
@Override
public void performAction(ActionEvent e) {
ProjectController mediator = getProjectController();
if (getProjectController().getCurrentProcedure() != null) {
Procedure procedure = getProjectController().getCurrentProcedure();
ProcedureParameter parameter = new ProcedureParameter();
parameter.setName(NameBuilder.builder(parameter, procedure).name());
createProcedureParameter(procedure, parameter);
application.getUndoManager().addEdit(new CreateProcedureParameterUndoableEdit((DataChannelDescriptor) mediator.getProject().getRootNode(), mediator.getCurrentDataMap(), procedure, parameter));
}
}
use of org.apache.cayenne.modeler.ProjectController in project cayenne by apache.
the class CreateProcedureParameterAction method createProcedureParameter.
public void createProcedureParameter(Procedure procedure, ProcedureParameter parameter) {
procedure.addCallParameter(parameter);
ProjectController mediator = getProjectController();
fireProcedureParameterEvent(this, mediator, procedure, parameter);
}
Aggregations