Search in sources :

Example 1 with StatusInfo

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);
        }
    }
}
Also used : StatusInfo(com.cubrid.common.ui.spi.StatusInfo) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig)

Example 2 with StatusInfo

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) SelectionListener(org.eclipse.swt.events.SelectionListener) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) FillLayout(org.eclipse.swt.layout.FillLayout) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) StatusInfo(com.cubrid.common.ui.spi.StatusInfo) ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) PageChangingEvent(org.eclipse.jface.dialogs.PageChangingEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 3 with StatusInfo

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);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) StatusInfo(com.cubrid.common.ui.spi.StatusInfo) ArrayList(java.util.ArrayList) File(java.io.File)

Example 4 with StatusInfo

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));
    }
}
Also used : StatusInfo(com.cubrid.common.ui.spi.StatusInfo) Connection(java.sql.Connection) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException)

Aggregations

StatusInfo (com.cubrid.common.ui.spi.StatusInfo)4 ExportConfig (com.cubrid.common.ui.cubrid.table.progress.ExportConfig)2 ArrayList (java.util.ArrayList)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 IStatus (org.eclipse.core.runtime.IStatus)1 IInputValidator (org.eclipse.jface.dialogs.IInputValidator)1 InputDialog (org.eclipse.jface.dialogs.InputDialog)1 PageChangedEvent (org.eclipse.jface.dialogs.PageChangedEvent)1 PageChangingEvent (org.eclipse.jface.dialogs.PageChangingEvent)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridLayout (org.eclipse.swt.layout.GridLayout)1