Search in sources :

Example 11 with CubridGroupNode

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

the class ServiceDashboardLabelProvider method getColumnImage.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int)
	 */
public Image getColumnImage(Object element, int columnIndex) {
    String iconPath = "";
    if (columnIndex != 0 || element == null) {
        return null;
    }
    if (element instanceof ServiceDashboardInfo) {
        CubridServer server = ((ServiceDashboardInfo) element).getServer();
        if (server.isConnected()) {
            iconPath = server.getConnectedIconPath();
        } else {
            iconPath = server.getDisConnectedIconPath();
        }
        Image serverImage = CubridManagerUIPlugin.getImage(iconPath);
        return decorateServerImgae(serverImage, server);
    } else if (element instanceof CubridDatabase) {
        CubridDatabase database = (CubridDatabase) element;
        if (database.getRunningType() == DbRunningType.STANDALONE && database.isLogined()) {
            iconPath = database.getStopAndLoginIconPath();
        } else if (database.getRunningType() == DbRunningType.STANDALONE && !database.isLogined()) {
            iconPath = database.getStopAndLogoutIconPath();
        } else if (database.getRunningType() == DbRunningType.CS && database.isLogined()) {
            iconPath = database.getStartAndLoginIconPath();
        } else if (database.getRunningType() == DbRunningType.CS && !database.isLogined()) {
            iconPath = database.getStartAndLogoutIconPath();
        }
    } else if (element instanceof CubridGroupNode) {
        CubridGroupNode group = (CubridGroupNode) element;
        iconPath = group.getIconPath();
    }
    if (iconPath != null && iconPath.length() > 0) {
        return CubridManagerUIPlugin.getImage(iconPath.trim());
    }
    return null;
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Image(org.eclipse.swt.graphics.Image) DecoratedImage(com.cubrid.common.ui.decorator.DecoratedImage) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 12 with CubridGroupNode

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

the class ServiceDashboardLabelProvider method getColumnText.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
	 */
public String getColumnText(Object element, int columnIndex) {
    if (element != null && (element instanceof ServiceDashboardInfo || element instanceof CubridGroupNode)) {
        if (element instanceof ServiceDashboardInfo) {
            ServiceDashboardInfo sDashInfo = (ServiceDashboardInfo) element;
            CubridServer server = sDashInfo.getServer();
            switch(columnIndex) {
                case 0:
                    return decorateServerText(server.getName(), server);
                case 1:
                    return server.getHostAddress() == null ? "" : server.getHostAddress();
                case 2:
                    return server.getMonPort() == null ? "" : server.getMonPort();
                case 3:
                    return server.getUserName() == null ? "" : server.getUserName();
                case 4:
                    int freeDataPerc = sDashInfo.getFreeDataPerc();
                    String freeDataPercText = sDashInfo.getServer().isConnected() && freeDataPerc >= 0 ? freeDataPerc + "%" : "-";
                    return freeDataPercText;
                case 5:
                    int freeIndexPerc = sDashInfo.getFreeIndexPerc();
                    String freeIndexPercText = sDashInfo.getServer().isConnected() && freeIndexPerc >= 0 ? freeIndexPerc + "%" : "-";
                    return freeIndexPercText;
                case 6:
                    int freeTempPerc = sDashInfo.getFreeTempPerc();
                    String freeTempPercText = sDashInfo.getServer().isConnected() && freeTempPerc >= 0 ? freeTempPerc + "%" : "-";
                    return freeTempPercText;
                case 7:
                    int freeGenericPerc = sDashInfo.getFreeGenericPerc();
                    String freeGenericPercText = sDashInfo.getServer().isConnected() && freeGenericPerc >= 0 ? freeGenericPerc + "%" : "-";
                    return freeGenericPercText;
                case 8:
                    int tps = sDashInfo.getServerTps();
                    return sDashInfo.getServer().isConnected() ? Integer.toString(tps) : "-";
                case 9:
                    int qps = sDashInfo.getServerQps();
                    return sDashInfo.getServer().isConnected() ? Integer.toString(qps) : "-";
                case 10:
                    int errorQ = sDashInfo.getServerErrorQ();
                    return sDashInfo.getServer().isConnected() ? Integer.toString(errorQ) : "-";
                case 11:
                    double memUsed = sDashInfo.getMemUsed();
                    double memTotal = sDashInfo.getMemTotal();
                    return sDashInfo.getServer().isConnected() ? formater.format(StringUtil.convertToG(new Double(memUsed).longValue() * 1024)) + "GB / " + formater.format(StringUtil.convertToG(new Double(memTotal).longValue() * 1024)) + "GB" : "- / -";
                case 12:
                    long freespaceOnStorage = sDashInfo.getFreespaceOnStorage();
                    return sDashInfo.getServer().isConnected() ? getSpaceDesc(freespaceOnStorage) : "-";
                case 13:
                    double cpuUsed = sDashInfo.getCpuUsed();
                    return sDashInfo.getServer().isConnected() ? cpuUsed + "%" : "-";
                case 14:
                    return sDashInfo.getServer().isConnected() ? "Yes" : "No";
                case 15:
                    String serverVersion = sDashInfo.getServerVersion();
                    return sDashInfo.getServer().isConnected() ? serverVersion : "-";
                case 16:
                    String brokerPort = sDashInfo.getBrokerPort();
                    return sDashInfo.getServer().isConnected() ? brokerPort : "-";
            }
        } else if (element instanceof CubridGroupNode) {
            CubridGroupNode group = (CubridGroupNode) element;
            switch(columnIndex) {
                case 0:
                    return group.getName();
            }
        }
    }
    return "";
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer)

Example 13 with CubridGroupNode

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

the class CMGroupNodePersistManager 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.CM_UI_PLUGIN_ID, COM_CUBRID_MANAGER_HOSTGROUP, 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)

Example 14 with CubridGroupNode

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

the class CMGroupNodePersistManager method fix.

/**
	 * To fix when it has crashed group information
	 *
	 * @deprecated
	 */
public void fix() {
    List<CubridServer> svrs = CMHostNodePersistManager.getInstance().getAllServers();
    if (svrs == null)
        return;
    List<ICubridNode> cnodes = new ArrayList<ICubridNode>();
    try {
        List<CubridGroupNode> gnodes = getAllGroupNodes();
        for (int i = 0; i < gnodes.size(); i++) {
            CubridGroupNode node = gnodes.get(i);
            List<ICubridNode> snode = node.getChildren();
            for (int j = 0; j < snode.size(); j++) {
                cnodes.add(snode.get(j));
            }
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    try {
        for (int i = 0; i < svrs.size(); i++) {
            CubridServer svr = svrs.get(i);
            String gid = svr.getName();
            boolean exists = false;
            for (int j = 0; j < cnodes.size(); j++) {
                ICubridNode cnode = cnodes.get(j);
                if (cnode.getId() != null && cnode.getId().equals(gid)) {
                    exists = true;
                    break;
                }
            }
            if (!exists) {
                getDefaultGroup().addChild(svr);
            }
        }
    } catch (Exception e) {
        LOGGER.error(e.getMessage(), e);
    }
    saveAllGroupNode();
}
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) IOException(java.io.IOException)

Example 15 with CubridGroupNode

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

the class CQBGroupNodePersistManager 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