Search in sources :

Example 26 with ISchemaNode

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);
    }
}
Also used : DeleteBackupPlanAction(com.cubrid.cubridmanager.ui.cubrid.jobauto.action.DeleteBackupPlanAction) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo) HashSet(java.util.HashSet)

Example 27 with ISchemaNode

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);
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) Shell(org.eclipse.swt.widgets.Shell) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) EditFunctionDialog(com.cubrid.common.ui.cubrid.procedure.dialog.EditFunctionDialog) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 28 with ISchemaNode

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);
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CommonSQLExcuterTask(com.cubrid.cubridmanager.core.common.task.CommonSQLExcuterTask) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 29 with ISchemaNode

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;
}
Also used : QueryEditorPart(com.cubrid.common.ui.query.editor.QueryEditorPart) QueryUnit(com.cubrid.common.ui.query.editor.QueryUnit) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 30 with ISchemaNode

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);
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)158 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)104 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)55 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)30 ArrayList (java.util.ArrayList)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)23 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)23 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)22 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)22 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)21 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)21 Shell (org.eclipse.swt.widgets.Shell)16 ITask (com.cubrid.common.core.task.ITask)13 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)13 IEditorPart (org.eclipse.ui.IEditorPart)12 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)12 HashSet (java.util.HashSet)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 PartInitException (org.eclipse.ui.PartInitException)10