Search in sources :

Example 6 with ShowSetting

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

the class DbStatusHistoryViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 * 
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    final HistoryComposite historyComposite = new HistoryComposite();
    historyComposite.loadTimeSelection(composite);
    serverInfo = cubridNode.getServer().getServerInfo();
    Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = new TreeMap<String, String>();
    for (Map.Entry<IDiagPara, String> entry : dbStatDumpData.getDiagStatusResultMap().entrySet()) {
        map.put(entry.getKey().getName(), entry.getValue());
    }
    chartPart = new ChartCompositePart(composite, map);
    dbCombo = new DbComboContribution("database");
    List<String> databaseLst = new ArrayList<String>();
    List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
    if (null != databaseInfoLst && !databaseInfoLst.isEmpty()) {
        for (DatabaseInfo databaseInfo : databaseInfoLst) {
            databaseLst.add(databaseInfo.getDbName());
        }
        dbCombo.setDatabaseLst(databaseLst);
        if (!databaseLst.isEmpty()) {
            dbCombo.setSelectedDb(databaseLst.get(0));
        }
    }
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = chartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
    }
    chartPart.setChartTitle(Messages.databaseHistoryChartTtl);
    String dbName = dbCombo.getSelectedDb();
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    chartPart.setHistoryFileName(historyFileName);
    IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
    String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
    chartPart.setHistoryPath(sHistoryPath);
    chartPart.loadContent();
    chartPart.addChartMouseListener();
    makeActions();
    historyComposite.getQueryBtn().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent ex) {
            String date = historyComposite.getDate();
            String fromTime = historyComposite.getFromTime();
            String toTime = historyComposite.getToTime();
            // check date/fromTime/toTime
            boolean timeOrder = historyComposite.checkTime(date, fromTime, toTime);
            if (!timeOrder) {
                CommonUITool.openErrorBox(Messages.errDbHistorySettingTime);
                return;
            }
            String[] ymd = date.split("-");
            int year = Integer.valueOf(ymd[0]);
            int month = Integer.valueOf(ymd[1]);
            int day = Integer.valueOf(ymd[2]);
            String[] fromHms = fromTime.split(":");
            int fromHour = Integer.valueOf(fromHms[0]);
            int fromMinute = Integer.valueOf(fromHms[1]);
            int fromSecond = Integer.valueOf(fromHms[2]);
            Calendar calFrom = Calendar.getInstance();
            calFrom.set(year, month, day, fromHour, fromMinute, fromSecond);
            long millisFrom = calFrom.getTimeInMillis();
            String[] toHms = toTime.split(":");
            int toHour = Integer.valueOf(toHms[0]);
            int toMinute = Integer.valueOf(toHms[1]);
            int toSecond = Integer.valueOf(toHms[2]);
            Calendar calTo = Calendar.getInstance();
            calTo.set(year, month, day, toHour, toMinute, toSecond);
            long millisTo = calTo.getTimeInMillis();
            XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
            plot.getDomainAxis().setRange(millisFrom, millisTo);
            CounterFile countFile = chartPart.openHistoryFile();
            if (countFile == null) {
                return;
            }
            List<String> types = new ArrayList<String>();
            for (DbStatDumpEnum diagName : DbStatDumpEnum.values()) {
                String type = diagName.getName();
                types.add(type);
            }
            chartPart.executeQueryWithBusyCursor(countFile, types, millisFrom, millisTo);
            try {
                countFile.close();
            } catch (IOException e1) {
                LOGGER.error(e1.getMessage());
            }
        }

        public void widgetSelected(SelectionEvent ex) {
            widgetDefaultSelected(ex);
        }
    });
}
Also used : DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) GridLayout(org.eclipse.swt.layout.GridLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) Calendar(java.util.Calendar) IOException(java.io.IOException) TreeMap(java.util.TreeMap) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) DbStatDumpEnum(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum) XYPlot(org.jfree.chart.plot.XYPlot) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) GridData(org.eclipse.swt.layout.GridData) Map(java.util.Map) TreeMap(java.util.TreeMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 7 with ShowSetting

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

the class HostDashboardViewPart method loadBrokerChart.

/**
	 * Load an instance of ChartCompositePart stand for broker monitor info
	 *
	 * @param parent the instance of Composite
	 */
private void loadBrokerChart(Composite parent) {
    brokerComp = new Composite(parent, SWT.NULL);
    brokerComp.setLayout(new GridLayout());
    brokerComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    Group brokerGrp = new Group(brokerComp, SWT.NONE);
    brokerGrp.setText(Messages.hostBrokerSeriesGroupName);
    GridLayout layoutGrp = new GridLayout();
    layoutGrp.verticalSpacing = 0;
    layoutGrp.horizontalSpacing = 0;
    layoutGrp.marginLeft = 0;
    layoutGrp.marginRight = 0;
    layoutGrp.marginTop = 0;
    layoutGrp.marginBottom = 0;
    brokerGrp.setLayout(layoutGrp);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    brokerGrp.setLayoutData(gridData);
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    brokerChartPart = new ChartCompositePart(brokerGrp, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = brokerChartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.BROKER);
    }
    brokerChartPart.loadContent();
    JFreeChart chart = (JFreeChart) brokerChartPart.getChart();
    chart.setBorderVisible(false);
    XYPlot xyplot = (XYPlot) brokerChartPart.getChart().getPlot();
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(false);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    renderer.setURLGenerator(null);
    renderer.setBaseToolTipGenerator(null);
}
Also used : Group(org.eclipse.swt.widgets.Group) DateAxis(org.jfree.chart.axis.DateAxis) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) JFreeChart(org.jfree.chart.JFreeChart) GridLayout(org.eclipse.swt.layout.GridLayout) XYPlot(org.jfree.chart.plot.XYPlot) GridData(org.eclipse.swt.layout.GridData) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 8 with ShowSetting

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

the class DbStatusDumpMonitorViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 * 
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new FillLayout());
    serverInfo = cubridNode.getServer().getServerInfo();
    List<String> databaseLst = new ArrayList<String>();
    List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
    for (DatabaseInfo databaseInfo : databaseInfoLst) {
        DbRunningType dbRunningType = databaseInfo.getRunningType();
        if (dbRunningType == DbRunningType.CS) {
            databaseLst.add(databaseInfo.getDbName());
        }
    }
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = convertMapKey(dbStatDumpData.getDiagStatusResultMap());
    chartPart = new ChartCompositePart(composite, map);
    dbCombo = new DbComboContribution("database", this);
    dbCombo.setDatabaseLst(databaseLst);
    if (databaseLst.isEmpty()) {
        runflag = false;
    } else {
        dbCombo.setSelectedDb(databaseLst.get(0));
    }
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String dbName = dbCombo.getSelectedDb();
    String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    chartPart.setHistoryFileName(historyFileName);
    if (null == monInstaceData) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String key = entry.getKey();
            ShowSetting showSetting = chartPart.getSettingMap().get(key);
            ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
        }
        chartPart.setChartTitle(Messages.dbMonitorChartTtl);
        IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
        String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
        chartPart.setHistoryPath(sHistoryPath);
    } else {
        String titleName = monInstaceData.getTitleName();
        chartPart.setChartTitle(titleName);
        chartPart.setSettingData(monInstaceData);
    }
    chartPart.loadContent();
    makeActions();
    this.dbName = dbCombo.getSelectedDb();
    new DataGenerator().start();
}
Also used : DbComboContribution(com.cubrid.cubridmanager.ui.monitoring.editor.internal.DbComboContribution) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 9 with ShowSetting

use of com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting 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

HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)9 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)9 Map (java.util.Map)9 TreeMap (java.util.TreeMap)9 Composite (org.eclipse.swt.widgets.Composite)9 ChartCompositePart (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart)8 GridData (org.eclipse.swt.layout.GridData)7 GridLayout (org.eclipse.swt.layout.GridLayout)7 XYPlot (org.jfree.chart.plot.XYPlot)6 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)5 IPath (org.eclipse.core.runtime.IPath)5 DbStatDumpData (com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData)4 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)4 Group (org.eclipse.swt.widgets.Group)4 JFreeChart (org.jfree.chart.JFreeChart)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)4 ArrayList (java.util.ArrayList)3 Label (org.eclipse.swt.widgets.Label)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2