use of com.cubrid.common.ui.spi.model.MonitorStatistic in project cubrid-manager by CUBRID.
the class AddDashboardDialog method verify.
/**
*
* Verify data
*
*/
private void verify() {
String dashboardName = dashboardNameText.getText();
if (dashboardName.trim().length() == 0) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
setErrorMessage(Messages.errDashboardName);
return;
}
List<ICubridNode> dashboardList = MonitorDashboardPersistManager.getInstance().getAllMonitorDashboards();
for (int i = 0; i < dashboardList.size(); i++) {
ICubridNode node = dashboardList.get(i);
if (dashboardName.equals(node.getLabel()) && (dashboard == null || !dashboard.getName().equals(dashboardName))) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
setErrorMessage(Messages.errDashboardNameExist);
return;
}
}
/*TOOLS-3672 Avoid to dashboard node and statistic node have the same name*/
List<MonitorStatistic> monitorList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(null);
for (MonitorStatistic monitorStatistic : monitorList) {
if (dashboardName.equals(monitorStatistic.getId())) {
if (dashboardName.equals(monitorStatistic.getLabel())) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
setErrorMessage(Messages.errDashboardNameExist);
return;
}
}
}
if (hostNodeList.isEmpty()) {
getButton(IDialogConstants.OK_ID).setEnabled(false);
setErrorMessage(Messages.errHostAndDbList);
return;
}
getButton(IDialogConstants.OK_ID).setEnabled(true);
setErrorMessage(null);
}
use of com.cubrid.common.ui.spi.model.MonitorStatistic in project cubrid-manager by CUBRID.
the class MonitorStatisticPersistManager method removeMonitorStatistic.
/**
* Remove MonitorStatistic node according to <i>hostId</i>. If <i>hostId</i>
* is null, will check all the MonitorStatistic node belong to Dashboard
* tab.
*
* @param node
* @param hostId
*/
public void removeMonitorStatistic(MonitorStatistic node, String hostId) {
if (node == null) {
return;
}
synchronized (this) {
if (hostId == null) {
hostId = HOST_ID_FOR_MULTI_HOST;
}
List<MonitorStatistic> monitorStatisticList = monitorStatisticMap.get(hostId);
if (monitorStatisticList != null) {
monitorStatisticList.remove(node);
saveStatistic();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
}
}
}
use of com.cubrid.common.ui.spi.model.MonitorStatistic in project cubrid-manager by CUBRID.
the class MonitorStatisticPersistManager method addMonitorStatistic.
/**
*
* Add MonitorStatistic node according to <i>hostId</i>. If <i>hostId</i> is
* not null, will add a single host node for the specified host, else add a
* multi-host node for Dashboard tab.
*
* @param node MonitorStatistic
* @param hostId Host node id
*/
public void addMonitorStatistic(MonitorStatistic node, String hostId) {
if (node == null) {
return;
}
synchronized (this) {
if (hostId == null) {
hostId = HOST_ID_FOR_MULTI_HOST;
}
List<MonitorStatistic> monitorStatisticList = monitorStatisticMap.get(hostId);
if (monitorStatisticList == null) {
monitorStatisticList = new ArrayList<MonitorStatistic>();
}
monitorStatisticList.add(node);
//TODO:
monitorStatisticMap.put(hostId, monitorStatisticList);
saveStatistic();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_ADD));
}
}
use of com.cubrid.common.ui.spi.model.MonitorStatistic in project cubrid-manager by CUBRID.
the class CubridMonitorFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
if (userInfo == null || StatusMonitorAuthType.AUTH_NONE == userInfo.getStatusMonitorAuth()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
//add status node
if (CompatibleUtil.isSupportBrokerOrDBStatusMonitor(serverInfo)) {
String brokerStatusId = parent.getId() + NODE_SEPARATOR + BROKER_STATUS_ID;
ICubridNode brokerStatusNode = new DefaultCubridNode(brokerStatusId, Messages.msgBrokerStatusMonitorName, "icons/navigator/status_item.png");
brokerStatusNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
brokerStatusNode.setViewId(BrokerStatusMonitorViewPart.ID);
brokerStatusNode.setContainer(false);
parent.addChild(brokerStatusNode);
String dbStatusId = parent.getId() + NODE_SEPARATOR + DB_STATUS_ID;
ICubridNode dbStautsNode = new DefaultCubridNode(dbStatusId, Messages.msgDbStatusMonitorName, "icons/navigator/status_item.png");
dbStautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
dbStautsNode.setViewId(DbStatusDumpMonitorViewPart.ID);
dbStautsNode.setContainer(false);
parent.addChild(dbStautsNode);
createTempStatusNode(parent);
} else {
if (!loadStatusTempInfoTask(parent, monitor, serverInfo)) {
return;
}
}
//add system node
if (CompatibleUtil.isSupportSystemMonitor(serverInfo)) {
String hostSystemId = parent.getId() + NODE_SEPARATOR + HOST_SYSTEM_ID;
ICubridNode hostSystemNode = new DefaultCubridNode(hostSystemId, Messages.msgHostSystemMonitorName, "icons/navigator/status_item.png");
hostSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
hostSystemNode.setViewId(HostSystemMonitorViewPart.ID);
hostSystemNode.setContainer(false);
parent.addChild(hostSystemNode);
if (CompatibleUtil.isSupportDBSystemMonitor(serverInfo)) {
String dbSystemId = parent.getId() + NODE_SEPARATOR + DB_SYSTEM_ID;
ICubridNode dbSystemNode = new DefaultCubridNode(dbSystemId, Messages.msgDbSystemMonitorName, "icons/navigator/status_item.png");
dbSystemNode.setType(CubridNodeType.SYSTEM_MONITOR_TEMPLATE);
dbSystemNode.setViewId(DbSystemMonitorViewPart.ID);
dbSystemNode.setContainer(false);
parent.addChild(dbSystemNode);
}
}
//add monitor statistic node
if (CompatibleUtil.isSupportMonitorStatistic(serverInfo)) {
List<MonitorStatistic> childList = MonitorStatisticPersistManager.getInstance().getMonitorStatisticListByHostId(serverInfo.getServerName());
for (MonitorStatistic node : childList) {
if (node == null) {
continue;
}
parent.addChild(node);
}
}
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.MonitorStatistic in project cubrid-manager by CUBRID.
the class AddMonitorStatisticPageAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode node = null;
if (obj.length > 0) {
node = (ICubridNode) obj[0];
}
String hostId = null;
boolean isSingleHost = node != null && CubridNodeType.MONITOR_FOLDER.equals(node.getType());
if (isSingleHost) {
ServerInfo serverInfo = node.getServer().getServerInfo();
hostId = serverInfo.getServerName();
if (!serverInfo.isSupportMonitorStatistic()) {
CommonUITool.openWarningBox(Messages.needEnableMonitorStatisticMsg);
return;
}
}
AddStatisticPageDialog dialog = new AddStatisticPageDialog(getShell());
dialog.setCubridServerId(hostId);
if (dialog.open() == Dialog.OK) {
final String iconPath = "icons/navigator/status_item.png";
String labelName = dialog.getName();
String pageName = labelName;
if (hostId != null) {
pageName += "@" + hostId;
}
MonitorStatistic monitorStatisticNode = new MonitorStatistic(pageName, labelName, iconPath);
monitorStatisticNode.setType(CubridNodeType.MONITOR_STATISTIC_PAGE);
monitorStatisticNode.setEditorId(MonitorStatisticEditor.ID);
if (isSingleHost) {
monitorStatisticNode.setMultiHost(false);
ServerInfo serverInfo = node.getServer().getServerInfo();
monitorStatisticNode.setIp(serverInfo.getHostAddress());
monitorStatisticNode.setPort(serverInfo.getHostMonPort());
} else {
monitorStatisticNode.setMultiHost(true);
}
MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
persistManager.addMonitorStatistic(monitorStatisticNode, hostId);
persistManager.saveStatistic();
//refresh TreeViewer
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
if (isSingleHost) {
node.addChild(monitorStatisticNode);
treeViewer.add(node, monitorStatisticNode);
} else {
/*TOOLS-3665 Refresh the input of TreeViewer*/
treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(monitorStatisticNode, CubridNodeChangedEventType.NODE_ADD));
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(monitorStatisticNode, MonitorStatisticEditor.ID);
} catch (Exception ignore) {
}
} else {
//TODO
}
}
Aggregations