提交 b6681ea6 编写于 作者: S Serge Rider

#3717 MySQL: server timezone selector

上级 24ae171c
dialog.connection.header=MySQL Connection Settings dialog.connection.header=Connection Settings
tree.databases.node.name=Databases tree.databases.node.name=Databases
tree.database.node.name=Database tree.database.node.name=Database
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package org.jkiss.dbeaver.ext.mysql; package org.jkiss.dbeaver.ext.mysql;
import org.jkiss.dbeaver.model.DBConstants;
import org.jkiss.dbeaver.model.struct.rdb.DBSIndexType; import org.jkiss.dbeaver.model.struct.rdb.DBSIndexType;
/** /**
...@@ -33,6 +34,8 @@ public class MySQLConstants { ...@@ -33,6 +34,8 @@ public class MySQLConstants {
public static final String HANDLER_SSL = "mysql_ssl"; public static final String HANDLER_SSL = "mysql_ssl";
public static final String PROP_SERVER_TIMEZONE = DBConstants.INTERNAL_PROP_PREFIX + "serverTimezone@";
public static final String PROP_REQUIRE_SSL = "ssl.require"; public static final String PROP_REQUIRE_SSL = "ssl.require";
public static final String PROP_VERIFY_SERVER_SERT = "ssl.verify.server"; public static final String PROP_VERIFY_SERVER_SERT = "ssl.verify.server";
public static final String PROP_SSL_CIPHER_SUITES = "ssl.cipher.suites"; public static final String PROP_SSL_CIPHER_SUITES = "ssl.cipher.suites";
......
...@@ -41,6 +41,9 @@ public class MySQLMessages extends NLS { ...@@ -41,6 +41,9 @@ public class MySQLMessages extends NLS {
public static String dialog_connection_port; public static String dialog_connection_port;
public static String dialog_connection_test_connection; public static String dialog_connection_test_connection;
public static String dialog_connection_user_name; public static String dialog_connection_user_name;
public static String dialog_connection_server_timezone;
public static String dialog_connection_auto_detect;
public static String dialog_connection_local_client;
public static String edit_catalog_manager_dialog_schema_name; public static String edit_catalog_manager_dialog_schema_name;
public static String edit_command_change_user_action_create_new_user; public static String edit_command_change_user_action_create_new_user;
public static String edit_command_change_user_action_update_user_record; public static String edit_command_change_user_action_update_user_record;
......
...@@ -9,6 +9,9 @@ dialog_connection_database=Database ...@@ -9,6 +9,9 @@ dialog_connection_database=Database
dialog_connection_user_name=User name dialog_connection_user_name=User name
dialog_connection_password=Password dialog_connection_password=Password
dialog_connection_test_connection=Test Connection ... dialog_connection_test_connection=Test Connection ...
dialog_connection_server_timezone=Server Time Zone
dialog_connection_auto_detect=Auto-detect
dialog_connection_local_client=Local Client
edit_catalog_manager_dialog_schema_name=Schema name edit_catalog_manager_dialog_schema_name=Schema name
edit_command_change_user_action_create_new_user=Create new user edit_command_change_user_action_create_new_user=Create new user
......
...@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.mysql; ...@@ -19,6 +19,7 @@ package org.jkiss.dbeaver.ext.mysql;
import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.model.connection.DBPClientHome; import org.jkiss.dbeaver.model.connection.DBPClientHome;
import org.jkiss.dbeaver.model.connection.DBPDriver;
import org.jkiss.dbeaver.model.exec.DBCException; import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement; import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet; import org.jkiss.dbeaver.model.exec.jdbc.JDBCResultSet;
...@@ -144,4 +145,9 @@ public class MySQLUtils { ...@@ -144,4 +145,9 @@ public class MySQLUtils {
} }
} }
public static boolean isMariaDB(DBPDriver driver) {
return MySQLConstants.DRIVER_CLASS_MARIA_DB.equals(
driver.getDriverClassName());
}
} }
...@@ -101,6 +101,11 @@ public class MySQLDataSource extends JDBCDataSource implements DBSObjectSelector ...@@ -101,6 +101,11 @@ public class MySQLDataSource extends JDBCDataSource implements DBSObjectSelector
// Newer MySQL servers/connectors requires explicit SSL disable // Newer MySQL servers/connectors requires explicit SSL disable
props.put("useSSL", "false"); props.put("useSSL", "false");
} }
String serverTZ = connectionInfo.getProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
if (!CommonUtils.isEmpty(serverTZ)) {
props.put("serverTimezone", serverTZ);
}
/* /*
if (CommonUtils.toBoolean(connectionInfo.getProperty(MySQLConstants.PROP_USE_SSL))) { if (CommonUtils.toBoolean(connectionInfo.getProperty(MySQLConstants.PROP_USE_SSL))) {
url.append("?useSSL=true&requireSSL=true"); url.append("?useSSL=true&requireSSL=true");
......
...@@ -23,12 +23,14 @@ import org.eclipse.swt.events.ModifyEvent; ...@@ -23,12 +23,14 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.ext.mysql.Activator; import org.jkiss.dbeaver.ext.mysql.Activator;
import org.jkiss.dbeaver.ext.mysql.MySQLConstants; import org.jkiss.dbeaver.ext.mysql.MySQLConstants;
import org.jkiss.dbeaver.ext.mysql.MySQLMessages; import org.jkiss.dbeaver.ext.mysql.MySQLMessages;
import org.jkiss.dbeaver.ext.mysql.MySQLUtils;
import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration; import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPDriver; import org.jkiss.dbeaver.model.connection.DBPDriver;
...@@ -39,7 +41,9 @@ import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract; ...@@ -39,7 +41,9 @@ import org.jkiss.dbeaver.ui.dialogs.connection.ConnectionPageAbstract;
import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage; import org.jkiss.dbeaver.ui.dialogs.connection.DriverPropertiesDialogPage;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone;
/** /**
* MySQLConnectionPage * MySQLConnectionPage
...@@ -56,6 +60,7 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp ...@@ -56,6 +60,7 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
private static ImageDescriptor MYSQL_LOGO_IMG = Activator.getImageDescriptor("icons/mysql_logo.png"); private static ImageDescriptor MYSQL_LOGO_IMG = Activator.getImageDescriptor("icons/mysql_logo.png");
private static ImageDescriptor MARIADB_LOGO_IMG = Activator.getImageDescriptor("icons/mariadb_logo.png"); private static ImageDescriptor MARIADB_LOGO_IMG = Activator.getImageDescriptor("icons/mariadb_logo.png");
private Combo serverTimezoneCombo;
@Override @Override
...@@ -129,19 +134,26 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp ...@@ -129,19 +134,26 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
passwordText.setLayoutData(gd); passwordText.setLayoutData(gd);
passwordText.addModifyListener(textListener); passwordText.addModifyListener(textListener);
{ UIUtils.createHorizontalLine(addrGroup, 2, 10);
Composite clientPanel = UIUtils.createPlaceholder(addrGroup, 1);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
clientPanel.setLayoutData(gd);
UIUtils.createHorizontalLine(clientPanel);
homesSelector = new ClientHomesSelector(clientPanel, SWT.NONE, "Local Client"); if (!MySQLUtils.isMariaDB(getSite().getDriver())) {
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING); serverTimezoneCombo = UIUtils.createLabelCombo(addrGroup, MySQLMessages.dialog_connection_server_timezone, SWT.DROP_DOWN);
homesSelector.getPanel().setLayoutData(gd); serverTimezoneCombo.add(MySQLMessages.dialog_connection_auto_detect);
{
String[] tzList = TimeZone.getAvailableIDs();
for (String tzID : tzList) {
//TimeZone timeZone = TimeZone.getTimeZone(tzID);
serverTimezoneCombo.add(tzID);
}
}
serverTimezoneCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
} }
homesSelector = new ClientHomesSelector(addrGroup, SWT.NONE, MySQLMessages.dialog_connection_local_client);
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.horizontalSpan = 2;
homesSelector.getPanel().setLayoutData(gd);
createDriverPanel(addrGroup); createDriverPanel(addrGroup);
setControl(addrGroup); setControl(addrGroup);
} }
...@@ -197,6 +209,15 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp ...@@ -197,6 +209,15 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
if (passwordText != null) { if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword())); passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
} }
if (serverTimezoneCombo != null) {
String tzProp = connectionInfo.getProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
if (CommonUtils.isEmpty(tzProp)) {
serverTimezoneCombo.select(0);
} else {
serverTimezoneCombo.setText(tzProp);
}
}
homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId()); homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
activated = true; activated = true;
...@@ -221,6 +242,13 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp ...@@ -221,6 +242,13 @@ public class MySQLConnectionPage extends ConnectionPageAbstract implements IComp
if (passwordText != null) { if (passwordText != null) {
connectionInfo.setUserPassword(passwordText.getText()); connectionInfo.setUserPassword(passwordText.getText());
} }
if (serverTimezoneCombo != null) {
if (serverTimezoneCombo.getSelectionIndex() == 0 || CommonUtils.isEmpty(serverTimezoneCombo.getText())) {
connectionInfo.removeProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
} else {
connectionInfo.setProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE, serverTimezoneCombo.getText());
}
}
if (homesSelector != null) { if (homesSelector != null) {
connectionInfo.setClientHomeId(homesSelector.getSelectedHome()); connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
} }
......
...@@ -761,10 +761,16 @@ public class UIUtils { ...@@ -761,10 +761,16 @@ public class UIUtils {
gd.verticalSpan = verticalSpan; gd.verticalSpan = verticalSpan;
} }
public static Label createHorizontalLine(Composite parent) public static Label createHorizontalLine(Composite parent) {
{ return createHorizontalLine(parent, 1, 0);
}
public static Label createHorizontalLine(Composite parent, int hSpan, int vIndent) {
Label horizontalLine = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL); Label horizontalLine = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1)); GridData gd = new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1);
gd.horizontalSpan = hSpan;
gd.verticalIndent = vIndent;
horizontalLine.setLayoutData(gd);
return horizontalLine; return horizontalLine;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册