use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress in project cubrid-manager by CUBRID.
the class EditFunctionAction method run.
/**
* Open the EditFunctionDialog and edit function
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (!isSupported(objArr)) {
this.setEnabled(false);
return;
}
Shell shell = getShell();
CubridDatabase database = null;
ISchemaNode node = null;
if (objArr[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_FUNCTION.equals(((ISchemaNode) objArr[0]).getType())) {
node = (ISchemaNode) objArr[0];
database = node.getDatabase();
}
if (database == null || node == null) {
CommonUITool.openErrorBox(shell, Messages.errSelectProcedure);
return;
}
final GetSPInfoListTask task = new GetSPInfoListTask(database.getDatabaseInfo());
task.setSpName(node.getName());
TaskExecutor taskExcutor = new CommonTaskExec(getText());
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<SPInfo> list = task.getSPInfoList();
if (list.size() > 1) {
CommonUITool.openErrorBox(shell, Messages.errDuplicateName);
return;
}
if (list.isEmpty()) {
CommonUITool.openErrorBox(shell, Messages.errNotExistName);
return;
}
EditFunctionDialog dlg = new EditFunctionDialog(shell);
dlg.setDatabase(database);
dlg.setNewFlag(false);
dlg.setSpInfo(list.get(0));
if (dlg.open() == IDialogConstants.OK_ID) {
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.common.ui.spi.progress.ExecTaskWithProgress 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.ExecTaskWithProgress 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.ExecTaskWithProgress 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.ExecTaskWithProgress 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);
}
}
}
Aggregations