Search in sources :

Example 6 with ChartSettingDlg

use of com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg in project cubrid-manager by CUBRID.

the class HostDashboardHistoryViewPart method fireChartSetting.

/**
	 * This method is responsible for preparing data for ChartSettingDlg and
	 * dealing with the results of chartSettingDlg
	 *
	 */
private void fireChartSetting() {
    ChartSettingDlg chartSettingDlg = new ChartSettingDlg(composite.getShell());
    chartSettingDlg.setHasTitlSetting(false);
    chartSettingDlg.setHasHistoryPath(true);
    chartSettingDlg.setHasAxisSetting(false);
    chartSettingDlg.setHasChartSelection(true);
    // plot appearance
    XYPlot cpuSeriesPlot = cpuChart.getSeriesChart().getXYPlot();
    String plotBgColor = trimPaintColor(cpuSeriesPlot.getBackgroundPaint().toString());
    String plotDomainGridColor = trimPaintColor(cpuSeriesPlot.getDomainGridlinePaint().toString());
    String plotRangGridColor = trimPaintColor(cpuSeriesPlot.getRangeGridlinePaint().toString());
    chartSettingDlg.setPlotBgColor(plotBgColor);
    chartSettingDlg.setPlotDomainGridColor(plotDomainGridColor);
    chartSettingDlg.setPlotRangGridColor(plotRangGridColor);
    // series
    if (brokerChartPart == null) {
        chartSettingDlg.setHasSeriesItemSetting(false);
    } else {
        chartSettingDlg.setHasSeriesItemSetting(true);
        chartSettingDlg.setSettingMap(brokerChartPart.getSettingMap());
    }
    // history path
    chartSettingDlg.setHistoryPath(historyPath);
    chartSettingDlg.setHistoryFileName(historyFileName);
    // chart selection
    chartSettingDlg.setChartSelectionLst(getSelectedCharts());
    if (chartSettingDlg.open() == Dialog.OK) {
        // plot appearance
        plotBgColor = chartSettingDlg.getPlotBgColor();
        plotDomainGridColor = chartSettingDlg.getPlotDomainGridColor();
        plotRangGridColor = chartSettingDlg.getPlotRangGridColor();
        XYPlot memorySeriesPlot = (XYPlot) memoryChart.getSeriesChart().getPlot();
        XYPlot iowaitSeriesPlot = (XYPlot) iowaitChart.getSeriesChart().getPlot();
        // history path
        String newHistoryPath = chartSettingDlg.getHistoryPath();
        isChangedHistoryPath = historyPath.equals(newHistoryPath) ? false : true;
        if (isChangedHistoryPath) {
            historyPath = newHistoryPath;
            historyFileHelp.setHistoryPath(historyPath);
        }
        int red = 0;
        int green = 0;
        int blue = 0;
        //background
        red = getColorElem(plotBgColor, 0);
        green = getColorElem(plotBgColor, 1);
        blue = getColorElem(plotBgColor, 2);
        Color bgColor = new Color(red, green, blue);
        //cpu chart
        cpuSeriesPlot.setBackgroundPaint(bgColor);
        //memoryChart
        memorySeriesPlot.setBackgroundPaint(bgColor);
        //iowaitChart
        iowaitSeriesPlot.setBackgroundPaint(bgColor);
        //DomainGridColor
        //broker Chart
        red = getColorElem(plotDomainGridColor, 0);
        green = getColorElem(plotDomainGridColor, 1);
        blue = getColorElem(plotDomainGridColor, 2);
        Color domainGridlineColor = new Color(red, green, blue);
        //cpu chart
        cpuSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //memoryChart
        memorySeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //delayChart
        iowaitSeriesPlot.setDomainGridlinePaint(domainGridlineColor);
        //RangeGridColor
        red = getColorElem(plotRangGridColor, 0);
        green = getColorElem(plotRangGridColor, 1);
        blue = getColorElem(plotRangGridColor, 2);
        Color rangeGridColor = new Color(red, green, blue);
        //cpu chart
        cpuSeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //memoryChart
        memorySeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //delayChart
        iowaitSeriesPlot.setRangeGridlinePaint(rangeGridColor);
        //broker Chart;
        if (brokerChartPart != null) {
            XYPlot brokerPlot = brokerChartPart.getChart().getXYPlot();
            brokerPlot.setBackgroundPaint(bgColor);
            brokerPlot.setDomainGridlinePaint(domainGridlineColor);
            brokerPlot.setRangeGridlinePaint(rangeGridColor);
            brokerChartPart.setSettingMap(chartSettingDlg.getSettingMap());
            brokerChartPart.updateSettingSeries();
        }
        //chart Selection
        fireChartSelection(chartSettingDlg.getChartSelectionLst());
    }
}
Also used : ChartSettingDlg(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg) XYPlot(org.jfree.chart.plot.XYPlot) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor)

Example 7 with ChartSettingDlg

use of com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg in project cubrid-manager by CUBRID.

the class AddMonitorInstanceDlg 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) {
    initial();
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite comp = new Composite(parentComp, SWT.NO_FOCUS);
    GridLayout layout = new GridLayout();
    comp.setLayout(layout);
    comp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    Composite typeComp = new Composite(comp, SWT.NONE);
    typeComp.setLayout(new GridLayout(4, false));
    typeComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    Label typeLbl = new Label(typeComp, SWT.NONE);
    typeLbl.setText(Messages.addMonInsDlgTypeLbl);
    typeCombo = new Combo(typeComp, SWT.READ_ONLY);
    final GridData gdContentTxt = new GridData(SWT.FILL, SWT.CENTER, true, false);
    typeCombo.setLayoutData(gdContentTxt);
    typeCombo.setItems(monitorTypes);
    Label nodeLbl = new Label(typeComp, SWT.NONE);
    nodeLbl.setText(Messages.addMonInsDlgNodeName);
    nodeTxt = new Text(typeComp, SWT.BORDER);
    nodeTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (monData == null) {
        typeCombo.select(0);
    } else {
        MonitorType monitorType = monData.getMonitorType();
        typeCombo.setText(monitorType.toString());
        nodeTxt.setEnabled(false);
        String noteLabel = selection.getLabel();
        nodeTxt.setText(noteLabel);
    }
    nodeTxt.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent ex) {
            if (ValidateUtil.isValidDBName(nodeTxt.getText())) {
                //using db name rule
                isOkenable[0] = true;
            } else {
                isOkenable[0] = false;
            }
            enableOk();
        }
    });
    typeCombo.addSelectionListener(new TypeSelectionAdapter());
    final CTabFolder folder = new CTabFolder(comp, SWT.BORDER);
    folder.setLayout(new GridLayout());
    GridData gdTabFolder = new GridData(SWT.FILL, SWT.FILL, true, true);
    folder.setLayoutData(gdTabFolder);
    folder.setSimple(false);
    TreeMap<String, ShowSetting> settingMap = new TreeMap<String, ShowSetting>();
    chartSettingDlg = new ChartSettingDlg(null);
    chartSettingDlg.setFolder(folder);
    chartSettingDlg.setShowTitlteContent(true);
    String historyFileName = hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    if (typeCombo.getSelectionIndex() == 0) {
        historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + historyFileName;
    } else if (typeCombo.getSelectionIndex() == 1) {
        historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + historyFileName;
    }
    chartSettingDlg.setHistoryFileName(historyFileName);
    if (monData == null) {
        BrokerDiagData brokerDiagData = new BrokerDiagData();
        TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String key = entry.getKey();
            ShowSetting showSetting = new ShowSetting();
            ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
            settingMap.put(key, showSetting);
        }
        IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
        chartSettingDlg.setTitleName(defaultMonitorTtl[0]);
        String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
        chartSettingDlg.setHistoryPath(sHistoryPath);
    } else {
        //title
        String titleName = monData.getTitleName();
        String titleBgColor = monData.getTitleBgColor();
        String titleFontName = monData.getTitleFontName();
        int titleFontSize = monData.getTitleFontSize();
        String titleFontColor = monData.getTitleFontColor();
        chartSettingDlg.setTitleName(titleName);
        chartSettingDlg.setTtlBgColor(titleBgColor);
        chartSettingDlg.setTtlFontName(titleFontName);
        chartSettingDlg.setTtlFontSize(titleFontSize);
        chartSettingDlg.setTtlFontColor(titleFontColor);
        //plot
        String plotBgColor = monData.getPlotBgColor();
        String plotDateAxisColor = monData.getPlotDateAxisColor();
        String plotDomainGridColor = monData.getPlotDomainGridColor();
        String plotNumberAxisColor = monData.getPlotNumberAxisColor();
        String plotRangGridColor = monData.getPlotRangGridColor();
        chartSettingDlg.setPlotBgColor(plotBgColor);
        chartSettingDlg.setPlotDateAxisColor(plotDateAxisColor);
        chartSettingDlg.setPlotDomainGridColor(plotDomainGridColor);
        chartSettingDlg.setPlotNumberAxisColor(plotNumberAxisColor);
        chartSettingDlg.setPlotRangGridColor(plotRangGridColor);
        //series
        settingMap = monData.getSettingMap();
        //history path 
        String historyPath = monData.getHistoryPath();
        chartSettingDlg.setHistoryPath(historyPath);
    }
    chartSettingDlg.setSettingMap(settingMap);
    chartSettingDlg.createTtlTab();
    chartSettingDlg.createPlotItem();
    chartSettingDlg.createSeriesItemByDefault();
    chartSettingDlg.createHistoryPathItem();
    folder.setSelection(0);
    saveBtn = new Button(comp, SWT.CHECK);
    saveBtn.setText(Messages.btnSaveMonitorSetting);
    setTitle(Messages.addMonInsDlgTtl);
    setMessage(Messages.addMonInsDlgMsg);
    return comp;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) MonitorType(com.cubrid.cubridmanager.ui.monitoring.editor.internal.MonitorType) ModifyListener(org.eclipse.swt.events.ModifyListener) IPath(org.eclipse.core.runtime.IPath) Label(org.eclipse.swt.widgets.Label) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TreeMap(java.util.TreeMap) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ChartSettingDlg(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

ChartSettingDlg (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartSettingDlg)7 Color (java.awt.Color)6 XYPlot (org.jfree.chart.plot.XYPlot)6 CommonUITool.trimPaintColor (com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor)5 JFreeChart (org.jfree.chart.JFreeChart)2 Plot (org.jfree.chart.plot.Plot)2 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)1 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)1 MonitorType (com.cubrid.cubridmanager.ui.monitoring.editor.internal.MonitorType)1 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 IPath (org.eclipse.core.runtime.IPath)1 CTabFolder (org.eclipse.swt.custom.CTabFolder)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)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