use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.
the class DataMapView method setDataMapName.
void setDataMapName(String newName) {
if (newName == null || newName.trim().length() == 0) {
throw new ValidationException("Enter name for DataMap");
}
DataMap map = eventController.getCurrentDataMap();
// search for matching map name across domains, as currently they have to be
// unique globally
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
DataMap matchingMap = dataChannelDescriptor.getDataMap(newName);
if (matchingMap != null && !matchingMap.equals(map)) {
// there is an entity with the same name
throw new ValidationException("There is another DataMap named '" + newName + "'. Use a different name.");
}
String oldName = map.getName();
if (Util.nullSafeEquals(newName, oldName)) {
return;
}
// completely new name, set new name for domain
DataMapDefaults pref = eventController.getDataMapPreferences("");
DataMapEvent e = new DataMapEvent(this, map, map.getName());
ProjectUtil.setDataMapName((DataChannelDescriptor) eventController.getProject().getRootNode(), map, newName);
pref.copyPreferences(newName);
eventController.fireDataMapEvent(e);
}
use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.
the class ProjectController method getDataMapPreferences.
/**
* Returns preferences object for the current DataMap. If no preferences
* exist for the current DataMap, a new Preferences object is created. If no
* DataMap is currently selected, an exception is thrown. An optional
* nameSuffix allows to address more than one defaults instance for a single
* DataMap.
*/
public DataMapDefaults getDataMapPreferences(String nameSuffix) {
DataMap map = getCurrentDataMap();
if (map == null) {
throw new CayenneRuntimeException("No DataMap selected");
}
Preferences pref;
if (nameSuffix == null || nameSuffix.length() == 0) {
pref = getPreferenceForDataDomain().node("DataMap").node(map.getName());
} else {
pref = getPreferenceForDataDomain().node("DataMap").node(map.getName()).node(nameSuffix);
}
return (DataMapDefaults) application.getCayenneProjectPreferences().getProjectDetailObject(DataMapDefaults.class, pref);
}
use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.
the class ProjectController method getDataMapPreferences.
public DataMapDefaults getDataMapPreferences(DataMap dataMap) {
Preferences pref;
pref = getPreferenceForDataDomain().node("DataMap").node(dataMap.getName());
return (DataMapDefaults) application.getCayenneProjectPreferences().getProjectDetailObject(DataMapDefaults.class, pref);
}
use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.
the class StandardModeController method createDefaults.
protected void createDefaults() {
TreeMap<DataMap, DataMapDefaults> treeMap = new TreeMap<DataMap, DataMapDefaults>();
ArrayList<DataMap> dataMaps = (ArrayList<DataMap>) getParentController().getDataMaps();
for (DataMap dataMap : dataMaps) {
DataMapDefaults preferences = getApplication().getFrameController().getProjectController().getDataMapPreferences(dataMap);
preferences.setSuperclassPackage("");
preferences.updateSuperclassPackage(dataMap, false);
treeMap.put(dataMap, preferences);
if (getOutputPath() == null) {
setOutputPath(preferences.getOutputPath());
}
}
setMapPreferences(treeMap);
}
use of org.apache.cayenne.modeler.pref.DataMapDefaults in project cayenne by apache.
the class ClientModeController method createView.
protected GeneratorControllerPanel createView() {
this.view = new StandardModePanel();
Set<Entry<DataMap, DataMapDefaults>> entities = getMapPreferences().entrySet();
for (Entry<DataMap, DataMapDefaults> entry : entities) {
StandardPanelComponent dataMapLine = createDataMapLineBy(entry.getKey(), entry.getValue());
dataMapLine.getDataMapName().setText(dataMapLine.getDataMap().getName());
BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), dataMapLine);
builder.bindToTextField(dataMapLine.getSuperclassPackage(), "preferences.superclassPackage").updateView();
this.view.addDataMapLine(dataMapLine);
}
return view;
}
Aggregations