Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a regression in column type labeling #804

Merged
merged 5 commits into from
Nov 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -50,7 +50,7 @@ public String getColumnText(Object element, int columnIndex) {
//
switch(columnIndex) {
case 0:
text = calibrationFile.getSeparationColumnIndices().getSeparationColumn().getName();
text = calibrationFile.getSeparationColumnIndices().getSeparationColumn().getValue();
break;
case 1:
text = calibrationFile.getFile().getName();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -26,8 +26,8 @@ public int compare(Viewer viewer, Object e1, Object e2) {
//
CalibrationFile calibrationFile1 = (CalibrationFile)e1;
CalibrationFile calibrationFile2 = (CalibrationFile)e2;
String column1 = calibrationFile1.getSeparationColumnIndices().getSeparationColumn().getName();
String column2 = calibrationFile2.getSeparationColumnIndices().getSeparationColumn().getName();
String column1 = calibrationFile1.getSeparationColumnIndices().getSeparationColumn().getValue();
String column2 = calibrationFile2.getSeparationColumnIndices().getSeparationColumn().getValue();
//
switch(getPropertyIndex()) {
case 0:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2020 Lablicate GmbH.
* Copyright (c) 2014, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -32,7 +32,7 @@ public IProcessingInfo applyCalculator(IChromatogramSelection chromatogramSelect
if(chromatogramCalculatorSettings instanceof CalculatorSettings) {
CalculatorSettings calculatorSettings = (CalculatorSettings)chromatogramCalculatorSettings;
RetentionIndexCalculator calculator = new RetentionIndexCalculator();
IProcessingInfo<?> calculatorInfo = calculator.calculateIndices(chromatogramSelection, calculatorSettings, monitor);
IProcessingInfo<?> calculatorInfo = calculator.calculateIndices(chromatogramSelection, calculatorSettings);
processingInfo.addMessages(calculatorInfo);
}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public IChromatogramCSD parseChromatogram(String chromatogramPath, String pathRe
List<String> retentionIndexFiles = new ArrayList<>();
retentionIndexFiles.add(pathRetentionIndexFile);
calculatorSettings.setRetentionIndexFiles(retentionIndexFiles);
retentionIndexCalculator.calculateIndices(chromatogramSelectionCSD, calculatorSettings, monitor);
retentionIndexCalculator.calculateIndices(chromatogramSelectionCSD, calculatorSettings);
}
} catch(Exception e) {
logger.error(e.getLocalizedMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public IChromatogramMSD parseChromatogram(String chromatogramPath, String pathRe
List<String> retentionIndexFiles = new ArrayList<>();
retentionIndexFiles.add(pathRetentionIndexFile);
calculatorSettings.setRetentionIndexFiles(retentionIndexFiles);
retentionIndexCalculator.calculateIndices(chromatogramSelectionMSD, calculatorSettings, monitor);
retentionIndexCalculator.calculateIndices(chromatogramSelectionMSD, calculatorSettings);
}
/*
* Peak identifier
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -22,6 +22,7 @@ public class CalibrationFile {
private ISeparationColumnIndices separationColumnIndices;

public CalibrationFile(File file) {

this.file = file;
CalibrationFileReader calibrationFileReader = new CalibrationFileReader();
this.separationColumnIndices = calibrationFileReader.parse(file);
Expand Down Expand Up @@ -49,16 +50,20 @@ public int hashCode() {
@Override
public boolean equals(Object obj) {

if(this == obj)
if(this == obj) {
return true;
if(obj == null)
}
if(obj == null) {
return false;
if(getClass() != obj.getClass())
}
if(getClass() != obj.getClass()) {
return false;
}
CalibrationFile other = (CalibrationFile)obj;
if(file == null) {
if(other.file != null)
if(other.file != null) {
return false;
}
} else if(!file.equals(other.file)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2014, 2020 Lablicate GmbH.
* Copyright (c) 2014, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -27,7 +27,7 @@
import org.eclipse.chemclipse.model.columns.IRetentionIndexEntry;
import org.eclipse.chemclipse.model.columns.ISeparationColumn;
import org.eclipse.chemclipse.model.columns.ISeparationColumnIndices;
import org.eclipse.chemclipse.model.columns.SeparationColumnFactory;
import org.eclipse.chemclipse.model.columns.SeparationColumnType;
import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.core.IPeak;
import org.eclipse.chemclipse.model.core.IScan;
Expand Down Expand Up @@ -157,7 +157,7 @@ public static float getRetentionIndex(String name) {
}

@SuppressWarnings({"rawtypes", "unchecked"})
public IProcessingInfo calculateIndices(IChromatogramSelection chromatogramSelection, CalculatorSettings calculatorSettings, IProgressMonitor monitor) {
public IProcessingInfo calculateIndices(IChromatogramSelection chromatogramSelection, CalculatorSettings calculatorSettings) {

IProcessingInfo processingInfo = new ProcessingInfo();
if(chromatogramSelection != null) {
Expand Down Expand Up @@ -245,7 +245,7 @@ private ISeparationColumnIndices getAutoIndices(IChromatogramSelection chromatog
if(separationColumnIndices == null) {
separationColumnIndices = getFileIndices(chromatogramSelection, calculatorSettings);
} else {
if(separationColumnIndices.size() == 0) {
if(separationColumnIndices.isEmpty()) {
separationColumnIndices = getFileIndices(chromatogramSelection, calculatorSettings);
}
}
Expand Down Expand Up @@ -276,17 +276,15 @@ private ISeparationColumnIndices getFileIndices(IChromatogramSelection chromatog
File file = new File(retentionIndexFile);
ISeparationColumnIndices separationColumnIndices = calibrationFileReader.parse(file);
ISeparationColumn separationColumn = separationColumnIndices.getSeparationColumn();
calibrationMap.put(separationColumn.getName(), separationColumnIndices);
calibrationMap.put(separationColumn.getValue(), separationColumnIndices);
}
/*
* Run the calculation.
*/
String columnName = chromatogramSelection.getChromatogram().getSeparationColumnIndices().getSeparationColumn().getName();
String columnName = chromatogramSelection.getChromatogram().getSeparationColumnIndices().getSeparationColumn().getValue();
ISeparationColumnIndices separationColumnIndices = calibrationMap.get(columnName);
if(separationColumnIndices == null) {
if(calculatorSettings.isUseDefaultColumn()) {
separationColumnIndices = calibrationMap.get(SeparationColumnFactory.TYPE_DEFAULT);
}
if(separationColumnIndices == null && calculatorSettings.isUseDefaultColumn()) {
separationColumnIndices = calibrationMap.get(SeparationColumnType.DEFAULT.value());
}
//
return separationColumnIndices;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2018 Lablicate GmbH.
* Copyright (c) 2016, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -30,6 +30,7 @@ public class CalibrationFileWriter {
private DecimalFormat decimalFormat;

public CalibrationFileWriter() {

decimalFormat = ValueFormat.getDecimalFormatEnglish();
}

Expand All @@ -44,7 +45,7 @@ public void write(File file, ISeparationColumnIndices separationColumnIndices) {
*/
ISeparationColumn separationColumn = separationColumnIndices.getSeparationColumn();
if(separationColumn != null) {
printWriter.println(IColumnFormat.COLUMN_NAME + IColumnFormat.HEADER_VALUE_DELIMITER + separationColumn.getName());
printWriter.println(IColumnFormat.COLUMN_NAME + IColumnFormat.HEADER_VALUE_DELIMITER + separationColumn.getValue());
printWriter.println(IColumnFormat.COLUMN_LENGTH + IColumnFormat.HEADER_VALUE_DELIMITER + separationColumn.getLength());
printWriter.println(IColumnFormat.COLUMN_DIAMETER + IColumnFormat.HEADER_VALUE_DELIMITER + separationColumn.getDiameter());
printWriter.println(IColumnFormat.COLUMN_PHASE + IColumnFormat.HEADER_VALUE_DELIMITER + separationColumn.getPhase());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -23,8 +23,8 @@
import org.eclipse.chemclipse.model.columns.ISeparationColumnIndices;
import org.eclipse.chemclipse.model.columns.RetentionIndexEntry;
import org.eclipse.chemclipse.model.columns.SeparationColumn;
import org.eclipse.chemclipse.model.columns.SeparationColumnFactory;
import org.eclipse.chemclipse.model.columns.SeparationColumnIndices;
import org.eclipse.chemclipse.model.columns.SeparationColumnType;
import org.eclipse.chemclipse.model.core.AbstractChromatogram;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
Expand All @@ -50,12 +50,12 @@ public ISeparationColumnIndices parse(File file) {

ISeparationColumnIndices separationColumnIndices = new SeparationColumnIndices();
//
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
/*
* Column Specification
*/
String name = SeparationColumnFactory.TYPE_DEFAULT;
String name = SeparationColumnType.DEFAULT.name();
String value = SeparationColumnType.DEFAULT.value();
String length = "";
String diameter = "";
String phase = "";
Expand Down Expand Up @@ -117,10 +117,8 @@ public ISeparationColumnIndices parse(File file) {
/*
* Create and set the column.
*/
ISeparationColumn separationColumn = new SeparationColumn(name, length, diameter, phase);
ISeparationColumn separationColumn = new SeparationColumn(name, value, length, diameter, phase);
separationColumnIndices.setSeparationColumn(separationColumn);
//
bufferedReader.close();
} catch(IOException e) {
logger.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2020 Lablicate GmbH.
* Copyright (c) 2018, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -110,7 +110,7 @@ public IProcessingInfo<ISeparationColumnIndices> parseRetentionIndices(File file
while(matcherColumn.find()) {
String length = matcherColumn.group(3).trim();
String name = matcherColumn.group(5).trim();
separationColumn.setName(name);
separationColumn.setValue(name);
separationColumn.setLength(length);
}
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public String getColumnText(Object element, int columnIndex) {
IdentifierFile identifierFile = (IdentifierFile)element;
switch(columnIndex) {
case 0:
text = identifierFile.getSeparationColumn().getName();
text = identifierFile.getSeparationColumn().getValue();
break;
case 1:
text = identifierFile.getFile().getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public int compare(Viewer viewer, Object e1, Object e2) {
//
IdentifierFile identifierFile1 = (IdentifierFile)e1;
IdentifierFile identifierFile2 = (IdentifierFile)e2;
String column1 = identifierFile1.getSeparationColumn().getName();
String column2 = identifierFile2.getSeparationColumn().getName();
String column1 = identifierFile1.getSeparationColumn().getValue();
String column2 = identifierFile2.getSeparationColumn().getValue();
//
switch(getPropertyIndex()) {
case 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.chemclipse.model.columns.ISeparationColumn;
import org.eclipse.chemclipse.model.columns.SeparationColumn;
import org.eclipse.chemclipse.model.columns.SeparationColumnFactory;
import org.eclipse.chemclipse.model.columns.SeparationColumnType;

public class IdentifierFileReader {

Expand All @@ -32,7 +33,7 @@ public ISeparationColumn parse(File file) {
* Extract the separation column if the library contains the info, e.g. in a *.msl or *.msp file.
* Otherwise, create a default column.
*/
ISeparationColumn separationColumn = SeparationColumnFactory.getSeparationColumn(SeparationColumnFactory.TYPE_DEFAULT);
ISeparationColumn separationColumn = SeparationColumnFactory.getSeparationColumn(SeparationColumnType.DEFAULT);
if(isSeparationColumnFile(file)) {
separationColumn = extractSeparationColumn(file);
}
Expand All @@ -46,14 +47,14 @@ private ISeparationColumn extractSeparationColumn(File file) {
* Restrict to *.msl and *.msp files at the moment.
* Otherwise use default.
*/
ISeparationColumn separationColumn = SeparationColumnFactory.getSeparationColumn(SeparationColumnFactory.TYPE_DEFAULT);
ISeparationColumn separationColumn = SeparationColumnFactory.getSeparationColumn(SeparationColumnType.DEFAULT);
//
try {
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
/*
* Column Specification
*/
String name = SeparationColumnFactory.TYPE_DEFAULT;
String name = SeparationColumnType.DEFAULT.name();
String value = SeparationColumnType.DEFAULT.value();
String length = "";
String diameter = "";
String phase = "";
Expand All @@ -80,8 +81,7 @@ private ISeparationColumn extractSeparationColumn(File file) {
/*
* Create the column.
*/
separationColumn = new SeparationColumn(name, length, diameter, phase);
bufferedReader.close();
separationColumn = new SeparationColumn(name, value, length, diameter, phase);
} catch(IOException e) {
logger.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Lablicate GmbH.
* Copyright (c) 2019, 2021 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -17,7 +17,7 @@
import org.eclipse.chemclipse.converter.model.SeparationColumnMapping;
import org.eclipse.chemclipse.converter.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.converter.ui.swt.ColumExtractorTable;
import org.eclipse.chemclipse.model.columns.SeparationColumnFactory;
import org.eclipse.chemclipse.model.columns.SeparationColumnType;
import org.eclipse.chemclipse.support.ui.events.IKeyEventProcessor;
import org.eclipse.chemclipse.support.ui.menu.ITableMenuEntry;
import org.eclipse.chemclipse.support.ui.swt.ExtendedTableViewer;
Expand Down Expand Up @@ -74,6 +74,7 @@ public class ColumnExtractorFieldEditor extends FieldEditor {
private SeparationColumnMapping mapping = new SeparationColumnMapping();

public ColumnExtractorFieldEditor(String name, String labelText, Composite parent) {

init(name, labelText);
createControl(parent);
}
Expand Down Expand Up @@ -179,6 +180,7 @@ private Button createButtonAdd(Composite parent) {
button.setToolTipText(ADD_TOOLTIP);
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

InputDialog dialog = new InputDialog(button.getShell(), DIALOG_TITLE, MESSAGE_ADD, "DB5", new IInputValidator() {
Expand All @@ -204,7 +206,7 @@ public String isValid(String newText) {
String item = dialog.getValue().trim();
if(!"".equals(item)) {
if(!mapping.keySet().contains(item)) {
mapping.put(item, SeparationColumnFactory.TYPE_DEFAULT);
mapping.put(item, SeparationColumnType.DEFAULT.value());
setTableViewerInput();
}
}
Expand All @@ -222,6 +224,7 @@ private Button createButtonRemove(Composite parent) {
button.setToolTipText(REMOVE_TOOLTIP);
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

deleteItems(e.display.getActiveShell());
Expand All @@ -238,6 +241,7 @@ private Button createButtonRemoveAll(Composite parent) {
button.setToolTipText(REMOVE_ALL_TOOLTIP);
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

if(MessageDialog.openQuestion(button.getShell(), DIALOG_TITLE, MESSAGE_REMOVE_ALL)) {
Expand All @@ -257,6 +261,7 @@ private Button createButtonImport(Composite parent) {
button.setToolTipText(IMPORT_TITLE);
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

FileDialog fileDialog = new FileDialog(e.widget.getDisplay().getActiveShell(), SWT.READ_ONLY);
Expand Down Expand Up @@ -284,6 +289,7 @@ private Button createButtonExport(Composite parent) {
button.setToolTipText(EXPORT_TITLE);
button.addSelectionListener(new SelectionAdapter() {

@Override
public void widgetSelected(SelectionEvent e) {

FileDialog fileDialog = new FileDialog(e.widget.getDisplay().getActiveShell(), SWT.SAVE);
Expand Down
Loading