Exemplo n.º 1
0
 private String getBaseFileName(SourceIdentifier si) {
   String primaryName = si.getIdentifier();
   String secondaryName = si.getSecondaryIdentifier();
   primaryName = prepareName(primaryName);
   if (secondaryName != null) {
     secondaryName = prepareName(secondaryName);
     File parent = new File(baseDir, primaryName);
     parent.mkdirs();
     File baseFile = new File(parent, secondaryName);
     return baseFile.getAbsolutePath();
   } else {
     baseDir.mkdirs();
     File baseFile = new File(baseDir, primaryName);
     return baseFile.getAbsolutePath();
   }
 }
Exemplo n.º 2
0
 public static SourceIdentifier getSourceIdentifier() {
   try {
     return SOURCE_IDENTIFIER.clone();
   } catch (CloneNotSupportedException e) {
     // won't happen
     return null;
   }
 }
Exemplo n.º 3
0
    public boolean equals(Object o) {
      if (this == o) return true;
      if (o == null || getClass() != o.getClass()) return false;

      final WrappedSourceIdentifier that = (WrappedSourceIdentifier) o;

      if (resolvedName != null
          ? !resolvedName.equals(that.resolvedName)
          : that.resolvedName != null) return false;
      return !(sourceIdentifier != null
          ? !sourceIdentifier.equals(that.sourceIdentifier)
          : that.sourceIdentifier != null);
    }
  protected String createGraphTitle(SourceIdentifier sourceIdentifier) {
    ApplicationPreferences applicationPreferences = mainFrame.getApplicationPreferences();
    Map<String, String> sourceNames = null;
    boolean showingPrimaryIdentifier = false;
    if (applicationPreferences != null) {
      sourceNames = applicationPreferences.getSourceNames();
      showingPrimaryIdentifier = applicationPreferences.isShowingPrimaryIdentifier();
    }
    String title =
        ViewActions.getPrimarySourceTitle(
            sourceIdentifier.getIdentifier(), sourceNames, showingPrimaryIdentifier);

    return title + " @ " + DateTimeFormatters.DATETIME_IN_SYSTEM_ZONE_SPACE.format(Instant.now());
  }
Exemplo n.º 5
0
  private void initUI() {
    SortedMap<String, SourceIdentifier> stats = mainFrame.getAvailableStatistics();

    List<WrappedSourceIdentifier> wrappedSources =
        new ArrayList<WrappedSourceIdentifier>(stats.size() + 1);
    wrappedSources.add(new WrappedSourceIdentifier("Global", new SourceIdentifier("global")));
    for (Map.Entry<String, SourceIdentifier> current : stats.entrySet()) {
      WrappedSourceIdentifier wrapped =
          new WrappedSourceIdentifier(current.getKey(), current.getValue());
      wrappedSources.add(wrapped);
    }
    Object[] newSourcesArray = wrappedSources.toArray();
    if (!Arrays.equals(previousSourcesArray, newSourcesArray)) {
      previousSourcesArray = newSourcesArray;
      DefaultComboBoxModel model = new DefaultComboBoxModel(newSourcesArray);
      sourcesComboBox.setModel(model);
    }
    int index = 0;
    if (sourceIdentifier != null) {
      ComboBoxModel model = sourcesComboBox.getModel();
      for (int i = 0; i < model.getSize(); i++) {
        Object current = model.getElementAt(i);
        if (current instanceof WrappedSourceIdentifier) {
          WrappedSourceIdentifier wrapped = (WrappedSourceIdentifier) current;
          if (sourceIdentifier.getIdentifier().equals(wrapped.sourceIdentifier.getIdentifier())) {
            if (logger.isDebugEnabled()) logger.debug("Equal");
            index = i;
            break;
          } else {
            if (logger.isDebugEnabled()) {
              logger.debug("Not equal: {} != {}", sourceIdentifier, wrapped.sourceIdentifier);
            }
          }
        } else {
          if (logger.isWarnEnabled()) logger.warn("Not instanceof WrappedSourceIdentifier");
        }
      }
    }
    sourcesComboBox.setSelectedIndex(index);
  }
 protected File getRrdFile(SourceIdentifier sourceIdentifier) {
   File statisticsParent =
       new File(mainFrame.getApplicationPreferences().getStartupApplicationPath(), "statistics");
   return new File(statisticsParent, sourceIdentifier.getIdentifier() + ".rrd");
 }
Exemplo n.º 7
0
 public int hashCode() {
   int result;
   result = (resolvedName != null ? resolvedName.hashCode() : 0);
   result = 29 * result + (sourceIdentifier != null ? sourceIdentifier.hashCode() : 0);
   return result;
 }