use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class JobAutoDashboardEditorPart method deleteBackupPlan.
public void deleteBackupPlan() {
TableItem[] items = backupPlanInfoTable.getTable().getSelection();
if (items.length > 0) {
List<ISchemaNode> selectNodeList = new ArrayList<ISchemaNode>();
for (TableItem item : items) {
BackupPlanInfo backupPlanInfo = (BackupPlanInfo) item.getData();
Set<String> typeSet = new HashSet<String>();
typeSet.add(CubridNodeType.BACKUP_PLAN);
ICubridNode backupPlanNode = CommonUITool.findNode(database, typeSet, backupPlanInfo.getBackupid());
selectNodeList.add((ISchemaNode) backupPlanNode);
}
if (selectNodeList.size() > 0) {
DeleteBackupPlanAction action = (DeleteBackupPlanAction) ActionManager.getInstance().getAction(DeleteBackupPlanAction.ID);
ISchemaNode[] nodeArr = new ISchemaNode[selectNodeList.size()];
action.run(selectNodeList.toArray(nodeArr));
refreshBackupPlan();
}
} else {
CommonUITool.openWarningBox(Messages.errJobAutoNoSelection);
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class DeleteProcedureAction method run.
public void run() {
// FIXME logic code move to core module
Object[] objects = this.getSelectedObj();
if (objects == null || !isSupported(objects)) {
this.setEnabled(false);
return;
}
Shell shell = getShell();
CubridDatabase database = null;
ISchemaNode node = null;
if (objects[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_PROCEDURE.equals(((ISchemaNode) objects[0]).getType())) {
node = (ISchemaNode) objects[0];
database = node.getDatabase();
}
if (database == null || node == null) {
CommonUITool.openErrorBox(shell, Messages.errSelectProcedure);
return;
}
if (!CommonUITool.openConfirmBox(shell, Messages.msgSureDropProcedure)) {
return;
}
CommonSQLExcuterTask task = new CommonSQLExcuterTask(database.getDatabaseInfo());
String sql = " DROP PROCEDURE " + QuerySyntax.escapeKeyword(node.getName());
task.addSqls(sql);
TaskExecutor taskExcutor = new CommonTaskExec(null);
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 CopyToClipboardAction method openNewQueryEditor.
/**
* Open the new query editor
*
* @return IEditorPart
*/
private IEditorPart openNewQueryEditor() {
IWorkbenchPage activePage = LayoutUtil.getActivePage();
QueryUnit queryUnit = new QueryUnit();
Object[] selected = getSelectedObj();
CubridDatabase database = null;
if (selected.length >= 1 && selected[0] instanceof ISchemaNode) {
database = ((ISchemaNode) selected[0]).getDatabase();
queryUnit.setDatabase(database);
}
try {
IEditorPart editor = activePage.openEditor(queryUnit, QueryEditorPart.ID);
if (editor != null && database != null) {
((QueryEditorPart) editor).connect(database);
}
return editor;
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
return null;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CreateViewAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
run(database);
}
Aggregations