Skip to content

Commit

Permalink
Fixed #1969 - PCA - ISample group name must not be null
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Nov 22, 2024
1 parent e2140b0 commit f395833
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2023 Lablicate GmbH.
* Copyright (c) 2018, 2024 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 @@ -236,8 +236,7 @@ private void updateGroupNames() {
}
//
String groupName = textGroupName.getText().trim();
final String setGroupName = groupName.isEmpty() ? null : groupName;
filterInput.forEach(i -> i.setGroupName(setGroupName));
filterInput.forEach(i -> i.setGroupName(groupName));
update();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2023 Lablicate GmbH.
* Copyright (c) 2017, 2024 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 @@ -44,8 +44,8 @@ private void createColumns() {
String[] titles = {"Name", "Group", "Filename", "Path"};
int[] bounds = {100, 100, 100, 100};
// first column is for the first name
TableViewerColumn col = createTableViewerColumn(titles[0], bounds[0], 0);
col.setLabelProvider(new ColumnLabelProvider() {
TableViewerColumn tableViewerColumn = createTableViewerColumn(titles[0], bounds[0], 0);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {

@Override
public String getText(Object element) {
Expand All @@ -54,8 +54,8 @@ public String getText(Object element) {
return inputData.getSampleName();
}
});
col = createTableViewerColumn(titles[1], bounds[1], 1);
col.setLabelProvider(new CellLabelProvider() {
tableViewerColumn = createTableViewerColumn(titles[1], bounds[1], 1);
tableViewerColumn.setLabelProvider(new CellLabelProvider() {

@Override
public void update(ViewerCell cell) {
Expand All @@ -65,7 +65,7 @@ public void update(ViewerCell cell) {
cell.setText(text);
}
});
col.setEditingSupport(new EditingSupport(tableViewer) {
tableViewerColumn.setEditingSupport(new EditingSupport(tableViewer) {

private TextCellEditor editor = new TextCellEditor(tableViewer.getTable());

Expand Down Expand Up @@ -98,17 +98,12 @@ protected void setValue(Object element, Object value) {

IDataInputEntry inputData = (IDataInputEntry)element;
String groupName = (String)value;
groupName = groupName.trim();
if(!groupName.isEmpty()) {
inputData.setGroupName(groupName);
} else {
inputData.setGroupName(null);
}
inputData.setGroupName(groupName.trim());
update();
}
});
col = createTableViewerColumn(titles[2], bounds[2], 2);
col.setLabelProvider(new ColumnLabelProvider() {
tableViewerColumn = createTableViewerColumn(titles[2], bounds[2], 2);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {

@Override
public String getText(Object element) {
Expand All @@ -117,8 +112,8 @@ public String getText(Object element) {
return inputData.getFileName();
}
});
col = createTableViewerColumn(titles[3], bounds[3], 3);
col.setLabelProvider(new ColumnLabelProvider() {
tableViewerColumn = createTableViewerColumn(titles[3], bounds[3], 3);
tableViewerColumn.setLabelProvider(new ColumnLabelProvider() {

@Override
public String getText(Object element) {
Expand Down Expand Up @@ -180,4 +175,4 @@ public void update() {
column.pack();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,9 @@ private void updateOplsGroupTargets() {
oplsGroupTargets.add(OPLS_GROUP_TARGET_NONE);
//
if(samples != null) {
/*
* Group Name must not be null!
*/
for(ISample sample : samples.getSamples()) {
if(sample.getGroupName() == null) {
logger.warn("Fix GroupName (must not be null): " + sample);
sample.setGroupName("");
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022, 2023 Lablicate GmbH.
* Copyright (c) 2022, 2024 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 @@ -105,7 +105,7 @@ public static void read(File file, List<ISample> samples) throws IOException {
if(sample != null) {
sample.setSelected(valueParserSupport.parseBoolean(values, 1));
sample.setRGB(valueParserSupport.parseString(values, 2));
sample.setGroupName(valueParserSupport.parseString(values, 3));
sample.setGroupName(valueParserSupport.parseString(values, 3, ""));
sample.setClassification(valueParserSupport.parseString(values, 4));
sample.setDescription(valueParserSupport.parseString(values, 5));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2011, 2022 Lablicate GmbH.
* Copyright (c) 2011, 2024 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.xxd.process.supplier.pca.model;

Expand All @@ -16,7 +16,7 @@

public class DataInputEntry implements IDataInputEntry {

private String groupName;
private String groupName = "";
private String inputFile = "";

/**
Expand Down Expand Up @@ -89,4 +89,4 @@ public boolean equals(Object o) {
DataInputEntry dataInputEntry = (DataInputEntry)o;
return dataInputEntry.getSampleName().equals(getSampleName());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2011, 2022 Lablicate GmbH.
* Copyright (c) 2011, 2024 Lablicate GmbH.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dr. Philip Wenig - initial API and implementation
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.xxd.process.supplier.pca.model;

Expand Down Expand Up @@ -37,4 +37,4 @@ public interface IDataInputEntry {
String getSampleName();

void setGroupName(String groupName);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 Lablicate GmbH.
* Copyright (c) 2020, 2024 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 @@ -20,9 +20,9 @@ public PeakSample(IDataInputEntry dataInputEntry) {
this(dataInputEntry.getSampleName(), dataInputEntry.getGroupName());
}

public PeakSample(String name, String groupName) {
public PeakSample(String sampleName, String groupName) {

super(name);
super(sampleName);
setGroupName(groupName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ public class Sample extends AbstractSample<PeakSampleData> {

public Sample(String sampleName, String groupName) {

super(sampleName);
setGroupName(groupName);
this(sampleName, groupName, "", "");
}

public Sample(String sampleName, String groupName, String description) {

super(sampleName);
setGroupName(groupName);
setDescription(description);
this(sampleName, groupName, "", description);
}

public Sample(String sampleName, String groupName, String classification, String description) {
Expand Down

0 comments on commit f395833

Please sign in to comment.