use of com.cubrid.common.ui.query.control.QueryExecuter in project cubrid-manager by CUBRID.
the class ExportQueryResultDialog method buttonPressed.
/**
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
* @param buttonId the id of the button that was pressed (see
* <code>IDialogConstants.*_ID</code> constants)
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
ExportConfig exportConfig = new ExportConfig();
exportConfig.setUsePagination(false);
exportConfig.setExportData(true);
exportConfig.setExportFileType(getFileType());
exportConfig.setExportType(ExportConfig.EXPORT_TO_FILE);
exportConfig.setExportFromCache(exportFromCacheBtn.getSelection());
exportConfig.setThreadCount(threadCountSpinner.getSelection());
exportConfig.setFileCharset(fileCharsetCombo.getText());
exportConfig.setFirstRowAsColumnName(useFirstAsColumnBtn.getSelection());
exportConfig.setRowDelimeter(getRowDelimeter());
exportConfig.setColumnDelimeter(getColumnDelimeter());
String fileFullName = filePathText.getText();
int start = fileFullName.lastIndexOf(File.separator);
String fileName = fileFullName.substring(start + 1, fileFullName.length());
fileName = fileName.replace(getFileExtName(getFileType()), "");
String dir = fileFullName.substring(0, start);
exportConfig.setDataFileFolder(dir);
String nullValue = "";
if (nullOneButton.getSelection()) {
nullValue = NULL_VALUES[0];
} else if (nullTwoButton.getSelection()) {
nullValue = NULL_VALUES[1];
} else if (nullThreeButton.getSelection()) {
nullValue = NULL_VALUES[2];
} else if (otherButton.getSelection()) {
nullValue = otherText.getText();
}
exportConfig.setNULLValueTranslation(nullValue);
CubridDatabase database = null;
for (QueryExecuter queryExecuter : queryExecuterList) {
exportConfig.setSQL(fileName, queryExecuter.getOrignQuery());
exportConfig.setResultSetDataCache(queryExecuter.getTableDataCache());
exportConfig.setDataFilePath(fileName, fileFullName);
if (database == null) {
database = queryExecuter.getDatabase();
}
}
ExportDataEditorInput input = new ExportDataEditorInput();
input.setDatabase(database);
input.setExportConfig(exportConfig);
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, ExportQueryResultDataViewPart.ID);
} catch (Exception e) {
CommonUITool.openErrorBox(getShell(), e.getMessage());
LOGGER.error("", e);
}
}
super.buttonPressed(buttonId);
}
Aggregations