Search in sources :

Example 1 with MetricType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType 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;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SingleHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem) MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType) GridData(org.eclipse.swt.layout.GridData)

Example 2 with MetricType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType in project cubrid-manager by CUBRID.

the class EditStatisticHostDialog method init.

public void init(StatisticType dataType, TimeType timeType, StatisticChartHost hostInfo) {
    if (hostInfo == null) {
        return;
    }
    this.oldHostItem = hostInfo;
    this.hostValue = hostInfo.getCubridServerId();
    this.dataType = dataType;
    this.timeValue = timeType == null ? VALUE_DEFAULT : timeType.getMessage();
    MetricType metricType = MetricType.getEnumByMetric(hostInfo.getMetric());
    this.metricValue = metricType != null ? metricType.getMessage() : VALUE_DEFAULT;
    switch(dataType) {
        case DB:
            dbNameValue = hostInfo.getDbName();
            break;
        case DB_VOL:
            dbNameValue = hostInfo.getDbName();
            dbVolNameValue = hostInfo.getVolName();
            break;
        case BROKER:
            brokerNameValue = hostInfo.getBrokerName();
        case OS:
            break;
        default:
            break;
    }
}
Also used : MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)

Example 3 with MetricType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType in project cubrid-manager by CUBRID.

the class StatisticData method getDescription.

public String getDescription(boolean isMultiHost) {
    StringBuilder sb = new StringBuilder();
    MetricType metricType = MetricType.getEnumByMetric(metric);
    sb.append(metricType.getMessage());
    switch(getType()) {
        case DB:
            sb.append(":").append(dbName);
            break;
        case DB_VOL:
            sb.append(":").append(dbName);
            sb.append(":").append(volName);
            break;
        case BROKER:
            sb.append(":").append(bName);
            break;
        case OS:
            break;
        default:
            break;
    }
    if (isMultiHost && serverInfo != null) {
        if (serverInfo.getServerName() != null) {
            sb.append("@").append(serverInfo.getServerName());
        } else {
            sb.append("@").append(serverInfo.getHostAddress());
            sb.append(":").append(serverInfo.getHostMonPort());
        }
    }
    return sb.toString();
}
Also used : MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)

Example 4 with MetricType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType in project cubrid-manager by CUBRID.

the class StatisticData method getSimpleDescription.

public String getSimpleDescription(boolean isMultiHost) {
    StringBuilder sb = new StringBuilder();
    MetricType metricType = MetricType.getEnumByMetric(metric);
    sb.append(metricType.getMessage());
    if (isMultiHost && serverInfo != null) {
        if (serverInfo.getServerName() != null) {
            sb.append("@").append(serverInfo.getServerName());
        } else {
            sb.append("@").append(serverInfo.getHostAddress());
            sb.append(":").append(serverInfo.getHostMonPort());
        }
    }
    return sb.toString();
}
Also used : MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)

Example 5 with MetricType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType in project cubrid-manager by CUBRID.

the class EditStatisticHostDialog method refreshMetricData.

private void refreshMetricData(StatisticType type, boolean isRefreshMetricValue) {
    if (type == null) {
        itemsMetric = ITEMS_EMPTY;
        if (isRefreshMetricValue) {
            metricValue = VALUE_DEFAULT;
        }
    } else {
        Set<MetricType> metricTypeSet = null;
        if (isFirstHost) {
            metricTypeSet = StatisticParamUtil.getSupportedMetricTypes(type);
        } else {
            metricTypeSet = StatisticParamUtil.getCompatibleMetricsForDisplay(firstMetric);
        }
        if (metricTypeSet != null)
            itemsMetric = new String[metricTypeSet.size()];
        int index = 0;
        for (MetricType metricType : metricTypeSet) {
            itemsMetric[index] = metricType.getMessage();
            index++;
        }
        if (isRefreshMetricValue) {
            metricValue = itemsMetric[0];
        }
    }
    comboMetric.setItems(itemsMetric);
    if (isRefreshMetricValue || metricValue != null) {
        comboMetric.setText(metricValue);
    }
}
Also used : MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)

Aggregations

MetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)7 StatisticType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)2 TimeType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)2 SingleHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem)1 StatisticData (com.cubrid.cubridmanager.core.monstatistic.model.StatisticData)1 DbMetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.DbMetricType)1 OsMetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.OsMetricType)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Combo (org.eclipse.swt.widgets.Combo)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 Day (org.jfree.data.time.Day)1 Hour (org.jfree.data.time.Hour)1 Second (org.jfree.data.time.Second)1