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);
}
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;
}
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);
}
}
Aggregations