提交 779aa4e8 编写于 作者: J jurgen

Misc model refactorings

上级 81629fb6
......@@ -37,6 +37,7 @@ Export-Package: org.jkiss.dbeaver,
org.jkiss.dbeaver.model.navigator,
org.jkiss.dbeaver.model.net,
org.jkiss.dbeaver.model.project,
org.jkiss.dbeaver.model.properties,
org.jkiss.dbeaver.model.qm,
org.jkiss.dbeaver.model.qm.meta,
org.jkiss.dbeaver.model.runtime,
......
......@@ -24,14 +24,13 @@ import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPApplication;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.impl.net.GlobalProxyAuthenticator;
import org.jkiss.dbeaver.model.impl.net.GlobalProxySelector;
import org.jkiss.dbeaver.runtime.net.GlobalProxyAuthenticator;
import org.jkiss.dbeaver.runtime.net.GlobalProxySelector;
import org.jkiss.dbeaver.model.navigator.DBNModel;
import org.jkiss.dbeaver.model.qm.QMController;
import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
import org.jkiss.dbeaver.registry.OSDescriptor;
import org.jkiss.dbeaver.registry.ProjectRegistry;
import org.jkiss.dbeaver.runtime.preferences.BundlePreferenceStore;
import org.jkiss.dbeaver.runtime.qm.QMControllerImpl;
import org.jkiss.dbeaver.runtime.qm.QMLogFileWriter;
import org.osgi.framework.Bundle;
......
......@@ -18,13 +18,17 @@
package org.jkiss.dbeaver.model;
import org.eclipse.core.runtime.FileLocator;
import org.jkiss.dbeaver.DBeaverConstants;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
......@@ -262,12 +266,17 @@ public class DBIcon implements DBPImage
}
try {
DBIcon icon = (DBIcon) field.get(null);
File file = RuntimeUtils.getPlatformFile(icon.getLocation());
if (!file.exists()) {
log.warn("Bad image '" + icon.getToken() + "' location: " + icon.getLocation());
continue;
URL fileURL = FileLocator.toFileURL(new URL(icon.getLocation()));
try {
File file = new File(new URI(fileURL.toString()));
if (!file.exists()) {
log.warn("Bad image '" + icon.getToken() + "' location: " + icon.getLocation());
continue;
}
DBIcon.iconMap.put(icon.getToken(), icon);
} catch (URISyntaxException e) {
throw new IOException("Bad local file path: " + fileURL, e);
}
DBIcon.iconMap.put(icon.getToken(), icon);
} catch (Exception e) {
log.error(e);
}
......
......@@ -23,7 +23,7 @@ import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
......@@ -89,7 +89,7 @@ public abstract class JDBCDataSourceProvider implements DBPDataSourceProvider {
continue;
}
desc.value = getConnectionPropertyDefaultValue(desc.name, desc.value);
properties.add(new PropertyDescriptorEx(
properties.add(new PropertyDescriptor(
CoreMessages.model_jdbc_driver_properties,
desc.name,
desc.name,
......
......@@ -21,7 +21,7 @@ package org.jkiss.dbeaver.registry;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.model.data.DBDDataFormatter;
import org.jkiss.dbeaver.model.data.DBDDataFormatterSample;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import java.util.ArrayList;
import java.util.List;
......@@ -36,7 +36,7 @@ public class DataFormatterDescriptor extends AbstractDescriptor
private String id;
private String name;
private String description;
private List<PropertyDescriptorEx> properties = new ArrayList<PropertyDescriptorEx>();
private List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
private DBDDataFormatterSample sample;
private ObjectType formatterType;
......@@ -49,9 +49,9 @@ public class DataFormatterDescriptor extends AbstractDescriptor
this.name = config.getAttribute(RegistryConstants.ATTR_LABEL);
this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptorEx.TAG_PROPERTY_GROUP);
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP);
for (IConfigurationElement prop : propElements) {
properties.addAll(PropertyDescriptorEx.extractProperties(prop));
properties.addAll(PropertyDescriptor.extractProperties(prop));
}
Class<?> objectClass = getObjectClass(config.getAttribute(RegistryConstants.ATTR_SAMPLE_CLASS));
try {
......@@ -81,7 +81,7 @@ public class DataFormatterDescriptor extends AbstractDescriptor
return sample;
}
public List<PropertyDescriptorEx> getProperties() {
public List<PropertyDescriptor> getProperties() {
return properties;
}
......
......@@ -18,11 +18,11 @@
package org.jkiss.dbeaver.registry;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.data.DBDDataFormatter;
import org.jkiss.dbeaver.model.data.DBDDataFormatterProfile;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.runtime.preferences.SimplePreferenceStore;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.utils.CommonUtils;
import java.io.IOException;
......@@ -73,7 +73,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile {
for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
Map<Object, Object> defaultProperties = formatter.getSample().getDefaultProperties(locale);
Map<Object, Object> formatterProps = new HashMap<Object, Object>();
for (PropertyDescriptorEx prop : formatter.getProperties()) {
for (DBPPropertyDescriptor prop : formatter.getProperties()) {
Object defaultValue = defaultProperties.get(prop.getId());
Object propValue = RuntimeUtils.getPreferenceValue(
store,
......@@ -95,7 +95,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile {
for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
Map<Object, Object> formatterProps = properties.get(formatter.getId());
for (PropertyDescriptorEx prop : formatter.getProperties()) {
for (DBPPropertyDescriptor prop : formatter.getProperties()) {
Object propValue = formatterProps == null ? null : formatterProps.get(prop.getId());
if (propValue != null) {
RuntimeUtils.setPreferenceValue(store, DATAFORMAT_TYPE_PREFIX + formatter.getId() + "." + prop.getId(), propValue);
......@@ -160,7 +160,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile {
}
for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
for (PropertyDescriptorEx prop : formatter.getProperties()) {
for (DBPPropertyDescriptor prop : formatter.getProperties()) {
if (prefStore.isSet(DATAFORMAT_TYPE_PREFIX + formatter.getId() + "." + prop.getId())) {
return true;
}
......@@ -182,7 +182,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile {
store.setToDefault(PROP_VARIANT);
for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
for (PropertyDescriptorEx prop : formatter.getProperties()) {
for (DBPPropertyDescriptor prop : formatter.getProperties()) {
store.setToDefault(DATAFORMAT_TYPE_PREFIX + formatter.getId() + "." + prop.getId());
}
}
......@@ -218,7 +218,7 @@ public class DataFormatterProfile implements DBDDataFormatterProfile {
for (DataFormatterDescriptor formatter : DataFormatterRegistry.getInstance().getDataFormatters()) {
Map<Object, Object> defaultProperties = formatter.getSample().getDefaultProperties(locale);
Map<Object, Object> formatterProps = new HashMap<Object, Object>();
for (PropertyDescriptorEx prop : formatter.getProperties()) {
for (DBPPropertyDescriptor prop : formatter.getProperties()) {
Object defaultValue = defaultProperties.get(prop.getId());
if (defaultValue != null) {
RuntimeUtils.setPreferenceDefaultValue(store, DATAFORMAT_TYPE_PREFIX + formatter.getId() + "." + prop.getId(), defaultValue);
......
......@@ -32,7 +32,7 @@ import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.registry.tree.*;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.ui.NavigatorUtils;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.utils.ArrayUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.SecurityUtils;
......@@ -87,8 +87,8 @@ public class DataSourceProviderDescriptor extends AbstractDescriptor
// Load driver properties
{
for (IConfigurationElement propsElement : config.getChildren(RegistryConstants.TAG_DRIVER_PROPERTIES)) {
for (IConfigurationElement prop : propsElement.getChildren(PropertyDescriptorEx.TAG_PROPERTY_GROUP)) {
driverProperties.addAll(PropertyDescriptorEx.extractProperties(prop));
for (IConfigurationElement prop : propsElement.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP)) {
driverProperties.addAll(PropertyDescriptor.extractProperties(prop));
}
}
}
......
......@@ -38,10 +38,10 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.AcceptLicenseDialog;
import org.jkiss.dbeaver.ui.dialogs.ConfirmationDialog;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.utils.ContentUtils;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.SAXListener;
......@@ -189,9 +189,9 @@ public class DriverDescriptor extends AbstractDescriptor implements DBPDriver
{
// Connection property groups
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptorEx.TAG_PROPERTY_GROUP);
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP);
for (IConfigurationElement prop : propElements) {
connectionPropertyDescriptors.addAll(PropertyDescriptorEx.extractProperties(prop));
connectionPropertyDescriptors.addAll(PropertyDescriptor.extractProperties(prop));
}
}
......
......@@ -24,8 +24,8 @@ import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.registry.AbstractDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.dbeaver.tools.transfer.IDataTransferProcessor;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.utils.ArrayUtils;
import java.util.ArrayList;
......@@ -59,8 +59,8 @@ public class DataTransferProcessorDescriptor extends AbstractDescriptor
sourceTypes.add(new ObjectType(typeCfg.getAttribute(RegistryConstants.ATTR_TYPE)));
}
for (IConfigurationElement prop : ArrayUtils.safeArray(config.getChildren(PropertyDescriptorEx.TAG_PROPERTY_GROUP))) {
properties.addAll(PropertyDescriptorEx.extractProperties(prop));
for (IConfigurationElement prop : ArrayUtils.safeArray(config.getChildren(PropertyDescriptor.TAG_PROPERTY_GROUP))) {
properties.addAll(PropertyDescriptor.extractProperties(prop));
}
}
......
......@@ -15,7 +15,7 @@
* 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.model.impl.net;
package org.jkiss.dbeaver.runtime.net;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBeaverPreferences;
......@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.access.DBAAuthInfo;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.impl.net.SocksConstants;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.net.DBWHandlerType;
import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer;
......
......@@ -15,10 +15,11 @@
* 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.model.impl.net;
package org.jkiss.dbeaver.runtime.net;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.impl.net.SocksConstants;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.net.DBWHandlerType;
import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer;
......
......@@ -31,12 +31,12 @@ import java.util.ArrayList;
import java.util.List;
/**
* PropertyDescriptorEx
* PropertyDescriptor
*/
public class PropertyDescriptorEx implements DBPPropertyDescriptor, IPropertyValueListProvider<Object>
public class PropertyDescriptor implements DBPPropertyDescriptor, IPropertyValueListProvider<Object>
{
static final Log log = Log.getLog(PropertyDescriptorEx.class);
static final Log log = Log.getLog(PropertyDescriptor.class);
public static final String TAG_PROPERTY_GROUP = "propertyGroup"; //NON-NLS-1
public static final String NAME_UNDEFINED = "<undefined>"; //NON-NLS-1
......@@ -60,21 +60,21 @@ public class PropertyDescriptorEx implements DBPPropertyDescriptor, IPropertyVal
private Object[] validValues;
private boolean editable;
public static List<PropertyDescriptorEx> extractProperties(IConfigurationElement config)
public static List<PropertyDescriptor> extractProperties(IConfigurationElement config)
{
String category = config.getAttribute(ATTR_LABEL);
if (CommonUtils.isEmpty(category)) {
category = NAME_UNDEFINED;
}
List<PropertyDescriptorEx> properties = new ArrayList<PropertyDescriptorEx>();
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptorEx.TAG_PROPERTY);
List<PropertyDescriptor> properties = new ArrayList<PropertyDescriptor>();
IConfigurationElement[] propElements = config.getChildren(PropertyDescriptor.TAG_PROPERTY);
for (IConfigurationElement prop : propElements) {
properties.add(new PropertyDescriptorEx(category, prop));
properties.add(new PropertyDescriptor(category, prop));
}
return properties;
}
public PropertyDescriptorEx(String category, IConfigurationElement config)
public PropertyDescriptor(String category, IConfigurationElement config)
{
this.category = category;
this.id = config.getAttribute(ATTR_ID);
......@@ -105,7 +105,7 @@ public class PropertyDescriptorEx implements DBPPropertyDescriptor, IPropertyVal
this.editable = true;
}
public PropertyDescriptorEx(String category, Object id, String name, String description, Class<?> type, boolean required, String defaultValue, String[] validValues, boolean editable) {
public PropertyDescriptor(String category, Object id, String name, String description, Class<?> type, boolean required, String defaultValue, String[] validValues, boolean editable) {
this.category = category;
this.id = id;
this.name = name;
......
......@@ -76,7 +76,7 @@ public abstract class PropertySourceAbstract implements DBPPropertyManager, IPro
public void addProperty(@Nullable String category, Object id, String name, Object value)
{
props.add(new PropertyDescriptorEx(category, id, name, null, value == null ? null : value.getClass(), false, null, null, false));
props.add(new PropertyDescriptor(category, id, name, null, value == null ? null : value.getClass(), false, null, null, false));
propValues.put(id, value);
}
......
......@@ -30,7 +30,7 @@ import org.jkiss.dbeaver.model.DBPDriver;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableContext;
import org.jkiss.dbeaver.ui.dialogs.EnterNameDialog;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.utils.CommonUtils;
......@@ -116,7 +116,7 @@ public class ConnectionPropertiesControl extends PropertyTreeViewer {
String propName = EnterNameDialog.chooseName(getControl().getShell(), CoreMessages.controls_connection_properties_dialog_new_property_title);
if (propName != null) {
// Check property name (must be unique
addProperty(node, new PropertyDescriptorEx(category, propName, propName, null, null, false, null, null, true));
addProperty(node, new PropertyDescriptor(category, propName, propName, null, null, false, null, null, true));
}
}
......@@ -163,7 +163,7 @@ public class ConnectionPropertiesControl extends PropertyTreeViewer {
continue;
}
if (!propNames.contains(propName)) {
customProperties.add(new PropertyDescriptorEx(
customProperties.add(new PropertyDescriptor(
USER_PROPERTIES_CATEGORY,
propName,
propName,
......
......@@ -21,7 +21,7 @@ import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.model.exec.plan.DBCPlanNode;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.XMLUtils;
import org.w3c.dom.Element;
......@@ -122,7 +122,7 @@ public class PostgrePlanNode implements DBCPlanNode, DBPPropertySource {
DBPPropertyDescriptor[] props = new DBPPropertyDescriptor[attributes.size()];
int index = 0;
for (Map.Entry<String, String> attr : attributes.entrySet()) {
props[index++] = new PropertyDescriptorEx("Source", attr.getKey(), attr.getKey(), null, String.class, false, null, null, false);
props[index++] = new PropertyDescriptor("Source", attr.getKey(), attr.getKey(), null, String.class, false, null, null, false);
}
return props;
}
......
......@@ -21,7 +21,7 @@ import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPPropertyDescriptor;
import org.jkiss.dbeaver.model.DBPPropertySource;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptorEx;
import org.jkiss.dbeaver.runtime.properties.PropertyDescriptor;
import org.jkiss.wmi.service.WMIException;
import org.jkiss.wmi.service.WMIQualifiedObject;
import org.jkiss.wmi.service.WMIQualifier;
......@@ -68,7 +68,7 @@ public abstract class WMIPropertySource implements DBPPropertySource
int index = 0;
for (WMIQualifier qualifier : qualifiers) {
String name = qualifier.getName();
PropertyDescriptorEx prop = new PropertyDescriptorEx("WMI", name, name, null, null, false, null, null, false);
PropertyDescriptor prop = new PropertyDescriptor("WMI", name, name, null, null, false, null, null, false);
result[index++] = prop;
}
return result;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册