Skip to content

Commit

Permalink
Fixed #787 - Unify Enum getOptions()
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Oct 19, 2021
1 parent e6a1c9e commit 0b40353
Show file tree
Hide file tree
Showing 40 changed files with 125 additions and 173 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void createFieldEditors() {
addField(new FloatFieldEditor(PreferenceSupplier.P_MAX_LEADING, "Max Leading:", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new FloatFieldEditor(PreferenceSupplier.P_MIN_TAILING, "Min Tailing:", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new FloatFieldEditor(PreferenceSupplier.P_MAX_TAILING, "Max Tailing:", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_MODEL_PEAK_OPTION, "Model Peak Option", ModelPeakOption.getItems(), getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_MODEL_PEAK_OPTION, "Model Peak Option", ModelPeakOption.getOptions(), getFieldEditorParent()));
//
addField(new SpacerFieldEditor(getFieldEditorParent()));
addField(new LabelFieldEditor("Extra settings (to improve the result quality).", getFieldEditorParent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum AdjacentPeakSubtraction implements ILabel {

TWO("Two", "0"), //
ONE("One", "1"), //
NONE("None", "2");
Expand Down Expand Up @@ -47,4 +46,4 @@ public static String[][] getItems() {
{NONE.label(), NONE.value()}//
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum InstrumentFile implements ILabel {

CDF("CDF", "2");

private String label = "";
Expand Down Expand Up @@ -43,4 +42,4 @@ public static String[][] getItems() {
{CDF.label(), CDF.value()}//
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum InstrumentType implements ILabel {

QUADRUPOLE("Quadrupole", "0"), //
ION_TRAP("Ion Trap", "1"), //
MAGNETIC_SECTOR("Magnetic Sector", "2"), //
Expand Down Expand Up @@ -48,4 +47,4 @@ public static String[][] getItems() {
{SIM.label(), SIM.value()}//
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum Option implements ILabel {

YES("Yes", "1"), //
NO("No", "0");

Expand Down Expand Up @@ -44,4 +43,4 @@ public static String[][] getItems() {
{NO.label(), NO.value()}//
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum Resolution implements ILabel {

HIGH("High", "0"), //
MEDIUM("Medium", "1"), //
LOW("Low", "2");
Expand Down Expand Up @@ -46,4 +45,4 @@ public static String[][] getItems() {
{LOW.label(), LOW.value()} //
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum ScanDirection implements ILabel {

HIGH_TO_LOW("High to Low", "-1"), //
NONE("None", "0"), //
LOW_TO_HIGH("Low to High", "1");
Expand Down Expand Up @@ -47,4 +46,4 @@ public static String[][] getItems() {
{LOW_TO_HIGH.label(), LOW_TO_HIGH.value()}//
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum Sensitivity implements ILabel {

VERY_HIGH("Very High", "60"), //
HIGH("High", "30"), //
MEDIUM("Medium", "10"), //
Expand Down Expand Up @@ -51,4 +50,4 @@ public static String[][] getItems() {
{VERY_LOW.label(), VERY_LOW.value()} //
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum ShapeRequirements implements ILabel {

HIGH("High", "2"), //
MEDIUM("Medium", "1"), //
LOW("Low", "0"); //
Expand Down Expand Up @@ -46,4 +45,4 @@ public static String[][] getItems() {
{LOW.label(), LOW.value()} //
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum Threshold implements ILabel {

HIGH("High", "3"), //
MEDIUM("Medium", "2"), //
LOW("Low", "1"), //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum ModelPeakOption implements ILabel {

ALL("MPx (All)", 0), //
MP1("MP1", 1), //
MP2("MP2", 2), //
Expand All @@ -40,13 +39,8 @@ public int value() {
return value;
}

public static String[][] getItems() {
public static String[][] getOptions() {

return new String[][]{//
{ALL.label(), ALL.name()}, //
{MP1.label(), MP1.name()}, //
{MP2.label(), MP2.name()}, //
{MP3.label(), MP3.name()} //
};
return ILabel.getOptions(values());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum FilterMode implements ILabel {

INCLUDE("inclusive"), //
EXCLUDE("exclusive");
INCLUDE("Inclusive"), //
EXCLUDE("Exclusive");

private String label;

Expand All @@ -33,15 +32,8 @@ public String label() {
return label;
}

public static String[][] getElements() {
public static String[][] getOptions() {

String[][] elements = new String[values().length][2];
int counter = 0;
for(FilterMode filterMode : values()) {
elements[counter][0] = filterMode.label();
elements[counter][1] = filterMode.name();
counter++;
}
return elements;
return ILabel.getOptions(values());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum Threshold implements ILabel {

OFF(1), //
LOW(2), //
MEDIUM(3), //
Expand All @@ -39,15 +38,8 @@ public String label() {
return name().toLowerCase();
}

public static String[][] getElements() {
public static String[][] getOptions() {

String[][] elements = new String[values().length][2];
int counter = 0;
for(Threshold threshold : values()) {
elements[counter][0] = threshold.label();
elements[counter][1] = threshold.name();
counter++;
}
return elements;
return ILabel.getOptions(values());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum CalculatorStrategy implements ILabel {

AUTO("First Chromatogram - Then File(s)"), //
CHROMATOGRAM("Chromatogram Only"), //
FILES("File(s) Only");
Expand All @@ -31,4 +30,9 @@ public String label() {

return label;
}
}

public static String[][] getOptions() {

return ILabel.getOptions(values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public PreferencePageCSD() {
@Override
public void createFieldEditors() {

addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getElements(), getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getOptions(), getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_INCLUDE_BACKGROUND_CSD, "Include Background (VV: true, BV|VB: false)", getFieldEditorParent()));
addField(new FloatFieldEditor(PreferenceSupplier.P_MIN_SN_RATIO_CSD, "Min S/N Ratio", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new WindowSizeFieldEditor(PreferenceSupplier.P_MOVING_AVERAGE_WINDOW_SIZE_CSD, "Window Size", getFieldEditorParent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public PreferencePageMSD() {
@Override
public void createFieldEditors() {

addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getElements(), getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getOptions(), getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_INCLUDE_BACKGROUND_MSD, "Include Background (VV: true, BV|VB: false)", getFieldEditorParent()));
addField(new FloatFieldEditor(PreferenceSupplier.P_MIN_SN_RATIO_MSD, "Min S/N Ratio", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new WindowSizeFieldEditor(PreferenceSupplier.P_MOVING_AVERAGE_WINDOW_SIZE_MSD, "Window Size", getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_USE_NOISE_SEGMENTS_MSD, "Use Noise-Segments", getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_FILTER_MODE_MSD, "Filter Mode", FilterMode.getElements(), getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_FILTER_MODE_MSD, "Filter Mode", FilterMode.getOptions(), getFieldEditorParent()));
addField(new StringFieldEditor(PreferenceSupplier.P_MZ_VALUES_TO_FILTER_MSD, "m/z values to filter", getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_USE_INDIVIDUAL_TRACES_MSD, "Use Individual Traces", getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_OPTIMIZE_BASELINE_MSD, "Optimize Baseline (VV)", getFieldEditorParent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public PreferencePageWSD() {
@Override
public void createFieldEditors() {

addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getElements(), getFieldEditorParent()));
addField(new ComboFieldEditor(PreferenceSupplier.P_THRESHOLD_MSD, "Threshold", Threshold.getOptions(), getFieldEditorParent()));
addField(new BooleanFieldEditor(PreferenceSupplier.P_INCLUDE_BACKGROUND_WSD, "Include Background (VV: true, BV|VB: false)", getFieldEditorParent()));
addField(new FloatFieldEditor(PreferenceSupplier.P_MIN_SN_RATIO_WSD, "Min S/N Ratio", 0.0f, Float.MAX_VALUE, getFieldEditorParent()));
addField(new WindowSizeFieldEditor(PreferenceSupplier.P_MOVING_AVERAGE_WINDOW_SIZE_WSD, "Window Size", getFieldEditorParent()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

public class SeparationColumnFactory {

public static final String TYPE_DEFAULT = "default";
//
public static final String TYPE_POLAR = "polar";
public static final String TYPE_APOLAR = "apolar";
public static final String TYPE_SEMI_POLAR = "semi-polar";
//
public static final String TYPE_DEFAULT = "Default";
public static final String TYPE_POLAR = "Polar";
public static final String TYPE_APOLAR = "Nonpolar";
public static final String TYPE_SEMI_POLAR = "Semipolar";
/*
* Specific columns might be removed soon as basic types.
* Mappings shall be added to group specific columns into
* one of the three above classes.
*/
public static final String TYPE_DB1 = "DB-1";
public static final String TYPE_DB5 = "DB-5";
public static final String TYPE_DB1701 = "DB-1701";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum HeaderField implements ILabel {

DEFAULT("Default"), //
NAME("Name"), //
DATA_NAME("Data Name"), //
Expand All @@ -36,20 +35,6 @@ public String label() {

public static String[][] getOptions() {

return getOptions(values());
}

public static String[][] getOptions(HeaderField[] elements) {

String[][] dataArray = new String[elements.length][2];
//
int counter = 0;
for(HeaderField element : elements) {
dataArray[counter][0] = element.label();
dataArray[counter][1] = element.name();
counter++;
}
//
return dataArray;
return ILabel.getOptions(values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.eclipse.chemclipse.support.text.ILabel;

public enum PenaltyCalculation implements ILabel {

NONE("None"), //
RETENTION_TIME("Retention Time"), //
RETENTION_INDEX("Retention Index"), //
Expand All @@ -31,4 +30,9 @@ public String label() {

return label;
}
}

public static String[][] getOptions() {

return ILabel.getOptions(values());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*
*/
public enum IonRoundMethod implements ILabel {

DEFAULT(v -> Math.round(v), "Default: round to nearest integer"), //
MINUS_00(v -> round(v, 10), createDescription(-0.0d)), //
MINUS_01(v -> round(v, 9), createDescription(-0.1d)), //
Expand Down Expand Up @@ -69,17 +68,7 @@ public int round(double mz) {

public static String[][] getOptions() {

IonRoundMethod[] methods = values();
String[][] elements = new String[methods.length][2];
//
int counter = 0;
for(IonRoundMethod method : methods) {
elements[counter][0] = method.label();
elements[counter][1] = method.name();
counter++;
}
//
return elements;
return ILabel.getOptions(values());
}

public static IonRoundMethod getActive() {
Expand Down Expand Up @@ -119,4 +108,4 @@ private static String createDescription(double offset) {
DecimalFormat decimalFormat = ValueFormat.getDecimalFormatEnglish("0.0");
return "Round m/z from " + decimalFormat.format(offset) + " (incl.) to +" + decimalFormat.format(offset + 1.0d) + " (excl.)";
}
}
}
Loading

0 comments on commit 0b40353

Please sign in to comment.