Skip to content

Commit

Permalink
Differentiate column label and internal name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Nov 2, 2021
1 parent ce221c7 commit e334206
Show file tree
Hide file tree
Showing 38 changed files with 183 additions and 92 deletions.
Original file line number Diff line number Diff line change
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
Expand Up @@ -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
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 @@ -276,15 +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 && calculatorSettings.isUseDefaultColumn()) {
separationColumnIndices = calibrationMap.get(SeparationColumnFactory.TYPE_DEFAULT);
separationColumnIndices = calibrationMap.get(SeparationColumnType.DEFAULT.value());
}
//
return separationColumnIndices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,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
Expand Up @@ -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 Down Expand Up @@ -54,7 +54,8 @@ public ISeparationColumnIndices parse(File 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 @@ -116,7 +117,7 @@ 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);
} catch(IOException e) {
logger.error(e);
Expand Down
Original file line number Diff line number Diff line change
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,13 +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))) {
/*
* 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 @@ -79,7 +81,7 @@ private ISeparationColumn extractSeparationColumn(File file) {
/*
* Create the column.
*/
separationColumn = new SeparationColumn(name, length, diameter, phase);
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
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.Map;

import org.eclipse.chemclipse.model.columns.SeparationColumnFactory;
import org.eclipse.chemclipse.model.columns.SeparationColumnType;
import org.eclipse.chemclipse.support.ui.swt.ExtendedTableViewer;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxCellEditor;
Expand All @@ -27,13 +27,14 @@ public class ColumExtractorEditingSupport extends EditingSupport {
private ExtendedTableViewer tableViewer;
private String column;
private static final String[] ITEMS = new String[]{ //
SeparationColumnFactory.TYPE_DEFAULT, //
SeparationColumnFactory.TYPE_APOLAR, //
SeparationColumnFactory.TYPE_SEMI_POLAR, //
SeparationColumnFactory.TYPE_POLAR //
SeparationColumnType.DEFAULT.value(), //
SeparationColumnType.APOLAR.value(), //
SeparationColumnType.SEMI_POLAR.value(), //
SeparationColumnType.POLAR.value() //
};

public ColumExtractorEditingSupport(ExtendedTableViewer tableViewer, String column) {

super(tableViewer);
this.column = column;
if(column.equals(ColumExtractorLabelProvider.SEPRATION_COLUMN)) {
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 @@ -13,11 +13,24 @@

public abstract class AbstractSeparationColumn implements ISeparationColumn {

private String value = "";
private String name = "";
private String length = "";
private String diameter = "";
private String phase = "";

@Override
public String getValue() {

return value;
}

@Override
public void setValue(String value) {

this.value = value;
}

@Override
public String getName() {

Expand Down Expand Up @@ -87,33 +100,51 @@ 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;
}
AbstractSeparationColumn other = (AbstractSeparationColumn)obj;
if(diameter == null) {
if(other.diameter != null)
if(other.diameter != null) {
return false;
} else if(!diameter.equals(other.diameter))
}
} else if(!diameter.equals(other.diameter)) {
return false;
}
if(length == null) {
if(other.length != null)
if(other.length != null) {
return false;
} else if(!length.equals(other.length))
}
} else if(!length.equals(other.length)) {
return false;
}
if(name == null) {
if(other.name != null)
if(other.name != null) {
return false;
}
} else if(!name.equals(other.name)) {
return false;
}
if(value == null) {
if(other.value != null) {
return false;
} else if(!name.equals(other.name))
}
} else if(!value.equals(other.value)) {
return false;
}
if(phase == null) {
if(other.phase != null)
if(other.phase != null) {
return false;
} else if(!phase.equals(other.phase))
}
} else if(!phase.equals(other.phase)) {
return false;
}
return true;
}
}
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 @@ -17,6 +17,10 @@ public interface ISeparationColumn {

void setName(String name);

String getValue();

void setValue(String value);

String getLength();

void setLength(String length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@

public class SeparationColumn extends AbstractSeparationColumn implements ISeparationColumn {

public SeparationColumn(String name, String length, String diameter, String phase) {
public SeparationColumn(String name, String value, String length, String diameter, String phase) {

setName(name);
setValue(value);
setLength(length);
setDiameter(diameter);
setPhase(phase);
Expand Down
Loading

0 comments on commit e334206

Please sign in to comment.