use of com.cubrid.common.ui.cubrid.procedure.dialog.EditFunctionDialog in project cubrid-manager by CUBRID.
the class AddFunctionAction method run.
/**
* Open addFunctionDialog
*/
public void run() {
// FIXME logic code move to core module
Shell shell = getShell();
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
EditFunctionDialog dlg = new EditFunctionDialog(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.FUNCTION_FOLDER_ID);
TreeViewer treeViewer = (TreeViewer) provider;
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String functionName = dlg.getFunctionName().toLowerCase(Locale.getDefault());
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + functionName;
DbUserInfo userInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
SPInfo spInfo = new SPInfo(functionName);
spInfo.setOwner(userInfo.getName());
ICubridNode newNode = CubridFunctionFolderLoader.createFunctionNode(id, spInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
}
}
use of com.cubrid.common.ui.cubrid.procedure.dialog.EditFunctionDialog 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());
}
}
Aggregations