use of com.cubrid.common.ui.cubrid.procedure.dialog.EditProcedureDialog in project cubrid-manager by CUBRID.
the class EditProcedureAction method run.
/**
* Open the EditProcedureDialog and edit procedure
*/
public void run() {
// FIXME logic code move to core module
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_PROCEDURE.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(null);
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;
}
EditProcedureDialog dlg = new EditProcedureDialog(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.cubrid.procedure.dialog.EditProcedureDialog in project cubrid-manager by CUBRID.
the class AddProcedureAction method run.
/**
* Open AddProcedureDialog
*/
public void run() {
// FIXME logic code move to core module
Shell shell = getShell();
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
EditProcedureDialog dlg = new EditProcedureDialog(shell);
dlg.setDatabase(database);
dlg.setNewFlag(true);
ISelectionProvider provider = getSelectionProvider();
if (dlg.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.SP_FOLDER_ID);
folderNode = folderNode.getChild(folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridSPFolderLoader.PROCEDURE_FOLDER_ID);
TreeViewer treeViewer = (TreeViewer) provider;
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String procedureName = dlg.getProcedureName().toLowerCase(Locale.getDefault());
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + procedureName;
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
SPInfo spInfo = new SPInfo(procedureName);
spInfo.setOwner(userInfo.getName());
ICubridNode newNode = CubridProcedureFolderLoader.createProcedureNode(id, spInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
}
}
Aggregations