提交 39bc665c 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #9849 from dbeaver/datatransfer-export-variables#8033

#8033 Implement 'type' variable

Former-commit-id: 68a21b3a
...@@ -432,6 +432,7 @@ public class CoreMessages extends NLS { ...@@ -432,6 +432,7 @@ public class CoreMessages extends NLS {
public static String pref_page_connection_types_label_delete_connection_type; public static String pref_page_connection_types_label_delete_connection_type;
public static String pref_page_connection_types_label_delete_connection_type_description; public static String pref_page_connection_types_label_delete_connection_type_description;
public static String pref_page_connection_types_group_settings; public static String pref_page_connection_types_group_settings;
public static String pref_page_connection_types_label_id;
public static String pref_page_connection_types_label_name; public static String pref_page_connection_types_label_name;
public static String pref_page_connection_types_label_description; public static String pref_page_connection_types_label_description;
public static String pref_page_connection_types_label_color; public static String pref_page_connection_types_label_color;
......
...@@ -416,6 +416,7 @@ pref_page_connection_types_label_table_column_description = Description ...@@ -416,6 +416,7 @@ pref_page_connection_types_label_table_column_description = Description
pref_page_connection_types_label_delete_connection_type = Delete connection type pref_page_connection_types_label_delete_connection_type = Delete connection type
pref_page_connection_types_label_delete_connection_type_description = Are you sure you want to delete connection type "{0}" ?\n All connections of this type will be reset to default type ({1}) pref_page_connection_types_label_delete_connection_type_description = Are you sure you want to delete connection type "{0}" ?\n All connections of this type will be reset to default type ({1})
pref_page_connection_types_group_settings = Settings pref_page_connection_types_group_settings = Settings
pref_page_connection_types_label_id=Identifier
pref_page_connection_types_label_name = Name pref_page_connection_types_label_name = Name
pref_page_connection_types_label_description = Description pref_page_connection_types_label_description = Description
pref_page_connection_types_label_color = Color pref_page_connection_types_label_color = Color
......
...@@ -420,6 +420,7 @@ pref_page_connection_types_label_table_column_description = \u041E\u043F\u0438\u ...@@ -420,6 +420,7 @@ pref_page_connection_types_label_table_column_description = \u041E\u043F\u0438\u
pref_page_connection_types_label_delete_connection_type = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F pref_page_connection_types_label_delete_connection_type = \u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F
pref_page_connection_types_label_delete_connection_type_description = \u0412\u044B \u0443\u0432\u0435\u0440\u0435\u043D\u044B, \u0447\u0442\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F "{0}" ?\n\u0412\u0441\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F \u044D\u0442\u043E\u0433\u043E \u0442\u0438\u043F\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u044B \u043D\u0430 \u0442\u0438\u043F \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E ({1}) pref_page_connection_types_label_delete_connection_type_description = \u0412\u044B \u0443\u0432\u0435\u0440\u0435\u043D\u044B, \u0447\u0442\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u0443\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0438\u043F \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F "{0}" ?\n\u0412\u0441\u0435 \u0441\u043E\u0435\u0434\u0438\u043D\u0435\u043D\u0438\u044F \u044D\u0442\u043E\u0433\u043E \u0442\u0438\u043F\u0430 \u0431\u0443\u0434\u0443\u0442 \u0441\u0431\u0440\u043E\u0448\u0435\u043D\u044B \u043D\u0430 \u0442\u0438\u043F \u043F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E ({1})
pref_page_connection_types_group_settings = \u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 pref_page_connection_types_group_settings = \u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438
pref_page_connection_types_label_id=\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440
pref_page_connection_types_label_name = \u0418\u043C\u044F pref_page_connection_types_label_name = \u0418\u043C\u044F
pref_page_connection_types_label_description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 pref_page_connection_types_label_description = \u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435
pref_page_connection_types_label_color = \u0426\u0432\u0435\u0442 pref_page_connection_types_label_color = \u0426\u0432\u0435\u0442
......
...@@ -58,6 +58,7 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -58,6 +58,7 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.connectionTypes"; //$NON-NLS-1$ public static final String PAGE_ID = "org.jkiss.dbeaver.preferences.connectionTypes"; //$NON-NLS-1$
private Table typeTable; private Table typeTable;
private Text typeId;
private Text typeName; private Text typeName;
private Text typeDescription; private Text typeDescription;
private ColorSelector colorPicker; private ColorSelector colorPicker;
...@@ -120,7 +121,7 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -120,7 +121,7 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
} }
} }
DBPConnectionType newType = new DBPConnectionType( DBPConnectionType newType = new DBPConnectionType(
SecurityUtils.generateUniqueId(), name.toLowerCase(),
name, name,
"255,255,255", "255,255,255",
"New type", "New type",
...@@ -158,11 +159,15 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -158,11 +159,15 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
Group groupSettings = UIUtils.createControlGroup(composite, CoreMessages.pref_page_connection_types_group_settings, 2, GridData.VERTICAL_ALIGN_BEGINNING, 300); Group groupSettings = UIUtils.createControlGroup(composite, CoreMessages.pref_page_connection_types_group_settings, 2, GridData.VERTICAL_ALIGN_BEGINNING, 300);
groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH)); groupSettings.setLayoutData(new GridData(GridData.FILL_BOTH));
typeId = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_id, null);
typeId.addModifyListener(e -> {
getSelectedType().setId(typeId.getText());
updateTableInfo();
});
typeName = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_name, null); typeName = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_name, null);
typeName.addModifyListener(e -> { typeName.addModifyListener(e -> {
getSelectedType().setName(typeName.getText()); getSelectedType().setName(typeName.getText());
updateTableInfo(); updateTableInfo();
}); });
typeDescription = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_description, null); typeDescription = UIUtils.createLabelText(groupSettings, CoreMessages.pref_page_connection_types_label_description, null);
typeDescription.addModifyListener(e -> { typeDescription.addModifyListener(e -> {
...@@ -274,6 +279,8 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -274,6 +279,8 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
colorPicker.setColorValue(colorPicker.getButton().getBackground().getRGB()); colorPicker.setColorValue(colorPicker.getButton().getBackground().getRGB());
} }
typeId.setText(connectionType.getId());
typeId.setEnabled(changedInfo.get(connectionType) == connectionType);
typeName.setText(connectionType.getName()); typeName.setText(connectionType.getName());
typeDescription.setText(connectionType.getDescription()); typeDescription.setText(connectionType.getDescription());
autocommitCheck.setSelection(connectionType.isAutocommit()); autocommitCheck.setSelection(connectionType.isAutocommit());
...@@ -347,6 +354,8 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -347,6 +354,8 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
@Override @Override
public boolean performOk() public boolean performOk()
{ {
typeId.setEnabled(false);
DataSourceProviderRegistry registry = DataSourceProviderRegistry.getInstance(); DataSourceProviderRegistry registry = DataSourceProviderRegistry.getInstance();
List<DBPConnectionType> toRemove = new ArrayList<>(); List<DBPConnectionType> toRemove = new ArrayList<>();
for (DBPConnectionType type : registry.getConnectionTypes()) { for (DBPConnectionType type : registry.getConnectionTypes()) {
...@@ -363,15 +372,27 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe ...@@ -363,15 +372,27 @@ public class PrefPageConnectionTypes extends AbstractPrefPage implements IWorkbe
changedSet.add(connectionType); changedSet.add(connectionType);
} }
for (DBPConnectionType changed : changedInfo.keySet()) { for (Map.Entry<DBPConnectionType, DBPConnectionType> entry : changedInfo.entrySet()) {
boolean hasChanges = false; boolean hasChanges = false;
DBPConnectionType source = changedInfo.get(changed); DBPConnectionType changed = entry.getKey();
DBPConnectionType source = entry.getValue();
if (source == changed) { if (source == changed) {
// New type // New type
if (CommonUtils.isEmpty(changed.getId())) {
changed.setId(SecurityUtils.generateUniqueId());
}
for (DBPConnectionType type : changedInfo.keySet()) {
if (type != changed && type.getId().equals(changed.getId())) {
changed.setId(SecurityUtils.generateUniqueId());
break;
}
}
entry.setValue(new DBPConnectionType(source));
registry.addConnectionType(changed); registry.addConnectionType(changed);
hasChanges = true; hasChanges = true;
} else if (!source.equals(changed)) { } else if (!source.equals(changed)) {
// Changed type // Changed type
source.setId(changed.getId());
source.setName(changed.getName()); source.setName(changed.getName());
source.setDescription(changed.getDescription()); source.setDescription(changed.getDescription());
source.setAutocommit(changed.isAutocommit()); source.setAutocommit(changed.isAutocommit());
......
...@@ -49,6 +49,7 @@ public class PrefPageConnections extends TargetPrefPage ...@@ -49,6 +49,7 @@ public class PrefPageConnections extends TargetPrefPage
DBPConnectionConfiguration.VARIABLE_USER, DBPConnectionConfiguration.VARIABLE_USER,
DBPConnectionConfiguration.VARIABLE_PASSWORD, DBPConnectionConfiguration.VARIABLE_PASSWORD,
DBPConnectionConfiguration.VARIABLE_URL, DBPConnectionConfiguration.VARIABLE_URL,
DBPConnectionConfiguration.VARIABLE_CONN_TYPE,
DBConstants.VAR_CONTEXT_NAME, DBConstants.VAR_CONTEXT_NAME,
DBConstants.VAR_CONTEXT_ID, DBConstants.VAR_CONTEXT_ID,
......
...@@ -102,7 +102,8 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar ...@@ -102,7 +102,8 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_TIMESTAMP,
StreamTransferConsumer.VARIABLE_DATE, StreamTransferConsumer.VARIABLE_DATE,
StreamTransferConsumer.VARIABLE_INDEX, StreamTransferConsumer.VARIABLE_INDEX,
StreamTransferConsumer.VARIABLE_PROJECT); StreamTransferConsumer.VARIABLE_PROJECT,
StreamTransferConsumer.VARIABLE_CONN_TYPE);
fileNameText.setLayoutData(gd); fileNameText.setLayoutData(gd);
fileNameText.addModifyListener(e -> { fileNameText.addModifyListener(e -> {
settings.setOutputFilePattern(fileNameText.getText()); settings.setOutputFilePattern(fileNameText.getText());
...@@ -119,6 +120,7 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar ...@@ -119,6 +120,7 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_INDEX), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_INDEX),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_CONN_TYPE),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT))); GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT)));
{ {
...@@ -218,7 +220,8 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar ...@@ -218,7 +220,8 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
StreamTransferConsumer.VARIABLE_TABLE, StreamTransferConsumer.VARIABLE_TABLE,
StreamTransferConsumer.VARIABLE_TIMESTAMP, StreamTransferConsumer.VARIABLE_TIMESTAMP,
StreamTransferConsumer.VARIABLE_DATE, StreamTransferConsumer.VARIABLE_DATE,
StreamTransferConsumer.VARIABLE_PROJECT); StreamTransferConsumer.VARIABLE_PROJECT,
StreamTransferConsumer.VARIABLE_CONN_TYPE);
ContentAssistUtils.installContentProposal( ContentAssistUtils.installContentProposal(
execProcessText, execProcessText,
new SmartTextContentAdapter(), new SmartTextContentAdapter(),
...@@ -227,6 +230,7 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar ...@@ -227,6 +230,7 @@ public class StreamConsumerPageOutput extends ActiveWizardPage<DataTransferWizar
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_TIMESTAMP),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_DATE),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT), GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_PROJECT),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_CONN_TYPE),
GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_FILE))); GeneralUtils.variablePattern(StreamTransferConsumer.VARIABLE_FILE)));
showFinalMessageCheckbox = UIUtils.createCheckbox(resultsSettings, DTUIMessages.stream_consumer_page_output_label_show_finish_message, null, getWizard().getSettings().isShowFinalMessage(), 4); showFinalMessageCheckbox = UIUtils.createCheckbox(resultsSettings, DTUIMessages.stream_consumer_page_output_label_show_finish_message, null, getWizard().getSettings().isShowFinalMessage(), 4);
......
...@@ -79,6 +79,7 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu ...@@ -79,6 +79,7 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
public static final String VARIABLE_INDEX = "index"; public static final String VARIABLE_INDEX = "index";
public static final String VARIABLE_DATE = "date"; public static final String VARIABLE_DATE = "date";
public static final String VARIABLE_PROJECT = "project"; public static final String VARIABLE_PROJECT = "project";
public static final String VARIABLE_CONN_TYPE = "connectionType";
public static final String VARIABLE_FILE = "file"; public static final String VARIABLE_FILE = "file";
public static final int OUT_FILE_BUFFER_SIZE = 100000; public static final int OUT_FILE_BUFFER_SIZE = 100000;
...@@ -538,6 +539,11 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu ...@@ -538,6 +539,11 @@ public class StreamTransferConsumer implements IDataTransferConsumer<StreamConsu
} }
case VARIABLE_FILE: case VARIABLE_FILE:
return targetFile == null ? "" : targetFile.getAbsolutePath(); return targetFile == null ? "" : targetFile.getAbsolutePath();
case VARIABLE_CONN_TYPE:
if (dataContainer == null) {
return null;
}
return dataContainer.getDataSource().getContainer().getConnectionConfiguration().getConnectionType().getId();
} }
return null; return null;
}); });
......
...@@ -45,6 +45,7 @@ public class DBPConnectionConfiguration implements DBPObject { ...@@ -45,6 +45,7 @@ public class DBPConnectionConfiguration implements DBPObject {
public static final String VARIABLE_USER = "user"; public static final String VARIABLE_USER = "user";
public static final String VARIABLE_PASSWORD = "password"; public static final String VARIABLE_PASSWORD = "password";
public static final String VARIABLE_URL = "url"; public static final String VARIABLE_URL = "url";
public static final String VARIABLE_CONN_TYPE = "connectionType";
public static final String VAR_PROJECT_PATH = "project.path"; public static final String VAR_PROJECT_PATH = "project.path";
public static final String VAR_PROJECT_NAME = "project.name"; public static final String VAR_PROJECT_NAME = "project.name";
......
...@@ -90,6 +90,10 @@ public class DBPConnectionType implements DBPDataSourcePermissionOwner { ...@@ -90,6 +90,10 @@ public class DBPConnectionType implements DBPDataSourcePermissionOwner {
return id; return id;
} }
public String setId(String id) {
return this.id = id;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -45,6 +45,8 @@ public class DataSourceVariableResolver extends SystemVariablesResolver { ...@@ -45,6 +45,8 @@ public class DataSourceVariableResolver extends SystemVariablesResolver {
return configuration.getUserPassword(); return configuration.getUserPassword();
case DBPConnectionConfiguration.VARIABLE_URL: case DBPConnectionConfiguration.VARIABLE_URL:
return configuration.getUrl(); return configuration.getUrl();
case DBPConnectionConfiguration.VARIABLE_CONN_TYPE:
return configuration.getConnectionType().getId();
case DBPConnectionConfiguration.VAR_PROJECT_PATH: case DBPConnectionConfiguration.VAR_PROJECT_PATH:
return dataSourceContainer == null ? null : dataSourceContainer.getProject().getEclipseProject().getLocation().toOSString(); return dataSourceContainer == null ? null : dataSourceContainer.getProject().getEclipseProject().getLocation().toOSString();
case DBPConnectionConfiguration.VAR_PROJECT_NAME: case DBPConnectionConfiguration.VAR_PROJECT_NAME:
......
...@@ -89,6 +89,7 @@ public class DataSourceDescriptor ...@@ -89,6 +89,7 @@ public class DataSourceDescriptor
{DBPConnectionConfiguration.VARIABLE_USER, "database user name"}, {DBPConnectionConfiguration.VARIABLE_USER, "database user name"},
{DBPConnectionConfiguration.VARIABLE_PASSWORD, "database password (plain)"}, {DBPConnectionConfiguration.VARIABLE_PASSWORD, "database password (plain)"},
{DBPConnectionConfiguration.VARIABLE_URL, "connection URL"}, {DBPConnectionConfiguration.VARIABLE_URL, "connection URL"},
{DBPConnectionConfiguration.VARIABLE_CONN_TYPE, "connection type"},
{DBPConnectionConfiguration.VAR_PROJECT_PATH, "project path"}, {DBPConnectionConfiguration.VAR_PROJECT_PATH, "project path"},
{DBPConnectionConfiguration.VAR_PROJECT_NAME, "project name"}, {DBPConnectionConfiguration.VAR_PROJECT_NAME, "project name"},
...@@ -1401,6 +1402,7 @@ public class DataSourceDescriptor ...@@ -1401,6 +1402,7 @@ public class DataSourceDescriptor
case DBPConnectionConfiguration.VARIABLE_USER: return configuration.getUserName(); case DBPConnectionConfiguration.VARIABLE_USER: return configuration.getUserName();
case DBPConnectionConfiguration.VARIABLE_PASSWORD: return configuration.getUserPassword(); case DBPConnectionConfiguration.VARIABLE_PASSWORD: return configuration.getUserPassword();
case DBPConnectionConfiguration.VARIABLE_URL: return configuration.getUrl(); case DBPConnectionConfiguration.VARIABLE_URL: return configuration.getUrl();
case DBPConnectionConfiguration.VARIABLE_CONN_TYPE: return configuration.getConnectionType().getId();
default: return SystemVariablesResolver.INSTANCE.get(name); default: return SystemVariablesResolver.INSTANCE.get(name);
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册