use of com.cubrid.common.ui.spi.progress.CommonTaskExec in project cubrid-manager by CUBRID.
the class DeleteFunctionAction method run.
public void run() {
// FIXME logic code move to core module
Object[] objects = this.getSelectedObj();
if (objects == null || !isSupported(objects)) {
setEnabled(false);
return;
}
Shell shell = getShell();
CubridDatabase database = null;
ISchemaNode node = null;
if (objects[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_FUNCTION.equals(((ISchemaNode) objects[0]).getType())) {
node = (ISchemaNode) objects[0];
database = node.getDatabase();
}
if (database == null || node == null) {
CommonUITool.openErrorBox(shell, Messages.errSelectFunction);
return;
}
if (!CommonUITool.openConfirmBox(shell, Messages.msgSureDropFunction)) {
return;
}
CommonSQLExcuterTask task = new CommonSQLExcuterTask(database.getDatabaseInfo());
for (Object object : objects) {
node = (ISchemaNode) object;
String sql = "DROP FUNCTION " + QuerySyntax.escapeKeyword(node.getName());
task.addSqls(sql);
}
TaskExecutor taskExcutor = new CommonTaskExec(getText());
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
ISelectionProvider provider = this.getSelectionProvider();
ICubridNode parent = node.getParent();
if (provider instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer) provider;
for (int i = 0; objects != null && i < objects.length; i++) {
parent.removeChild((ISchemaNode) objects[i]);
}
viewer.remove(parent, objects);
viewer.setSelection(new StructuredSelection(parent), true);
}
}
use of com.cubrid.common.ui.spi.progress.CommonTaskExec 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.CommonTaskExec 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.CommonTaskExec 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.CommonTaskExec 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