Search in sources :

Example 36 with CubridGroupNode

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

the class PasteQueryConnAction method isSupported.

/**
	 * 
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj the Object
	 * @return <code>true</code> if support this obj;<code>false</code>
	 *         otherwise
	 */
public boolean isSupported(Object obj) {
    if (ApplicationType.CUBRID_QUERY_BROWSER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        if (navigatorView == null) {
            return false;
        }
        boolean isShowGroup = navigatorView.isShowGroup();
        if (isShowGroup && !(obj instanceof CubridDatabase) && !(obj instanceof CubridGroupNode)) {
            return false;
        }
        if (!isShowGroup && obj != null && !(obj instanceof CubridDatabase)) {
            return false;
        }
        Object[] 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 false;
        }
        if (!(objs[0] instanceof CubridDatabase)) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 37 with CubridGroupNode

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

the class CMGroupNodePersistManager 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 38 with CubridGroupNode

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

the class CMGroupNodePersistManager method addGroupNode.

/**
	 * Add a new group node to list. The default group node only contain the
	 * items which has no parent group.
	 *
	 * @param group new group node.
	 */
public void addGroupNode(CubridGroupNode group) {
    synchronized (this) {
        if (!groupNodeList.contains(group)) {
            groupNodeList.add(group);
        }
        //refresh the default node.
        List<ICubridNode> nodesHasParent = new ArrayList<ICubridNode>();
        CubridGroupNode dftNode = null;
        for (CubridGroupNode grp : groupNodeList) {
            //if is default node, don't add children here.
            if (isDefaultGroup(grp)) {
                dftNode = grp;
            } else {
                nodesHasParent.addAll(grp.getChildren());
            }
        }
        dftNode.removeAllChild();
        List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
        for (CubridServer ser : servers) {
            if (!nodesHasParent.contains(ser)) {
                dftNode.addChild(ser);
            }
        }
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 39 with CubridGroupNode

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

the class CMGroupNodePersistManager method loadGroupNode.

/**
	 * Load group nodes from xml memento.
	 *
	 * @param memento IXMLMemento
	 *
	 */
private void loadGroupNode(IXMLMemento memento) {
    IXMLMemento[] children = memento == null ? null : memento.getChildren("group");
    groupNodeList.clear();
    for (int i = 0; children != null && i < children.length; i++) {
        String id = children[i].getString("id");
        String name = children[i].getString("name");
        CubridGroupNode cgn = getGroupById(id);
        if (cgn == null) {
            cgn = new CubridGroupNode(id, name, DEFAULT_GROUP_NODE.getIconPath());
            groupNodeList.add(cgn);
        }
        cgn.setLoader(DEFAULT_GROUP_NODE.getLoader());
        IXMLMemento[] items = children[i].getChildren("item");
        for (IXMLMemento item : items) {
            String itemId = item.getString("id");
            CubridServer cs = CMHostNodePersistManager.getInstance().getServer(itemId);
            if (cs == null) {
                continue;
            }
            cgn.addChild(cs);
        }
    }
    //groupNodeList.size >=1
    if (groupNodeList.isEmpty()) {
        try {
            groupNodeList.add((CubridGroupNode) DEFAULT_GROUP_NODE.clone());
            List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
            for (CubridServer server : servers) {
                groupNodeList.get(0).addChild(server);
            }
        } catch (CloneNotSupportedException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 40 with CubridGroupNode

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

the class CMGroupNodePersistManager method removeGroup.

/**
	 * Remove group by id
	 *
	 * @param groupId group id or group name
	 */
public void removeGroup(String groupId) {
    List<CubridGroupNode> groups = getAllGroupNodes();
    CubridGroupNode tobeRemoved = null;
    for (CubridGroupNode group : groups) {
        if (group.getId().equals(groupId)) {
            tobeRemoved = group;
        }
    }
    this.groupNodeList.remove(tobeRemoved);
    CubridGroupNode defaultGroup = getDefaultGroup();
    List<ICubridNode> children = tobeRemoved.getChildren();
    for (ICubridNode chi : children) {
        defaultGroup.addChild(chi);
    }
    saveAllGroupNode();
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

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