use of org.jkiss.dbeaver.model.impl.DBSObjectCache in project dbeaver by serge-rider.
the class PropertySourceEditable method setPropertyValue.
@Override
@SuppressWarnings("unchecked")
public void setPropertyValue(@Nullable DBRProgressMonitor monitor, Object editableValue, ObjectPropertyDescriptor prop, Object newValue) throws IllegalArgumentException {
if (prop.getValueTransformer() != null) {
newValue = prop.getValueTransformer().transform(editableValue, newValue);
}
final Object oldValue = getPropertyValue(monitor, editableValue, prop);
if (!updatePropertyValue(monitor, editableValue, prop, newValue, false)) {
return;
}
if (commandContext != null) {
if (lastCommand == null || lastCommand.getObject() != editableValue || lastCommand.property != prop) {
final DBEObjectEditor<DBPObject> objectEditor = getObjectEditor(DBEObjectEditor.class);
if (objectEditor == null) {
log.error("Can't obtain object editor for " + getEditableValue());
return;
}
final DBEPropertyHandler<DBPObject> propertyHandler = objectEditor.makePropertyHandler((DBPObject) editableValue, prop);
PropertyChangeCommand curCommand = new PropertyChangeCommand((DBPObject) editableValue, prop, propertyHandler, oldValue, newValue);
commandContext.addCommand(curCommand, commandReflector);
lastCommand = curCommand;
} else {
lastCommand.setNewValue(newValue);
commandContext.updateCommand(lastCommand, commandReflector);
}
}
// To update name-based cache
if (prop.isNameProperty() && editableValue instanceof DBSObject) {
DBEObjectMaker objectManager = getObjectEditor(DBEObjectMaker.class);
if (objectManager != null) {
DBSObjectCache cache = objectManager.getObjectsCache((DBSObject) editableValue);
if (cache != null && cache.isFullyCached()) {
List<? extends DBSObject> cachedObjects = CommonUtils.copyList(cache.getCachedObjects());
cache.setCache(cachedObjects);
}
}
}
/*
// Notify listeners
for (IPropertySourceListener listener : listeners) {
listener.handlePropertyChange(editableValue, prop, newValue);
}
*/
}
Aggregations