use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CubridTitleLineContrItem method getTitleForViewOrEdit.
/**
*
* Get the title of view or editor(not including query editor)
*
* @param cubridNode the ICubridNode object
* @param workbenchPart the IWorkbenchPart object
* @return String
*/
protected String getTitleForViewOrEdit(ICubridNode cubridNode, IWorkbenchPart workbenchPart) {
StringBuffer titleStrBuffer = new StringBuffer();
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
CubridDatabase database = schemaNode.getDatabase();
titleStrBuffer.append(database.getLabel());
}
String partTitle = "";
if (workbenchPart == null) {
if (null != cubridNode.getViewId()) {
IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, cubridNode.getViewId());
if (viewPart != null) {
partTitle = viewPart.getTitle();
}
}
if (null != cubridNode.getEditorId()) {
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, cubridNode.getEditorId());
if (editorPart != null) {
partTitle = editorPart.getTitle();
}
}
} else {
partTitle = workbenchPart.getTitle();
}
if (partTitle != null && partTitle.trim().length() > 0) {
titleStrBuffer.append(" / " + partTitle);
}
return titleStrBuffer.toString();
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class QueryNewCustomAction method getSelectedSchemaNode.
/**
* Get current selected schema node.
*
* @return CubridDatabase
*/
private CubridDatabase getSelectedSchemaNode() {
Object[] selected = getSelectedObj();
CubridDatabase database = null;
if (selected != null && selected.length >= 1 && selected[0] instanceof ISchemaNode) {
database = ((ISchemaNode) selected[0]).getDatabase();
}
return database;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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);
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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.model.ISchemaNode 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