Search in sources :

Example 41 with CubridGroupNode

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

the class ServiceDashboardEditor method loadAllData.

/**
	 * Load all data
	 */
public void loadAllData() {
    ServiceDashboardInfoMap.clear();
    CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
    if (navigatorView != null && navigatorView.savedIsShowGroup()) {
        inputList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
        List<CubridGroupNode> groupList = loadCubridGroupData(inputList);
        serviceTreeViewer.setInput(groupList);
    } else {
        inputList = CMHostNodePersistManager.getInstance().getAllServers();
        loadServerDashboardInfo(inputList);
        serviceTreeViewer.setInput(ServiceDashboardInfoMap);
    }
    serviceTreeViewer.expandAll();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode)

Example 42 with CubridGroupNode

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

the class CQDatabaseNavigatorMenu method loadNavigatorMenu.

/**
	 * load all database on all server. if not login or database not started,
	 * the item disabled.
	  * 
	  * @param dbSelectionMenu
	 */
public void loadNavigatorMenu(Menu dbSelectionMenu) {
    setSelectedImage(CubridQueryUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
    boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
    List<CubridGroupNode> groupList = CQBGroupNodePersistManager.getInstance().getAllGroupNodes();
    if (groupList == null || groupList.isEmpty()) {
        return;
    }
    Collections.sort(groupList, new Comparator<CubridGroupNode>() {

        public int compare(CubridGroupNode o1, CubridGroupNode o2) {
            if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
                return 0;
            }
            return o1.getLabel().compareToIgnoreCase(o2.getLabel());
        }
    });
    int count = 0;
    for (CubridGroupNode groupNode : groupList) {
        //			if (NodeFilterManager.getInstance().isHidden(groupNode)) {
        //				continue;
        //			}
        List<ICubridNode> nodeList = groupNode.getChildren();
        if (nodeList == null || nodeList.isEmpty()) {
            continue;
        }
        DatabaseMenuItem groupMenuItem = null;
        Menu groupSub = null;
        String groupName = null;
        if (isShowGroup) {
            groupName = groupNode.getLabel();
            groupMenuItem = new DatabaseMenuItem(groupNode.getId(), dbSelectionMenu, SWT.CASCADE);
            groupMenuItem.setImage(CubridQueryUIPlugin.getImage("/icons/navigator/group.png"));
            groupMenuItem.setText(groupNode.getLabel());
            groupSub = new Menu(dbSelectionMenu);
            groupMenuItem.setMenu(groupSub);
        }
        Collections.sort(nodeList, new Comparator<ICubridNode>() {

            public int compare(ICubridNode o1, ICubridNode o2) {
                if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
                    return 0;
                }
                return o1.getLabel().compareToIgnoreCase(o2.getLabel());
            }
        });
        int itemCountInGroup = 0;
        for (ICubridNode node : nodeList) {
            //				}
            if (node instanceof CubridDatabase) {
                CubridDatabase database = (CubridDatabase) node;
                if (!database.isLogined()) {
                    continue;
                }
                itemCountInGroup++;
                DatabaseMenuItem dbItem = null;
                if (isShowGroup) {
                    dbItem = new DatabaseMenuItem(database.getId(), groupSub, SWT.RADIO);
                } else {
                    dbItem = new DatabaseMenuItem(database.getId(), dbSelectionMenu, SWT.RADIO);
                }
                dbItem.setText(database.getLabelWithUser());
                dbItem.setDatabase((CubridDatabase) database);
                dbItem.setEnabled(database.isLogined() && database.getRunningType() == DbRunningType.CS);
                dbItem.setGroupName(groupName);
                count++;
            }
        }
        // If it has no active item on the group, it's group should be disposed
        if (isShowGroup && itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
            groupSub.dispose();
            groupMenuItem.dispose();
        }
    }
    if (count > 0) {
        new MenuItem(dbSelectionMenu, SWT.SEPARATOR);
    }
}
Also used : MenuItem(org.eclipse.swt.widgets.MenuItem) DatabaseMenuItem(com.cubrid.common.ui.query.control.DatabaseMenuItem) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DatabaseMenuItem(com.cubrid.common.ui.query.control.DatabaseMenuItem) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) DatabaseNavigatorMenu(com.cubrid.common.ui.query.control.DatabaseNavigatorMenu) Menu(org.eclipse.swt.widgets.Menu) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 43 with CubridGroupNode

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

the class CQBGroupNodePersistManager 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<CubridDatabase> databases = CQBDBNodePersistManager.getInstance().getAllDatabase();
        for (CubridDatabase db : databases) {
            if (!nodesHasParent.contains(db)) {
                dftNode.addChild(db);
            }
        }
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 44 with CubridGroupNode

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

the class CQBGroupNodePersistManager method loadGroupNode.

/**
	 * Load group nodes from xml memento.
	 *
	 * @param memento IXMLMemento
	 */
private void loadGroupNode(IXMLMemento memento) {
    if (memento != null) {
        IXMLMemento[] children = memento.getChildren("group");
        for (int i = 0; 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");
                CubridDatabase cs = CQBDBNodePersistManager.getInstance().getDatabase(itemId);
                if (cs == null || cs.getParent() != null) {
                    continue;
                }
                cgn.addChild(cs);
            }
        }
    }
    //groupNodeList.size >=1
    if (groupNodeList.isEmpty()) {
        try {
            CubridGroupNode defaultGroup = (CubridGroupNode) DEFAULT_GROUP_NODE.clone();
            groupNodeList.add(defaultGroup);
            List<CubridDatabase> servers = CQBDBNodePersistManager.getInstance().getAllDatabase();
            for (CubridDatabase server : servers) {
                defaultGroup.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) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 45 with CubridGroupNode

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

the class CQBGroupNodePersistManager method saveAllGroupNode.

/**
	 * Save all group node.
	 *
	 */
public void saveAllGroupNode() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("groups");
        for (CubridGroupNode group : groupNodeList) {
            IXMLMemento child = memento.createChild("group");
            child.putString("id", group.getId());
            child.putString("name", group.getName());
            for (ICubridNode cn : group.getChildren()) {
                IXMLMemento childHost = child.createChild("item");
                childHost.putString("id", cn.getId());
            }
        }
        PersistUtils.saveXMLMemento(ApplicationUtil.CQB_UI_PLUGIN_ID, COM_CUBRID_QB_DBGROUP, memento);
    }
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) 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