提交 0a27e689 编写于 作者: S Serge Rider

UI controls refactoring

上级 e4c0a491
......@@ -291,9 +291,9 @@ meta.org.jkiss.dbeaver.registry.DriverDescriptor.name.name=Driver Name
meta.org.jkiss.dbeaver.registry.DriverDescriptor.description.name=Description
meta.org.jkiss.dbeaver.registry.DriverDescriptor.driverClassName.name=Driver Class
meta.org.jkiss.dbeaver.registry.DriverDescriptor.sampleURL.name=URL
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.type.name=Type
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.name.name=Name
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.columns.name=Columns
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.type.name=Type
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.name.name=Name
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.columns.name=Columns
meta.org.jkiss.dbeaver.ui.search.data.SearchDataObject.name.name=Name
meta.org.jkiss.dbeaver.ui.search.data.SearchDataObject.foundRows.name=Rows Found (>=)
......
......@@ -254,9 +254,9 @@ meta.org.jkiss.dbeaver.registry.DriverDescriptor.name.name=\u0418\u043C\u044F \u
meta.org.jkiss.dbeaver.registry.DriverDescriptor.description.name=\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435
meta.org.jkiss.dbeaver.registry.DriverDescriptor.driverClassName.name=\u041A\u043B\u0430\u0441\u0441 \u0414\u0440\u0430\u0439\u0432\u0435\u0440\u0430
meta.org.jkiss.dbeaver.registry.DriverDescriptor.sampleURL.name=URL
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.type.name=\u0422\u0438\u043F
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.name.name=\u0418\u043C\u044F
meta.org.jkiss.dbeaver.ui.controls.ColumnInfoPanel$CellKeyInfo.columns.name=\u041A\u043E\u043B\u043E\u043D\u043A\u0438
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.type.name=\u0422\u0438\u043F
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.name.name=\u0418\u043C\u044F
meta.org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel$CellKeyInfo.columns.name=\u041A\u043E\u043B\u043E\u043D\u043A\u0438
command.org.jkiss.dbeaver.core.resultset.row.edit.inline.name=\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C
command.org.jkiss.dbeaver.core.resultset.row.edit.inline.description=\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044F \u0432\u0441\u0442\u0440\u043E\u0435\u043D\u043D\u044B\u0435 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440
......
......@@ -16,7 +16,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.ui.controls;
package org.jkiss.dbeaver.ui.dialogs;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.controls;
import org.jkiss.dbeaver.Log;
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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.connection.DBPClientHome;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.ui.UIUtils;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* ClientHomesSelector
*/
public class ClientHomesSelector extends Composite
{
static final Log log = Log.getLog(ClientHomesSelector.class);
private Combo homesCombo;
//private Label versionLabel;
private DBPDriver driver;
private List<String> homeIds = new ArrayList<>();
private String currentHomeId;
public ClientHomesSelector(
Composite parent,
int style,
String title)
{
super(parent, style);
this.setLayout(new GridLayout(2, false));
UIUtils.createControlLabel(this, title);
//label.setFont(UIUtils.makeBoldFont(label.getFont()));
homesCombo = new Combo(this, SWT.READ_ONLY);
//directoryDialog = new DirectoryDialog(selectorContainer.getShell(), SWT.OPEN);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
homesCombo.setLayoutData(gd);
homesCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
if (homesCombo.getSelectionIndex() == homesCombo.getItemCount() - 1) {
manageHomes();
} else {
currentHomeId = homeIds.get(homesCombo.getSelectionIndex());
}
displayClientVersion();
handleHomeChange();
}
});
// versionLabel = new Label(this, SWT.CENTER);
// gd = new GridData();
// gd.widthHint = 60;
// versionLabel.setLayoutData(gd);
}
private void manageHomes()
{
String newHomeId = ClientHomesPanel.chooseClientHome(getShell(), driver);
if (newHomeId != null) {
currentHomeId = newHomeId;
}
populateHomes(driver, currentHomeId);
}
public void populateHomes(DBPDriver driver, String currentHome)
{
this.driver = driver;
this.currentHomeId = currentHome;
this.homesCombo.removeAll();
this.homeIds.clear();
Set<String> homes = new LinkedHashSet<>(
driver.getClientManager().findClientHomeIds());
homes.addAll(driver.getClientHomeIds());
for (String homeId : homes) {
DBPClientHome home = driver.getClientHome(homeId);
if (home != null) {
homesCombo.add(home.getDisplayName());
homeIds.add(home.getHomeId());
if (currentHomeId != null && home.getHomeId().equals(currentHomeId)) {
homesCombo.select(homesCombo.getItemCount() - 1);
}
}
}
this.homesCombo.add(CoreMessages.controls_client_home_selector_browse);
displayClientVersion();
}
private void displayClientVersion()
{
/*
DBPClientHome clientHome = currentHomeId == null ? null : driver.getClientHome(currentHomeId);
if (clientHome != null) {
try {
// display client version
if (clientHome.getProductVersion() != null) {
versionLabel.setText(clientHome.getProductVersion());
} else {
versionLabel.setText(clientHome.getProductName());
}
} catch (DBException e) {
log.error(e);
}
} else {
versionLabel.setText(""); //$NON-NLS-1$
}
*/
}
protected void handleHomeChange()
{
}
public String getSelectedHome()
{
return currentHomeId;
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.dialogs.connection;
import org.jkiss.dbeaver.Log;
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.Combo;
import org.eclipse.swt.widgets.Composite;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.connection.DBPClientHome;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.ui.UIUtils;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* ClientHomesSelector
*/
public class ClientHomesSelector extends Composite
{
static final Log log = Log.getLog(ClientHomesSelector.class);
private Combo homesCombo;
//private Label versionLabel;
private DBPDriver driver;
private List<String> homeIds = new ArrayList<>();
private String currentHomeId;
public ClientHomesSelector(
Composite parent,
int style,
String title)
{
super(parent, style);
this.setLayout(new GridLayout(2, false));
UIUtils.createControlLabel(this, title);
//label.setFont(UIUtils.makeBoldFont(label.getFont()));
homesCombo = new Combo(this, SWT.READ_ONLY);
//directoryDialog = new DirectoryDialog(selectorContainer.getShell(), SWT.OPEN);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
homesCombo.setLayoutData(gd);
homesCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e)
{
if (homesCombo.getSelectionIndex() == homesCombo.getItemCount() - 1) {
manageHomes();
} else {
currentHomeId = homeIds.get(homesCombo.getSelectionIndex());
}
displayClientVersion();
handleHomeChange();
}
});
// versionLabel = new Label(this, SWT.CENTER);
// gd = new GridData();
// gd.widthHint = 60;
// versionLabel.setLayoutData(gd);
}
private void manageHomes()
{
String newHomeId = ClientHomesPanel.chooseClientHome(getShell(), driver);
if (newHomeId != null) {
currentHomeId = newHomeId;
}
populateHomes(driver, currentHomeId);
}
public void populateHomes(DBPDriver driver, String currentHome)
{
this.driver = driver;
this.currentHomeId = currentHome;
this.homesCombo.removeAll();
this.homeIds.clear();
Set<String> homes = new LinkedHashSet<>(
driver.getClientManager().findClientHomeIds());
homes.addAll(driver.getClientHomeIds());
for (String homeId : homes) {
DBPClientHome home = driver.getClientHome(homeId);
if (home != null) {
homesCombo.add(home.getDisplayName());
homeIds.add(home.getHomeId());
if (currentHomeId != null && home.getHomeId().equals(currentHomeId)) {
homesCombo.select(homesCombo.getItemCount() - 1);
}
}
}
this.homesCombo.add(CoreMessages.controls_client_home_selector_browse);
displayClientVersion();
}
private void displayClientVersion()
{
/*
DBPClientHome clientHome = currentHomeId == null ? null : driver.getClientHome(currentHomeId);
if (clientHome != null) {
try {
// display client version
if (clientHome.getProductVersion() != null) {
versionLabel.setText(clientHome.getProductVersion());
} else {
versionLabel.setText(clientHome.getProductName());
}
} catch (DBException e) {
log.error(e);
}
} else {
versionLabel.setText(""); //$NON-NLS-1$
}
*/
}
protected void handleHomeChange()
{
}
public String getSelectedHome()
{
return currentHomeId;
}
}
\ No newline at end of file
......@@ -26,9 +26,9 @@ import org.jkiss.dbeaver.registry.DataSourceProviderDescriptor;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.DriverTreeControl;
import org.jkiss.dbeaver.ui.controls.DriverTreeViewer;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardPage;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeControl;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeViewer;
/**
* Driver selection page
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.controls;
import org.jkiss.dbeaver.Log;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.widgets.Composite;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.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.model.impl.PropertyDescriptor;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.utils.CommonUtils;
import java.util.*;
/**
* Connection properties control
*/
public class ConnectionPropertiesControl extends PropertyTreeViewer {
static final Log log = Log.getLog(ConnectionPropertiesControl.class);
public static final String USER_PROPERTIES_CATEGORY = CoreMessages.controls_connection_properties_category_user_properties;
private List<DBPPropertyDescriptor> driverProvidedProperties;
private List<DBPPropertyDescriptor> customProperties;
public ConnectionPropertiesControl(Composite parent, int style)
{
super(parent, style);
setExpandSingleRoot(false);
}
public PropertySourceCustom makeProperties(DBRRunnableContext runnableContext, DBPDriver driver, DBPConnectionConfiguration connectionInfo)
{
Map<Object, Object> connectionProps = new HashMap<>();
connectionProps.putAll(driver.getConnectionProperties());
connectionProps.putAll(connectionInfo.getProperties());
driverProvidedProperties = null;
customProperties = null;
loadDriverProperties(runnableContext, driver, connectionInfo);
loadCustomProperties(driver, connectionProps);
return new PropertySourceCustom(
getAllProperties(driver, true),
connectionProps);
}
public PropertySourceCustom makeProperties(DBPDriver driver, Map<Object, Object> properties)
{
driverProvidedProperties = null;
customProperties = null;
loadCustomProperties(driver, properties);
return new PropertySourceCustom(
getAllProperties(driver, true),
properties);
}
@Override
protected String[] getCustomCategories()
{
return new String[] { USER_PROPERTIES_CATEGORY };
}
@Override
protected void contributeContextMenu(IMenuManager manager, final Object node, final String category, final DBPPropertyDescriptor property)
{
boolean isCustom = USER_PROPERTIES_CATEGORY.equals(category);
if (isCustom) {
manager.add(new Action(CoreMessages.controls_connection_properties_action_add_property) {
@Override
public void run() {
createNewProperty(node, category);
}
});
if (property != null) {
manager.add(new Action(CoreMessages.controls_connection_properties_action_remove_property) {
@Override
public void run() {
removeProperty(node);
}
});
}
}
}
private void createNewProperty(Object node, String category) {
// Ask user for new property name
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 PropertyDescriptor(category, propName, propName, null, null, false, null, null, true));
}
}
private List<DBPPropertyDescriptor> getAllProperties(DBPDriver driver, boolean includeCustom) {
List<DBPPropertyDescriptor> propertyDescriptors = new ArrayList<>();
propertyDescriptors.addAll(driver.getConnectionPropertyDescriptors());
if (driverProvidedProperties != null) {
propertyDescriptors.addAll(driverProvidedProperties);
}
if (includeCustom && customProperties != null) {
propertyDescriptors.addAll(customProperties);
}
return propertyDescriptors;
}
private void loadDriverProperties(DBRRunnableContext runnableContext, DBPDriver driver, DBPConnectionConfiguration connectionInfo)
{
try {
final DBPPropertyDescriptor[] connectionsProps =
driver.getDataSourceProvider().getConnectionProperties(runnableContext, driver, connectionInfo);
driverProvidedProperties = new ArrayList<>();
if (connectionsProps != null) {
Collections.addAll(driverProvidedProperties, connectionsProps);
}
} catch (DBException e) {
log.warn("Can't load driver properties", e); //$NON-NLS-1$
}
}
private void loadCustomProperties(DBPDriver driver, Map<Object, Object> properties)
{
// Collect all driver (and all other) properties
Set<String> propNames = new TreeSet<>();
List<DBPPropertyDescriptor> allProperties = getAllProperties(driver, false);
for (DBPPropertyDescriptor prop : allProperties) {
propNames.add(CommonUtils.toString(prop.getId()));
}
customProperties = new ArrayList<>();
// Find prop values which are not from driver
for (Object propId : properties.keySet()) {
final String propName = propId.toString();
if (propName.startsWith(DBConstants.INTERNAL_PROP_PREFIX)) {
continue;
}
if (!propNames.contains(propName)) {
customProperties.add(new PropertyDescriptor(
USER_PROPERTIES_CATEGORY,
propName,
propName,
null,
String.class,
false,
null,
null,
true));
}
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.dialogs.connection;
import org.jkiss.dbeaver.Log;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.widgets.Composite;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.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.model.impl.PropertyDescriptor;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
import org.jkiss.utils.CommonUtils;
import java.util.*;
/**
* Connection properties control
*/
public class ConnectionPropertiesControl extends PropertyTreeViewer {
static final Log log = Log.getLog(ConnectionPropertiesControl.class);
public static final String USER_PROPERTIES_CATEGORY = CoreMessages.controls_connection_properties_category_user_properties;
private List<DBPPropertyDescriptor> driverProvidedProperties;
private List<DBPPropertyDescriptor> customProperties;
public ConnectionPropertiesControl(Composite parent, int style)
{
super(parent, style);
setExpandSingleRoot(false);
}
public PropertySourceCustom makeProperties(DBRRunnableContext runnableContext, DBPDriver driver, DBPConnectionConfiguration connectionInfo)
{
Map<Object, Object> connectionProps = new HashMap<>();
connectionProps.putAll(driver.getConnectionProperties());
connectionProps.putAll(connectionInfo.getProperties());
driverProvidedProperties = null;
customProperties = null;
loadDriverProperties(runnableContext, driver, connectionInfo);
loadCustomProperties(driver, connectionProps);
return new PropertySourceCustom(
getAllProperties(driver, true),
connectionProps);
}
public PropertySourceCustom makeProperties(DBPDriver driver, Map<Object, Object> properties)
{
driverProvidedProperties = null;
customProperties = null;
loadCustomProperties(driver, properties);
return new PropertySourceCustom(
getAllProperties(driver, true),
properties);
}
@Override
protected String[] getCustomCategories()
{
return new String[] { USER_PROPERTIES_CATEGORY };
}
@Override
protected void contributeContextMenu(IMenuManager manager, final Object node, final String category, final DBPPropertyDescriptor property)
{
boolean isCustom = USER_PROPERTIES_CATEGORY.equals(category);
if (isCustom) {
manager.add(new Action(CoreMessages.controls_connection_properties_action_add_property) {
@Override
public void run() {
createNewProperty(node, category);
}
});
if (property != null) {
manager.add(new Action(CoreMessages.controls_connection_properties_action_remove_property) {
@Override
public void run() {
removeProperty(node);
}
});
}
}
}
private void createNewProperty(Object node, String category) {
// Ask user for new property name
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 PropertyDescriptor(category, propName, propName, null, null, false, null, null, true));
}
}
private List<DBPPropertyDescriptor> getAllProperties(DBPDriver driver, boolean includeCustom) {
List<DBPPropertyDescriptor> propertyDescriptors = new ArrayList<>();
propertyDescriptors.addAll(driver.getConnectionPropertyDescriptors());
if (driverProvidedProperties != null) {
propertyDescriptors.addAll(driverProvidedProperties);
}
if (includeCustom && customProperties != null) {
propertyDescriptors.addAll(customProperties);
}
return propertyDescriptors;
}
private void loadDriverProperties(DBRRunnableContext runnableContext, DBPDriver driver, DBPConnectionConfiguration connectionInfo)
{
try {
final DBPPropertyDescriptor[] connectionsProps =
driver.getDataSourceProvider().getConnectionProperties(runnableContext, driver, connectionInfo);
driverProvidedProperties = new ArrayList<>();
if (connectionsProps != null) {
Collections.addAll(driverProvidedProperties, connectionsProps);
}
} catch (DBException e) {
log.warn("Can't load driver properties", e); //$NON-NLS-1$
}
}
private void loadCustomProperties(DBPDriver driver, Map<Object, Object> properties)
{
// Collect all driver (and all other) properties
Set<String> propNames = new TreeSet<>();
List<DBPPropertyDescriptor> allProperties = getAllProperties(driver, false);
for (DBPPropertyDescriptor prop : allProperties) {
propNames.add(CommonUtils.toString(prop.getId()));
}
customProperties = new ArrayList<>();
// Find prop values which are not from driver
for (Object propId : properties.keySet()) {
final String propName = propId.toString();
if (propName.startsWith(DBConstants.INTERNAL_PROP_PREFIX)) {
continue;
}
if (!propNames.contains(propName)) {
customProperties.add(new PropertyDescriptor(
USER_PROPERTIES_CATEGORY,
propName,
propName,
null,
String.class,
false,
null,
null,
true));
}
}
}
}
......@@ -25,10 +25,8 @@ import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.registry.DataSourceDescriptor;
import org.jkiss.dbeaver.registry.DataSourceRegistry;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
import org.jkiss.dbeaver.ui.controls.ConnectionPropertiesControl;
import java.lang.reflect.InvocationTargetException;
......
......@@ -43,7 +43,7 @@ import org.jkiss.dbeaver.registry.DataSourceRegistry;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.DriverTreeControl;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeControl;
import java.util.*;
......
......@@ -37,10 +37,9 @@ import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.data.DBDValueHandler;
import org.jkiss.dbeaver.model.exec.DBCExecutionContext;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.*;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.ColumnInfoPanel;
import org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel;
import org.jkiss.dbeaver.ui.data.*;
import org.jkiss.dbeaver.ui.data.managers.BaseValueManager;
import org.jkiss.utils.CommonUtils;
......
......@@ -50,8 +50,8 @@ import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIIcon;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.CImageCombo;
import org.jkiss.dbeaver.ui.controls.ClientHomesPanel;
import org.jkiss.dbeaver.ui.controls.ConnectionPropertiesControl;
import org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesPanel;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPropertiesControl;
import org.jkiss.dbeaver.ui.dialogs.HelpEnabledDialog;
import org.jkiss.dbeaver.ui.dialogs.StandardErrorDialog;
import org.jkiss.dbeaver.ui.properties.PropertyTreeViewer;
......
......@@ -37,8 +37,6 @@ import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
import org.jkiss.dbeaver.registry.driver.DriverDescriptor;
import org.jkiss.dbeaver.ui.IHelpContextIds;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.DriverTreeControl;
import org.jkiss.dbeaver.ui.controls.DriverTreeViewer;
import org.jkiss.dbeaver.ui.dialogs.HelpEnabledDialog;
import org.jkiss.utils.CommonUtils;
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.controls;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.jkiss.dbeaver.registry.DataSourceProviderDescriptor;
import java.util.List;
/**
* DriverTreeControl
*
* @author Serge Rieder
*/
public class DriverTreeControl extends FilteredTree {
private static final String DRIVER_INIT_DATA = "driverInitData";
public DriverTreeControl(Composite parent, Object site, List<DataSourceProviderDescriptor> providers, boolean expandRecent) {
super(
saveInitParameters(parent, site, providers, expandRecent),
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER,
new DriverFilter(),
true);
}
private static Composite saveInitParameters(Composite parent, Object site, List<DataSourceProviderDescriptor> providers, boolean expandRecent) {
parent.setData("driverInitData", new Object[] {site, providers, expandRecent} );
return parent;
}
@Override
protected DriverTreeViewer doCreateTreeViewer(Composite parent, int style) {
Object[] initData = (Object[]) getParent().getData(DRIVER_INIT_DATA);
parent.setData(DRIVER_INIT_DATA, null);
DriverTreeViewer viewer = new DriverTreeViewer(parent, style);
viewer.initDrivers(initData[0], (List<DataSourceProviderDescriptor>) initData[1], (Boolean) initData[2]);
return viewer;
}
private static class DriverFilter extends PatternFilter {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)
.getContentProvider()).getParent(element);
if (parent != null && isLeafMatch(viewer, parent)) {
return true;
}
return isParentMatch(viewer, element) || isLeafMatch(viewer, element);
}
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2015 Serge Rieder (serge@jkiss.org)
* Copyright (C) 2011-2012 Eugene Fradkin (eugene.fradkin@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* 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.dialogs.driver;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.jkiss.dbeaver.registry.DataSourceProviderDescriptor;
import java.util.List;
/**
* DriverTreeControl
*
* @author Serge Rieder
*/
public class DriverTreeControl extends FilteredTree {
private static final String DRIVER_INIT_DATA = "driverInitData";
public DriverTreeControl(Composite parent, Object site, List<DataSourceProviderDescriptor> providers, boolean expandRecent) {
super(
saveInitParameters(parent, site, providers, expandRecent),
SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER,
new DriverFilter(),
true);
}
private static Composite saveInitParameters(Composite parent, Object site, List<DataSourceProviderDescriptor> providers, boolean expandRecent) {
parent.setData("driverInitData", new Object[] {site, providers, expandRecent} );
return parent;
}
@Override
protected DriverTreeViewer doCreateTreeViewer(Composite parent, int style) {
Object[] initData = (Object[]) getParent().getData(DRIVER_INIT_DATA);
parent.setData(DRIVER_INIT_DATA, null);
DriverTreeViewer viewer = new DriverTreeViewer(parent, style);
viewer.initDrivers(initData[0], (List<DataSourceProviderDescriptor>) initData[1], (Boolean) initData[2]);
return viewer;
}
private static class DriverFilter extends PatternFilter {
@Override
public boolean isElementVisible(Viewer viewer, Object element) {
Object parent = ((ITreeContentProvider) ((AbstractTreeViewer) viewer)
.getContentProvider()).getParent(element);
if (parent != null && isLeafMatch(viewer, parent)) {
return true;
}
return isParentMatch(viewer, element) || isLeafMatch(viewer, element);
}
}
}
......@@ -40,7 +40,7 @@ import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.ColumnInfoPanel;
import org.jkiss.dbeaver.ui.dialogs.ColumnInfoPanel;
import org.jkiss.dbeaver.ui.editors.MultiPageAbstractEditor;
import org.jkiss.dbeaver.utils.ContentUtils;
......
......@@ -35,7 +35,7 @@ import org.jkiss.dbeaver.ui.ICompositeDialogPage;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.ClientHomesSelector;
import org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils;
......
......@@ -36,7 +36,7 @@ import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.ui.ICompositeDialogPage;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.ClientHomesSelector;
import org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector;
import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册