コード例 #1
0
  /**
   * 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;
  }
コード例 #2
0
 /** Save charts to properties. */
 private void saveChartsToProperties() {
   ArrayList<ChartMappings> chartMappings = new ArrayList<ChartMappings>();
   Iterator<Component> iter = iterator();
   while (iter.hasNext()) {
     ChartButton chartButton = (ChartButton) iter.next();
     UserChart userChart = (UserChart) chartButton.getData();
     ChartMappings chartMapping = new ChartMappings(userChart);
     chartMappings.add(chartMapping);
   }
   chartProperties.setChartMappings(systemType, chartMappings);
 }