use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig 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);
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportTypePage method createControl.
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(new FormLayout());
setTitle(Messages.titleExportStep1);
setDescription(Messages.exportWizardTypeDescription);
setControl(container);
Composite leftComposite = new Composite(container, SWT.NONE);
FormData leftData = new FormData();
leftData.top = new FormAttachment(0, 5);
leftData.bottom = new FormAttachment(100, 0);
leftData.left = new FormAttachment(0, 5);
leftData.right = new FormAttachment(50, 0);
GridLayout leftLayout = new GridLayout();
leftLayout.verticalSpacing = 0;
leftComposite.setLayout(leftLayout);
leftComposite.setLayoutData(leftData);
Composite rightComposite = new Composite(container, SWT.NONE);
FormData rightData = new FormData();
rightData.top = new FormAttachment(0, 5);
rightData.bottom = new FormAttachment(100, 0);
rightData.left = new FormAttachment(50, 0);
rightData.right = new FormAttachment(100, -5);
GridLayout rightLayout = new GridLayout();
rightLayout.verticalSpacing = 0;
rightComposite.setLayout(rightLayout);
rightComposite.setLayoutData(rightData);
fileButton = new Button(leftComposite, SWT.RADIO);
fileButton.setText(Messages.exportWizardType1);
fileButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
fileButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
historyButton.setSelection(!fileButton.getSelection());
loadDBButton.setSelection(!fileButton.getSelection());
changeHistoryCompStatus();
}
});
Group fileLabelGroup = new Group(leftComposite, SWT.None);
fileLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
fileLabelGroup.setLayout(new FillLayout());
Label fileLabel = new Label(fileLabelGroup, SWT.WRAP);
fileLabel.setText(Messages.exportWizardTypeDescription1);
Label separator1Label = new Label(leftComposite, SWT.None);
separator1Label.setLayoutData(CommonUITool.createGridData(1, 1, 0, 20));
historyButton = new Button(leftComposite, SWT.RADIO);
historyButton.setText(Messages.exportWizardType3);
historyButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
historyButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
fileButton.setSelection(!historyButton.getSelection());
loadDBButton.setSelection(!historyButton.getSelection());
changeHistoryCompStatus();
setPageComplete(true);
}
});
Group historyLabelGroup = new Group(leftComposite, SWT.None);
historyLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
historyLabelGroup.setLayout(new FillLayout());
Label historyLabel = new Label(historyLabelGroup, SWT.WRAP);
historyLabel.setText(Messages.exportWizardTypeDescription3);
Composite historyComposite = new Composite(leftComposite, SWT.None);
historyComposite.setLayout(new GridLayout(3, false));
historyComposite.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
historyCombo = new Combo(historyComposite, SWT.READ_ONLY);
historyCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
historyCombo.setEnabled(false);
historyCombo.addListener(SWT.Modify, new Listener() {
public void handleEvent(Event event) {
ExportConfig historyExportConfigModel = ExportConfigManager.getInstance().getConfig(historyCombo.getText());
if (historyExportConfigModel != null) {
ExportConfig exportConfigModel = cloneExportConfigModel(historyExportConfigModel);
getExportDataWizardWizard().setConfigModel(exportConfigModel);
}
firePageStatusChanged(new StatusInfo(IStatus.INFO, ""));
setPageComplete(true);
}
});
final ExportConfigManager configManager = ExportConfigManager.getInstance();
List<ExportConfig> configList = configManager.getAllConfigs();
for (ExportConfig model : configList) {
historyCombo.add(model.getName());
}
renameButton = new Button(historyComposite, SWT.None);
renameButton.setText(Messages.btnRenameHistory);
renameButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
renameButton.setEnabled(false);
renameButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
String historyName = historyCombo.getText();
if (historyName == null || historyName.trim().length() == 0) {
return;
}
ExportConfig model = configManager.getConfig(historyName);
if (model == null) {
return;
}
InputDialog dialog = new InputDialog(getShell(), Messages.titleExportRenameDialog, Messages.descExportRenameDialog, historyName, new IInputValidator() {
public String isValid(String newText) {
if (newText == null || newText.trim().length() == 0) {
return Messages.msgExportRenamePleaseInputNewName;
}
if (configManager.getConfig(newText) != null) {
return Messages.msgExportRenameAlreadyExists;
}
return null;
}
});
if (dialog.open() == IDialogConstants.OK_ID) {
String newName = dialog.getValue();
model.setName(newName);
configManager.saveConfigs();
historyCombo.remove(historyName);
historyCombo.add(newName);
historyCombo.setText(newName);
}
}
});
deleteButton = new Button(historyComposite, SWT.None);
deleteButton.setText(Messages.btnDeleteHistory);
deleteButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
deleteButton.setEnabled(false);
deleteButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
if (!CommonUITool.openConfirmBox(Messages.confirmDeleteExportHistory)) {
return;
}
String historyName = historyCombo.getText();
if (historyName == null || historyName.trim().length() == 0) {
return;
}
configManager.removeConfig(configManager.getConfig(historyName));
configManager.saveConfigs();
historyCombo.remove(historyName);
}
});
loadDBButton = new Button(rightComposite, SWT.RADIO);
loadDBButton.setText(Messages.exportWizardType2);
loadDBButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
loadDBButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
public void widgetSelected(SelectionEvent e) {
fileButton.setSelection(!loadDBButton.getSelection());
historyButton.setSelection(!loadDBButton.getSelection());
changeHistoryCompStatus();
historyButton.setSelection(false);
fileButton.setSelection(false);
}
});
Group loadDBLabelGroup = new Group(rightComposite, SWT.None);
loadDBLabelGroup.setLayoutData(CommonUITool.createGridData(1, 1, 370, 100));
loadDBLabelGroup.setLayout(new FillLayout());
Label loadDBLabel = new Label(loadDBLabelGroup, SWT.WRAP);
loadDBLabel.setText(Messages.exportWizardTypeDescription2);
}
use of com.cubrid.common.ui.cubrid.table.progress.ExportConfig in project cubrid-manager by CUBRID.
the class ExportSettingForLoadDBPage method init.
/**
* Initial the page values.
*
*/
private void init() {
initTableColumnInfo();
ctv.setInput(tablesOrViewLst);
if (getExportConfig().isHistory()) {
//history
ExportConfig exportConfig = getExportConfig();
for (String table : exportConfig.getTableNameList()) {
for (ICubridNode node : tablesOrViewLst) {
if (table.equalsIgnoreCase(node.getName())) {
ctv.setChecked(node, true);
String whereCondition = getExportConfig().getWhereCondition(table);
if (StringUtil.isNotEmpty(whereCondition)) {
node.setData(ExportObjectLabelProvider.CONDITION, whereCondition);
}
}
}
}
ctv.refresh();
if (exportConfig.isExportSchema()) {
schemaButton.setSelection(true);
schemaPathText.setText(exportConfig.getSchemaFilePath());
schemaPathText.setEnabled(true);
schemaBrowseButton.setEnabled(true);
if (exportConfig.isExportSerialStartValue()) {
startValueButton.setEnabled(true);
}
}
if (exportConfig.isExportData()) {
dataButton.setSelection(true);
dataPathText.setText(exportConfig.getDataFileFolder());
dataPathText.setEnabled(true);
dataBrowseButton.setEnabled(true);
}
if (exportConfig.isExportIndex()) {
indexButton.setSelection(true);
indexPathText.setText(exportConfig.getIndexFilePath());
indexPathText.setEnabled(true);
indexBrowseButton.setEnabled(true);
}
} else {
List<String> tableList = ((ExportDataWizard) getWizard()).getTableNameList();
for (String table : tableList) {
for (ICubridNode node : tablesOrViewLst) {
if (table.equalsIgnoreCase(node.getName())) {
ctv.setChecked(node, true);
}
}
}
ctv.refresh();
schemaButton.setSelection(true);
indexButton.setSelection(true);
dataButton.setSelection(true);
startValueButton.setSelection(true);
}
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(getExportConfig().getFileCharset())) {
index = i;
break;
}
}
fileCharsetCombo.select(index);
updateDialogStatus();
}
Aggregations