/*
 * Copyright 2006-2021 The MZmine Development Team
 *
 * This file is part of MZmine.
 *
 * MZmine 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 2 of the
 * License, or (at your option) any later version.
 *
 * MZmine 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 MZmine; if not,
 * write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

package io.github.mzmine.datamodel.features.types;

import io.github.mzmine.datamodel.MobilityType;
import javafx.beans.property.SimpleObjectProperty;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class MobilityUnitType extends DataType<SimpleObjectProperty<MobilityType>> {

  @NotNull
  @Override
  public final String getUniqueID() {
    // Never change the ID for compatibility during saving/loading of type
    return "ion_mobility_unit";
  }

  @NotNull
  @Override
  public String getHeaderString() {
    return "Mobility unit";
  }

  @Override
  public SimpleObjectProperty<MobilityType> createProperty() {
    return new SimpleObjectProperty<>(MobilityType.NONE);
  }

  @NotNull
  @Override
  public String getFormattedString(@Nullable Object value) {
    if (value instanceof MobilityType mt) {
      return mt.getUnit();
    }
    return super.getFormattedString(value);
  }
}

@@ -889,50 +889,411 @@
 ort 
-javafx.beans.property.SimpleObjectProperty
+io.github.mzmine.datamodel.RawDataFile;%0Aimport io.github.mzmine.datamodel.features.ModularFeature;%0Aimport io.github.mzmine.datamodel.features.ModularFeatureList;%0Aimport io.github.mzmine.datamodel.features.ModularFeatureListRow;%0Aimport javafx.beans.property.SimpleObjectProperty;%0Aimport javax.xml.stream.XMLStreamException;%0Aimport javax.xml.stream.XMLStreamReader;%0Aimport javax.xml.stream.XMLStreamWriter
 ;%0Aim
@@ -2026,16 +2026,16 @@
 ;%0A    %7D%0A
-
     retu
@@ -2073,11 +2073,720 @@
 ue);%0A  %7D
+%0A%0A  @Override%0A  public void saveToXML(@NotNull XMLStreamWriter writer, @Nullable Object value,%0A      @NotNull ModularFeatureList flist, @NotNull ModularFeatureListRow row,%0A      @Nullable ModularFeature feature, @Nullable RawDataFile file) throws XMLStreamException %7B%0A    if(!(value instanceof MobilityType mt)) %7B%0A      return;%0A    %7D%0A    writer.writeCharacters(mt.name());%0A  %7D%0A%0A  @Override%0A  public Object loadFromXML(@NotNull XMLStreamReader reader, @NotNull ModularFeatureList flist,%0A      @NotNull ModularFeatureListRow row, @Nullable ModularFeature feature,%0A      @Nullable RawDataFile file) throws XMLStreamException %7B%0A    String name = reader.getElementText();%0A    return MobilityType.valueOf(name);%0A  %7D
 %0A%7D%0A

load / save MobilityUnitType