提交 14ed345a 编写于 作者: S serge-rider

Object editor fix

上级 0af7d786
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.model.impl;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPDataKind;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSTypedObject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* SimpleTypedObject
*/
public class SimpleTypedObject implements DBSTypedObject {
public static final SimpleTypedObject DEFAULT_TYPE = new SimpleTypedObject("Object");
private String typeName;
public SimpleTypedObject(String typeName) {
this.typeName = typeName;
}
@Override
public String getTypeName() {
return typeName;
}
@Override
public String getFullTypeName() {
return getTypeName();
}
@Override
public int getTypeID() {
return 0;
}
@Override
public DBPDataKind getDataKind() {
return DBPDataKind.OBJECT;
}
@Override
public Integer getScale() {
return null;
}
@Override
public Integer getPrecision() {
return null;
}
@Override
public long getMaxLength() {
return 0;
}
}
\ No newline at end of file
...@@ -44,6 +44,7 @@ import org.jkiss.dbeaver.model.exec.DBCException; ...@@ -44,6 +44,7 @@ import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext; import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose; import org.jkiss.dbeaver.model.exec.DBCExecutionPurpose;
import org.jkiss.dbeaver.model.exec.DBCSession; import org.jkiss.dbeaver.model.exec.DBCSession;
import org.jkiss.dbeaver.model.impl.SimpleTypedObject;
import org.jkiss.dbeaver.model.impl.data.DefaultValueHandler; import org.jkiss.dbeaver.model.impl.data.DefaultValueHandler;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult; import org.jkiss.dbeaver.model.runtime.DBRRunnableWithResult;
...@@ -58,6 +59,7 @@ import org.jkiss.dbeaver.ui.UIUtils; ...@@ -58,6 +59,7 @@ import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.resultset.ResultSetPreferences; import org.jkiss.dbeaver.ui.controls.resultset.ResultSetPreferences;
import org.jkiss.dbeaver.ui.controls.resultset.ThemeConstants; import org.jkiss.dbeaver.ui.controls.resultset.ThemeConstants;
import org.jkiss.dbeaver.ui.data.*; import org.jkiss.dbeaver.ui.data.*;
import org.jkiss.dbeaver.ui.data.managers.DefaultValueManager;
import org.jkiss.dbeaver.ui.data.registry.ValueManagerRegistry; import org.jkiss.dbeaver.ui.data.registry.ValueManagerRegistry;
import org.jkiss.dbeaver.ui.internal.UIMessages; import org.jkiss.dbeaver.ui.internal.UIMessages;
import org.jkiss.utils.ArrayUtils; import org.jkiss.utils.ArrayUtils;
...@@ -438,9 +440,14 @@ public class ComplexObjectEditor extends TreeViewer { ...@@ -438,9 +440,14 @@ public class ComplexObjectEditor extends TreeViewer {
value = arrayItem.value; value = arrayItem.value;
} else if (this.item instanceof MapEntry) { } else if (this.item instanceof MapEntry) {
valueHandler = DefaultValueHandler.INSTANCE; valueHandler = DefaultValueHandler.INSTANCE;
type = null; type = SimpleTypedObject.DEFAULT_TYPE;
name = ((MapEntry) this.item).name; name = ((MapEntry) this.item).name;
value = ((MapEntry) this.item).value; value = ((MapEntry) this.item).value;
} else if (this.item instanceof CollItem) {
valueHandler = DefaultValueHandler.INSTANCE;
type = SimpleTypedObject.DEFAULT_TYPE;
name = String.valueOf(((CollItem) this.item).index);
value = ((CollItem) this.item).value;
} else { } else {
throw new DBCException("Unsupported complex object element: " + this.item); throw new DBCException("Unsupported complex object element: " + this.item);
} }
...@@ -507,7 +514,7 @@ public class ComplexObjectEditor extends TreeViewer { ...@@ -507,7 +514,7 @@ public class ComplexObjectEditor extends TreeViewer {
public IValueManager getValueManager() { public IValueManager getValueManager() {
DBSTypedObject valueType = getValueType(); DBSTypedObject valueType = getValueType();
if (valueType == null) { if (valueType == null) {
return null; return DefaultValueManager.INSTANCE;
} }
return ValueManagerRegistry.findValueManager( return ValueManagerRegistry.findValueManager(
getExecutionContext().getDataSource(), getExecutionContext().getDataSource(),
......
...@@ -52,7 +52,7 @@ public class StringValueManager extends ContentValueManager { ...@@ -52,7 +52,7 @@ public class StringValueManager extends ContentValueManager {
case INLINE: case INLINE:
// Open inline/panel editor // Open inline/panel editor
Object value = controller.getValue(); Object value = controller.getValue();
if (dataKind == DBPDataKind.STRING || dataKind == DBPDataKind.NUMERIC || dataKind == DBPDataKind.DATETIME || dataKind == DBPDataKind.BOOLEAN) { if (dataKind == DBPDataKind.STRING || dataKind == DBPDataKind.NUMERIC || dataKind == DBPDataKind.DATETIME || dataKind == DBPDataKind.BOOLEAN || dataKind == DBPDataKind.OBJECT) {
return new StringInlineEditor(controller); return new StringInlineEditor(controller);
} else if (value instanceof DBDContentCached && } else if (value instanceof DBDContentCached &&
ContentUtils.isTextValue(((DBDContentCached) value).getCachedValue())) ContentUtils.isTextValue(((DBDContentCached) value).getCachedValue()))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册