Search in sources :

Example 1 with TableSchemaCompareEditorInput

use of com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput in project cubrid-manager by CUBRID.

the class SchemaCompareDialog method buttonPressed.

/**
	 * Call this method when the button in button bar is pressed
	 *
	 * @param buttonId
	 *            the button id
	 */
protected void buttonPressed(int buttonId) {
    isCanceled = false;
    if (buttonId == COMPARE_ID) {
        if (!isSelectedAllSideDatabases()) {
            CommonUITool.openWarningBox(com.cubrid.common.ui.compare.Messages.errNeedSelectCompareDb);
            return;
        }
        if (isSelectedSameDatabases()) {
            CommonUITool.openWarningBox(com.cubrid.common.ui.compare.Messages.errSelectSameCompareDb);
            return;
        }
        final List<String> origDbLabel = new ArrayList<String>();
        for (int i = 0; i < selections.size(); i++) {
            origDbLabel.add(leftCombo.getItem(i));
        }
        final int leftIndex = leftCombo.getSelectionIndex();
        final int rightIndex = rightCombo.getSelectionIndex();
        final List<String> rightDbLabel = new ArrayList<String>();
        final List<CubridDatabase> sourceDBList = new ArrayList<CubridDatabase>();
        final List<CubridDatabase> targetDBList = new ArrayList<CubridDatabase>();
        final List<TableSchemaCompareEditorInput> editorInput = new ArrayList<TableSchemaCompareEditorInput>();
        ITask reportBugTask = new AbstractUITask() {

            public void cancel() {
                isCanceled = true;
            }

            public void finish() {
            }

            public boolean isCancel() {
                return isCanceled;
            }

            public boolean isSuccess() {
                return true;
            }

            public void execute(IProgressMonitor monitor) {
                // FIXME logic code move to core module
                CubridDatabase leftDb = (CubridDatabase) selections.get(leftIndex);
                sourceDBList.add(leftDb);
                List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(leftDb);
                TableSchemaCompareRunner thread = null;
                CubridDatabase rightDb = (CubridDatabase) selections.get(rightIndex);
                targetDBList.add(rightDb);
                rightDbLabel.add(origDbLabel.get(rightIndex));
                thread = new TableSchemaCompareRunner(SchemaCompareDialog.this, leftDb, rightDb, leftDbTableInfoList);
                thread.start();
                try {
                    thread.join();
                } catch (InterruptedException e) {
                    LOGGER.error(e.getMessage(), e);
                }
                TableSchemaCompareEditorInput input = thread.getInput();
                editorInput.add(input);
            }
        };
        TaskExecutor taskExecutor = new CommonTaskExec(Messages.titleSchemaComparison);
        taskExecutor.addTask(reportBugTask);
        new ExecTaskWithProgress(taskExecutor).exec();
        if (taskExecutor.isSuccess()) {
            for (int i = 0; i < rightDbLabel.size(); i++) {
                if (isCanceled) {
                    return;
                }
                showSchemaCompareEditor(editorInput.get(i));
            }
            if (isCanceled) {
                return;
            }
            super.buttonPressed(IDialogConstants.OK_ID);
        }
    }
    super.buttonPressed(buttonId);
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaCompareEditorInput(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) TableSchemaCompareRunner(com.cubrid.common.ui.compare.schema.TableSchemaCompareRunner)

Example 2 with TableSchemaCompareEditorInput

use of com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput in project cubrid-manager by CUBRID.

the class TableSchemaCompareRunner method compareTableSchema.

/**
	 * Create a schema compare editor input
	 *
	 * @param sourceDatabase
	 * @param targetDatabase
	 * @return
	 */
private TableSchemaCompareEditorInput compareTableSchema(CubridDatabase sourceDatabase, CubridDatabase targetDatabase) {
    List<TableDetailInfo> lTableInfoList;
    if (sourceTableInfoList != null) {
        lTableInfoList = sourceTableInfoList;
    } else {
        lTableInfoList = TableSchemaCompareUtil.getTableInfoList(sourceDatabase);
    }
    if (dialog.isCanceled()) {
        return null;
    }
    List<TableDetailInfo> rTableInfoList = getTableInfoList(targetDatabase);
    if (dialog.isCanceled()) {
        return null;
    }
    TableSchemaCompareEditorInput CompareInput = new TableSchemaCompareEditorInput(sourceDatabase, targetDatabase, lTableInfoList, rTableInfoList);
    return CompareInput;
}
Also used : TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaCompareEditorInput(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput)

Example 3 with TableSchemaCompareEditorInput

use of com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput in project cubrid-manager by CUBRID.

the class TableSchemaCompareRunner method run.

public void run() {
    try {
        TableSchemaCompareEditorInput editorInput = compareTableSchema(sourceDb, targetDb);
        setInput(editorInput);
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
        CommonUITool.openErrorBox(Display.getDefault().getActiveShell(), Messages.fetchSchemaErrorFromDB);
    }
}
Also used : TableSchemaCompareEditorInput(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput)

Aggregations

TableSchemaCompareEditorInput (com.cubrid.common.ui.compare.schema.control.TableSchemaCompareEditorInput)3 TableDetailInfo (com.cubrid.common.core.common.model.TableDetailInfo)2 AbstractUITask (com.cubrid.common.core.task.AbstractUITask)1 ITask (com.cubrid.common.core.task.ITask)1 TableSchemaCompareRunner (com.cubrid.common.ui.compare.schema.TableSchemaCompareRunner)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)1 ArrayList (java.util.ArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1