use of com.cubrid.common.ui.compare.schema.TableSchemaCompareRunner 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);
}
Aggregations