提交 56379d5d 编写于 作者: J jurgen

Properties model refactoring

上级 fc672250
......@@ -99,8 +99,6 @@ public @interface Property
Class<? extends IPropertyValueTransformer> valueTransformer() default IPropertyValueTransformer.class;
Class<? extends IPropertyValueEditorProvider> valueEditor() default IPropertyValueEditorProvider.class;
Class<? extends IPropertyValueListProvider> listProvider() default IPropertyValueListProvider.class;
}
......@@ -24,6 +24,7 @@ import org.eclipse.jface.commands.ActionHandler;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.SWT;
......@@ -53,15 +54,24 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.DBeaverConstants;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.*;
import org.jkiss.dbeaver.model.DBPNamedObject;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.runtime.RunnableWithResult;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.controls.CustomCheckboxCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomComboBoxCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomNumberCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomTextCellEditor;
import org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog;
import org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog;
import org.jkiss.dbeaver.ui.editors.text.BaseTextEditor;
import org.jkiss.dbeaver.ui.properties.IPropertyValueListProvider;
import org.jkiss.dbeaver.utils.GeneralUtils;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.BeanUtils;
import org.jkiss.utils.CommonUtils;
import java.lang.reflect.InvocationTargetException;
......@@ -1221,6 +1231,60 @@ public class UIUtils {
return saveRunner.getResult();
}
public static CellEditor createPropertyEditor(Composite parent, DBPPropertySource source, DBPPropertyDescriptor property)
{
if (source == null) {
return null;
}
final Object object = source.getEditableValue();
if (!property.isEditable(object)) {
return null;
}
return UIUtils.createCellEditor(parent, object, property);
}
public static CellEditor createCellEditor(Composite parent, Object object, DBPPropertyDescriptor property)
{
// List
if (property instanceof IPropertyValueListProvider) {
final IPropertyValueListProvider listProvider = (IPropertyValueListProvider) property;
final Object[] items = listProvider.getPossibleValues(object);
if (!ArrayUtils.isEmpty(items)) {
final String[] strings = new String[items.length];
for (int i = 0, itemsLength = items.length; i < itemsLength; i++) {
strings[i] = items[i] instanceof DBPNamedObject ? ((DBPNamedObject)items[i]).getName() : CommonUtils.toString(items[i]);
}
final CustomComboBoxCellEditor editor = new CustomComboBoxCellEditor(
parent,
strings,
SWT.DROP_DOWN | (listProvider.allowCustomValue() ? SWT.NONE : SWT.READ_ONLY));
return editor;
}
}
Class<?> propertyType = property.getDataType();
if (propertyType == null || CharSequence.class.isAssignableFrom(propertyType)) {
return new CustomTextCellEditor(parent);
} else if (BeanUtils.isNumericType(propertyType)) {
return new CustomNumberCellEditor(parent, propertyType);
} else if (BeanUtils.isBooleanType(propertyType)) {
return new CustomCheckboxCellEditor(parent);
//return new CheckboxCellEditor(parent);
} else if (propertyType.isEnum()) {
final Object[] enumConstants = propertyType.getEnumConstants();
final String[] strings = new String[enumConstants.length];
for (int i = 0, itemsLength = enumConstants.length; i < itemsLength; i++) {
strings[i] = ((Enum)enumConstants[i]).name();
}
return new CustomComboBoxCellEditor(
parent,
strings,
SWT.DROP_DOWN | SWT.READ_ONLY);
} else {
log.warn("Unsupported property type: " + propertyType.getName());
return null;
}
}
private static class SaveRunner implements Runnable {
private final DBRProgressMonitor monitor;
private final ISaveablePart saveable;
......
......@@ -23,7 +23,6 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBConstants;
......@@ -91,7 +90,7 @@ public class ConnectionPropertiesControl extends PropertyTreeViewer {
}
@Override
protected void contributeContextMenu(IMenuManager manager, final Object node, final String category, final IPropertyDescriptor property)
protected void contributeContextMenu(IMenuManager manager, final Object node, final String category, final DBPPropertyDescriptor property)
{
boolean isCustom = USER_PROPERTIES_CATEGORY.equals(category);
if (isCustom) {
......
......@@ -197,7 +197,7 @@ public class ItemListControl extends NodeListControl
setCurListObject(object);
final ObjectPropertyDescriptor property = getObjectProperty(object, columnIndex);
if (property != null && property.isEditable(getObjectValue(object))) {
return property.createPropertyEditor(getControl());
return UIUtils.createPropertyEditor(getControl(), property.getSource(), property);
}
return null;
}
......
......@@ -22,9 +22,9 @@ import org.eclipse.ui.IMemento;
import org.eclipse.ui.IPersistableElement;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.model.WorkbenchAdapter;
import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.IDataSourceContainerProvider;
import org.jkiss.dbeaver.model.edit.DBECommandContext;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
......@@ -193,7 +193,7 @@ public abstract class DatabaseEditorInput<NODE extends DBNDatabaseNode> implemen
}
@Override
public IPropertySource2 getPropertySource()
public DBPPropertySource getPropertySource()
{
if (propertySource == null) {
propertySource = new PropertySourceEditable(
......
......@@ -21,6 +21,7 @@ package org.jkiss.dbeaver.ui.editors;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.dbeaver.model.DBPContextProvider;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.edit.DBECommandContext;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.struct.DBSObject;
......@@ -58,7 +59,7 @@ public interface IDatabaseEditorInput extends IEditorInput, DBPContextProvider {
* Underlying object's property source
* @return property source
*/
IPropertySource2 getPropertySource();
DBPPropertySource getPropertySource();
Collection<String> getAttributeNames();
......
......@@ -26,11 +26,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.dbeaver.model.DBPEvent;
import org.jkiss.dbeaver.model.DBPEventListener;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.folders.FolderPage;
......@@ -47,7 +43,7 @@ public class FolderPageProperties extends FolderPage implements ILazyPropertyLoa
protected PropertyTreeViewer propertyTree;
private Font boldFont;
private UIJob refreshJob = null;
private IPropertySource curPropertySource;
private DBPPropertySource curPropertySource;
public FolderPageProperties(IDatabaseEditorInput input) {
this.input = input;
......
......@@ -18,7 +18,6 @@
package org.jkiss.dbeaver.ui.editors.entity.properties;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.ui.properties.ILazyPropertyLoadListener;
......
......@@ -23,7 +23,6 @@ import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.contentassist.*;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.DBeaverCore;
......@@ -534,7 +533,7 @@ public class SQLCompletionProcessor implements IContentAssistProcessor
StringBuilder info = new StringBuilder();
PropertyCollector collector = new PropertyCollector(object, false);
collector.collectProperties();
for (IPropertyDescriptor descriptor : collector.getPropertyDescriptors()) {
for (DBPPropertyDescriptor descriptor : collector.getPropertyDescriptors2()) {
Object propValue = collector.getPropertyValue(descriptor.getId());
if (propValue == null) {
continue;
......
......@@ -17,9 +17,9 @@
*/
package org.jkiss.dbeaver.ui.properties;
import org.jkiss.dbeaver.core.Log;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.meta.IPropertyCacheValidator;
import org.jkiss.dbeaver.model.meta.LazyProperty;
import org.jkiss.dbeaver.model.meta.Property;
......@@ -41,7 +41,7 @@ public abstract class ObjectAttributeDescriptor {
static final Log log = Log.getLog(ObjectAttributeDescriptor.class);
private final IPropertySource source;
private final DBPPropertySource source;
private ObjectPropertyGroupDescriptor parent;
private int orderNumber;
private String id;
......@@ -51,7 +51,7 @@ public abstract class ObjectAttributeDescriptor {
private Class<?> declaringClass;
public ObjectAttributeDescriptor(
IPropertySource source,
DBPPropertySource source,
ObjectPropertyGroupDescriptor parent,
Method getter,
String id,
......@@ -88,7 +88,7 @@ public abstract class ObjectAttributeDescriptor {
return declaringClass;
}
public IPropertySource getSource()
public DBPPropertySource getSource()
{
return source;
}
......@@ -148,7 +148,7 @@ public abstract class ObjectAttributeDescriptor {
public abstract String getDescription();
public static List<ObjectPropertyDescriptor> extractAnnotations(
IPropertySource source,
DBPPropertySource source,
Class<?> theClass,
IFilter filter)
{
......@@ -157,7 +157,7 @@ public abstract class ObjectAttributeDescriptor {
return annoProps;
}
static void extractAnnotations(IPropertySource source, ObjectPropertyGroupDescriptor parent, Class<?> theClass, List<ObjectPropertyDescriptor> annoProps, IFilter filter)
static void extractAnnotations(DBPPropertySource source, ObjectPropertyGroupDescriptor parent, Class<?> theClass, List<ObjectPropertyDescriptor> annoProps, IFilter filter)
{
Method[] methods = theClass.getMethods();
for (Method method : methods) {
......
......@@ -22,26 +22,19 @@ import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.dbeaver.model.DBPNamedObject;
import org.jkiss.dbeaver.model.DBPPersistedObject;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.meta.IPropertyValueEditorProvider;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.meta.IPropertyValueTransformer;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.ui.controls.CustomCheckboxCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomComboBoxCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomNumberCellEditor;
import org.jkiss.dbeaver.ui.controls.CustomTextCellEditor;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.BeanUtils;
import org.jkiss.utils.CommonUtils;
import org.osgi.framework.Bundle;
......@@ -61,12 +54,11 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
private final String propDescription;
private Method setter;
private ILabelProvider labelProvider;
private IPropertyValueEditorProvider valueEditor;
private IPropertyValueTransformer valueTransformer;
private final Class<?> declaringClass;
public ObjectPropertyDescriptor(
IPropertySource source,
DBPPropertySource source,
ObjectPropertyGroupDescriptor parent,
Property propInfo,
Method getter)
......@@ -99,16 +91,6 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
this.labelProvider = new DefaultLabelProvider();
}
// Obtain value editor
Class<? extends IPropertyValueEditorProvider> valueEditorClass = propInfo.valueEditor();
if (valueEditorClass != null && valueEditorClass != IPropertyValueEditorProvider.class) {
try {
valueEditor = valueEditorClass.newInstance();
} catch (Throwable e) {
log.warn("Can't create value editor", e);
}
}
// Obtain value transformer
Class<? extends IPropertyValueTransformer> valueTransformerClass = propInfo.valueTransformer();
if (valueTransformerClass != null && valueTransformerClass != IPropertyValueTransformer.class) {
......@@ -159,25 +141,13 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
@Override
public CellEditor createPropertyEditor(Composite parent)
{
IPropertySource source = getSource();
if (source == null) {
return null;
}
final Object object = source.getEditableValue();
if (!isEditable(object)) {
return null;
}
if (valueEditor != null) {
return valueEditor.createCellEditor(parent, object, propInfo);
} else {
return createCellEditor(parent, object, this);
}
return UIUtils.createPropertyEditor(parent, getSource(), this);
}
@Override
public boolean isEditable(Object object)
{
final IPropertySource propertySource = getSource();
final DBPPropertySource propertySource = getSource();
if (!(propertySource instanceof IPropertySourceEditable) || !((IPropertySourceEditable) propertySource).isEditable(object)) {
return false;
}
......@@ -331,48 +301,6 @@ public class ObjectPropertyDescriptor extends ObjectAttributeDescriptor implemen
return null;
}
public static CellEditor createCellEditor(Composite parent, Object object, DBPPropertyDescriptor property)
{
// List
if (property instanceof IPropertyValueListProvider) {
final IPropertyValueListProvider listProvider = (IPropertyValueListProvider) property;
final Object[] items = listProvider.getPossibleValues(object);
if (!ArrayUtils.isEmpty(items)) {
final String[] strings = new String[items.length];
for (int i = 0, itemsLength = items.length; i < itemsLength; i++) {
strings[i] = items[i] instanceof DBPNamedObject ? ((DBPNamedObject)items[i]).getName() : CommonUtils.toString(items[i]);
}
final CustomComboBoxCellEditor editor = new CustomComboBoxCellEditor(
parent,
strings,
SWT.DROP_DOWN | (listProvider.allowCustomValue() ? SWT.NONE : SWT.READ_ONLY));
return editor;
}
}
Class<?> propertyType = property.getDataType();
if (propertyType == null || CharSequence.class.isAssignableFrom(propertyType)) {
return new CustomTextCellEditor(parent);
} else if (BeanUtils.isNumericType(propertyType)) {
return new CustomNumberCellEditor(parent, propertyType);
} else if (BeanUtils.isBooleanType(propertyType)) {
return new CustomCheckboxCellEditor(parent);
//return new CheckboxCellEditor(parent);
} else if (propertyType.isEnum()) {
final Object[] enumConstants = propertyType.getEnumConstants();
final String[] strings = new String[enumConstants.length];
for (int i = 0, itemsLength = enumConstants.length; i < itemsLength; i++) {
strings[i] = ((Enum)enumConstants[i]).name();
}
return new CustomComboBoxCellEditor(
parent,
strings,
SWT.DROP_DOWN | SWT.READ_ONLY);
} else {
log.warn("Unsupported property type: " + propertyType.getName());
return null;
}
}
@Override
public int hashCode()
{
......
......@@ -18,7 +18,7 @@
package org.jkiss.dbeaver.ui.properties;
import org.eclipse.jface.viewers.IFilter;
import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.meta.PropertyGroup;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
......@@ -37,7 +37,7 @@ public class ObjectPropertyGroupDescriptor extends ObjectAttributeDescriptor
private List<ObjectPropertyDescriptor> children = new ArrayList<ObjectPropertyDescriptor>();
public ObjectPropertyGroupDescriptor(
IPropertySource source,
DBPPropertySource source,
ObjectPropertyGroupDescriptor parent,
Method getter,
PropertyGroup groupInfo,
......
......@@ -27,6 +27,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
......@@ -126,7 +127,7 @@ public class PropertyDescriptorEx implements DBPPropertyDescriptor, IPropertyDes
if (!editable) {
return null;
}
return ObjectPropertyDescriptor.createCellEditor(parent, null, this);
return UIUtils.createCellEditor(parent, null, this);
}
@Nullable
......
......@@ -22,6 +22,8 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.DBUtils;
import java.util.ArrayList;
......@@ -31,7 +33,7 @@ import java.util.List;
/**
* Simple property source which store properties in map
*/
public class PropertySourceCollection implements IPropertySource {
public class PropertySourceCollection implements DBPPropertySource, IPropertySource {
private List<IPropertyDescriptor> props = new ArrayList<IPropertyDescriptor>();
......@@ -52,6 +54,11 @@ public class PropertySourceCollection implements IPropertySource {
return this;
}
@Override
public DBPPropertyDescriptor[] getPropertyDescriptors2() {
return props.toArray(new DBPPropertyDescriptor[props.size()]);
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors()
{
......@@ -70,18 +77,38 @@ public class PropertySourceCollection implements IPropertySource {
return false;
}
@Override
public boolean isPropertyResettable(Object id) {
return false;
}
@Override
public void resetPropertyValue(Object id)
{
}
@Override
public void resetPropertyValueToDefault(Object id) {
}
@Override
public void setPropertyValue(Object id, Object value)
{
}
private class ItemPropertyDescriptor implements IPropertyDescriptor {
@Override
public boolean isDirty(Object id) {
return false;
}
@Override
public boolean hasDefaultValue(Object id) {
return false;
}
private class ItemPropertyDescriptor implements DBPPropertyDescriptor, IPropertyDescriptor {
private Integer id;
private Object item;
......@@ -105,6 +132,26 @@ public class PropertySourceCollection implements IPropertySource {
return null;
}
@Override
public Class<?> getDataType() {
return Object.class;
}
@Override
public boolean isRequired() {
return false;
}
@Override
public Object getDefaultValue() {
return null;
}
@Override
public boolean isEditable(Object object) {
return false;
}
@Override
public String getDisplayName() {
return DBUtils.getObjectShortName(item);
......
......@@ -29,8 +29,6 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
......@@ -64,7 +62,7 @@ public class PropertyTreeViewer extends TreeViewer {
//private Color colorBlue;
private int selectedColumn = -1;
private CellEditor curCellEditor;
private IPropertyDescriptor selectedProperty;
private DBPPropertyDescriptor selectedProperty;
private String[] customCategories;
private IBaseLabelProvider extraLabelProvider;
......@@ -174,12 +172,12 @@ public class PropertyTreeViewer extends TreeViewer {
};
}
public void loadProperties(IPropertySource propertySource)
public void loadProperties(DBPPropertySource propertySource)
{
loadProperties(null, propertySource);
}
protected void loadProperties(TreeNode parent, IPropertySource propertySource)
protected void loadProperties(TreeNode parent, DBPPropertySource propertySource)
{
// Make tree model
customCategories = getCustomCategories();
......@@ -209,11 +207,11 @@ public class PropertyTreeViewer extends TreeViewer {
UIUtils.packColumns(getTree(), true, new float[]{0.5f, 0.5f});
}
private Map<String, TreeNode> loadTreeNodes(TreeNode parent, IPropertySource propertySource)
private Map<String, TreeNode> loadTreeNodes(TreeNode parent, DBPPropertySource propertySource)
{
Map<String, TreeNode> categories = new LinkedHashMap<String, TreeNode>();
final IPropertyDescriptor[] props = propertySource.getPropertyDescriptors();
for (IPropertyDescriptor prop : props) {
final DBPPropertyDescriptor[] props = propertySource.getPropertyDescriptors2();
for (DBPPropertyDescriptor prop : props) {
String categoryName = prop.getCategory();
if (CommonUtils.isEmpty(categoryName)) {
categoryName = CATEGORY_GENERAL;
......@@ -225,7 +223,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
TreeNode propNode = new TreeNode(category, propertySource, prop);
// Load nested object's properties
if (!(propertySource instanceof IPropertySourceEditable) && prop instanceof DBPPropertyDescriptor) {
if (!(propertySource instanceof IPropertySourceEditable)) {
Class<?> propType = ((DBPPropertyDescriptor) prop).getDataType();
if (propType != null) {
if (DBPObject.class.isAssignableFrom(propType)) {
......@@ -246,7 +244,7 @@ public class PropertyTreeViewer extends TreeViewer {
collection = (Collection<?>) propertyValue;
}
PropertySourceCollection psc = new PropertySourceCollection(collection);
for (IPropertyDescriptor pd : psc.getPropertyDescriptors()) {
for (DBPPropertyDescriptor pd : psc.getPropertyDescriptors2()) {
TreeNode itemNode = new TreeNode(propNode, psc, pd);
}
}
......@@ -262,7 +260,7 @@ public class PropertyTreeViewer extends TreeViewer {
super.setInput(null);
}
protected void addProperty(Object node, IPropertyDescriptor property)
protected void addProperty(Object node, DBPPropertyDescriptor property)
{
if (node instanceof TreeNode) {
TreeNode treeNode = (TreeNode) node;
......@@ -295,7 +293,7 @@ public class PropertyTreeViewer extends TreeViewer {
super.refresh();
}
public IPropertyDescriptor getSelectedProperty()
public DBPPropertyDescriptor getSelectedProperty()
{
return selectedProperty;
}
......@@ -385,7 +383,7 @@ public class PropertyTreeViewer extends TreeViewer {
if (prop.property == null || !prop.isEditable()) {
return;
}
final CellEditor cellEditor = prop.property.createPropertyEditor(treeControl);
final CellEditor cellEditor = UIUtils.createPropertyEditor(treeControl, prop.propertySource, prop.property);
if (cellEditor == null) {
return;
}
......@@ -510,7 +508,7 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
private boolean isCustomProperty(IPropertyDescriptor property)
private boolean isCustomProperty(DBPPropertyDescriptor property)
{
if (customCategories != null) {
for (String category : customCategories) {
......@@ -527,7 +525,7 @@ public class PropertyTreeViewer extends TreeViewer {
return null;
}
protected void contributeContextMenu(IMenuManager manager, Object node, String category, IPropertyDescriptor property)
protected void contributeContextMenu(IMenuManager manager, Object node, String category, DBPPropertyDescriptor property)
{
}
......@@ -584,12 +582,12 @@ public class PropertyTreeViewer extends TreeViewer {
private static class TreeNode {
final TreeNode parent;
final IPropertySource propertySource;
final IPropertyDescriptor property;
final DBPPropertySource propertySource;
final DBPPropertyDescriptor property;
final String category;
final List<TreeNode> children = new ArrayList<TreeNode>();
private TreeNode(TreeNode parent, IPropertySource propertySource, IPropertyDescriptor property, String category)
private TreeNode(TreeNode parent, DBPPropertySource propertySource, DBPPropertyDescriptor property, String category)
{
this.parent = parent;
this.propertySource = propertySource;
......@@ -600,12 +598,12 @@ public class PropertyTreeViewer extends TreeViewer {
}
}
private TreeNode(TreeNode parent, IPropertySource propertySource, IPropertyDescriptor property)
private TreeNode(TreeNode parent, DBPPropertySource propertySource, DBPPropertyDescriptor property)
{
this(parent, propertySource, property, null);
}
private TreeNode(TreeNode parent, IPropertySource propertySource, String category)
private TreeNode(TreeNode parent, DBPPropertySource propertySource, String category)
{
this(parent, propertySource, null, category);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册