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;
}
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 "";
}
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);
}
}
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();
}
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();
}
Aggregations