use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportDataConfirmPage method afterShowCurrentPage.
/**
* When displayed current page.
*
* @param event PageChangedEvent
*/
protected void afterShowCurrentPage(PageChangedEvent event) {
// FIXME move this logic to core module
ExportConfig exportConfigModel = getExportConfig();
StringBuilder info = new StringBuilder();
if (exportConfigModel.getExportType() == ExportConfig.EXPORT_TO_LOADDB) {
info.append(Messages.lblExportConfirmExportType).append(NEW_LINE);
info.append(TAB_SPACE).append(Messages.exportWizardType2).append(NEW_LINE);
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmExportObjects).append(NEW_LINE);
if (exportConfigModel.isExportSchema()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmSchema);
info.append(" - ");
info.append(exportConfigModel.getSchemaFilePath()).append(NEW_LINE);
}
if (exportConfigModel.isExportIndex()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmIndex);
info.append(" - ");
info.append(exportConfigModel.getIndexFilePath()).append(NEW_LINE);
}
if (exportConfigModel.isExportData()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmData);
info.append(" - ");
info.append(exportConfigModel.getDataFileFolder()).append(NEW_LINE);
}
info.append(NEW_LINE);
} else {
info.append(Messages.lblExportConfirmExportType).append(NEW_LINE);
info.append(TAB_SPACE).append(Messages.exportWizardType1).append(NEW_LINE);
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmExportObjects).append(NEW_LINE);
if (exportConfigModel.isExportSchema()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmSchema).append(NEW_LINE);
}
if (exportConfigModel.isExportData()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmData).append(NEW_LINE);
}
if (exportConfigModel.isExportSchema()) {
if (exportConfigModel.isExportIndex()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmIndex).append(NEW_LINE);
}
if (exportConfigModel.isExportSerial()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmSerial).append(NEW_LINE);
}
if (exportConfigModel.isExportView()) {
info.append(TAB_SPACE).append(Messages.lblExportConfirmView).append(NEW_LINE);
}
}
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmFileType).append(NEW_LINE);
if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_SQL) {
info.append(TAB_SPACE).append("SQL").append(NEW_LINE);
} else if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_CSV) {
info.append(TAB_SPACE).append("CSV").append(NEW_LINE);
} else if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_XLS) {
info.append(TAB_SPACE).append("XLS").append(NEW_LINE);
} else if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_XLSX) {
info.append(TAB_SPACE).append("XLSX").append(NEW_LINE);
} else if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_OBS) {
info.append(TAB_SPACE).append("OBS").append(NEW_LINE);
} else if (exportConfigModel.getExportFileType() == ExportConfig.FILE_TYPE_TXT) {
info.append(TAB_SPACE).append("TXT").append(NEW_LINE);
}
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmFilePath).append(NEW_LINE);
info.append(TAB_SPACE).append(exportConfigModel.getDataFileFolder()).append(NEW_LINE);
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmThreads).append(NEW_LINE);
info.append(TAB_SPACE).append(exportConfigModel.getThreadCount()).append(NEW_LINE);
info.append(NEW_LINE);
}
info.append(Messages.lblExportConfirmCharset).append(NEW_LINE);
info.append(TAB_SPACE).append(exportConfigModel.getFileCharset()).append(NEW_LINE);
info.append(NEW_LINE);
info.append(Messages.lblExportConfirmTables).append(NEW_LINE);
for (String tableName : exportConfigModel.getTableNameList()) {
info.append(TAB_SPACE).append(tableName);
String whereCondition = exportConfigModel.getWhereCondition(tableName);
if (whereCondition != null) {
info.append(TAB_SPACE).append(whereCondition);
}
info.append(NEW_LINE);
}
infoTest.setText(info.toString().trim());
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportConfigManager method loadExportConfigs.
/**
*
* Load the added export configs from plug-in preference
*
*/
protected void loadExportConfigs() {
synchronized (this) {
exportConfigList.clear();
IXMLMemento memento = PersistUtils.getXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_EXPORT_SETTING);
IXMLMemento[] children = memento == null ? null : memento.getChildren("config");
for (int i = 0; children != null && i < children.length; i++) {
String historyName = children[i].getString("name");
int exportType = children[i].getInteger("exportType");
int fileType = children[i].getInteger("fileType");
boolean isExportSchema = children[i].getBoolean("exportSchema");
boolean isExportIndex = children[i].getBoolean("exportIndex");
boolean isExportData = children[i].getBoolean("exportData");
boolean isExportSerial = children[i].getBoolean("exportSerial");
boolean isExportView = children[i].getBoolean("exportView");
boolean isExportStartValue = children[i].getBoolean("exportStartValue");
boolean isExportLobData = children[i].getBoolean("exportLob");
String schemaFilePath = children[i].getString("schemaFile");
String indexFilePath = children[i].getString("indexFile");
String dataFilePath = children[i].getString("dataFile");
String fileCharset = children[i].getString("fileCharset");
int threadCount = children[i].getInteger("threadCount");
boolean useFirstAsColumnBtn = children[i].getBoolean("useFirstAsColumn");
String nullValue = children[i].getString("nullValue");
String rowDelimiter = children[i].getString("rowDelimiter");
String colDelimiter = children[i].getString("colDelimiter");
Map<String, List<String>> exportTableColumnMap = new LinkedHashMap<String, List<String>>();
Map<String, String> tableWhereConditionMap = new HashMap<String, String>();
IXMLMemento[] tables = children[i].getChildren("table");
List<String> tableList = new ArrayList<String>();
for (int j = 0; tables != null && j < tables.length; j++) {
String tableName = tables[j].getString("name");
tableList.add(tableName);
String whereCondition = tables[j].getString("where");
if (whereCondition != null && whereCondition.trim().length() > 0) {
tableWhereConditionMap.put(tableName, whereCondition);
}
}
ExportConfig model = new ExportConfig();
model.setHistory(true);
model.setName(historyName);
model.setExportType(exportType);
model.setExportFileType(fileType);
model.setExportData(isExportData);
model.setExportIndex(isExportIndex);
model.setExportSchema(isExportSchema);
model.setExportSerial(isExportSerial);
model.setExportView(isExportView);
model.setExportSerialStartValue(isExportStartValue);
model.setExportLob(isExportLobData);
model.setSchemaFilePath(schemaFilePath);
model.setIndexFilePath(indexFilePath);
model.setDataFileFolder(dataFilePath);
model.setFileCharset(fileCharset);
model.setThreadCount(threadCount);
model.setFirstRowAsColumnName(useFirstAsColumnBtn);
model.setNULLValueTranslation(nullValue);
model.setRowDelimeter(rowDelimiter);
model.setColumnDelimeter(colDelimiter);
model.setTableNameList(tableList);
for (String tableName : tableList) {
List<String> columnList = exportTableColumnMap.get(tableName);
model.setColumnNameList(tableName, columnList);
String whereCondition = tableWhereConditionMap.get(tableName);
if (StringUtil.isNotEmpty(whereCondition)) {
model.setWhereCondition(tableName, whereCondition);
}
}
exportConfigList.add(model);
}
}
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportConfigManager method saveConfigs.
/**
*
* Save the export configs to plug-in preference
*
*/
public void saveConfigs() {
synchronized (this) {
XMLMemento memento = XMLMemento.createWriteRoot("databases");
Iterator<ExportConfig> iterator = exportConfigList.iterator();
while (iterator.hasNext()) {
ExportConfig model = (ExportConfig) iterator.next();
IXMLMemento configMemento = memento.createChild("config");
configMemento.putString("name", model.getName());
configMemento.putInteger("exportType", model.getExportType());
configMemento.putInteger("fileType", model.getExportFileType());
configMemento.putBoolean("exportData", model.isExportData());
configMemento.putBoolean("exportIndex", model.isExportIndex());
configMemento.putBoolean("exportSchema", model.isExportSchema());
configMemento.putBoolean("exportSerial", model.isExportSerial());
configMemento.putBoolean("exportView", model.isExportView());
configMemento.putBoolean("exportStartValue", model.isExportSerialStartValue());
configMemento.putBoolean("exportLob", model.isExportLob());
configMemento.putString("schemaFile", model.getSchemaFilePath());
configMemento.putString("indexFile", model.getIndexFilePath());
configMemento.putString("dataFile", model.getDataFileFolder());
configMemento.putString("fileCharset", model.getFileCharset());
configMemento.putInteger("threadCount", model.getThreadCount());
configMemento.putBoolean("useFirstAsColumn", model.isFirstRowAsColumnName());
configMemento.putString("nullValue", model.getNULLValueTranslation());
configMemento.putString("rowDelimiter", model.getRowDelimeter());
configMemento.putString("colDelimiter", model.getColumnDelimeter());
List<String> tableList = model.getTableNameList();
for (String tableName : tableList) {
IXMLMemento tableMemento = configMemento.createChild("table");
tableMemento.putString("name", tableName);
String whereCondition = model.getWhereCondition(tableName);
if (StringUtil.isNotEmpty(whereCondition)) {
tableMemento.putString("where", whereCondition);
}
}
}
PersistUtils.saveXMLMemento(CommonUIPlugin.PLUGIN_ID, COM_CUBRID_EXPORT_SETTING, memento);
}
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportSettingPage method init.
/**
* Initials some values.
*/
private void init() {
initTableColumnInfo();
treeViewer.setInput(tablesOrViewLst);
if (getExportConfig().isHistory()) {
// history
ExportConfig exportConfig = getExportConfig();
for (String table : exportConfig.getTableNameList()) {
for (ICubridNode node : tablesOrViewLst) {
if (table.equalsIgnoreCase(node.getName())) {
treeViewer.setChecked(node, true);
String whereCondition = exportConfig.getWhereCondition(table);
if (whereCondition != null) {
node.setData(ExportObjectLabelProvider.CONDITION, whereCondition);
}
}
}
}
treeViewer.refresh();
if (exportConfig.isExportSchema()) {
schemaButton.setSelection(true);
indexButton.setEnabled(true);
serialButton.setEnabled(true);
viewButton.setEnabled(true);
startValueButton.setEnabled(true);
if (exportConfig.isExportIndex()) {
indexButton.setSelection(true);
}
if (exportConfig.isExportSerial()) {
serialButton.setSelection(true);
}
if (exportConfig.isExportView()) {
viewButton.setSelection(true);
}
if (exportConfig.isExportSerialStartValue()) {
startValueButton.setSelection(true);
}
}
if (exportConfig.isExportData()) {
dataButton.setSelection(true);
}
if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_SQL) {
sqlButton.setSelection(true);
} else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_CSV) {
csvButton.setSelection(true);
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
} else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_XLS) {
xlsButton.setSelection(true);
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
} else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_XLSX) {
xlsxButton.setSelection(true);
useFirstAsColumnBtn.setEnabled(true);
setNullWidgetStatus(true);
} else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_OBS) {
obsButton.setSelection(true);
} else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_TXT) {
txtButton.setSelection(true);
setNullWidgetStatus(true);
setDelimiterWidgetStatus(true);
useFirstAsColumnBtn.setEnabled(true);
}
updateExportLobButtonStatus();
if (exportLobButton.isEnabled()) {
exportLobButton.setSelection(exportConfig.isExportLob());
}
pathText.setText(exportConfig.getDataFileFolder());
String[] charsets = QueryOptions.getAllCharset(null);
int index = 0;
for (int i = 0; i < charsets.length; i++) {
String charset = charsets[i];
if (charset.equals(getDatabase().getDatabaseInfo().getCharSet())) {
index = i;
break;
}
}
dbCharsetCombo.select(index);
index = 0;
for (int i = 0; i < charsets.length; i++) {
String charset = charsets[i];
if (charset.equals(exportConfig.getFileCharset())) {
index = i;
break;
}
}
fileCharsetCombo.select(index);
threadCountSpinner.setSelection(exportConfig.getThreadCount());
useFirstAsColumnBtn.setSelection(exportConfig.isFirstRowAsColumnName());
setColumnDelimeter(exportConfig.getColumnDelimeter());
setRowDelimeter(exportConfig.getRowDelimeter());
if (exportConfig.getNULLValueTranslation() == null || "NULL".equals(exportConfig.getNULLValueTranslation())) {
nullOneButton.setSelection(true);
} else if ("\\N".equals(exportConfig.getNULLValueTranslation())) {
nullTwoButton.setSelection(true);
} else if ("(NULL)".equals(exportConfig.getNULLValueTranslation())) {
nullThreeButton.setSelection(true);
} else {
otherButton.setSelection(true);
String nullValueTranslation = exportConfig.getNULLValueTranslation() == null ? "" : exportConfig.getNULLValueTranslation();
otherText.setText(nullValueTranslation);
}
} else {
// initial check element
List<String> tableList = getExportDataWizardWizard().getTableNameList();
for (String table : tableList) {
for (ICubridNode node : tablesOrViewLst) {
if (table.equalsIgnoreCase(node.getName())) {
treeViewer.setChecked(node, true);
}
}
}
treeViewer.refresh();
String[] charsets = QueryOptions.getAllCharset(null);
int index = 0;
for (int i = 0; i < charsets.length; i++) {
String charset = charsets[i];
if (charset.equals(getDatabase().getDatabaseInfo().getCharSet())) {
index = i;
break;
}
}
schemaButton.setSelection(true);
dataButton.setSelection(true);
indexButton.setSelection(true);
serialButton.setSelection(true);
viewButton.setSelection(true);
startValueButton.setSelection(true);
sqlButton.setSelection(true);
nullOneButton.setSelection(true);
dbCharsetCombo.select(index);
rowDelimiterCombo.setEnabled(false);
fileCharsetCombo.select(index);
rowDelimiterCombo.select(1);
columnDelimiterCombo.select(0);
setDelimiterWidgetStatus(false);
useFirstAsColumnBtn.setEnabled(false);
updateExportLobButtonStatus();
}
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportTypePage method handlePageLeaving.
/**
* When leave current page
*
* @param event PageChangingEvent
*/
protected void handlePageLeaving(PageChangingEvent event) {
if (historyButton.getSelection() && StringUtil.isEmpty(historyCombo.getText())) {
event.doit = false;
firePageStatusChanged(new StatusInfo(IStatus.ERROR, Messages.exportWizardTypePageErrMsg1));
return;
}
if (fileButton.getSelection() || loadDBButton.getSelection()) {
getExportDataWizardWizard().setConfigModel(new ExportConfig());
getExportConfig().setExportType(getExportType());
} else {
ExportConfig historyExportConfigModel = ExportConfigManager.getInstance().getConfig(historyCombo.getText());
if (historyExportConfigModel != null) {
ExportConfig exportConfigModel = cloneExportConfigModel(historyExportConfigModel);
getExportDataWizardWizard().setConfigModel(exportConfigModel);
}
}
}
Aggregations