use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.
the class StatisticChartItemTest method testStatisticChartItem.
public void testStatisticChartItem() {
String nodeId = "demo";
StatisticType type = StatisticType.OS;
StatisticChartItem statisticChartItem = new SingleHostChartItem(nodeId, type);
String dtype = TimeType.DAILY.getType();
statisticChartItem.setDType(dtype);
assertEquals(statisticChartItem.getDType(), dtype);
assertFalse(statisticChartItem.isMultiHost());
String name = "";
statisticChartItem.setName(name);
assertEquals(statisticChartItem.getName(), "");
assertEquals(statisticChartItem.getNodeId(), nodeId);
int series = 10;
statisticChartItem.setSeries(series);
assertEquals(statisticChartItem.getSeries(), series);
statisticChartItem.setType(StatisticType.DB);
assertEquals(statisticChartItem.getType(), StatisticType.DB);
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.
the class SingleHostChartItemTest method testSingleHostChartItem.
public void testSingleHostChartItem() {
String nodeId = "demo";
StatisticType type = StatisticType.OS;
SingleHostChartItem singleHostChartItem = new SingleHostChartItem(nodeId, type);
String brokerName = "query_editor";
singleHostChartItem.setBrokerName(brokerName);
assertEquals(singleHostChartItem.getBrokerName(), brokerName);
String dtype = TimeType.DAILY.getType();
singleHostChartItem.setDType(dtype);
assertEquals(singleHostChartItem.getDType(), dtype);
String dbName = "demodb";
singleHostChartItem.setDbName(dbName);
assertEquals(singleHostChartItem.getDbName(), dbName);
List<String> metricList = new ArrayList<String>();
String metric = MetricType.OS_CPU_IDLE.getMetric();
String metric2 = MetricType.OS_CPU_USER.getMetric();
metricList.add(metric);
singleHostChartItem.setMetricList(metricList);
assertEquals(singleHostChartItem.getMetricList(), metricList);
assertTrue(singleHostChartItem.getMetricList().contains(metric));
singleHostChartItem.addMetric(metric2);
assertTrue(singleHostChartItem.getMetricList().contains(metric2));
assertFalse(singleHostChartItem.isMultiHost());
assertNotNull(singleHostChartItem.getName());
assertEquals(singleHostChartItem.getNodeId(), nodeId);
int series = 10;
singleHostChartItem.setSeries(series);
assertEquals(singleHostChartItem.getSeries(), series);
assertEquals(singleHostChartItem.getType(), type);
singleHostChartItem.setType(type);
String volName = "demodb_lgat";
singleHostChartItem.setVolName(volName);
assertEquals(singleHostChartItem.getVolName(), volName);
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.
the class EditSingleHostStatisticItemDialog method okPressed.
/**
* When press "ok" button, call it.
*/
public void okPressed() {
StatisticType type = StatisticType.getEnumByMessage(comboDataType.getText());
String timeType = getTimeType();
int series = 0;
if (!isNew) {
series = statisticChartItem.getSeries();
}
statisticChartItem = new SingleHostChartItem(editor.getNodeId(), type);
statisticChartItem.setDType(timeType);
switch(type) {
case DB:
((SingleHostChartItem) statisticChartItem).setDbName(comboDbName.getText());
break;
case DB_VOL:
((SingleHostChartItem) statisticChartItem).setDbName(comboDbName.getText());
((SingleHostChartItem) statisticChartItem).setVolName(comboVolName.getText());
break;
case BROKER:
((SingleHostChartItem) statisticChartItem).setBrokerName(comboBrokerName.getText());
break;
case OS:
break;
default:
}
for (Group grp : grpMetricList) {
if (grp.getChildren() == null) {
continue;
}
for (Control control : grp.getChildren()) {
if (control instanceof Button) {
if (((Button) control).getSelection()) {
((SingleHostChartItem) statisticChartItem).addMetric(MetricType.getEnumByMessage(((Button) control).getText()).getMetric());
}
}
}
}
if (!isNew) {
statisticChartItem.setSeries(series);
}
super.okPressed();
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.
the class EditSingleHostStatisticItemDialog method createDialogArea.
/**
* Creates and returns the contents of the upper part of this dialog (above
* the button bar).
*
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
final Composite parentComp = (Composite) super.createDialogArea(parent);
parentComp.setLayout(new GridLayout(1, false));
GridData gdParent = new GridData(SWT.FILL);
gdParent.widthHint = DIALOG_AREA_WIDTH;
gdParent.heightHint = LINE_HEIGHT * 11;
parentComp.setLayoutData(gdParent);
//init data
StatisticType statisticType = StatisticType.DB;
if (!isNew && statisticChartItem != null) {
statisticType = statisticChartItem.getType();
oldDataType = statisticType;
dataTypeValue = statisticType.getMessage();
TimeType timeType = TimeType.getEnumByType(statisticChartItem.getDType());
timeValue = timeType == null ? TimeType.DAILY.getMessage() : timeType.getMessage();
switch(statisticType) {
case DB:
dbNameValue = ((SingleHostChartItem) statisticChartItem).getDbName();
break;
case DB_VOL:
dbNameValue = ((SingleHostChartItem) statisticChartItem).getDbName();
dbVolNameValue = ((SingleHostChartItem) statisticChartItem).getVolName();
break;
case BROKER:
brokerNameValue = ((SingleHostChartItem) statisticChartItem).getBrokerName();
break;
case OS:
break;
default:
}
}
compDataType = new Composite(parentComp, SWT.RESIZE);
GridLayout layoutCompDataType = new GridLayout(4, false);
compDataType.setLayout(layoutCompDataType);
final Label lblDataType = new Label(compDataType, SWT.NONE);
GridData gdlblDataType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdlblDataType.widthHint = 120;
lblDataType.setText(Messages.lblDataType);
comboDataType = new Combo(compDataType, SWT.NONE | SWT.READ_ONLY);
GridData gdComboDataType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdComboDataType.widthHint = 180;
comboDataType.setLayoutData(gdComboDataType);
comboDataType.setItems(itemsDataType);
comboDataType.setText(dataTypeValue);
comboDataType.addSelectionListener(new ComboDataTypeSelectionAdapter());
final Label lblTimeType = new Label(compDataType, SWT.NONE);
GridData gdlblTimeType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdlblTimeType.widthHint = 120;
lblTimeType.setText(Messages.lblTimeType);
comboTimeType = new Combo(compDataType, SWT.NONE | SWT.READ_ONLY);
GridData gdComboTimeType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
gdComboTimeType.widthHint = 180;
comboTimeType.setLayoutData(gdComboTimeType);
comboTimeType.setItems(itemsTimeType);
comboTimeType.setText(timeValue);
compMetrics = new Composite(parentComp, SWT.RESIZE);
refreshChangeableItems(statisticType);
if (!isNew && statisticChartItem != null) {
List<String> metricList = ((SingleHostChartItem) statisticChartItem).getMetricList();
for (Group grp : grpMetricList) {
if (grp.getChildren() == null) {
continue;
}
boolean isFindInGroup = false;
for (Control control : grp.getChildren()) {
if (control instanceof Button) {
Button btn = ((Button) control);
btn.setEnabled(false);
String msg = btn.getText();
MetricType metricType = MetricType.getEnumByMessage(msg);
for (String metric : metricList) {
if (metric.equals(metricType.getMetric())) {
btn.setSelection(true);
isFindInGroup = true;
break;
}
}
}
}
if (isFindInGroup) {
for (Control control : grp.getChildren()) {
if (control instanceof Button) {
((Button) control).setEnabled(true);
}
}
}
}
}
//add btn
final Composite btnComp = new Composite(parentComp, SWT.NONE);
btnComp.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
{
GridLayout layout = new GridLayout();
layout.marginRight = 5;
layout.numColumns = 1;
layout.marginWidth = 0;
btnComp.setLayout(layout);
}
btnClearAll = new Button(btnComp, SWT.NONE);
btnClearAll.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
btnClearAll.setText(Messages.btnCleanSelected);
btnClearAll.addSelectionListener(new ButtonCleanAllSelectionAdapter());
return parentComp;
}
use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.
the class EditStatisticHostDialog method okPressed.
/**
* When press "ok" button, call it.
*/
public void okPressed() {
StatisticType type = StatisticType.getEnumByMessage(comboDataType.getText());
if (isFirstHost) {
((EditMultiHostStatisticItemDialog) parentDialog).setType(type);
((EditMultiHostStatisticItemDialog) parentDialog).setTimeType(getTimeType());
}
String cubridServerId = comboHost.getText();
hostItem = new StatisticChartHost(cubridServerId);
ServerInfo serverInfo = hostNodePersistManager.getServer(cubridServerId).getServerInfo();
hostItem.setServerInfo(serverInfo);
hostItem.setIp(serverInfo.getHostAddress());
hostItem.setPort(serverInfo.getHostMonPort());
hostItem.setUser(serverInfo.getUserName());
hostItem.setPassword(serverInfo.getUserPassword());
switch(type) {
case DB:
hostItem.setDbName(comboDbName.getText());
break;
case DB_VOL:
hostItem.setDbName(comboDbName.getText());
hostItem.setVolName(comboVolName.getText());
break;
case BROKER:
hostItem.setBrokerName(comboBrokerName.getText());
break;
case OS:
break;
default:
}
hostItem.setMetric(MetricType.getEnumByMessage(comboMetric.getText()).getMetric());
boolean isDuplicated = ((EditMultiHostStatisticItemDialog) parentDialog).isDuplicatedHostInfo(hostItem, oldHostItem);
if (isDuplicated) {
CommonUITool.openWarningBox(Messages.errDuplicateHost);
return;
}
super.okPressed();
}
Aggregations