提交 ac338324 编写于 作者: J jurgen

Driver settings panel.

Provided datasources save fix

Former-commit-id: a8657014
上级 b301fce8
......@@ -1359,8 +1359,10 @@ public class CoreMessages extends NLS {
public static String ui_properties_tree_viewer_action_reset_value;
public static String ui_properties_tree_viewer_category_general;
public static String ui_properties_value;
public static String dialog_connection_edit_driver_button;
public static String dialog_connection_driver;
static {
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, CoreMessages.class);
}
......
......@@ -911,3 +911,6 @@ ui_properties_tree_viewer__to_default=\ to default
ui_properties_tree_viewer_action_copy_value=Copy value
ui_properties_tree_viewer_action_reset_value=Reset value
ui_properties_tree_viewer_category_general=General
dialog_connection_driver=Driver Name:
dialog_connection_edit_driver_button=Edit Driver Settings
......@@ -468,3 +468,7 @@ editor_binary_hex_status_line_selection=\u0412\u044B\u0434\u0435\u043B\u0435\u04
editor_binary_hex_status_line_text_insert=\u0412\u0441\u0442\u0430\u0432\u043A\u0430
editor_binary_hex_status_line_text_ovewrite=\u0417\u0430\u043C\u0435\u0449\u0435\u043D\u0438\u0435
editor_binary_hex_status_line_value=\u0417\u043D\u0430\u0447\u0435\u043D\u0438\u0435\:
dialog_connection_driver=\u0414\u0440\u0430\u0439\u0432\u0435\u0440:
dialog_connection_edit_driver_button=\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430
......@@ -127,6 +127,8 @@ public class DataSourceDescriptor
private final List<DBPDataSourceUser> users = new ArrayList<DBPDataSourceUser>();
private boolean provided;
private volatile boolean connectFailed = false;
private volatile Date connectTime = null;
private volatile boolean disposed = false;
......@@ -438,6 +440,14 @@ public class DataSourceDescriptor
return clientHome;
}
public boolean isProvided() {
return provided;
}
public void setProvided(boolean provided) {
this.provided = provided;
}
@Override
public DBSObject getParentObject()
{
......
......@@ -310,11 +310,12 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
if (!fromFile.exists()) {
return;
}
boolean extraConfig = !fromFile.getName().equalsIgnoreCase(CONFIG_FILE_NAME);
try {
InputStream is = new FileInputStream(fromFile);
try {
try {
loadDataSources(is, encrypter);
loadDataSources(is, extraConfig, encrypter);
} catch (DBException ex) {
log.warn("Error loading datasource config from " + fromFile.getAbsolutePath(), ex);
}
......@@ -333,12 +334,12 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
}
}
private void loadDataSources(InputStream is, PasswordEncrypter encrypter)
private void loadDataSources(InputStream is, boolean extraConfig, PasswordEncrypter encrypter)
throws DBException, IOException
{
SAXReader parser = new SAXReader(is);
try {
parser.parse(new DataSourcesParser(encrypter));
parser.parse(new DataSourcesParser(extraConfig, encrypter));
}
catch (XMLException ex) {
throw new DBException("Datasource config parse error", ex);
......@@ -365,7 +366,9 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
xml.setButify(true);
xml.startElement("data-sources");
for (DataSourceDescriptor dataSource : localDataSources) {
saveDataSource(xml, dataSource, encrypter);
if (!dataSource.isProvided()) {
saveDataSource(xml, dataSource, encrypter);
}
}
xml.endElement();
xml.flush();
......@@ -603,6 +606,7 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private class DataSourcesParser implements SAXListener
{
DataSourceDescriptor curDataSource;
boolean extraConfig;
PasswordEncrypter encrypter;
boolean isDescription = false;
DBRShellCommand curCommand = null;
......@@ -610,8 +614,9 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
private DBSObjectFilter curFilter;
private StringBuilder curQuery;
private DataSourcesParser(PasswordEncrypter encrypter)
private DataSourcesParser(boolean extraConfig, PasswordEncrypter encrypter)
{
this.extraConfig = extraConfig;
this.encrypter = encrypter;
}
......@@ -648,6 +653,9 @@ public class DataSourceRegistry implements DBPDataSourceRegistry
id,
driver,
new DBPConnectionConfiguration());
if (extraConfig) {
curDataSource.setProvided(true);
}
curDataSource.setName(name);
String createDate = atts.getValue(RegistryConstants.ATTR_CREATE_DATE);
if (!CommonUtils.isEmpty(createDate)) {
......
......@@ -18,8 +18,18 @@
package org.jkiss.dbeaver.ui.dialogs.connection;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.model.DBPConnectionConfiguration;
import org.jkiss.dbeaver.model.DBPDriver;
import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer;
import org.jkiss.dbeaver.ui.IDataSourceConnectionEditor;
import org.jkiss.dbeaver.ui.IDataSourceConnectionEditorSite;
......@@ -30,6 +40,8 @@ import org.jkiss.dbeaver.ui.IDataSourceConnectionEditorSite;
public abstract class ConnectionPageAbstract extends DialogPage implements IDataSourceConnectionEditor
{
protected IDataSourceConnectionEditorSite site;
// Driver name
protected Text driverText;
public IDataSourceConnectionEditorSite getSite() {
return site;
......@@ -71,4 +83,47 @@ public abstract class ConnectionPageAbstract extends DialogPage implements IData
}
}
protected void createDriverPanel(Composite parent) {
Label divLabel = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
divLabel.setLayoutData(gd);
Label driverLabel = new Label(parent, SWT.NONE);
driverLabel.setText(CoreMessages.dialog_connection_driver);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
driverLabel.setLayoutData(gd);
driverText = new Text(parent, SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
//gd.widthHint = 200;
driverText.setLayoutData(gd);
Button driverButton = new Button(parent, SWT.PUSH);
driverButton.setText(CoreMessages.dialog_connection_edit_driver_button);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
driverButton.setLayoutData(gd);
driverButton.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
if (site.openDriverEditor()) {
updateDriverInfo(site.getDriver());
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
}
});
}
protected void updateDriverInfo(DBPDriver driver) {
}
}
......@@ -36,14 +36,12 @@ public class GenericMessages extends NLS {
public static String dialog_connection_db_folder_chooser_text;
public static String dialog_connection_edit_driver_button;
public static String dialog_connection_general_tab;
public static String dialog_connection_general_tab_tooltip;
public static String dialog_connection_host_label;
public static String dialog_connection_driver;
public static String dialog_connection_jdbc_url_;
public static String dialog_connection_password_label;
......
......@@ -22,11 +22,9 @@ dialog_connection_database_schema_label=Database/Schema:
dialog_connection_db_file_chooser_text=Choose database file
dialog_connection_db_folder_chooser_message=Choose folder with database files
dialog_connection_db_folder_chooser_text=Choose database folder
dialog_connection_edit_driver_button=Edit Driver Settings
dialog_connection_general_tab=General
dialog_connection_general_tab_tooltip=General connection properties
dialog_connection_host_label=Host:
dialog_connection_driver=Driver Name:
dialog_connection_jdbc_url_=JDBC URL:
dialog_connection_password_label=Password:
dialog_connection_path_label=Path:
......
......@@ -20,7 +20,6 @@ dialog_connection_database_schema_label = Database/Schema\:
dialog_connection_db_file_chooser_text = Scegli file database
dialog_connection_db_folder_chooser_message = Scegli cartella con file database
dialog_connection_db_folder_chooser_text = Scegli cartella database
dialog_connection_edit_driver_button = Modifica Impostazioni Driver
dialog_connection_general_tab = Generale
dialog_connection_general_tab_tooltip = Propriet\u00E0 generali connessione
dialog_connection_host_label = Host\:
......
......@@ -22,11 +22,9 @@ dialog_connection_database_schema_label=\u0411\u0414/\u0421\u0445\u0435\u043C\u0
dialog_connection_db_file_chooser_text=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0444\u0430\u0439\u043B \u0411\u0414
dialog_connection_db_folder_chooser_message=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0430\u043F\u043A\u0443 \u0441 \u0444\u0430\u0439\u043B\u0430\u043C\u0438 \u0411\u0414
dialog_connection_db_folder_chooser_text=\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u043F\u0430\u043F\u043A\u0443 \u0411\u0414
dialog_connection_edit_driver_button=\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430
dialog_connection_general_tab=\u041E\u0431\u0449\u0438\u0435
dialog_connection_general_tab_tooltip=\u041E\u0431\u0449\u0438\u0435 \u0441\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F
dialog_connection_host_label=\u0421\u0435\u0440\u0432\u0435\u0440:
dialog_connection_driver=\u0414\u0440\u0430\u0439\u0432\u0435\u0440:
dialog_connection_jdbc_url_=JDBC URL:
dialog_connection_password_label=\u041F\u0430\u0440\u043E\u043B\u044C:
dialog_connection_path_label=\u041F\u0443\u0442\u044C:
......
......@@ -20,7 +20,6 @@ dialog_connection_database_schema_label = \u6570\u636E\u5E93/\u6A21\u5F0F\:
dialog_connection_db_file_chooser_text = \u9009\u62E9\u6570\u636E\u5E93\u6587\u4EF6
dialog_connection_db_folder_chooser_message = \u9009\u62E9\u6570\u636E\u5E93\u6240\u5728\u6587\u4EF6\u5939
dialog_connection_db_folder_chooser_text = \u9009\u62E9\u6570\u636E\u5E93\u6587\u4EF6\u5939
dialog_connection_edit_driver_button = \u7F16\u8F91\u9A71\u52A8\u5C5E\u6027
dialog_connection_general_tab = \u4E00\u822C
dialog_connection_general_tab_tooltip = \u4E00\u822C\u8FDE\u63A5\u5C5E\u6027
dialog_connection_host_label = \u4E3B\u673A\:
......
......@@ -44,8 +44,6 @@ import java.util.List;
*/
public class GenericConnectionPage extends ConnectionPageAbstract implements ICompositeDialogPage
{
// Driver name
private Text driverText;
// Host/port
private Text hostText;
private Text portText;
......@@ -279,45 +277,7 @@ public class GenericConnectionPage extends ConnectionPageAbstract implements ICo
gd.grabExcessVerticalSpace = true;
placeholder.setLayoutData(gd);
Label divLabel = new Label(settingsGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 4;
divLabel.setLayoutData(gd);
{
Label driverLabel = new Label(settingsGroup, SWT.NONE);
driverLabel.setText(GenericMessages.dialog_connection_driver);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
driverLabel.setLayoutData(gd);
driverText = new Text(settingsGroup, SWT.READ_ONLY);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.grabExcessHorizontalSpace = true;
//gd.widthHint = 200;
driverText.setLayoutData(gd);
Button driverButton = new Button(settingsGroup, SWT.PUSH);
driverButton.setText(GenericMessages.dialog_connection_edit_driver_button);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
driverButton.setLayoutData(gd);
driverButton.addSelectionListener(new SelectionListener()
{
@Override
public void widgetSelected(SelectionEvent e)
{
if (site.openDriverEditor()) {
parseSampleURL(site.getDriver());
saveAndUpdate();
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e)
{
}
});
}
createDriverPanel(settingsGroup);
setControl(settingsGroup);
}
......@@ -332,6 +292,12 @@ public class GenericConnectionPage extends ConnectionPageAbstract implements ICo
return emptyLabel;
}
@Override
protected void updateDriverInfo(DBPDriver driver) {
parseSampleURL(driver);
saveAndUpdate();
}
@Override
public boolean isComplete()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册