未验证 提交 6acd9121 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #2432 from liuyuanyuan/devel

Clean non-working code from plugin.xml of org.jkiss.dbeaver.core
......@@ -1151,6 +1151,67 @@ public class CoreMessages extends NLS {
public static String pref_page_projects_settings_label_not_store_resources_in_another_project;
public static String pref_page_projects_settings_label_restart_require_refresh_global_settings;
// Preference/Properties
// Connection edit
public static String dialog_connection_edit_title;
public static String dialog_connection_edit_wizard_conn_conf_network_link;
public static String dialog_connection_edit_wizard_general;
public static String dialog_connection_edit_wizard_general_bootstrap_query_title;
public static String dialog_connection_edit_wizard_general_bootstrap_query_sql_label;
public static String dialog_connection_edit_wizard_general_bootstrap_query_sql_title;
public static String dialog_connection_edit_wizard_general_bootstrap_query_ignore_error_lable;
public static String dialog_connection_edit_wizard_general_filter_save_button;
public static String dialog_connection_edit_wizard_general_filter_remove_button;
public static String dialog_connection_edit_wizard_general_filter_save_label;
public static String dialog_connection_edit_wizard_general_filter_name_label;
public static String dialog_connection_edit_wizard_general_filter_hint_text;
public static String dialog_connection_edit_wizard_shell_cmd;
public static String dialog_connection_edit_wizard_shell_cmd_pause_label;
public static String dialog_connection_edit_wizard_shell_cmd_pause_tooltip;
public static String dialog_connection_edit_wizard_shell_cmd_directory_label;
public static String dialog_connection_edit_wizard_shell_cmd_directory_title;
public static String dialog_connection_edit_wizard_shell_cmd_variables_hint_label;
public static String dialog_connection_edit_wizard_shell_cmd_variables_hint_title;
public static String dialog_connection_edit_wizard_metadata;
public static String dialog_connection_edit_wizard_metadata_description;
public static String dialog_connection_edit_wizard_resultset;
public static String dialog_connection_edit_wizard_resultset_description;
public static String dialog_connection_edit_wizard_binary;
public static String dialog_connection_edit_wizard_binary_description;
public static String dialog_connection_edit_wizard_data_format;
public static String dialog_connection_edit_wizard_data_format_description;
public static String dialog_connection_edit_wizard_presentation;
public static String dialog_connection_edit_wizard_presentation_description;
public static String dialog_connection_edit_wizard_sql_editor;
public static String dialog_connection_edit_wizard_sql_editor_description;
public static String dialog_connection_edit_wizard_sql_processing;
public static String dialog_connection_edit_wizard_sql_processing_description;
public static String dialog_connection_edit_wizard_conn_change_title;
public static String dialog_connection_edit_wizard_conn_change_question;
public static String dialog_connection_edit_wizard_lock_pwd_title;
public static String dialog_connection_edit_wizard_bad_pwd_title;
public static String dialog_connection_edit_wizard_bad_pwd_msg;
public static String dialog_connection_edit_wizard_error_md5_title;
public static String dialog_connection_edit_wizard_error_md5_msg;
// Connection edit
// Driver edit
public static String dialog_edit_driver_setting;
public static String dialog_edit_driver_type_label;
public static String dialog_edit_driver_embedded_label;
public static String dialog_edit_driver_description;
public static String dialog_edit_driver_edit_maven_title;
public static String dialog_edit_driver_edit_maven_group_id_label;
public static String dialog_edit_driver_edit_maven_artifact_id_label;
public static String dialog_edit_driver_edit_maven_classfier_label;
public static String dialog_edit_driver_edit_maven_version_label;
// Driver edit
static {
......
......@@ -948,8 +948,6 @@ pref_page_database_resultsets_label_fetch_size_tip = Should DBeaver use explicit
pref_page_database_resultsets_group_common = Common
pref_page_database_resultsets_label_switch_mode_on_rows = Switch to record/grid mode on single/multiple row(s)
pref_page_database_resultsets_label_show_column_description = Show column description in header
pref_page_database_resultsets_label_calc_column_width_by_values = Calculate column width by cell values
pref_page_database_resultsets_label_calc_column_width_by_values_tip = When calculating column width use only cell values.\nThis might be useful if you have tables with very long column names.
pref_page_database_resultsets_label_show_connection_name = Show connection name in status
pref_page_database_resultsets_label_structurize_complex_types = Structurize complex types
pref_page_database_resultsets_label_structurize_complex_types_tip = Visualize complex types (arrays, structures, maps) in results grid as separate columns
......@@ -1116,3 +1114,64 @@ pref_page_projects_settings_label_restart_require_refresh_global_settings = Rest
pref_page_sql_editor_checkbox_create_script_folders = Create script folders
## Preference/Properties ##
## Connection edit ##
dialog_connection_edit_title = Connection '{0}' configuration
dialog_connection_edit_wizard_conn_conf_network_link = Network settings (SSH, SSL, Proxy, ...)
dialog_connection_edit_wizard_general = General
dialog_connection_edit_wizard_general_bootstrap_query_title = Bootstrap SQL queries
dialog_connection_edit_wizard_general_bootstrap_query_sql_label = SQL Queries
dialog_connection_edit_wizard_general_bootstrap_query_sql_title = Enter SQL
dialog_connection_edit_wizard_general_bootstrap_query_ignore_error_lable = Ignore SQL errors
dialog_connection_edit_wizard_general_filter_save_button = Save
dialog_connection_edit_wizard_general_filter_remove_button = Remove
dialog_connection_edit_wizard_general_filter_save_label = Saved filter
dialog_connection_edit_wizard_general_filter_name_label = Name
dialog_connection_edit_wizard_general_filter_hint_text = You can use masks (%, _ and *) in filters
dialog_connection_edit_wizard_shell_cmd = Shell Commands
dialog_connection_edit_wizard_shell_cmd_pause_label = Pause after execute (ms)
dialog_connection_edit_wizard_shell_cmdp_pause_tooliti = Wait for specified amount of milliseconds after process spawn
dialog_connection_edit_wizard_shell_cmd_directory_label = Working directory
dialog_connection_edit_wizard_shell_cmd_directory_title = Working directory
dialog_connection_edit_wizard_shell_cmd_variables_hint_label = You can use variables in commands. Click to see the list.
dialog_connection_edit_wizard_shell_cmd_variables_hint_title = Variables
dialog_connection_edit_wizard_metadata = Metadata
dialog_connection_edit_wizard_metadata_description = Metadata reading preferences
dialog_connection_edit_wizard_resultset = Result Sets
dialog_connection_edit_wizard_resultset_description = Result Set preferences
dialog_connection_edit_wizard_binary = Binaries
dialog_connection_edit_wizard_binary_description = Binary data representation
dialog_connection_edit_wizard_data_format = Data Formatting
dialog_connection_edit_wizard_data_format_description = Data formatting preferences
dialog_connection_edit_wizard_presentation = Presentation
dialog_connection_edit_wizard_presentation_description = ResultSets UI & presentation
dialog_connection_edit_wizard_sql_editor = SQL Editor
dialog_connection_edit_wizard_sql_editor_description = SQL editor settings
dialog_connection_edit_wizard_sql_processing = SQL Processing
dialog_connection_edit_wizard_sql_processing_description = SQL processing settings
dialog_connection_edit_wizard_conn_change_title = Connection changed
dialog_connection_edit_wizard_conn_change_question = Connection '{0}' has been changed.\nDo you want to reconnect?
dialog_connection_edit_wizard_lock_pwd_title = Enter lock password
dialog_connection_edit_wizard_bad_pwd_title = Bad password
dialog_connection_edit_wizard_bad_pwd_msg = Password doesn't match
dialog_connection_edit_wizard_error_md5_title = Error making MD5
dialog_connection_edit_wizard_error_md5_msg =Can't generate password hash
## Connection edit ##
## Driver edit ##
dialog_edit_driver_type_label = Driver Type
dialog_edit_driver_embedded_label = Embedded
dialog_edit_driver_setting = Settings
dialog_edit_driver_description = Descriptions
dialog_edit_driver_edit_maven_title = Edit Maven Artifact
dialog_edit_driver_edit_maven_group_id_label = Group Id
dialog_edit_driver_edit_maven_artifact_id_label = Artifact Id
dialog_edit_driver_edit_maven_classfier_label = Classifier
dialog_edit_driver_edit_maven_version_label = Version
## Driver edit ##
......@@ -1118,3 +1118,63 @@ pref_page_projects_settings_label_not_store_resources_in_another_project = \u4E0
pref_page_projects_settings_label_restart_require_refresh_global_settings = \u66F4\u65B0\u901A\u7528\u8BBE\u7F6E\u540E\u8981\u6C42\u91CD\u542F
##Preference/Properties End
## Connection edit ##
dialog_connection_edit_title = \u8FDE\u63A5 '{0}' \u914D\u7F6E
dialog_connection_edit_wizard_conn_conf_network_link = \u7F51\u7EDC\u8BBE\u7F6E (SSH, SSL, Proxy, ...)
dialog_connection_edit_wizard_general = \u5E38\u89C4
dialog_connection_edit_wizard_general_bootstrap_query_title = \u542F\u52A8\u65F6 SQL \u67E5\u8BE2
dialog_connection_edit_wizard_general_bootstrap_query_sql_label = SQL \u67E5\u8BE2
dialog_connection_edit_wizard_general_bootstrap_query_sql_title = \u8F93\u5165 SQL
dialog_connection_edit_wizard_general_bootstrap_query_ignore_error_lable = \u5FFD\u7565 SQL \u9519\u8BEF
dialog_connection_edit_wizard_general_filter_save_button = \u4FDD\u5B58
dialog_connection_edit_wizard_general_filter_remove_button = \u79FB\u9664
dialog_connection_edit_wizard_general_filter_save_label = \u4FDD\u5B58\u7684\u8FC7\u6EE4
dialog_connection_edit_wizard_general_filter_name_label = \u540D\u79F0
dialog_connection_edit_wizard_general_filter_hint_text = \u4F60\u53EF\u4EE5\u5728\u8FC7\u6EE4\u4E2D\u4F7F\u7528\u63A9\u7801 (%, _ and *)
dialog_connection_edit_wizard_shell_cmd = Shell \u547D\u4EE4
dialog_connection_edit_wizard_shell_cmd_pause_label = \u6267\u884C\u540E\u6682\u505C (ms)
dialog_connection_edit_wizard_shell_cmdp_pause_tooliti = \u5728\u8FDB\u7A0B\u751F\u6210\u540E\u7B49\u5F85\u6307\u5B9A\u7684\u6BEB\u79D2\u6570
dialog_connection_edit_wizard_shell_cmd_directory_label = \u5DE5\u4F5C\u76EE\u5F55
dialog_connection_edit_wizard_shell_cmd_directory_title = \u5DE5\u4F5C\u76EE\u5F55
dialog_connection_edit_wizard_shell_cmd_variables_hint_label = \u4F60\u53EF\u4EE5\u5728\u547D\u4EE4\u4E2D\u4F7F\u7528\u53D8\u91CF\u3002\u5355\u51FB\u770B\u5217\u8868\u3002
dialog_connection_edit_wizard_shell_cmd_variables_hint_title = \u53D8\u91CF
dialog_connection_edit_wizard_metadata = \u5143\u6570\u636E
dialog_connection_edit_wizard_metadata_description = \u5143\u6570\u636E\u8BFB\u53D6\u504F\u597D
dialog_connection_edit_wizard_resultset = \u7ED3\u679C\u96C6
dialog_connection_edit_wizard_resultset_description = \u7ED3\u679C\u96C6\u504F\u597D
dialog_connection_edit_wizard_binary = \u4E8C\u8FDB\u5236
dialog_connection_edit_wizard_binary_description = \u4E8C\u8FDB\u5236\u6570\u636E\u8868\u793A
dialog_connection_edit_wizard_data_format = \u6570\u636E\u683C\u5F0F\u5316
dialog_connection_edit_wizard_data_format_description = \u6570\u636E\u683C\u5F0F\u5316\u504F\u597D
dialog_connection_edit_wizard_presentation = \u5C55\u793A
dialog_connection_edit_wizard_presentation_description = \u7ED3\u679C\u96C6\u7528\u6237\u754C\u9762\u548C\u5C55\u793A
dialog_connection_edit_wizard_sql_editor = SQL \u7F16\u8F91\u5668
dialog_connection_edit_wizard_sql_editor_description = SQL \u7F16\u8F91\u5668\u8BBE\u7F6E
dialog_connection_edit_wizard_sql_processing = SQL \u5904\u7406
dialog_connection_edit_wizard_sql_processing_description = SQL \u5904\u7406\u8BBE\u7F6E
dialog_connection_edit_wizard_conn_change_title = \u8FDE\u63A5\u53D8\u66F4
dialog_connection_edit_wizard_conn_change_question = \u8FDE\u63A5 '{0}' \u5DF2\u7ECF\u88AB\u66F4\u6539\u3002\n\u4F60\u60F3\u91CD\u65B0\u8FDE\u63A5\u5417?
dialog_connection_edit_wizard_lock_pwd_title = \u8BF7\u8F93\u5165\u9501\u5BC6\u7801
dialog_connection_edit_wizard_bad_pwd_title = \u9519\u8BEF\u7684\u5BC6\u7801
dialog_connection_edit_wizard_bad_pwd_msg = \u5BC6\u7801\u4E0D\u5339\u914D
dialog_connection_edit_wizard_error_md5_title = \u9519\u8BEF\u751F\u6210 MD5
dialog_connection_edit_wizard_error_md5_msg = \u4E0D\u80FD\u751F\u6210\u5BC6\u7801\u54C8\u5E0C
## Connection edit ##
## Driver edit ##
dialog_edit_driver_type_label = \u9A71\u52A8\u7C7B\u578B
dialog_edit_driver_embedded_label = \u5D4C\u5165
dialog_edit_driver_setting = \u8BBE\u7F6E
dialog_edit_driver_description = \u63CF\u8FF0
dialog_edit_driver_edit_maven_title = \u7F16\u8F91 Maven Artifact
dialog_edit_driver_edit_maven_group_id_label = \u7EC4 Id
dialog_edit_driver_edit_maven_artifact_id_label = Artifact Id
dialog_edit_driver_edit_maven_classfier_label = Classifier
dialog_edit_driver_edit_maven_version_label = \u7248\u672C
## Driver edit ##
......@@ -24,6 +24,7 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Layout;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.dialogs.EditTextDialog;
import org.jkiss.dbeaver.utils.GeneralUtils;
......@@ -38,7 +39,7 @@ public class VariablesHintLabel
{
String varsText = GeneralUtils.generateVariablesLegend(vars);
CLabel infoLabel = UIUtils.createInfoLabel(parent, "You can use variables in commands. Click to see the list.");
CLabel infoLabel = UIUtils.createInfoLabel(parent, CoreMessages.dialog_connection_edit_wizard_shell_cmd_variables_hint_label);
Layout layout = parent.getLayout();
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
if (layout instanceof GridLayout) {
......@@ -49,7 +50,7 @@ public class VariablesHintLabel
infoLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
new EditTextDialog(parent.getShell(), "Variables", varsText, true).open();
new EditTextDialog(parent.getShell(), CoreMessages.dialog_connection_edit_wizard_shell_cmd_variables_hint_title, varsText, true).open();
}
});
infoLabel.setToolTipText(varsText);
......
......@@ -104,7 +104,7 @@ public abstract class ConnectionPageAbstract extends DialogPage implements IData
if (!site.isNew() && !site.getDriver().isEmbedded()) {
Link netConfigLink = new Link(panel, SWT.NONE);
netConfigLink.setText("<a>Network settings (SSH, SSL, Proxy, ...)</a>");
netConfigLink.setText("<a>" + CoreMessages.dialog_connection_edit_wizard_conn_conf_network_link + "</a>");
netConfigLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
......
/*
* 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.ui.dialogs.connection;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.*;
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.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.connection.DBPDriver;
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.dialogs.ActiveWizardPage;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeControl;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeViewer;
import java.util.List;
/**
* Driver selection page
*/
class ConnectionPageDriver extends ActiveWizardPage implements ISelectionChangedListener, IDoubleClickListener {
private NewConnectionWizard wizard;
private DriverDescriptor selectedDriver;
private IProject connectionProject;
ConnectionPageDriver(NewConnectionWizard wizard)
{
super("newConnectionDrivers");
this.wizard = wizard;
setTitle(CoreMessages.dialog_new_connection_wizard_start_title);
setDescription(CoreMessages.dialog_new_connection_wizard_start_description);
}
@Override
public void createControl(Composite parent)
{
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
DriverTreeControl driverTreeControl = new DriverTreeControl(placeholder, this, wizard.getAvailableProvides(), true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
driverTreeControl.setLayoutData(gd);
setControl(placeholder);
Group projectGroup = UIUtils.createControlGroup(placeholder, "Project", 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT);
final Combo projectCombo = new Combo(projectGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
projectCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final List<IProject> projects = DBeaverCore.getInstance().getLiveProjects();
if (!projects.isEmpty()) {
final IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
for (IProject project : projects) {
projectCombo.add(project.getName());
}
if (activeProject == null) {
projectCombo.select(0);
connectionProject = projects.get(0);
} else {
connectionProject = activeProject;
projectCombo.setText(activeProject.getName());
}
projectCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectionProject = projects.get(projectCombo.getSelectionIndex());
}
});
if (projects.size() < 2) {
projectCombo.setEnabled(false);
}
} else {
setErrorMessage("You need to create a project first");
}
UIUtils.setHelp(placeholder, IHelpContextIds.CTX_CON_WIZARD_DRIVER);
}
public DriverDescriptor getSelectedDriver()
{
return selectedDriver;
}
public IProject getConnectionProject() {
return connectionProject;
}
@Override
public boolean canFlipToNextPage()
{
return this.connectionProject != null && this.selectedDriver != null;
}
@Override
public boolean isPageComplete()
{
return canFlipToNextPage();
}
@Override
public void selectionChanged(SelectionChangedEvent event)
{
this.selectedDriver = null;
this.setMessage("");
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof DBPDriver) {
selectedDriver = (DriverDescriptor) selectedObject;
this.setMessage(selectedDriver.getDescription());
} else if (selectedObject instanceof DataSourceProviderDescriptor) {
this.setMessage(((DataSourceProviderDescriptor) selectedObject).getDescription());
} else if (selectedObject instanceof DriverTreeViewer.DriverCategory) {
this.setMessage(((DriverTreeViewer.DriverCategory) selectedObject).getName() + " drivers");
}
}
getWizard().getContainer().updateButtons();
getWizard().getContainer().updateMessage();
}
@Override
public void doubleClick(DoubleClickEvent event)
{
if (selectedDriver != null) {
wizard.getContainer().showPage(wizard.getNextPage(this));
}
}
@Override
public void activatePage()
{
}
@Override
public void deactivatePage()
{
}
/*
* 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.ui.dialogs.connection;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.viewers.*;
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.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverCore;
import org.jkiss.dbeaver.model.connection.DBPDriver;
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.dialogs.ActiveWizardPage;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeControl;
import org.jkiss.dbeaver.ui.dialogs.driver.DriverTreeViewer;
import java.util.List;
/**
* Driver selection page
* step1
*/
class ConnectionPageDriver extends ActiveWizardPage implements ISelectionChangedListener, IDoubleClickListener {
private NewConnectionWizard wizard;
private DriverDescriptor selectedDriver;
private IProject connectionProject;
ConnectionPageDriver(NewConnectionWizard wizard)
{
super("newConnectionDrivers");
this.wizard = wizard;
setTitle(CoreMessages.dialog_new_connection_wizard_start_title);
setDescription(CoreMessages.dialog_new_connection_wizard_start_description);
}
@Override
public void createControl(Composite parent)
{
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
DriverTreeControl driverTreeControl = new DriverTreeControl(placeholder, this, wizard.getAvailableProvides(), true);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
driverTreeControl.setLayoutData(gd);
setControl(placeholder);
Group projectGroup = UIUtils.createControlGroup(placeholder, CoreMessages.dialog_connection_driver_project, 1, GridData.FILL_HORIZONTAL, SWT.DEFAULT);
final Combo projectCombo = new Combo(projectGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
projectCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final List<IProject> projects = DBeaverCore.getInstance().getLiveProjects();
if (!projects.isEmpty()) {
final IProject activeProject = DBeaverCore.getInstance().getProjectRegistry().getActiveProject();
for (IProject project : projects) {
projectCombo.add(project.getName());
}
if (activeProject == null) {
projectCombo.select(0);
connectionProject = projects.get(0);
} else {
connectionProject = activeProject;
projectCombo.setText(activeProject.getName());
}
projectCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectionProject = projects.get(projectCombo.getSelectionIndex());
}
});
if (projects.size() < 2) {
projectCombo.setEnabled(false);
}
} else {
setErrorMessage("You need to create a project first");
}
UIUtils.setHelp(placeholder, IHelpContextIds.CTX_CON_WIZARD_DRIVER);
}
public DriverDescriptor getSelectedDriver()
{
return selectedDriver;
}
public IProject getConnectionProject() {
return connectionProject;
}
@Override
public boolean canFlipToNextPage()
{
return this.connectionProject != null && this.selectedDriver != null;
}
@Override
public boolean isPageComplete()
{
return canFlipToNextPage();
}
@Override
public void selectionChanged(SelectionChangedEvent event)
{
this.selectedDriver = null;
this.setMessage("");
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
Object selectedObject = ((IStructuredSelection) selection).getFirstElement();
if (selectedObject instanceof DBPDriver) {
selectedDriver = (DriverDescriptor) selectedObject;
this.setMessage(selectedDriver.getDescription());
} else if (selectedObject instanceof DataSourceProviderDescriptor) {
this.setMessage(((DataSourceProviderDescriptor) selectedObject).getDescription());
} else if (selectedObject instanceof DriverTreeViewer.DriverCategory) {
this.setMessage(((DriverTreeViewer.DriverCategory) selectedObject).getName() + " drivers");
}
}
getWizard().getContainer().updateButtons();
getWizard().getContainer().updateMessage();
}
@Override
public void doubleClick(DoubleClickEvent event)
{
if (selectedDriver != null) {
wizard.getContainer().showPage(wizard.getNextPage(this));
}
}
@Override
public void activatePage()
{
}
@Override
public void deactivatePage()
{
}
}
\ No newline at end of file
......@@ -78,7 +78,7 @@ public class ConnectionPageNetwork extends ActiveWizardPage<ConnectionWizard> {
{
super(PAGE_NAME);
this.wizard = wizard;
setTitle("Network");
setTitle(CoreMessages.dialog_connection_network_title);
setDescription(CoreMessages.dialog_tunnel_title);
}
......
......@@ -45,8 +45,8 @@ public class DriverPropertiesDialogPage extends ConnectionPageAbstract
public DriverPropertiesDialogPage(ConnectionPageAbstract hostPage)
{
this.hostPage = hostPage;
setTitle("Driver properties");
setDescription("JDBC driver properties");
setTitle(CoreMessages.dialog_setting_connection_driver_properties_title);
setDescription(CoreMessages.dialog_setting_connection_driver_properties_description);
}
@Override
......
......@@ -54,11 +54,11 @@ public class EditBootstrapQueriesDialog extends HelpEnabledDialog {
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText("Bootstrap SQL queries");
getShell().setText(CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_title);
Composite composite = (Composite) super.createDialogArea(parent);
Group group = UIUtils.createControlGroup(composite, "SQL Queries", 2, GridData.FILL_BOTH, 0);
Group group = UIUtils.createControlGroup(composite, CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_sql_label, 2, GridData.FILL_BOTH, 0);
queriesTable = new Table(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
final GridData gd = new GridData(GridData.FILL_BOTH);
......@@ -95,7 +95,7 @@ public class EditBootstrapQueriesDialog extends HelpEnabledDialog {
@Override
public void widgetSelected(SelectionEvent e) {
tableEditor.closeEditor();
String sql = EditTextDialog.editText(getShell(), "Enter SQL", "");
String sql = EditTextDialog.editText(getShell(), CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_sql_title, "");
if (sql != null) {
TableItem newItem = new TableItem(queriesTable, SWT.LEFT);
newItem.setText(sql);
......@@ -129,7 +129,7 @@ public class EditBootstrapQueriesDialog extends HelpEnabledDialog {
}
});
ignoreErrorButton = UIUtils.createCheckbox(composite, "Ignore SQL errors", ignoreErrors);
ignoreErrorButton = UIUtils.createCheckbox(composite, CoreMessages.dialog_connection_edit_wizard_general_bootstrap_query_ignore_error_lable, ignoreErrors);
new VariablesHintLabel(composite, DataSourceDescriptor.CONNECT_VARIABLES);
UIUtils.packColumns(queriesTable, true);
......
......@@ -17,6 +17,7 @@
package org.jkiss.dbeaver.ui.dialogs.connection;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
......@@ -57,7 +58,7 @@ public class EditConnectionDialog extends MultiPageWizardDialog
{
Control contents = super.createContents(parent);
DataSourceDescriptor activeDataSource = getWizard().getActiveDataSource();
getShell().setText("Connection '" + activeDataSource.getName() + "' configuration");
getShell().setText(NLS.bind( CoreMessages.dialog_connection_edit_title, activeDataSource.getName()));
getShell().setImage(DBeaverIcons.getImage(activeDataSource.getObjectImage()));
return contents;
}
......
......@@ -102,11 +102,11 @@ public class EditObjectFilterDialog extends HelpEnabledDialog {
includeTable = createEditableList(CoreMessages.dialog_filter_list_include, filter.getInclude());
excludeTable = createEditableList(CoreMessages.dialog_filter_list_exclude, filter.getExclude());
UIUtils.createInfoLabel(blockControl, "You can use masks (%, _ and *) in filters");
UIUtils.createInfoLabel(blockControl, CoreMessages.dialog_connection_edit_wizard_general_filter_hint_text);
{
Group sfGroup = UIUtils.createControlGroup(composite, "Saved filter", 4, GridData.FILL_HORIZONTAL, 0);
namesCombo = UIUtils.createLabelCombo(sfGroup, "Name", SWT.DROP_DOWN);
Group sfGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_connection_edit_wizard_general_filter_save_label, 4, GridData.FILL_HORIZONTAL, 0);
namesCombo = UIUtils.createLabelCombo(sfGroup, CoreMessages.dialog_connection_edit_wizard_general_filter_name_label, SWT.DROP_DOWN);
namesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
namesCombo.add(NULL_FILTER_NAME);
......@@ -126,14 +126,14 @@ public class EditObjectFilterDialog extends HelpEnabledDialog {
}
});
Button saveButton = UIUtils.createPushButton(sfGroup, "Save", null);
Button saveButton = UIUtils.createPushButton(sfGroup, CoreMessages.dialog_connection_edit_wizard_general_filter_save_button, null);
saveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
saveConfigurations();
}
});
Button removeButton = UIUtils.createPushButton(sfGroup, "Remove", null);
Button removeButton = UIUtils.createPushButton(sfGroup, CoreMessages.dialog_connection_edit_wizard_general_filter_remove_button, null);
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
......
......@@ -45,7 +45,8 @@ import java.util.Map;
*/
public class EditShellCommandsDialogPage extends ActiveWizardPage<ConnectionWizard> {
private Text commandText;
private static final String CoreMessagesdialog_connection_edit_wizard_shell_cmd_directory_title = null;
private Text commandText;
private Button showProcessCheck;
private Button waitFinishCheck;
private Spinner waitFinishTimeoutMs;
......@@ -60,7 +61,7 @@ public class EditShellCommandsDialogPage extends ActiveWizardPage<ConnectionWiza
protected EditShellCommandsDialogPage(DataSourceDescriptor dataSource)
{
super(CoreMessages.dialog_connection_events_title);
setTitle("Shell Commands");
setTitle(CoreMessages.dialog_connection_edit_wizard_shell_cmd);
setDescription(CoreMessages.dialog_connection_events_title);
setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.EVENT));
for (DBPConnectionEventType eventType : DBPConnectionEventType.values()) {
......@@ -154,11 +155,11 @@ public class EditShellCommandsDialogPage extends ActiveWizardPage<ConnectionWiza
Composite pauseComposite = UIUtils.createPlaceholder(detailsGroup, 2, 5);
pauseComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
pauseAfterExecute = UIUtils.createLabelSpinner(pauseComposite, "Pause after execute (ms)", "Wait for specified amount of milliseconds after process spawn", 0, 0, Integer.MAX_VALUE);
pauseAfterExecute = UIUtils.createLabelSpinner(pauseComposite, CoreMessages.dialog_connection_edit_wizard_shell_cmd_pause_label, CoreMessages.dialog_connection_edit_wizard_shell_cmd_pause_tooltip, 0, 0, Integer.MAX_VALUE);
pauseAfterExecute.addSelectionListener(eventEditAdapter);
UIUtils.createControlLabel(pauseComposite, "Working directory");
workingDirectory = new TextWithOpenFolder(pauseComposite, "Working directory");
UIUtils.createControlLabel(pauseComposite, CoreMessages.dialog_connection_edit_wizard_shell_cmd_directory_label);
workingDirectory = new TextWithOpenFolder(pauseComposite, CoreMessagesdialog_connection_edit_wizard_shell_cmd_directory_title);
workingDirectory.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
workingDirectory.getTextControl().addModifyListener(new ModifyListener() {
@Override
......
......@@ -25,6 +25,7 @@ import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.registry.maven.MavenArtifactReference;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils;
......@@ -59,7 +60,7 @@ class EditMavenArtifactDialog extends Dialog
@Override
protected Control createDialogArea(Composite parent)
{
getShell().setText("Edit Maven Artifact");
getShell().setText(CoreMessages.dialog_edit_driver_edit_maven_title);
Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout)composite.getLayout()).numColumns = 2;
......@@ -67,14 +68,14 @@ class EditMavenArtifactDialog extends Dialog
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.widthHint = 200;
groupText = UIUtils.createLabelText(composite, "Group Id", artifact.getGroupId());
groupText = UIUtils.createLabelText(composite, CoreMessages.dialog_edit_driver_edit_maven_group_id_label, artifact.getGroupId());
groupText.setLayoutData(gd);
artifactText = UIUtils.createLabelText(composite, "Artifact Id", artifact.getArtifactId());
artifactText = UIUtils.createLabelText(composite, CoreMessages.dialog_edit_driver_edit_maven_artifact_id_label, artifact.getArtifactId());
artifactText.setLayoutData(gd);
classifierText = UIUtils.createLabelText(composite, "Classifier", CommonUtils.notEmpty(artifact.getClassifier()));
classifierText = UIUtils.createLabelText(composite, CoreMessages.dialog_edit_driver_edit_maven_classfier_label, CommonUtils.notEmpty(artifact.getClassifier()));
classifierText.setLayoutData(gd);
versionText = UIUtils.createLabelCombo(composite, "Version", SWT.DROP_DOWN | SWT.BORDER);
versionText = UIUtils.createLabelCombo(composite, CoreMessages.dialog_edit_driver_edit_maven_version_label, SWT.DROP_DOWN | SWT.BORDER);
versionText.setLayoutData(gd);
versionText.setText(artifact.getVersion());
......
/*
* 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.ui;
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;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.ext.postgresql.PostgreActivator;
import org.jkiss.dbeaver.ext.postgresql.PostgreConstants;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.ui.ICompositeDialogPage;
import org.jkiss.dbeaver.ui.UIUtils;
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;
import java.util.Locale;
/**
* PostgreConnectionPage
*/
public class PostgreConnectionPage extends ConnectionPageAbstract implements ICompositeDialogPage
{
private Text hostText;
private Text portText;
private Text dbText;
private Text usernameText;
private Text passwordText;
private ClientHomesSelector homesSelector;
private Button hideNonDefault;
private boolean activated = false;
private static ImageDescriptor LOGO_IMG = PostgreActivator.getImageDescriptor("icons/postgresql_logo.png");
@Override
public void dispose()
{
super.dispose();
}
@Override
public void createControl(Composite composite)
{
//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) {
saveSettings(site.getActiveDataSource());
site.updateButtons();
}
}
};
Composite addrGroup = UIUtils.createPlaceholder(composite, 4);
GridLayout gl = new GridLayout(4, false);
addrGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
addrGroup.setLayoutData(gd);
Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host");
hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
hostText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
hostText.setLayoutData(gd);
hostText.addModifyListener(textListener);
Label portLabel = UIUtils.createControlLabel(addrGroup, "Port");
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
portLabel.setLayoutData(gd);
portText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = 40;
portText.setLayoutData(gd);
portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
portText.addModifyListener(textListener);
Label dbLabel = UIUtils.createControlLabel(addrGroup, "Database");
dbLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
dbText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 3;
dbText.setLayoutData(gd);
dbText.addModifyListener(textListener);
Label usernameLabel = UIUtils.createControlLabel(addrGroup, "User");
usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
usernameText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
usernameText.setLayoutData(gd);
usernameText.addModifyListener(textListener);
Label passwordLabel = UIUtils.createControlLabel(addrGroup, "Password");
passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
passwordText.setLayoutData(gd);
passwordText.addModifyListener(textListener);
{
Composite buttonsGroup = new Composite(addrGroup, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
buttonsGroup.setLayoutData(gd);
buttonsGroup.setLayout(new GridLayout(2, false));
homesSelector = new ClientHomesSelector(buttonsGroup, SWT.NONE, "Local Client");
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
homesSelector.getPanel().setLayoutData(gd);
}
{
Group secureGroup = new Group(addrGroup, SWT.NONE);
secureGroup.setText("Settings");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
secureGroup.setLayoutData(gd);
secureGroup.setLayout(new GridLayout(2, false));
hideNonDefault = UIUtils.createLabelCheckbox(secureGroup, "Show non-default databases", true);
}
createDriverPanel(addrGroup);
setControl(addrGroup);
}
@Override
public boolean isComplete()
{
return hostText != null && portText != null &&
!CommonUtils.isEmpty(hostText.getText()) &&
!CommonUtils.isEmpty(portText.getText());
}
@Override
public void loadSettings()
{
super.loadSettings();
if (!activated) {
setImageDescriptor(LOGO_IMG);
}
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
if (hostText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
hostText.setText(connectionInfo.getHostName());
} else {
hostText.setText(PostgreConstants.DEFAULT_HOST);
}
}
if (portText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(String.valueOf(connectionInfo.getHostPort()));
} else if (site.getDriver().getDefaultPort() != null) {
portText.setText(site.getDriver().getDefaultPort());
} else {
portText.setText("");
}
}
if (dbText != null) {
String databaseName = connectionInfo.getDatabaseName();
if (CommonUtils.isEmpty(databaseName) && getSite().isNew()) {
databaseName = PostgreConstants.DEFAULT_DATABASE;
}
dbText.setText(databaseName);
}
if (usernameText != null) {
usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
final boolean showNDD = CommonUtils.toBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB));
hideNonDefault.setSelection(showNDD);
activated = true;
}
@Override
public void saveSettings(DBPDataSourceContainer dataSource)
{
DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
if (hostText != null) {
connectionInfo.setHostName(hostText.getText().trim());
}
if (portText != null) {
connectionInfo.setHostPort(portText.getText().trim());
}
if (dbText != null) {
connectionInfo.setDatabaseName(dbText.getText().trim());
}
if (usernameText != null) {
connectionInfo.setUserName(usernameText.getText().trim());
}
if (passwordText != null) {
connectionInfo.setUserPassword(passwordText.getText());
}
if (homesSelector != null) {
connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
}
connectionInfo.setProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB, String.valueOf(hideNonDefault.getSelection()));
super.saveSettings(dataSource);
}
@Override
public IDialogPage[] getSubPages()
{
return new IDialogPage[] {
new DriverPropertiesDialogPage(this)
};
}
}
/*
* 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.ui;
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;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.ext.postgresql.PostgreActivator;
import org.jkiss.dbeaver.ext.postgresql.PostgreConstants;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.ui.ICompositeDialogPage;
import org.jkiss.dbeaver.ui.UIUtils;
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;
import java.util.Locale;
/**
* PostgreConnectionPage
*/
public class PostgreConnectionPage extends ConnectionPageAbstract implements ICompositeDialogPage
{
private Text hostText;
private Text portText;
private Text dbText;
private Text usernameText;
private Text passwordText;
private ClientHomesSelector homesSelector;
private Button hideNonDefault;
private boolean activated = false;
private static ImageDescriptor LOGO_IMG = PostgreActivator.getImageDescriptor("icons/postgresql_logo.png");
@Override
public void dispose()
{
super.dispose();
}
@Override
public void createControl(Composite composite)
{
//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) {
saveSettings(site.getActiveDataSource());
site.updateButtons();
}
}
};
Composite addrGroup = UIUtils.createPlaceholder(composite, 4);
GridLayout gl = new GridLayout(4, false);
addrGroup.setLayout(gl);
GridData gd = new GridData(GridData.FILL_BOTH);
addrGroup.setLayoutData(gd);
Label hostLabel = UIUtils.createControlLabel(addrGroup, CoreMessages.dialog_setting_connection_host);
hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
hostText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
hostText.setLayoutData(gd);
hostText.addModifyListener(textListener);
Label portLabel = UIUtils.createControlLabel(addrGroup, CoreMessages.dialog_setting_connection_port);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
portLabel.setLayoutData(gd);
portText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint = 40;
portText.setLayoutData(gd);
portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
portText.addModifyListener(textListener);
Label dbLabel = UIUtils.createControlLabel(addrGroup, CoreMessages.dialog_setting_connection_database);
dbLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
dbText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = 3;
dbText.setLayoutData(gd);
dbText.addModifyListener(textListener);
Label usernameLabel = UIUtils.createControlLabel(addrGroup, CoreMessages.dialog_setting_connection_user);
usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
usernameText = new Text(addrGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
usernameText.setLayoutData(gd);
usernameText.addModifyListener(textListener);
Label passwordLabel = UIUtils.createControlLabel(addrGroup, CoreMessages.dialog_setting_connection_password);
passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.grabExcessHorizontalSpace = true;
passwordText.setLayoutData(gd);
passwordText.addModifyListener(textListener);
{
Composite buttonsGroup = new Composite(addrGroup, SWT.NONE);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
buttonsGroup.setLayoutData(gd);
buttonsGroup.setLayout(new GridLayout(2, false));
homesSelector = new ClientHomesSelector(buttonsGroup, SWT.NONE, CoreMessages.dialog_setting_connection_localClient);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
homesSelector.getPanel().setLayoutData(gd);
}
{
Group secureGroup = new Group(addrGroup, SWT.NONE);
secureGroup.setText(CoreMessages.dialog_setting_connection_settings);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
secureGroup.setLayoutData(gd);
secureGroup.setLayout(new GridLayout(2, false));
hideNonDefault = UIUtils.createLabelCheckbox(secureGroup, CoreMessages.dialog_setting_connection_nondefaultDatabase, true);
}
createDriverPanel(addrGroup);
setControl(addrGroup);
}
@Override
public boolean isComplete()
{
return hostText != null && portText != null &&
!CommonUtils.isEmpty(hostText.getText()) &&
!CommonUtils.isEmpty(portText.getText());
}
@Override
public void loadSettings()
{
super.loadSettings();
if (!activated) {
setImageDescriptor(LOGO_IMG);
}
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
if (hostText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
hostText.setText(connectionInfo.getHostName());
} else {
hostText.setText(PostgreConstants.DEFAULT_HOST);
}
}
if (portText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(String.valueOf(connectionInfo.getHostPort()));
} else if (site.getDriver().getDefaultPort() != null) {
portText.setText(site.getDriver().getDefaultPort());
} else {
portText.setText("");
}
}
if (dbText != null) {
String databaseName = connectionInfo.getDatabaseName();
if (CommonUtils.isEmpty(databaseName) && getSite().isNew()) {
databaseName = PostgreConstants.DEFAULT_DATABASE;
}
dbText.setText(databaseName);
}
if (usernameText != null) {
usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
final boolean showNDD = CommonUtils.toBoolean(connectionInfo.getProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB));
hideNonDefault.setSelection(showNDD);
activated = true;
}
@Override
public void saveSettings(DBPDataSourceContainer dataSource)
{
DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
if (hostText != null) {
connectionInfo.setHostName(hostText.getText().trim());
}
if (portText != null) {
connectionInfo.setHostPort(portText.getText().trim());
}
if (dbText != null) {
connectionInfo.setDatabaseName(dbText.getText().trim());
}
if (usernameText != null) {
connectionInfo.setUserName(usernameText.getText().trim());
}
if (passwordText != null) {
connectionInfo.setUserPassword(passwordText.getText());
}
if (homesSelector != null) {
connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
}
connectionInfo.setProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB, String.valueOf(hideNonDefault.getSelection()));
super.saveSettings(dataSource);
}
@Override
public IDialogPage[] getSubPages()
{
return new IDialogPage[] {
new DriverPropertiesDialogPage(this)
};
}
}
/*
* 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.ui;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ext.postgresql.PostgreConstants;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.registry.driver.DriverClassFindJob;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.TextWithOpen;
import org.jkiss.dbeaver.ui.controls.TextWithOpenFile;
import org.jkiss.dbeaver.ui.dialogs.net.SSLConfiguratorAbstractUI;
import org.jkiss.utils.CommonUtils;
/**
* PostgreSSLConfigurator
*/
public class PostgreSSLConfigurator extends SSLConfiguratorAbstractUI
{
public static final String[] SSL_MODES = {"","disable","allow","prefer","require","verify-ca","verify-full"};
private TextWithOpen rootCertText;
private TextWithOpen clientCertText;
private TextWithOpen clientKeyText;
private Combo sslModeCombo;
private Combo sslFactoryCombo;
@Override
public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 200;
composite.setLayoutData(gd);
{
Group certGroup = UIUtils.createControlGroup(composite, "Certificates", 2, GridData.FILL_HORIZONTAL, -1);
UIUtils.createControlLabel(certGroup, "Root certificate");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
rootCertText = new TextWithOpenFile(certGroup, "CA Certificate", new String[]{"*.*", "*.crt", "*.cert", "*.pem", "*"});
rootCertText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createControlLabel(certGroup, "SSL certificate");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
clientCertText = new TextWithOpenFile(certGroup, "SSL Certificate", new String[]{"*.*", "*.cert", "*.pem", "*"});
clientCertText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createControlLabel(certGroup, "SSL certificate key");
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
clientKeyText = new TextWithOpenFile(certGroup, "SSL Certificate", new String[]{"*.*", "*.cert", "*.pem", "*"});
clientKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
{
Group advGroup = UIUtils.createControlGroup(composite, "Advanced", 2, GridData.FILL_HORIZONTAL, -1);
sslModeCombo = UIUtils.createLabelCombo(advGroup, "SSL mode", SWT.READ_ONLY | SWT.DROP_DOWN);
sslModeCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
for (String mode : SSL_MODES) {
sslModeCombo.add(mode);
}
sslFactoryCombo = UIUtils.createLabelCombo(advGroup, "SSL Factory", SWT.DROP_DOWN);
}
}
@Override
public void loadSettings(final DBWHandlerConfiguration configuration) {
clientCertText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_CLIENT_CERT)));
clientKeyText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_CLIENT_KEY)));
rootCertText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_ROOT_CERT)));
UIUtils.setComboSelection(sslModeCombo, CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_MODE)));
final Job resolveJob = new Job("Find factories") {
{
setUser(true);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
final DriverClassFindJob finder = new DriverClassFindJob(
configuration.getDriver(),
"javax/net/ssl/SSLSocketFactory",
false);
finder.run(monitor);
DBeaverUI.syncExec(new Runnable() {
@Override
public void run() {
for (String cn : finder.getDriverClassNames()) {
sslFactoryCombo.add(cn);
}
final String factoryValue = configuration.getProperties().get(PostgreConstants.PROP_SSL_FACTORY);
if (!CommonUtils.isEmpty(factoryValue)) {
sslFactoryCombo.setText(factoryValue);
}
}
});
return Status.OK_STATUS;
}
};
resolveJob.schedule();
}
@Override
public void saveSettings(DBWHandlerConfiguration configuration) {
configuration.getProperties().put(PostgreConstants.PROP_SSL_ROOT_CERT, rootCertText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_CLIENT_CERT, clientCertText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_CLIENT_KEY, clientKeyText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_MODE, sslModeCombo.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_FACTORY, sslFactoryCombo.getText());
}
}
/*
* 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.ui;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.DBeaverUI;
import org.jkiss.dbeaver.ext.postgresql.PostgreConstants;
import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
import org.jkiss.dbeaver.registry.driver.DriverClassFindJob;
import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.dbeaver.ui.controls.TextWithOpen;
import org.jkiss.dbeaver.ui.controls.TextWithOpenFile;
import org.jkiss.dbeaver.ui.dialogs.net.SSLConfiguratorAbstractUI;
import org.jkiss.utils.CommonUtils;
/**
* PostgreSSLConfigurator
*/
public class PostgreSSLConfigurator extends SSLConfiguratorAbstractUI
{
public static final String[] SSL_MODES = {"","disable","allow","prefer","require","verify-ca","verify-full"};
private TextWithOpen rootCertText;
private TextWithOpen clientCertText;
private TextWithOpen clientKeyText;
private Combo sslModeCombo;
private Combo sslFactoryCombo;
@Override
public void createControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
GridData gd = new GridData(GridData.FILL_BOTH);
gd.minimumHeight = 200;
composite.setLayoutData(gd);
{
Group certGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_connection_network_postgres_ssl_certificates, 2, GridData.FILL_HORIZONTAL, -1);
UIUtils.createControlLabel(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_root);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
rootCertText = new TextWithOpenFile(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_ca, new String[]{"*.*", "*.crt", "*.cert", "*.pem", "*"});
rootCertText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createControlLabel(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_ssl);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
clientCertText = new TextWithOpenFile(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_ssl, new String[]{"*.*", "*.cert", "*.pem", "*"});
clientCertText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
UIUtils.createControlLabel(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_ssl_key);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.minimumWidth = 130;
clientKeyText = new TextWithOpenFile(certGroup, CoreMessages.dialog_connection_network_postgres_ssl_certificates_ssl, new String[]{"*.*", "*.cert", "*.pem", "*"});
clientKeyText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
{
Group advGroup = UIUtils.createControlGroup(composite, CoreMessages.dialog_connection_network_postgres_ssl_advanced, 2, GridData.FILL_HORIZONTAL, -1);
sslModeCombo = UIUtils.createLabelCombo(advGroup, CoreMessages.dialog_connection_network_postgres_ssl_advanced_ssl_mode, SWT.READ_ONLY | SWT.DROP_DOWN);
sslModeCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
for (String mode : SSL_MODES) {
sslModeCombo.add(mode);
}
sslFactoryCombo = UIUtils.createLabelCombo(advGroup, CoreMessages.dialog_connection_network_postgres_ssl_advanced_ssl_factory, SWT.DROP_DOWN);
}
}
@Override
public void loadSettings(final DBWHandlerConfiguration configuration) {
clientCertText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_CLIENT_CERT)));
clientKeyText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_CLIENT_KEY)));
rootCertText.setText(CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_ROOT_CERT)));
UIUtils.setComboSelection(sslModeCombo, CommonUtils.notEmpty(configuration.getProperties().get(PostgreConstants.PROP_SSL_MODE)));
final Job resolveJob = new Job("Find factories") {
{
setUser(true);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
final DriverClassFindJob finder = new DriverClassFindJob(
configuration.getDriver(),
"javax/net/ssl/SSLSocketFactory",
false);
finder.run(monitor);
DBeaverUI.syncExec(new Runnable() {
@Override
public void run() {
for (String cn : finder.getDriverClassNames()) {
sslFactoryCombo.add(cn);
}
final String factoryValue = configuration.getProperties().get(PostgreConstants.PROP_SSL_FACTORY);
if (!CommonUtils.isEmpty(factoryValue)) {
sslFactoryCombo.setText(factoryValue);
}
}
});
return Status.OK_STATUS;
}
};
resolveJob.schedule();
}
@Override
public void saveSettings(DBWHandlerConfiguration configuration) {
configuration.getProperties().put(PostgreConstants.PROP_SSL_ROOT_CERT, rootCertText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_CLIENT_CERT, clientCertText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_CLIENT_KEY, clientKeyText.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_MODE, sslModeCombo.getText());
configuration.getProperties().put(PostgreConstants.PROP_SSL_FACTORY, sslFactoryCombo.getText());
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册