提交 5af68c70 编写于 作者: S Serge Rider

Value managers registry fix (datasource name)

上级 84a5adfd
......@@ -169,8 +169,9 @@ public class ResultSetValueController implements IAttributeController, IRowContr
@Override
public IValueManager getValueManager() {
DBSAttributeBase valueType = binding.getPresentationAttribute();
final DBCExecutionContext executionContext = getExecutionContext();
return ValueManagerRegistry.findValueManager(
getDataSourceContainer(),
executionContext == null ? null : executionContext.getDataSource(),
valueType,
getValueHandler().getValueObjectType(valueType));
}
......
......@@ -21,6 +21,7 @@ import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.DBPDataKind;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.impl.AbstractDescriptor;
import org.jkiss.dbeaver.model.struct.DBSDataType;
......@@ -61,7 +62,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
DBPDataKind dataKind;
ObjectType valueType;
String extension;
DataSourceProviderDescriptor dataSource;
String dataSource;
}
private IValueManager instance;
......@@ -80,7 +81,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
String className = typeElement.getAttribute(ATTR_TYPE);
String ext = typeElement.getAttribute(ATTR_EXTENSION);
String dspId = typeElement.getAttribute(ATTR_DATA_SOURCE);
if (!CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(typeName) || !CommonUtils.isEmpty(className) || !CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(ext)) {
if (!CommonUtils.isEmpty(kindName) || !CommonUtils.isEmpty(typeName) || !CommonUtils.isEmpty(className) || !CommonUtils.isEmpty(dspId) || !CommonUtils.isEmpty(ext)) {
SupportInfo info = new SupportInfo();
if (!CommonUtils.isEmpty(kindName)) {
try {
......@@ -99,10 +100,7 @@ public class ValueManagerDescriptor extends AbstractDescriptor
info.extension = ext;
}
if (!CommonUtils.isEmpty(dspId)) {
info.dataSource = DataSourceProviderRegistry.getInstance().getDataSourceProvider(dspId);
if (info.dataSource == null) {
log.warn("Data source '" + dspId + "' not found");
}
info.dataSource = dspId;
}
supportInfos.add(info);
}
......@@ -128,13 +126,13 @@ public class ValueManagerDescriptor extends AbstractDescriptor
return instance;
}
public boolean supportsType(@Nullable DBPDataSourceContainer dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType)
public boolean supportsType(@Nullable DBPDataSource dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType)
{
final DBPDataKind dataKind = typedObject.getDataKind();
for (SupportInfo info : supportInfos) {
if (dataSource != null && info.dataSource != null) {
DriverDescriptor driver = (DriverDescriptor) dataSource.getDriver();
if (driver.getProviderDescriptor() != info.dataSource) {
DriverDescriptor driver = (DriverDescriptor) dataSource.getContainer().getDriver();
if (!info.dataSource.equals(driver.getProviderDescriptor().getId()) && !info.dataSource.equals(dataSource.getClass().getName())) {
continue;
}
} else if (checkDataSource) {
......@@ -169,8 +167,15 @@ public class ValueManagerDescriptor extends AbstractDescriptor
return true;
}
}
if (!checkType && info.valueType == null && info.dataKind == null && info.typeName == null && info.extension == null) {
return true;
}
}
return false;
}
@Override
public String toString() {
return id;
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.data.DBDContent;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
......@@ -66,7 +67,7 @@ public class ValueManagerRegistry {
}
@NotNull
public IValueManager getManager(@Nullable DBPDataSourceContainer dataSource, @NotNull DBSTypedObject dataKind, @NotNull Class<?> valueType) {
public IValueManager getManager(@Nullable DBPDataSource dataSource, @NotNull DBSTypedObject dataKind, @NotNull Class<?> valueType) {
// Check starting from most restrictive to less restrictive
IValueManager manager = findManager(dataSource, dataKind, valueType, true, true);
if (manager == null) {
......@@ -84,7 +85,7 @@ public class ValueManagerRegistry {
return manager;
}
private IValueManager findManager(@Nullable DBPDataSourceContainer dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType) {
private IValueManager findManager(@Nullable DBPDataSource dataSource, DBSTypedObject typedObject, Class<?> valueType, boolean checkDataSource, boolean checkType) {
for (ValueManagerDescriptor manager : managers) {
if (manager.supportsType(dataSource, typedObject, valueType, checkDataSource, checkType)) {
return manager.getInstance();
......@@ -94,7 +95,7 @@ public class ValueManagerRegistry {
}
@NotNull
public static IValueManager findValueManager(@Nullable DBPDataSourceContainer dataSource, @NotNull DBSTypedObject typedObject, @NotNull Class<?> valueType) {
public static IValueManager findValueManager(@Nullable DBPDataSource dataSource, @NotNull DBSTypedObject typedObject, @NotNull Class<?> valueType) {
return getInstance().getManager(dataSource, typedObject, valueType);
}
......
......@@ -451,7 +451,7 @@ public class ComplexObjectEditor extends TreeViewer {
public IValueManager getValueManager() {
DBSTypedObject valueType = getValueType();
return ValueManagerRegistry.findValueManager(
getExecutionContext().getDataSource().getContainer(),
getExecutionContext().getDataSource(),
valueType,
getValueHandler().getValueObjectType(valueType));
}
......
......@@ -792,7 +792,7 @@
id="org.jkiss.dbeaver.ext.generic.data.GenericValueHandlerProvider"
label="Generic data types provider">
<datasource id="generic"/>
<!-- Date/time value handler - needed to provide native datatime value formatting. Formatting itself provided in drivers configuration. -->
<!-- Date/time value handler - needed to provide native datetime value formatting. Formatting itself provided in drivers configuration. -->
<type kind="DATETIME"/>
</provider>
</extension>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册