use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class QueryErrorMsg method displayField.
public void displayField(ProjectController mediator, JFrame frame) {
Object object = super.validationFailure.getSource();
DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
QueryDescriptor query = (QueryDescriptor) object;
DataMap map = query.getDataMap();
QueryDisplayEvent event = new QueryDisplayEvent(frame, query, map, domain);
mediator.fireQueryDisplayEvent(event);
}
use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class DataDomainView method setDomainProperty.
/**
* Helper method that updates domain properties. If a value equals to default, null
* value is used instead.
*/
protected void setDomainProperty(String property, String value, String defaultValue) {
DataChannelDescriptor domain = (DataChannelDescriptor) projectController.getProject().getRootNode();
if (domain == null) {
return;
}
// no empty strings
if ("".equals(value)) {
value = null;
}
// use NULL for defaults
if (value != null && value.equals(defaultValue)) {
value = null;
}
Map properties = domain.getProperties();
Object oldValue = properties.get(property);
if (!Util.nullSafeEquals(value, oldValue)) {
properties.put(property, value);
DomainEvent e = new DomainEvent(this, domain);
projectController.fireDomainEvent(e);
}
}
use of org.apache.cayenne.configuration.DataChannelDescriptor in project cayenne by apache.
the class DataDomainView method setDomainName.
void setDomainName(String newName) {
DataChannelDescriptor dataChannelDescriptor = (DataChannelDescriptor) Application.getInstance().getProject().getRootNode();
if (Util.nullSafeEquals(dataChannelDescriptor.getName(), newName)) {
return;
}
if (newName == null || newName.trim().length() == 0) {
throw new ValidationException("Enter name for DataDomain");
}
Preferences prefs = projectController.getPreferenceForDataDomain();
DomainEvent e = new DomainEvent(this, dataChannelDescriptor, dataChannelDescriptor.getName());
dataChannelDescriptor.setName(newName);
RenamedPreferences.copyPreferences(newName, prefs);
projectController.fireDomainEvent(e);
}
use of org.apache.cayenne.configuration.DataChannelDescriptor 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.configuration.DataChannelDescriptor in project cayenne by apache.
the class Application method getMainPreferenceForProject.
public Preferences getMainPreferenceForProject() {
DataChannelDescriptor descriptor = (DataChannelDescriptor) getFrameController().getProjectController().getProject().getRootNode();
// if new project
if (descriptor.getConfigurationSource() == null) {
return getPreferencesNode(getProject().getClass(), getNewProjectTemporaryName());
}
String path = CayennePreference.filePathToPrefereceNodePath(descriptor.getConfigurationSource().getURL().getPath());
Preferences pref = getPreferencesNode(getProject().getClass(), "");
return pref.node(pref.absolutePath() + path);
}
Aggregations