use of com.cubrid.common.ui.spi.StatusInfo 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);
}
}
}
use of com.cubrid.common.ui.spi.StatusInfo 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.spi.StatusInfo in project cubrid-manager by CUBRID.
the class ExportSettingPage method updateDialogStatus.
/**
* update dialog status
*
* @param errorStatus IStatus errorStatus
*/
private void updateDialogStatus(IStatus errorStatus) {
if (errorStatus != null) {
firePageStatusChanged(errorStatus);
return;
}
List<IStatus> statusList = new ArrayList<IStatus>();
IStatus dialogStatus = new StatusInfo(IStatus.INFO, Messages.titleExportSetting);
statusList.add(dialogStatus);
if (treeViewer.getCheckedElements().length == 0) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.exportSelectTargetTableERRORMSG));
} else if (StringUtil.isEmpty(pathText.getText())) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.exportSelectFileERRORMSG));
} else if (!checkExportOptions()) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.exportDataCheckErrorMsg));
} else if (otherButton.getSelection()) {
if (otherText.getText().trim().length() == 0) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.msgErrorOtherValueEmpty));
} else if (otherText.getText().indexOf(",") >= 0) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.msgErrorContainsComma));
}
} else if (txtButton.getSelection()) {
if (columnDelimiterCombo.getText().indexOf("\"") >= 0 || columnDelimiterCombo.getText().indexOf("\n") >= 0) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.errorSeparatorInvalid));
} else if (columnDelimiterCombo.getText().equals(rowDelimiterCombo.getText())) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.errorSeparatorInvalid2));
}
}
if (getExportConfig().isHistory()) {
File testFilePath = new File(pathText.getText());
if (!testFilePath.exists()) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.exportWizardSettngPageFilepathErrMsg));
}
}
IStatus status = CommonUITool.getMostSevere(statusList);
firePageStatusChanged(status);
}
use of com.cubrid.common.ui.spi.StatusInfo in project cubrid-manager by CUBRID.
the class ExportSettingPage method checkWhereConditions.
/**
* check where condition
*
* @return error table list
*/
public void checkWhereConditions(List<IStatus> statusList) {
// FIXME move this logic to core module
Connection conn = null;
List<String> errorList = new ArrayList<String>();
try {
conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), false);
for (Object object : treeViewer.getCheckedElements()) {
ICubridNode node = (ICubridNode) object;
if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
Object o = node.getData(ExportObjectLabelProvider.CONDITION);
if (o == null) {
continue;
}
String tableName = node.getName();
if (!checkOneCondition(conn, tableName, o.toString())) {
errorList.add(tableName);
}
}
}
} catch (Exception e) {
CommonUITool.openErrorBox(getShell(), Messages.importErrorHead + e.getMessage());
LOGGER.error("", e);
} finally {
QueryUtil.freeQuery(conn);
}
if (!errorList.isEmpty()) {
statusList.add(new StatusInfo(IStatus.ERROR, Messages.conditionError + errorList));
}
}
Aggregations