提交 48e35f2c 编写于 作者: S serge-rider

Handlers configurator model model/ui refactoring

上级 66b8b587
......@@ -23,6 +23,7 @@ extension-point.org.jkiss.dbeaver.tools.name = Tools
extension-point.org.jkiss.dbeaver.product.bundles.name = Product bundles
extension-point.org.jkiss.dbeaver.workbenchHandler.name = Workbench handlers
extension-point.org.jkiss.dbeaver.language.name = Language
extension-point.org.jkiss.dbeaver.ui.propertyConfigurator.name = UI property configurator
content-type.org.jkiss.dbeaver.sql.name = SQL Script
content-type.org.jkiss.dbeaver.bookmark.name = Bookmark
......
......@@ -40,6 +40,7 @@
<extension-point id="org.jkiss.dbeaver.product.bundles" name="%extension-point.org.jkiss.dbeaver.product.bundles.name" schema="schema/org.jkiss.dbeaver.product.bundles.exsd"/>
<extension-point id="org.jkiss.dbeaver.workbenchHandler" name="%extension-point.org.jkiss.dbeaver.workbenchHandler.name" schema="schema/org.jkiss.dbeaver.workbenchHandler.exsd"/>
<extension-point id="org.jkiss.dbeaver.language" name="%extension-point.org.jkiss.dbeaver.language.name" schema="schema/org.jkiss.dbeaver.language.exsd"/>
<extension-point id="org.jkiss.dbeaver.ui.propertyConfigurator" name="%extension-point.org.jkiss.dbeaver.ui.propertyConfigurator.name" schema="schema/org.jkiss.dbeaver.ui.propertyConfigurator.exsd"/>
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type
......@@ -3582,26 +3583,21 @@
label="%handler.ssh_tunnel.label"
description="%handler.ssh_tunnel.description"
secured="true"
uiClass="org.jkiss.dbeaver.ui.dialogs.net.SSHTunnelConfiguratorUI"
handlerClass="org.jkiss.dbeaver.model.impl.net.SSHTunnelImpl"/>
<!--handler
type="tunnel"
id="http_tunnel"
label="HTTP Tunnel"
description="HTTP(S) tunnel"
secured="true"
uiClass="org.jkiss.dbeaver.ui.dialogs.net.HTTPTunnelConfiguratorUI"
handlerClass="org.jkiss.dbeaver.model.impl.net.HTTPTunnelImpl"/-->
<handler
type="proxy"
id="socks_proxy"
label="%handler.socks_proxy.label"
description="%handler.socks_proxy.description"
secured="true"
uiClass="org.jkiss.dbeaver.ui.dialogs.net.SocksProxyConfiguratorUI"
handlerClass="org.jkiss.dbeaver.model.impl.net.SocksProxyImpl"/>
</extension>
<extension point="org.jkiss.dbeaver.ui.propertyConfigurator">
<propertyConfigurator class="org.jkiss.dbeaver.model.impl.net.SSHTunnelImpl" uiClass="org.jkiss.dbeaver.ui.dialogs.net.SSHTunnelConfiguratorUI"/>
<propertyConfigurator class="org.jkiss.dbeaver.model.impl.net.SocksProxyImpl" uiClass="org.jkiss.dbeaver.ui.dialogs.net.SocksProxyConfiguratorUI"/>
</extension>
<extension point="org.jkiss.dbeaver.resultset.presentation">
<presentation
id="spreadsheet"
......
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.jkiss.dbeaver.core" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appInfo>
<meta.schema plugin="org.jkiss.dbeaver.core" id="org.jkiss.dbeaver.networkHandler" name="Network Handlers"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appInfo>
<meta.element />
</appInfo>
</annotation>
<complexType>
<sequence>
<element ref="propertyConfigurator" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
<element name="handler">
<complexType>
<attribute name="class" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="uiClass" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn=":org.jkiss.dbeaver.ui.IObjectPropertyConfigurator"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiinfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.registry.configurator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.registry.AbstractContextDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.ui.IObjectPropertyConfigurator;
/**
* UIPropertyConfiguratorDescriptor
*/
public class UIPropertyConfiguratorDescriptor extends AbstractContextDescriptor
{
public static final String EXTENSION_ID = "org.jkiss.dbeaver.ui.propertyConfigurator"; //$NON-NLS-1$
private final String objectType;
private final ObjectType uiConfigType;
public UIPropertyConfiguratorDescriptor(
IConfigurationElement config)
{
super(config);
this.objectType = config.getAttribute(RegistryConstants.ATTR_CLASS);
this.uiConfigType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_UI_CLASS));
}
public String getObjectType() {
return objectType;
}
@SuppressWarnings("unchecked")
public IObjectPropertyConfigurator<DBWHandlerConfiguration> createConfigurator()
throws DBException
{
return uiConfigType.createInstance(IObjectPropertyConfigurator.class);
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.registry.configurator;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import java.util.HashMap;
import java.util.Map;
public class UIPropertyConfiguratorRegistry
{
private static UIPropertyConfiguratorRegistry instance = null;
public synchronized static UIPropertyConfiguratorRegistry getInstance()
{
if (instance == null) {
instance = new UIPropertyConfiguratorRegistry(Platform.getExtensionRegistry());
}
return instance;
}
private final Map<String, UIPropertyConfiguratorDescriptor> descriptors = new HashMap<>();
private UIPropertyConfiguratorRegistry(IExtensionRegistry registry)
{
// Load data descriptors from external plugins
{
IConfigurationElement[] extElements = registry.getConfigurationElementsFor(UIPropertyConfiguratorDescriptor.EXTENSION_ID);
for (IConfigurationElement ext : extElements) {
UIPropertyConfiguratorDescriptor descriptor = new UIPropertyConfiguratorDescriptor(ext);
descriptors.put(descriptor.getObjectType(), descriptor);
}
}
}
public UIPropertyConfiguratorDescriptor getDescriptor(Object object)
{
return descriptors.get(object.getClass().getName());
}
public UIPropertyConfiguratorDescriptor getDescriptor(String className)
{
return descriptors.get(className);
}
}
......@@ -20,13 +20,11 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBPDataSourceProvider;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.model.net.DBWHandlerDescriptor;
import org.jkiss.dbeaver.model.net.DBWHandlerType;
import org.jkiss.dbeaver.model.net.DBWNetworkHandler;
import org.jkiss.dbeaver.registry.AbstractContextDescriptor;
import org.jkiss.dbeaver.registry.RegistryConstants;
import org.jkiss.dbeaver.ui.IObjectPropertyConfigurator;
import org.jkiss.utils.CommonUtils;
import java.util.Locale;
......@@ -44,7 +42,6 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
private DBWHandlerType type;
private final boolean secured;
private final ObjectType handlerType;
private final ObjectType uiConfigType;
public NetworkHandlerDescriptor(
IConfigurationElement config)
......@@ -57,7 +54,6 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
this.type = DBWHandlerType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE).toUpperCase(Locale.ENGLISH));
this.secured = CommonUtils.getBoolean(config.getAttribute(RegistryConstants.ATTR_SECURED), false);
this.handlerType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_HANDLER_CLASS));
this.uiConfigType = new ObjectType(config.getAttribute(RegistryConstants.ATTR_UI_CLASS));
}
@NotNull
......@@ -91,17 +87,14 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
return appliesTo(provider);
}
public <T extends DBWNetworkHandler> T createHandler(Class<T> impl)
throws DBException
{
return handlerType.createInstance(impl);
public ObjectType getHandlerType() {
return handlerType;
}
@SuppressWarnings("unchecked")
public IObjectPropertyConfigurator<DBWHandlerConfiguration> createConfigurator()
public <T extends DBWNetworkHandler> T createHandler(Class<T> impl)
throws DBException
{
return uiConfigType.createInstance(IObjectPropertyConfigurator.class);
return handlerType.createInstance(impl);
}
}
......@@ -32,6 +32,8 @@ import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorDescriptor;
import org.jkiss.dbeaver.registry.configurator.UIPropertyConfiguratorRegistry;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor;
import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry;
......@@ -95,7 +97,12 @@ public class ConnectionPageNetwork extends ActiveWizardPage<ConnectionWizard> {
{
IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
try {
configurator = descriptor.createConfigurator();
String implName = descriptor.getHandlerType().getImplName();
UIPropertyConfiguratorDescriptor configDescriptor = UIPropertyConfiguratorRegistry.getInstance().getDescriptor(implName);
if (configDescriptor == null) {
return;
}
configurator = configDescriptor.createConfigurator();
} catch (DBException e) {
log.error("Can't create network configurator '" + descriptor.getId() + "'", e);
return;
......
......@@ -375,12 +375,15 @@
label="SSL"
description="Secure socket layer"
secured="false"
uiClass="org.jkiss.dbeaver.ext.mysql.views.MySQLSSLConfigurator"
handlerClass="org.jkiss.dbeaver.model.impl.net.SSLHandlerImpl">
handlerClass="org.jkiss.dbeaver.ext.mysql.model.net.MySQLSSLHandlerImpl">
<objectType name="org.jkiss.dbeaver.ext.mysql.MySQLDataSourceProvider"/>
</handler>
</extension>
<extension point="org.jkiss.dbeaver.ui.propertyConfigurator">
<propertyConfigurator class="org.jkiss.dbeaver.ext.mysql.model.net.MySQLSSLHandlerImpl" uiClass="org.jkiss.dbeaver.ext.mysql.views.MySQLSSLConfigurator"/>
</extension>
<extension point="org.jkiss.dbeaver.sqlCommand">
<command id="mysql.source" class="org.jkiss.dbeaver.runtime.sql.commands.SQLCommandInclude" label="Include" description="Include another MySQL script file"/>
</extension>
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.ext.mysql.model.net;
import org.jkiss.dbeaver.model.impl.net.SSLHandlerImpl;
/**
* SSL Handler
*/
public class MySQLSSLHandlerImpl extends SSLHandlerImpl {
}
......@@ -368,12 +368,15 @@
label="%handler.ssl.name"
description="%handler.ssl.description"
secured="false"
uiClass="org.jkiss.dbeaver.ext.postgresql.ui.PostgreSSLConfigurator"
handlerClass="org.jkiss.dbeaver.model.impl.net.SSLHandlerImpl">
handlerClass="org.jkiss.dbeaver.ext.postgresql.model.net.PostgreSSLHandlerImpl">
<objectType name="org.jkiss.dbeaver.ext.postgresql.PostgreDataSourceProvider"/>
</handler>
</extension>
<extension point="org.jkiss.dbeaver.ui.propertyConfigurator">
<propertyConfigurator class="org.jkiss.dbeaver.ext.postgresql.model.net.PostgreSSLHandlerImpl" uiClass="org.jkiss.dbeaver.ext.postgresql.ui.PostgreSSLConfigurator"/>
</extension>
<extension point="org.jkiss.dbeaver.tools">
<tools>
<toolGroup
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 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.ext.postgresql.model.net;
import org.jkiss.dbeaver.model.impl.net.SSLHandlerImpl;
/**
* SSL Handler
*/
public class PostgreSSLHandlerImpl extends SSLHandlerImpl {
}
......@@ -16,7 +16,6 @@
*/
package org.jkiss.dbeaver.model.impl.net;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.app.DBPPlatform;
......
......@@ -31,17 +31,4 @@ public class SSLHandlerImpl implements DBWNetworkHandler, DBWConfigProvider {
public void invalidateHandler(DBRProgressMonitor monitor) throws DBException, IOException {
}
/*
@Override
public boolean isApplicable(DBPDataSourceContainer dataSource) {
try {
final DBPDataSourceProvider dsProvider = dataSource.getDriver().getDataSourceProvider();
return dsProvider instanceof DBPDataSourceConfigurator && ((DBPDataSourceConfigurator) dsProvider).supportsExtraConnectionProperties();
} catch (DBException e) {
return false;
}
}
*/
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册