/* Copyright (C) 2022 Free Software Foundation

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses>.  */


package org.gprofng.mpmt;

import org.gprofng.mpmt.picklist.PickListElement;

public class ExperimentPickListElement implements PickListElement {
  private String path;
  private String workingDirectory;
  private String confPath;

  public ExperimentPickListElement(String path, String workingDirectory, String confPath) {
    this.path = path;
    this.workingDirectory = workingDirectory;
    this.confPath = confPath;
  }

  public String getPath() {
    return path;
  }

  public String getWorkingDirectory() {
    return workingDirectory;
  }

  public String getConfPath() {
    return confPath;
  }

  public String getToolTip() {
    String tt = getPath();
    if (getWorkingDirectory() != null) {
      StringBuilder sb = new StringBuilder();
      sb.append("<html>");
      sb.append(AnLocale.getString("Path: "));
      sb.append(getPath());
      sb.append("<br>");
      sb.append(AnLocale.getString("Working Directory: "));
      sb.append(getWorkingDirectory());
      if (confPath != null) {
        sb.append("<br>");
        sb.append(AnLocale.getString("Configuration: "));
        sb.append(getConfPath());
      }
      sb.append("<html>");

      tt = sb.toString();
    }
    return tt;
  }

  /** Compares two PicklistElement for equality. Returns true if equal, otherwise false. */
  @Override
  public boolean equals(PickListElement elem) {
    return ((ExperimentPickListElement) elem).getPath().equals(this.path);
  }
}
