提交 37dd0763 编写于 作者: J jurgen

Properties model refactoring

Former-commit-id: a31a71be
上级 22b4970d
......@@ -15,19 +15,31 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.jkiss.dbeaver.ui.properties;
import org.eclipse.ui.views.properties.IPropertySource2;
package org.jkiss.dbeaver.model;
/**
* Property source which supports default property values
* Property source
*/
public interface IPropertySourceEx extends IPropertySource2 {
public interface DBPPropertySource {
public Object getEditableValue();
public DBPPropertyDescriptor[] getPropertyDescriptors2();
public Object getPropertyValue(Object id);
public boolean isPropertySet(Object id);
boolean isPropertyResettable(Object id);
public void resetPropertyValue(Object id);
void resetPropertyValueToDefault(Object id);
public void setPropertyValue(Object id, Object value);
boolean isDirty(Object id);
boolean hasDefaultValue(Object id);
void resetPropertyValueToDefault(Object id);
}
......@@ -26,6 +26,8 @@ import org.eclipse.ui.views.properties.IPropertySource;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPContextProvider;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSObject;
......@@ -43,7 +45,7 @@ import java.util.*;
/**
* PropertyCollector
*/
public abstract class PropertySourceAbstract implements IPropertySourceMulti
public abstract class PropertySourceAbstract implements DBPPropertySource, IPropertySourceMulti
{
static final Log log = Log.getLog(PropertySourceAbstract.class);
......@@ -102,6 +104,11 @@ public abstract class PropertySourceAbstract implements IPropertySourceMulti
return props.isEmpty();
}
@Override
public boolean isDirty(Object id) {
return false;
}
public Object getSourceObject()
{
return sourceObject;
......@@ -119,6 +126,10 @@ public abstract class PropertySourceAbstract implements IPropertySourceMulti
return props.toArray(new IPropertyDescriptor[props.size()]);
}
@Override
public DBPPropertyDescriptor[] getPropertyDescriptors2() {
return props.toArray(new DBPPropertyDescriptor[props.size()]);
}
/*
public IPropertyDescriptor getPropertyDescriptor(final Object id)
{
......@@ -252,6 +263,16 @@ public abstract class PropertySourceAbstract implements IPropertySourceMulti
throw new UnsupportedOperationException("Cannot reset property in non-editable property source");
}
@Override
public void resetPropertyValueToDefault(Object id) {
throw new UnsupportedOperationException("Cannot reset property in non-editable property source");
}
@Override
public boolean hasDefaultValue(Object id) {
return false;
}
@Override
public final void setPropertyValue(Object id, Object value)
{
......
......@@ -18,7 +18,10 @@
package org.jkiss.dbeaver.ui.properties;
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.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.utils.CommonUtils;
......@@ -27,7 +30,7 @@ import java.util.*;
/**
* Simple property source which store properties in map
*/
public class PropertySourceCustom implements IPropertySourceEx {
public class PropertySourceCustom implements DBPPropertySource, IPropertySource2 {
private List<DBPPropertyDescriptor> props = new ArrayList<DBPPropertyDescriptor>();
......@@ -99,6 +102,11 @@ public class PropertySourceCustom implements IPropertySourceEx {
return this;
}
@Override
public DBPPropertyDescriptor[] getPropertyDescriptors2() {
return props.toArray(new DBPPropertyDescriptor[props.size()]);
}
@Override
public IPropertyDescriptor[] getPropertyDescriptors()
{
......
......@@ -35,6 +35,7 @@ import org.eclipse.ui.views.properties.IPropertySource2;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.model.DBPObject;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
......@@ -276,8 +277,8 @@ public class PropertyTreeViewer extends TreeViewer {
{
if (node instanceof TreeNode) {
TreeNode treeNode = (TreeNode) node;
if (treeNode.propertySource instanceof IPropertySourceEx) {
((IPropertySourceEx) treeNode.propertySource).resetPropertyValueToDefault(treeNode.property.getId());
if (treeNode.propertySource instanceof DBPPropertySource) {
((DBPPropertySource) treeNode.propertySource).resetPropertyValueToDefault(treeNode.property.getId());
} else {
treeNode.propertySource.resetPropertyValue(treeNode.property.getId());
}
......@@ -489,7 +490,7 @@ public class PropertyTreeViewer extends TreeViewer {
} else {
manager.add(new ActionResetProperty(prop, false));
if (!isCustomProperty(prop.property) &&
prop.propertySource instanceof IPropertySourceEx) {
prop.propertySource instanceof DBPPropertySource) {
manager.add(new ActionResetProperty(prop, true));
}
}
......@@ -805,8 +806,8 @@ public class PropertyTreeViewer extends TreeViewer {
@Override
public void run()
{
if (toDefault && prop.propertySource instanceof IPropertySourceEx) {
((IPropertySourceEx) prop.propertySource).resetPropertyValueToDefault(prop.property.getId());
if (toDefault && prop.propertySource instanceof DBPPropertySource) {
((DBPPropertySource) prop.propertySource).resetPropertyValueToDefault(prop.property.getId());
} else {
prop.propertySource.resetPropertyValue(prop.property.getId());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册