Search in sources :

Example 31 with CubridGroupNode

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

the class PasteHostAction 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) {
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    if (navigatorView == null) {
        return false;
    }
    boolean isShowGroup = navigatorView.isShowGroup();
    if (isShowGroup && !(obj instanceof CubridServer) && !(obj instanceof CubridGroupNode)) {
        return false;
    }
    if (!isShowGroup && obj != null && !(obj instanceof CubridServer)) {
        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 CubridServer)) {
        return false;
    }
    return true;
}
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) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 32 with CubridGroupNode

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

the class ServiceDashboardEditor method loadCubridGroupData.

/**
	 * Load cubrid group data
	 */
private List<CubridGroupNode> loadCubridGroupData(Object input) {
    @SuppressWarnings("unchecked") List<CubridGroupNode> groupList = (List<CubridGroupNode>) input;
    List<CubridGroupNode> newGroupList = new ArrayList<CubridGroupNode>();
    List<CubridServer> serverList = new ArrayList<CubridServer>();
    if (groupList != null) {
        for (CubridGroupNode groupNode : groupList) {
            serverList = new ArrayList<CubridServer>();
            CubridGroupNode newGroupNode = new CubridGroupNode(groupNode.getId(), groupNode.getLabel(), groupNode.getIconPath());
            List<ICubridNode> nodeList = ((CubridGroupNode) groupNode).getChildren();
            for (ICubridNode node : nodeList) {
                serverList.add((CubridServer) node);
            }
            loadServerDashboardInfo(serverList);
            for (CubridServer server : serverList) {
                newGroupNode.addChild(ServiceDashboardInfoMap.get(server.getName()));
            }
            newGroupList.add(newGroupNode);
        }
    }
    return newGroupList;
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ArrayList(java.util.ArrayList) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 33 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 34 with CubridGroupNode

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

the class CMDatabaseNavigatorMenu 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(CubridManagerUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
    boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
    List<CubridGroupNode> groupList = CMGroupNodePersistManager.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(CubridManagerUIPlugin.getImage("/icons/navigator/group.png"));
            groupMenuItem.setText(groupName);
            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 CubridServer) {
                CubridServer server = (CubridServer) node;
                ICubridNode databaseFolderNode = server.getChild(server.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridServerLoader.DATABASE_FOLDER_ID);
                if (databaseFolderNode == null) {
                    continue;
                }
                //					if (NodeFilterManager.getInstance().isHidden(databaseFolderNode)) {
                //						continue;
                //					}
                ICubridNode[] dbs = databaseFolderNode.getChildren(new NullProgressMonitor());
                if (dbs == null || dbs.length == 0) {
                    continue;
                }
                String serverName = server.getLabel();
                DatabaseMenuItem serverMenuItem = null;
                Menu serverSub = null;
                if (isShowGroup) {
                    serverMenuItem = new DatabaseMenuItem(server.getId(), groupSub, SWT.CASCADE);
                    serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
                    serverMenuItem.setText(serverName);
                    serverSub = new Menu(groupSub);
                    serverMenuItem.setMenu(serverSub);
                } else {
                    serverMenuItem = new DatabaseMenuItem(server.getId(), dbSelectionMenu, SWT.CASCADE);
                    serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
                    serverMenuItem.setText(serverName);
                    serverSub = new Menu(dbSelectionMenu);
                    serverMenuItem.setMenu(serverSub);
                }
                count++;
                for (ICubridNode database : dbs) {
                    //						if (NodeFilterManager.getInstance().isHidden(database)) {
                    //							continue;
                    //						}
                    CubridDatabase db = (CubridDatabase) database;
                    if (!db.isLogined()) {
                        continue;
                    }
                    itemCountInGroup++;
                    DatabaseMenuItem dbItem = new DatabaseMenuItem(database.getId(), serverSub, SWT.RADIO);
                    dbItem.setText(database.getLabel());
                    dbItem.setDatabase((CubridDatabase) database);
                    dbItem.setEnabled(db.isLogined() && db.getRunningType() == DbRunningType.CS);
                    dbItem.setGroupName(groupName);
                    count++;
                }
            }
        }
        if (itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
            groupSub.dispose();
            groupMenuItem.dispose();
            continue;
        }
    }
    if (count > 0) {
        new MenuItem(dbSelectionMenu, SWT.SEPARATOR);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) 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) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) 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 35 with CubridGroupNode

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

the class NewQueryConnAction method run.

/**
	 * Open the QueryConnDialog
	 */
public void run() {
    QueryConnDialog dialog = new QueryConnDialog(getShell(), null, 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 : 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) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) QueryConnDialog(com.cubrid.cubridquery.ui.connection.dialog.QueryConnDialog)

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