提交 923c7e1d 编写于 作者: S serge@jkiss.org

Network handlers UI change (show all one the main page

上级 5100eea4
/*
* 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.ui.dialogs.connection;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.connection.DBPDriver;
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.network.NetworkHandlerDescriptor;
import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry;
import org.jkiss.dbeaver.ui.IObjectPropertyConfigurator;
import org.jkiss.dbeaver.ui.UIUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Network handlers edit dialog page
*/
public class ConnectionPageNetwork extends ConnectionWizardPage {
public static final String PAGE_NAME = ConnectionPageNetwork.class.getSimpleName();
private static final Log log = Log.getLog(ConnectionPageNetwork.class);
private TabFolder handlersFolder;
private DataSourceDescriptor prevDataSource;
private static class HandlerBlock {
private final IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
private final Composite blockControl;
private final Button useHandlerCheck;
private final TabItem tabItem;
ControlEnableState blockEnableState;
private final Map<String, DBWHandlerConfiguration> loadedConfigs = new HashMap<>();
private HandlerBlock(IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator, Composite blockControl, Button useHandlerCheck, TabItem tabItem)
{
this.configurator = configurator;
this.blockControl = blockControl;
this.useHandlerCheck = useHandlerCheck;
this.tabItem = tabItem;
}
}
private final ConnectionWizard wizard;
private Map<NetworkHandlerDescriptor, HandlerBlock> configurations = new HashMap<>();
ConnectionPageNetwork(ConnectionWizard wizard)
{
super(PAGE_NAME);
this.wizard = wizard;
setTitle(CoreMessages.dialog_connection_network_title);
setDescription(CoreMessages.dialog_tunnel_title);
}
@Override
public void createControl(Composite parent)
{
handlersFolder = new TabFolder(parent, SWT.TOP | SWT.FLAT);
handlersFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
setControl(handlersFolder);
}
private void createHandlerTab(final NetworkHandlerDescriptor descriptor) throws DBException
{
IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
try {
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;
}
TabItem tabItem = new TabItem(handlersFolder, SWT.NONE);
tabItem.setText(descriptor.getLabel());
tabItem.setToolTipText(descriptor.getDescription());
Composite composite = new Composite(handlersFolder, SWT.NONE);
tabItem.setControl(composite);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final Button useHandlerCheck = UIUtils.createCheckbox(composite, NLS.bind(CoreMessages.dialog_tunnel_checkbox_use_handler, descriptor.getLabel()), false);
useHandlerCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(wizard.getPageSettings().getActiveDataSource().getId());
handlerConfiguration.setEnabled(useHandlerCheck.getSelection());
enableHandlerContent(descriptor);
}
});
Composite handlerComposite = UIUtils.createPlaceholder(composite, 1);
configurations.put(descriptor, new HandlerBlock(configurator, handlerComposite, useHandlerCheck, tabItem));
handlerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
configurator.createControl(handlerComposite);
}
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DBPDriver driver = wizard.getSelectedDriver();
NetworkHandlerRegistry registry = NetworkHandlerRegistry.getInstance();
if (prevDataSource == null || prevDataSource != dataSource) {
for (TabItem item : handlersFolder.getItems()) {
item.dispose();
}
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
try {
createHandlerTab(descriptor);
} catch (DBException e) {
log.warn(e);
}
}
prevDataSource = dataSource;
handlersFolder.layout(true, true);
// for (TabItem item : handlersFolder.getItems()) {
// ((Composite)item.getControl()).layout(false);
// }
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, driver);
}
HandlerBlock handlerBlock = configurations.get(descriptor);
if (handlerBlock == null) {
continue;
}
//handlerBlock.useHandlerCheck.setSelection(configuration.isEnabled());
if (selectItem == null && configuration.isEnabled()) {
selectItem = handlerBlock.tabItem;
}
if (!handlerBlock.loadedConfigs.containsKey(dataSource.getId())) {
handlerBlock.configurator.loadSettings(configuration);
handlerBlock.loadedConfigs.put(dataSource.getId(), configuration);
}
enableHandlerContent(descriptor);
}
if (selectItem != null) {
handlersFolder.setSelection(selectItem);
} else {
handlersFolder.setSelection(0);
}
}
protected void enableHandlerContent(NetworkHandlerDescriptor descriptor)
{
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(wizard.getPageSettings().getActiveDataSource().getId());
handlerBlock.useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
if (handlerConfiguration.isEnabled()) {
if (handlerBlock.blockEnableState != null) {
handlerBlock.blockEnableState.restore();
handlerBlock.blockEnableState = null;
}
} else if (handlerBlock.blockEnableState == null) {
handlerBlock.blockEnableState = ControlEnableState.disable(handlerBlock.blockControl);
}
}
@Override
public void saveSettings(DataSourceDescriptor dataSource) {
boolean foundHandlers = false;
java.util.List<DBWHandlerConfiguration> handlers = new ArrayList<>();
for (HandlerBlock handlerBlock : configurations.values()) {
DBWHandlerConfiguration configuration = handlerBlock.loadedConfigs.get(dataSource.getId());
if (configuration != null) {
foundHandlers = true;
handlerBlock.configurator.saveSettings(configuration);
handlers.add(configuration);
}
}
if (foundHandlers) {
dataSource.getConnectionConfiguration().setHandlers(handlers);
}
}
}
/*
* 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.ui.dialogs.connection;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.connection.DBPDriver;
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.network.NetworkHandlerDescriptor;
import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry;
import org.jkiss.dbeaver.ui.IObjectPropertyConfigurator;
import org.jkiss.dbeaver.ui.UIUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Network handlers edit dialog page
*/
@Deprecated
public class ConnectionPageNetwork extends ConnectionWizardPage {
public static final String PAGE_NAME = ConnectionPageNetwork.class.getSimpleName();
private static final Log log = Log.getLog(ConnectionPageNetwork.class);
private TabFolder handlersFolder;
private DataSourceDescriptor prevDataSource;
private static class HandlerBlock {
private final IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
private final Composite blockControl;
private final Button useHandlerCheck;
private final TabItem tabItem;
ControlEnableState blockEnableState;
private final Map<String, DBWHandlerConfiguration> loadedConfigs = new HashMap<>();
private HandlerBlock(IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator, Composite blockControl, Button useHandlerCheck, TabItem tabItem)
{
this.configurator = configurator;
this.blockControl = blockControl;
this.useHandlerCheck = useHandlerCheck;
this.tabItem = tabItem;
}
}
private final ConnectionWizard wizard;
private Map<NetworkHandlerDescriptor, HandlerBlock> configurations = new HashMap<>();
ConnectionPageNetwork(ConnectionWizard wizard)
{
super(PAGE_NAME);
this.wizard = wizard;
setTitle(CoreMessages.dialog_connection_network_title);
setDescription(CoreMessages.dialog_tunnel_title);
}
@Override
public void createControl(Composite parent)
{
handlersFolder = new TabFolder(parent, SWT.TOP | SWT.FLAT);
handlersFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
setControl(handlersFolder);
}
private void createHandlerTab(final NetworkHandlerDescriptor descriptor) throws DBException
{
IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
try {
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;
}
TabItem tabItem = new TabItem(handlersFolder, SWT.NONE);
tabItem.setText(descriptor.getLabel());
tabItem.setToolTipText(descriptor.getDescription());
Composite composite = new Composite(handlersFolder, SWT.NONE);
tabItem.setControl(composite);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final Button useHandlerCheck = UIUtils.createCheckbox(composite, NLS.bind(CoreMessages.dialog_tunnel_checkbox_use_handler, descriptor.getLabel()), false);
useHandlerCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(wizard.getPageSettings().getActiveDataSource().getId());
handlerConfiguration.setEnabled(useHandlerCheck.getSelection());
enableHandlerContent(descriptor);
}
});
Composite handlerComposite = UIUtils.createPlaceholder(composite, 1);
configurations.put(descriptor, new HandlerBlock(configurator, handlerComposite, useHandlerCheck, tabItem));
handlerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
configurator.createControl(handlerComposite);
}
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DBPDriver driver = wizard.getSelectedDriver();
NetworkHandlerRegistry registry = NetworkHandlerRegistry.getInstance();
if (prevDataSource == null || prevDataSource != dataSource) {
for (TabItem item : handlersFolder.getItems()) {
item.dispose();
}
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
try {
createHandlerTab(descriptor);
} catch (DBException e) {
log.warn(e);
}
}
prevDataSource = dataSource;
handlersFolder.layout(true, true);
// for (TabItem item : handlersFolder.getItems()) {
// ((Composite)item.getControl()).layout(false);
// }
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, driver);
}
HandlerBlock handlerBlock = configurations.get(descriptor);
if (handlerBlock == null) {
continue;
}
//handlerBlock.useHandlerCheck.setSelection(configuration.isEnabled());
if (selectItem == null && configuration.isEnabled()) {
selectItem = handlerBlock.tabItem;
}
if (!handlerBlock.loadedConfigs.containsKey(dataSource.getId())) {
handlerBlock.configurator.loadSettings(configuration);
handlerBlock.loadedConfigs.put(dataSource.getId(), configuration);
}
enableHandlerContent(descriptor);
}
if (selectItem != null) {
handlersFolder.setSelection(selectItem);
} else {
handlersFolder.setSelection(0);
}
}
protected void enableHandlerContent(NetworkHandlerDescriptor descriptor)
{
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(wizard.getPageSettings().getActiveDataSource().getId());
handlerBlock.useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
if (handlerConfiguration.isEnabled()) {
if (handlerBlock.blockEnableState != null) {
handlerBlock.blockEnableState.restore();
handlerBlock.blockEnableState = null;
}
} else if (handlerBlock.blockEnableState == null) {
handlerBlock.blockEnableState = ControlEnableState.disable(handlerBlock.blockControl);
}
}
@Override
public void saveSettings(DataSourceDescriptor dataSource) {
boolean foundHandlers = false;
java.util.List<DBWHandlerConfiguration> handlers = new ArrayList<>();
for (HandlerBlock handlerBlock : configurations.values()) {
DBWHandlerConfiguration configuration = handlerBlock.loadedConfigs.get(dataSource.getId());
if (configuration != null) {
foundHandlers = true;
handlerBlock.configurator.saveSettings(configuration);
handlers.add(configuration);
}
}
if (foundHandlers) {
dataSource.getConnectionConfiguration().setHandlers(handlers);
}
}
}
/*
* 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.ui.dialogs.connection;
import org.eclipse.jface.dialogs.ControlEnableState;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TabItem;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
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.network.NetworkHandlerDescriptor;
import org.jkiss.dbeaver.ui.IDataSourceConnectionEditorSite;
import org.jkiss.dbeaver.ui.IObjectPropertyConfigurator;
import org.jkiss.dbeaver.ui.UIUtils;
/**
* Network handlers edit dialog page
*/
public class ConnectionPageNetworkHandler extends ConnectionWizardPage {
private static final Log log = Log.getLog(ConnectionPageNetworkHandler.class);
private final IDataSourceConnectionEditorSite site;
private final NetworkHandlerDescriptor handlerDescriptor;
private IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
private Composite blockControl;
private Button useHandlerCheck;
private TabItem tabItem;
private ControlEnableState blockEnableState;
private DBWHandlerConfiguration handlerConfiguration;
private Composite handlerComposite;
public ConnectionPageNetworkHandler(IDataSourceConnectionEditorSite site, NetworkHandlerDescriptor descriptor) {
super(ConnectionPageNetworkHandler.class.getSimpleName() + "." + descriptor.getId());
this.site = site;
this.handlerDescriptor = descriptor;
setTitle(descriptor.getCodeName());
setDescription(descriptor.getDescription());
}
@Override
public void createControl(Composite parent) {
try {
String implName = handlerDescriptor.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 '" + handlerDescriptor.getId() + "'", e);
return;
}
DBPDataSourceContainer dataSource = site.getActiveDataSource();
DBPConnectionConfiguration connectionConfiguration = dataSource.getConnectionConfiguration();
handlerConfiguration = connectionConfiguration.getHandler(handlerDescriptor.getId());
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, dataSource.getDriver());
connectionConfiguration.addHandler(handlerConfiguration);
}
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final Button useHandlerCheck = UIUtils.createCheckbox(composite, NLS.bind(CoreMessages.dialog_tunnel_checkbox_use_handler, handlerDescriptor.getLabel()), false);
useHandlerCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handlerConfiguration.setEnabled(useHandlerCheck.getSelection());
enableHandlerContent();
}
});
handlerComposite = UIUtils.createPlaceholder(composite, 1);
handlerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
configurator.createControl(handlerComposite);
configurator.loadSettings(handlerConfiguration);
enableHandlerContent();
setControl(composite);
}
protected void enableHandlerContent() {
if (handlerConfiguration.isEnabled()) {
if (blockEnableState != null) {
blockEnableState.restore();
blockEnableState = null;
}
} else if (blockEnableState == null) {
blockEnableState = ControlEnableState.disable(handlerComposite);
}
}
@Override
public void saveSettings(DataSourceDescriptor dataSource) {
configurator.saveSettings(handlerConfiguration);
}
}
......@@ -47,7 +47,7 @@ public class NewConnectionWizard extends ConnectionWizard
private ConnectionPageDriver pageDrivers;
private Map<DataSourceProviderDescriptor, ConnectionPageSettings> settingsPages = new HashMap<>();
private ConnectionPageGeneral pageGeneral;
private ConnectionPageNetwork pageNetwork;
//private ConnectionPageNetwork pageNetwork;
public NewConnectionWizard() {
setWindowTitle(CoreMessages.dialog_new_connection_wizard_title);
......@@ -119,9 +119,9 @@ public class NewConnectionWizard extends ConnectionWizard
}
pageGeneral = new ConnectionPageGeneral(this);
pageNetwork = new ConnectionPageNetwork(this);
//pageNetwork = new ConnectionPageNetwork(this);
addPage(pageGeneral);
addPage(pageNetwork);
//addPage(pageNetwork);
// Initial settings
if (selection != null && !selection.isEmpty()) {
......@@ -156,14 +156,12 @@ public class NewConnectionWizard extends ConnectionWizard
if (page == pageDrivers) {
ConnectionPageSettings pageSettings = getPageSettings((DriverDescriptor) getSelectedDriver());
if (pageSettings == null) {
return pageDrivers.getSelectedDriver().isEmbedded() ? pageGeneral : pageNetwork;
return pageGeneral;
} else {
return pageSettings;
}
} else if (page instanceof ConnectionPageSettings) {
return null;//pageDrivers.getSelectedDriver().isEmbedded() ? pageGeneral : pageNetwork;
} else if (page instanceof ConnectionPageNetwork) {
return null;//pageGeneral;
} else {
return null;
}
......@@ -203,7 +201,7 @@ public class NewConnectionWizard extends ConnectionWizard
pageSettings.saveSettings(dataSource);
}
pageGeneral.saveSettings(dataSource);
pageNetwork.saveSettings(dataSource);
//pageNetwork.saveSettings(dataSource);
}
@Override
......
......@@ -17,9 +17,7 @@
package org.jkiss.dbeaver.ext.mysql.views;
import org.eclipse.jface.dialogs.IDialogPage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
......@@ -41,7 +39,6 @@ import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils;
import java.util.Arrays;
import java.util.Locale;
import java.util.TimeZone;
......@@ -74,14 +71,9 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
{
//Composite group = new Composite(composite, SWT.NONE);
//group.setLayout(new GridLayout(1, true));
ModifyListener textListener = new ModifyListener()
{
@Override
public void modifyText(ModifyEvent e)
{
if (activated) {
site.updateButtons();
}
ModifyListener textListener = e -> {
if (activated) {
site.updateButtons();
}
};
final int fontHeight = UIUtils.getFontHeight(composite);
......@@ -197,7 +189,7 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
}
if (portText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(String.valueOf(connectionInfo.getHostPort()));
portText.setText(connectionInfo.getHostPort());
} else if (site.getDriver().getDefaultPort() != null) {
portText.setText(site.getDriver().getDefaultPort());
} else {
......@@ -268,7 +260,8 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
public IDialogPage[] getSubPages()
{
return new IDialogPage[] {
new DriverPropertiesDialogPage(this)
new DriverPropertiesDialogPage(this),
};
}
......
......@@ -280,6 +280,7 @@
<handler
type="config"
id="mysql_ssl"
codeName="SSL"
label="SSL"
description="Secure socket layer"
secured="false"
......
......@@ -476,6 +476,7 @@
<handler
type="config"
id="postgre_ssl"
codeName="SSL"
label="%handler.ssl.name"
description="%handler.ssl.description"
secured="false"
......
/*
* 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.net;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
/**
* Network handler descriptor
*/
public interface DBWHandlerDescriptor {
@NotNull
String getId();
String getLabel();
String getDescription();
DBWHandlerType getType();
boolean isSecured();
<T extends DBWNetworkHandler> T createHandler(Class<T> impl) throws DBException;
}
/*
* 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.net;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
/**
* Network handler descriptor
*/
public interface DBWHandlerDescriptor {
@NotNull
String getId();
@NotNull
String getCodeName();
String getLabel();
String getDescription();
DBWHandlerType getType();
boolean isSecured();
<T extends DBWNetworkHandler> T createHandler(Class<T> impl) throws DBException;
}
......@@ -9,6 +9,7 @@
<handler
type="tunnel"
id="ssh_tunnel"
codeName="SSH"
label="%handler.ssh_tunnel.label"
description="%handler.ssh_tunnel.description"
secured="true"
......
......@@ -41,6 +41,7 @@
<handler
type="proxy"
id="socks_proxy"
codeName="SOCKS"
label="%handler.socks_proxy.label"
description="%handler.socks_proxy.description"
secured="true"
......
......@@ -32,12 +32,12 @@ import java.util.Locale;
/**
* NetworkHandlerDescriptor
*/
public class NetworkHandlerDescriptor extends AbstractContextDescriptor implements DBWHandlerDescriptor
{
public class NetworkHandlerDescriptor extends AbstractContextDescriptor implements DBWHandlerDescriptor {
public static final String EXTENSION_ID = "org.jkiss.dbeaver.networkHandler"; //$NON-NLS-1$
private final String id;
private final String label;
private final String codeName;
private final String description;
private DBWHandlerType type;
private final boolean secured;
......@@ -45,11 +45,11 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
private final int order;
NetworkHandlerDescriptor(
IConfigurationElement config)
{
IConfigurationElement config) {
super(config);
this.id = config.getAttribute(RegistryConstants.ATTR_ID);
this.codeName = config.getAttribute("codeName") == null ? this.id : config.getAttribute("codeName");
this.label = config.getAttribute(RegistryConstants.ATTR_LABEL);
this.description = config.getAttribute(RegistryConstants.ATTR_DESCRIPTION);
this.type = DBWHandlerType.valueOf(config.getAttribute(RegistryConstants.ATTR_TYPE).toUpperCase(Locale.ENGLISH));
......@@ -59,28 +59,28 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
}
@NotNull
public String getId()
{
public String getId() {
return id;
}
public String getLabel()
{
@NotNull
public String getCodeName() {
return codeName;
}
public String getLabel() {
return label;
}
public String getDescription()
{
public String getDescription() {
return description;
}
public DBWHandlerType getType()
{
public DBWHandlerType getType() {
return type;
}
public boolean isSecured()
{
public boolean isSecured() {
return secured;
}
......@@ -88,8 +88,7 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
return order;
}
public boolean matches(DBPDataSourceProvider provider)
{
public boolean matches(DBPDataSourceProvider provider) {
return appliesTo(provider);
}
......@@ -98,8 +97,7 @@ public class NetworkHandlerDescriptor extends AbstractContextDescriptor implemen
}
public <T extends DBWNetworkHandler> T createHandler(Class<T> impl)
throws DBException
{
throws DBException {
return handlerType.createInstance(impl);
}
......
......@@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Platform;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
......@@ -68,6 +69,12 @@ public class NetworkHandlerRegistry
}
public List<NetworkHandlerDescriptor> getDescriptors(DBPDataSourceContainer dataSource) {
/*
if (dataSource.getDriver().isEmbedded()) {
// No network handlers for embedded drivers
return Collections.emptyList();
}
*/
List<NetworkHandlerDescriptor> result = new ArrayList<>();
for (NetworkHandlerDescriptor d : descriptors) {
if (!d.hasObjectTypes() || d.matches(dataSource.getDriver().getDataSourceProvider())) {
......
......@@ -46,8 +46,7 @@ import org.jkiss.utils.CommonUtils;
public abstract class ConnectionPageAbstract extends DialogPage implements IDataSourceConnectionEditor
{
// FIXME: make it private
public IDataSourceConnectionEditorSite site;
protected IDataSourceConnectionEditorSite site;
// Driver name
protected Text driverText;
protected Button savePasswordCheck;
......@@ -146,6 +145,7 @@ public abstract class ConnectionPageAbstract extends DialogPage implements IData
Label advancedLabel = UIUtils.createControlLabel(linksComposite, UIConnectionMessages.dialog_connection_advanced_settings);
advancedLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
/*
if (!site.getDriver().isEmbedded()) {
Button netConfigLink = new Button(linksComposite, SWT.PUSH);
netConfigLink.setText(UIConnectionMessages.dialog_connection_edit_wizard_conn_conf_network_link);
......@@ -158,6 +158,7 @@ public abstract class ConnectionPageAbstract extends DialogPage implements IData
netConfigLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
//((GridLayout)linksComposite.getLayout()).numColumns++;
}
*/
{
if (!site.getDriver().isEmbedded()) {
UIUtils.createEmptyLabel(linksComposite, 1, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册