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

#5716 Native client selector in tool wizards dialog

上级 bc217fa0
...@@ -474,7 +474,7 @@ tools_wizard_error_task_error_title = {0} error ...@@ -474,7 +474,7 @@ tools_wizard_error_task_error_title = {0} error
tools_wizard_log_io_error = IO Error: {0} tools_wizard_log_io_error = IO Error: {0}
tools_wizard_log_process_exit_code = Process exit code: {0} tools_wizard_log_process_exit_code = Process exit code: {0}
tools_wizard_message_client_home_not_found = Client home "{0}" not found tools_wizard_message_client_home_not_found = Client home "{0}" not found
tools_wizard_message_no_client_home = Client home is not specified for connection tools_wizard_message_no_client_home = Native client is not specified for connection
tools_wizard_page_log_task_finished = {0} finished at {1} tools_wizard_page_log_task_finished = {0} finished at {1}
tools_wizard_page_log_task_log_reader = {0} log reader tools_wizard_page_log_task_log_reader = {0} log reader
tools_wizard_page_log_task_progress = {0} progress tools_wizard_page_log_task_progress = {0} progress
......
...@@ -30,7 +30,6 @@ import org.jkiss.dbeaver.Log; ...@@ -30,7 +30,6 @@ import org.jkiss.dbeaver.Log;
import org.jkiss.dbeaver.core.CoreMessages; import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer; import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBUtils; import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration; import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.connection.DBPNativeClientLocation; import org.jkiss.dbeaver.model.connection.DBPNativeClientLocation;
import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode; import org.jkiss.dbeaver.model.navigator.DBNDatabaseNode;
...@@ -38,6 +37,7 @@ import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore; ...@@ -38,6 +37,7 @@ import org.jkiss.dbeaver.model.preferences.DBPPreferenceStore;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor; import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress; import org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress;
import org.jkiss.dbeaver.model.struct.DBSObject; import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.runtime.DBWorkbench;
import org.jkiss.dbeaver.runtime.ProgressStreamReader; import org.jkiss.dbeaver.runtime.ProgressStreamReader;
import org.jkiss.dbeaver.ui.UIUtils; import org.jkiss.dbeaver.ui.UIUtils;
import org.jkiss.utils.CommonUtils; import org.jkiss.utils.CommonUtils;
...@@ -68,7 +68,6 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_ ...@@ -68,7 +68,6 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
private String toolUserName; private String toolUserName;
private String toolUserPassword; private String toolUserPassword;
private String extraCommandArgs; private String extraCommandArgs;
protected boolean nativeClientHomeRequired = true;
protected String task; protected String task;
protected final DatabaseWizardPageLog logPage; protected final DatabaseWizardPageLog logPage;
...@@ -171,6 +170,10 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_ ...@@ -171,6 +170,10 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
} }
} }
public DBPDataSourceContainer getDataSourceContainer() {
return dataSourceContainer;
}
public DBPNativeClientLocation findNativeClientHome(String clientHomeId) { public DBPNativeClientLocation findNativeClientHome(String clientHomeId) {
return null; return null;
} }
...@@ -182,11 +185,16 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_ ...@@ -182,11 +185,16 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
{ {
super.createPageControls(pageContainer); super.createPageControls(pageContainer);
updateErrorMessage();
}
public void updateErrorMessage() {
WizardPage currentPage = (WizardPage) getStartingPage(); WizardPage currentPage = (WizardPage) getStartingPage();
if (nativeClientHomeRequired) { if (isNativeClientHomeRequired()) {
String clientHomeId = connectionInfo.getClientHomeId(); String clientHomeId = dataSourceContainer.getConnectionConfiguration().getClientHomeId();
if (clientHomeId == null) { if (clientHomeId == null) {
clientHome = null;
currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home); currentPage.setErrorMessage(CoreMessages.tools_wizard_message_no_client_home);
getContainer().updateMessage(); getContainer().updateMessage();
return; return;
...@@ -197,13 +205,15 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_ ...@@ -197,13 +205,15 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
} }
if (clientHome == null) { if (clientHome == null) {
currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId)); currentPage.setErrorMessage(NLS.bind(CoreMessages.tools_wizard_message_client_home_not_found, clientHomeId));
getContainer().updateMessage(); } else {
currentPage.setErrorMessage(null);
} }
getContainer().updateMessage();
} }
} }
private boolean validateClientFiles() { private boolean validateClientFiles() {
if (!nativeClientHomeRequired || clientHome == null) { if (!isNativeClientHomeRequired() || clientHome == null) {
return true; return true;
} }
try { try {
...@@ -364,6 +374,10 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_ ...@@ -364,6 +374,10 @@ public abstract class AbstractToolWizard<BASE_OBJECT extends DBSObject, PROCESS_
return true; return true;
} }
protected boolean isNativeClientHomeRequired() {
return true;
}
protected boolean isMergeProcessStreams() protected boolean isMergeProcessStreams()
{ {
return false; return false;
......
...@@ -21,17 +21,29 @@ package org.jkiss.dbeaver.ui.dialogs.tools; ...@@ -21,17 +21,29 @@ package org.jkiss.dbeaver.ui.dialogs.tools;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.IWizard; import org.eclipse.jface.wizard.IWizard;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
import org.jkiss.dbeaver.core.CoreMessages; import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPImage;
import org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog; import org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog;
import org.jkiss.dbeaver.ui.dialogs.BaseDialog;
import org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesPanel;
import org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector;
/** /**
* Tool wizard dialog * Tool wizard dialog
*/ */
public class ToolWizardDialog extends ActiveWizardDialog public class ToolWizardDialog extends ActiveWizardDialog
{ {
public static final int CLIENT_CONFIG_ID = 1000;
public ToolWizardDialog(IWorkbenchWindow window, IWizard wizard) public ToolWizardDialog(IWorkbenchWindow window, IWizard wizard)
{ {
super(window, wizard); super(window, wizard);
...@@ -42,10 +54,78 @@ public class ToolWizardDialog extends ActiveWizardDialog ...@@ -42,10 +54,78 @@ public class ToolWizardDialog extends ActiveWizardDialog
@Override @Override
protected void createButtonsForButtonBar(Composite parent) protected void createButtonsForButtonBar(Composite parent)
{ {
if (getWizard() instanceof AbstractToolWizard<?, ?>) {
boolean nativeClientRequired = ((AbstractToolWizard) getWizard()).isNativeClientHomeRequired();
if (nativeClientRequired) {
parent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button configButton = createButton(parent, CLIENT_CONFIG_ID, " Client configuration ... ", false);
configButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
Label spacer = new Label(parent, SWT.NONE);
spacer.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
((GridLayout)parent.getLayout()).numColumns++;
((GridLayout)parent.getLayout()).makeColumnsEqualWidth = false;
}
}
super.createButtonsForButtonBar(parent); super.createButtonsForButtonBar(parent);
Button cancelButton = getButton(IDialogConstants.CANCEL_ID); Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
cancelButton.setText(IDialogConstants.CLOSE_LABEL); cancelButton.setText(IDialogConstants.CLOSE_LABEL);
Button finishButton = getButton(IDialogConstants.FINISH_ID); Button finishButton = getButton(IDialogConstants.FINISH_ID);
finishButton.setText(CoreMessages.tools_wizard_dialog_button_start); finishButton.setText(CoreMessages.tools_wizard_dialog_button_start);
} }
@Override
protected void buttonPressed(int buttonId) {
if (buttonId == CLIENT_CONFIG_ID) {
openClientConfiguration();
}
super.buttonPressed(buttonId);
}
private void openClientConfiguration() {
AbstractToolWizard toolWizard = (AbstractToolWizard) getWizard();
DBPDataSourceContainer dataSource = toolWizard.getDataSourceContainer();
if (dataSource != null) {
NativeClientConfigDialog dialog = new NativeClientConfigDialog(getShell(), dataSource);
if (dialog.open() == IDialogConstants.OK_ID) {
toolWizard.updateErrorMessage();
updateButtons();
}
}
}
private static class NativeClientConfigDialog extends BaseDialog {
private final DBPDataSourceContainer dataSource;
private ClientHomesSelector homesSelector;
public NativeClientConfigDialog(Shell parentShell, DBPDataSourceContainer dataSource) {
super(parentShell, "Configure local client for " + dataSource.getName(), dataSource.getDriver().getIcon());
this.dataSource = dataSource;
}
@Override
protected Composite createDialogArea(Composite parent) {
Composite dialogArea = super.createDialogArea(parent);
homesSelector = new ClientHomesSelector(dialogArea, SWT.NONE, "Native client");
homesSelector.populateHomes(dataSource.getDriver(), dataSource.getConnectionConfiguration().getClientHomeId(), false);
homesSelector.getPanel().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
return dialogArea;
}
@Override
protected void okPressed() {
String selectedHome = homesSelector.getSelectedHome();
dataSource.getConnectionConfiguration().setClientHomeId(selectedHome);
dataSource.getRegistry().flushConfig();
super.okPressed();
}
}
} }
...@@ -57,7 +57,6 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato ...@@ -57,7 +57,6 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
MockDataExecuteWizard(MockDataSettings mockDataSettings, Collection<DBSDataManipulator> dbObjects, String task) { MockDataExecuteWizard(MockDataSettings mockDataSettings, Collection<DBSDataManipulator> dbObjects, String task) {
super(dbObjects, task); super(dbObjects, task);
this.nativeClientHomeRequired = false;
this.mockDataSettings = mockDataSettings; this.mockDataSettings = mockDataSettings;
setDialogSettings( setDialogSettings(
...@@ -66,6 +65,11 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato ...@@ -66,6 +65,11 @@ public class MockDataExecuteWizard extends AbstractToolWizard<DBSDataManipulato
WIZARD_DIALOG_SETTINGS)); WIZARD_DIALOG_SETTINGS));
} }
@Override
protected boolean isNativeClientHomeRequired() {
return false;
}
@Override @Override
public void init(IWorkbench workbench, IStructuredSelection selection) { public void init(IWorkbench workbench, IStructuredSelection selection) {
setWindowTitle(task); setWindowTitle(task);
......
...@@ -120,7 +120,7 @@ dialog_setting_connection_localClient = Local Client ...@@ -120,7 +120,7 @@ dialog_setting_connection_localClient = Local Client
dialog_setting_connection_nondefaultDatabase = Show all databases dialog_setting_connection_nondefaultDatabase = Show all databases
dialog_setting_connection_nondefaultDatabase_tip = Show all databases in database navigator.\nIf not set then only one database will be visible dialog_setting_connection_nondefaultDatabase_tip = Show all databases in database navigator.\nIf not set then only one database will be visible
dialog_setting_connection_show_templates = Show template databases dialog_setting_connection_show_templates = Show template databases
dialog_setting_connection_show_templates_tip = Show tamplate databases in database list.\nEnabled only if non-default databases are visible dialog_setting_connection_show_templates_tip = Show template databases in database list.\nEnabled only if non-default databases are visible
dialog_setting_connection_switchDatabaseOnExpand = Switch default database on access dialog_setting_connection_switchDatabaseOnExpand = Switch default database on access
dialog_setting_connection_switchDatabaseOnExpand_tip = Switch default database if you access any object inside non-default database (e.g. schema) dialog_setting_connection_switchDatabaseOnExpand_tip = Switch default database if you access any object inside non-default database (e.g. schema)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册