Search in sources :

Example 16 with CubridGroupNode

use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.

the class CQBGroupNodePersistManager method reorderGroup.

/**
	 * Reorder the groups by input string array.
	 *
	 * @param orderedName the ordered group names.
	 */
public void reorderGroup(String[] orderedName) {
    List<CubridGroupNode> tempNode = new ArrayList<CubridGroupNode>();
    for (String name : orderedName) {
        CubridGroupNode cgn = getGroupByName(name);
        if (cgn == null) {
            continue;
        }
        tempNode.add(cgn);
    }
    groupNodeList.clear();
    groupNodeList.addAll(tempNode);
    saveAllGroupNode();
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList)

Example 17 with CubridGroupNode

use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.

the class PasteQueryConnAction method run.

/**
	 * Paste the query connection
	 */
public void run() {
    Object[] objs = this.getSelectedObj();
    if (!isSupported(objs[0])) {
        setEnabled(false);
        return;
    }
    objs = null;
    ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection strSelection = (IStructuredSelection) selection;
        objs = strSelection.toArray();
    }
    if (objs == null || objs.length == 0) {
        return;
    }
    if (!(objs[0] instanceof CubridDatabase)) {
        return;
    }
    CubridDatabase pastedDb = (CubridDatabase) objs[0];
    QueryConnDialog dialog = new QueryConnDialog(getShell(), pastedDb, true);
    int returnCode = dialog.open();
    if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
        CubridDatabase database = dialog.getDatabase();
        CQBDBNodePersistManager.getInstance().addDatabase(database, false);
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
        if (treeViewer == null) {
            return;
        }
        Tree tree = treeViewer.getTree();
        TreeItem item;
        CubridGroupNode parent = getParentGroupNode();
        if (navigatorView.isShowGroup()) {
            item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
        } else {
            item = new TreeItem(tree, SWT.NONE);
        }
        parent.addChild(database);
        CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
        item.setText(database.getLabel());
        item.setData(database);
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        treeViewer.setSelection(new StructuredSelection(database), true);
        if (returnCode == QueryConnDialog.CONNECT_ID) {
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelection(org.eclipse.jface.viewers.ISelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryConnDialog(com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)

Example 18 with CubridGroupNode

use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.

the class CreateConnectionByUrlWizard method performFinish.

/**
	 * Perform finish
	 */
public boolean performFinish() {
    List<CubridDatabase> parsedDatabaseList = connectionPriviewPage.getParsedConnection();
    /*Add the database list to the tree*/
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
    TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
    if (treeViewer == null) {
        return false;
    }
    for (CubridDatabase database : parsedDatabaseList) {
        CQBDBNodePersistManager.getInstance().addDatabase(database, false);
        Tree tree = treeViewer.getTree();
        TreeItem item;
        CubridGroupNode parent = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
        if (navigatorView.isShowGroup()) {
            item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
        } else {
            item = new TreeItem(tree, SWT.NONE);
        }
        parent.addChild(database);
        item.setText(database.getLabel());
        item.setData(database);
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        treeViewer.setSelection(new StructuredSelection(database), true);
    }
    CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
    return true;
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Tree(org.eclipse.swt.widgets.Tree) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 19 with CubridGroupNode

use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.

the class ItemNodeDnDHandler method handle.

/**
	 * Handle the node to be DND.
	 *
	 * @param dragNode the drag node
	 * @param dropNode the drop node
	 * @param insertBefore insert into the drop node before or after
	 * @param dropOperation the drop operation type <code>DND.DROP_COPY</code>
	 *        <code>DND.DROP_MOVE</code>
	 * @return boolean whether to handle with the drop
	 */
public boolean handle(ICubridNode dragNode, ICubridNode dropNode, boolean insertBefore, int dropOperation) {
    ICubridNode newDragNode = dragNode;
    if (DND.DROP_COPY == dropOperation && dragNode instanceof CubridDatabase) {
        Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
        QueryConnDialog dialog = new QueryConnDialog(shell, (CubridDatabase) dragNode, true);
        int returnCode = dialog.open();
        if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
            newDragNode = dialog.getDatabase();
            CQBDBNodePersistManager.getInstance().addDatabase((CubridDatabase) newDragNode, false);
            CubridGroupNode groupNode = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
            groupNode.addChild(newDragNode);
        } else {
            return false;
        }
    }
    return super.handle(newDragNode, dropNode, insertBefore, dropOperation);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryConnDialog(com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)

Example 20 with CubridGroupNode

use of com.cubrid.common.ui.spi.model.CubridGroupNode in project cubrid-manager by CUBRID.

the class DeleteQueryConnAction method run.

/**
	 * Drop the query connection
	 */
public void run() {
    Object[] objArr = this.getSelectedObj();
    if (objArr == null || objArr.length <= 0) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = this.getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    StringBuffer connNames = new StringBuffer();
    for (int i = 0; objArr != null && i < objArr.length; i++) {
        if (!isSupported(objArr[i])) {
            setEnabled(false);
            return;
        }
        ICubridNode node = (ICubridNode) objArr[i];
        connNames.append(node.getLabel());
        if (i != objArr.length - 1) {
            connNames.append(",");
        }
    }
    boolean isDrop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmDropConn, connNames.toString()));
    if (!isDrop) {
        return;
    }
    for (int i = 0; i < objArr.length; i++) {
        CubridDatabase database = (CubridDatabase) objArr[i];
        boolean isContinue = CQBConnectionUtils.processConnectionDeleted(database);
        List<CubridGroupNode> groups = CQBGroupNodePersistManager.getInstance().getAllGroupNodes();
        for (CubridGroupNode grp : groups) {
            grp.removeChild(database);
        }
        if (isContinue) {
            TreeViewer viewer = (TreeViewer) provider;
            viewer.remove(database);
        }
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)46 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)25 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)15 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)15 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)15 ArrayList (java.util.ArrayList)11 TreeViewer (org.eclipse.jface.viewers.TreeViewer)11 TreeItem (org.eclipse.swt.widgets.TreeItem)9 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)6 Tree (org.eclipse.swt.widgets.Tree)6 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)5 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)4 HostDialog (com.cubrid.cubridmanager.ui.host.dialog.HostDialog)4 ISelection (org.eclipse.jface.viewers.ISelection)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 DatabaseMenuItem (com.cubrid.common.ui.query.control.DatabaseMenuItem)3 QueryConnDialog (com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)3 List (java.util.List)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3