/** * Initialize charts. * * @param chartProperties the chart properties * @param systemType the system type * @return true, if successful */ public boolean initializeCharts(ChartProperties chartProperties, String systemType) { this.chartProperties = chartProperties; this.systemType = systemType; ArrayList<ChartMappings> chartMappings = chartProperties.getChartMappings(systemType); if (chartMappings != null) { boolean isDirty = false; for (ChartMappings chartMapping : chartMappings.toArray(new ChartMappings[chartMappings.size()])) { isDirty |= stripMissingMonitors(chartMapping); if (!chartMapping.getMonitorIDs().isEmpty()) { UserChart userChart = new UserChart(chartMapping); ChartButton chartButton = new ChartButton(userChart); chartButton.setChartsLayout(this); addComponent(chartButton); } else { chartMappings.remove(chartMapping); } } if (isDirty) { chartProperties.setChartMappings(systemType, chartMappings); } return isDirty; } return false; }
/** * Strip missing monitors. * * @param chartMapping the chart mapping * @return true, if successful */ private boolean stripMissingMonitors(ChartMappings chartMapping) { boolean isDirty = false; ArrayList<String> monitorIDs = chartMapping.getMonitorIDs(); for (String monitorID : monitorIDs.toArray(new String[monitorIDs.size()])) { if (!Monitors.getMonitorsList().containsKey(monitorID)) { monitorIDs.remove(monitorID); isDirty |= true; } } return isDirty; }