use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class EditProcedureDialog method execute.
/**
* Execute tasks
*
* @param buttonId the button id
* @param tasks the tasks array
*/
public void execute(final int buttonId, final ITask[] tasks) {
TaskExecutor taskExcutor = new CommonTaskExec(null);
taskExcutor.setTask(tasks);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess() && buttonId >= 0) {
setReturnCode(buttonId);
close();
}
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class CreateOrEditSerialDialog method createSerial.
/**
* Execute task and create serial
*
* @param buttonId the button id
*/
private void createSerial(final int buttonId) {
// FIXME move this logic to core module
serialName = serialNameText.getText();
final String startVal = startValText.getText();
final String incrementVal = incrementValText.getText();
final String minVal = minValText.getText();
final String maxVal = maxValText.getText();
final boolean isNoMinValue = noMinValueBtn.getSelection();
final boolean isNoMaxValue = noMaxValueBtn.getSelection();
final boolean isCycle = cycleButton.getSelection();
final String cacheCount = isSupportCache ? cacheCountText.getText().trim() : null;
final boolean isNoCache = isSupportCache ? noCacheBtn.getSelection() : false;
if (editedNode == null) {
taskName = Messages.bind(Messages.createSerialTaskName, serialName);
} else {
taskName = Messages.bind(Messages.editSerialTaskName, serialName);
}
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
if (task instanceof CreateOrEditSerialTask) {
CreateOrEditSerialTask createSerialTask = (CreateOrEditSerialTask) task;
if (editedNode == null) {
createSerialTask.createSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
} else {
createSerialTask.editSerial(serialName, startVal, incrementVal, maxVal, minVal, isCycle, isNoMinValue, isNoMaxValue, cacheCount, isNoCache);
}
}
final String msg = task.getErrorMsg();
if (monitor.isCanceled()) {
return false;
}
if (openErrorBox(getShell(), msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
DatabaseInfo databaseInfo = database.getDatabaseInfo();
CreateOrEditSerialTask task = new CreateOrEditSerialTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
setReturnCode(buttonId);
close();
}
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor 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.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class ExportERwinAction method run.
public void run() {
// FIXME logic code move to core module
int selected = 0;
int logined = 0;
Object[] objects = getSelectedObj();
if (objects instanceof Object[]) {
for (Object object : objects) {
if (object instanceof CubridDatabase) {
selected++;
CubridDatabase database = (CubridDatabase) object;
if (database.isLogined()) {
logined++;
}
}
}
}
if (selected > 1) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectLeastOneDb);
return;
}
if (selected <= 0) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectExportDb);
return;
}
if (logined <= 0) {
CommonUITool.openWarningBox(com.cubrid.common.ui.cubrid.database.erwin.Messages.errERwinSelectLoginedDb);
return;
}
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE | SWT.APPLICATION_MODAL);
dialog.setFilterExtensions(new String[] { "*.xml" });
String filename = dialog.open();
if (filename == null) {
return;
}
if (filename.trim().equals("")) {
CommonUITool.openErrorBox(Messages.errFileNameIsEmpty);
return;
}
for (Object obj : objects) {
if (!(obj instanceof CubridDatabase)) {
continue;
}
CubridDatabase database = (CubridDatabase) obj;
final Map<String, SchemaInfo> allSchemaInfos = new HashMap<String, SchemaInfo>();
TaskExecutor executor = new TaskExecutor() {
public boolean exec(IProgressMonitor monitor) {
for (ITask task : taskList) {
if (task instanceof ExportSchemaTask) {
ExportSchemaTask eTask = (ExportSchemaTask) task;
try {
eTask.initMarshaller();
} catch (JAXBException e) {
e.printStackTrace();
eTask.cancel();
return false;
}
monitor.setTaskName(Messages.msgGenerateInfo);
monitor.worked(50);
eTask.execute();
monitor.setTaskName(Messages.msgFinished);
monitor.worked(100);
monitor.done();
} else if (task instanceof GetAllSchemaTask) {
monitor.beginTask(Messages.msgGenerateInfo, 100);
GetAllSchemaTask gTask = (GetAllSchemaTask) task;
gTask.execute();
if (task.getErrorMsg() == null) {
allSchemaInfos.putAll(gTask.getSchemas());
}
if (allSchemaInfos.size() == 0) {
continue;
}
}
}
return true;
}
};
ExportSchemaTask task = new ExportSchemaTask(allSchemaInfos, filename);
GetAllSchemaTask schemaTask = new GetAllSchemaTask(database.getDatabaseInfo());
executor.addTask(schemaTask);
executor.addTask(task);
new ExecTaskWithProgress(executor).busyCursorWhile();
if (executor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleExportSchema, Messages.msgExportSuccess);
}
}
}
use of com.cubrid.common.ui.spi.progress.TaskExecutor in project cubrid-manager by CUBRID.
the class CreateViewAction method run.
public void run(CubridDatabase database) {
TaskExecutor taskExcutor = new CommonTaskExec(null);
DatabaseInfo databaseInfo = database.getDatabaseInfo();
JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<String> dbUserList = task.getDbUserList();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, true);
dialog.setDbUserList(dbUserList);
ISelectionProvider provider = getSelectionProvider();
if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String viewName = dialog.getNewViewName();
String owner = dialog.getOwner();
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + viewName;
ClassInfo newClassInfo = new ClassInfo(viewName, owner, ClassType.VIEW, false, false);
ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode(id, newClassInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
Aggregations