Skip to content

Commit

Permalink
Fixed #856 - Reduce warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
eselmeister committed Dec 29, 2021
1 parent ec1007e commit 6fbf668
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2018 Lablicate GmbH.
* Copyright (c) 2012, 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,6 +13,7 @@

import org.eclipse.chemclipse.chromatogram.msd.process.supplier.peakidentification.model.IPeakOutputEntry;
import org.eclipse.chemclipse.chromatogram.msd.process.supplier.peakidentification.model.PeakOutputEntry;
import org.eclipse.chemclipse.converter.core.IConverterSupport;
import org.eclipse.chemclipse.converter.exceptions.NoConverterAvailableException;
import org.eclipse.chemclipse.msd.converter.peak.IPeakConverterSupport;
import org.eclipse.chemclipse.msd.converter.peak.PeakConverterMSD;
Expand All @@ -31,10 +32,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

/**
* @author Dr. Philip Wenig
*
*/
public class PeakOutputFilesWizardPage extends WizardPage {

private Combo peakConverterComboBox;
Expand All @@ -45,6 +42,7 @@ public class PeakOutputFilesWizardPage extends WizardPage {
* @param pageName
*/
protected PeakOutputFilesWizardPage(String pageName) {

super(pageName);
setTitle("Peak Output Formats");
setDescription("This wizard lets you select several output peak formats.");
Expand Down Expand Up @@ -98,7 +96,9 @@ public void createControl(Composite parent) {
* Select the output file format converter.
*/
converterSupport = PeakConverterMSD.getPeakConverterSupport();
try {
String[] filterNames = converterSupport.getFilterNames(IConverterSupport.EXPORT_SUPPLIER);
//
if(filterNames.length > 0) {
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
gridData.heightHint = 30;
Expand All @@ -111,7 +111,6 @@ public void createControl(Composite parent) {
/*
* Output converter combo box.
*/
String[] filterNames = converterSupport.getExportableFilterNames();
peakConverterComboBox = new Combo(composite, SWT.NONE);
peakConverterComboBox.setItems(filterNames);
peakConverterComboBox.setLayoutData(gridData);
Expand Down Expand Up @@ -146,7 +145,7 @@ public void widgetSelected(SelectionEvent e) {
}
}
});
} catch(NoConverterAvailableException e) {
} else {
gridData = new GridData(GridData.FILL_BOTH);
gridData.horizontalSpan = 2;
gridData.heightHint = 30;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ private Map<String, String> extractReportCompoundCasMap(File fileAdditionalRepor

private IReportRowModel extractReportRowModel(File fileImport, String extensionPointId) {

IReportRowModel reportRowModel;
IReportRowModel reportRowModel = null;
IProcessingInfo<?> processingInfo = ReportConverter.convert(fileImport, extensionPointId, new NullProgressMonitor());
try {
reportRowModel = processingInfo.getProcessingResult(IReportRowModel.class);
Object object = processingInfo.getProcessingResult();
if(object instanceof IReportRowModel) {
reportRowModel = (IReportRowModel)object;
}
} catch(TypeCastException e) {
reportRowModel = null;
}
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 @@ -169,7 +169,7 @@ public IProcessingInfo<T> convert(File file, String converterId, IProgressMonito
* @param monitor
* @return {@link IProcessingInfo}
*/
@SuppressWarnings({"unchecked", "deprecation", "rawtypes"})
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
public IProcessingInfo getChromatogram(File file, boolean overview, IProgressMonitor monitor) {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2019 Lablicate GmbH.
* Copyright (c) 2008, 2021 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -29,6 +29,7 @@ public interface IConverterSupport {
public static final Predicate<ISupplier> EXPORT_SUPPLIER = supplier -> supplier.isExportable();
public static final Predicate<ISupplier> IMPORT_SUPPLIER = supplier -> supplier.isImportable();
public static final Predicate<ISupplier> ALL_SUPPLIER = supplier -> true;

/**
* Returns the filter extension which are actually registered at the
* chromatogram converter extension point.<br/>
Expand Down Expand Up @@ -177,17 +178,18 @@ public boolean test(ISupplier supplier) {
* @return List<String>
* @throws NoConverterAvailableException
*/
@Deprecated
default List<String> getAvailableConverterIds(File file) throws NoConverterAvailableException {

List<ISupplier> suppliers = Converter.getSupplierForFile(file, getSupplier());
if(suppliers.isEmpty()) {
throw new NoConverterAvailableException();
}
//
ArrayList<String> list = new ArrayList<>();
for(ISupplier supplier : suppliers) {
list.add(supplier.getId());
}
//
return list;
}

Expand Down Expand Up @@ -254,4 +256,4 @@ default String getID() {

return "ConverterSupport:" + getClass().getName();
}
}
}
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,6 +17,7 @@
import java.util.List;

import org.eclipse.chemclipse.converter.chromatogram.ChromatogramExportSettings;
import org.eclipse.chemclipse.converter.core.IConverterSupport;
import org.eclipse.chemclipse.csd.model.core.IChromatogramCSD;
import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.selection.IChromatogramSelection;
Expand All @@ -43,7 +44,7 @@ public String getCategory() {
public Collection<IProcessSupplier<?>> getProcessorSuppliers() {

List<IProcessSupplier<?>> list = new ArrayList<>();
for(ISupplier supplier : ChromatogramConverterCSD.getInstance().getChromatogramConverterSupport().getExportSupplier()) {
for(ISupplier supplier : ChromatogramConverterCSD.getInstance().getChromatogramConverterSupport().getSupplier(IConverterSupport.EXPORT_SUPPLIER)) {
list.add(new ChromatogramConverterCSDProcessorSupplier(supplier, this));
}
return list;
Expand All @@ -54,6 +55,7 @@ private static final class ChromatogramConverterCSDProcessorSupplier extends Chr
private ISupplier supplier;

public ChromatogramConverterCSDProcessorSupplier(ISupplier supplier, IProcessTypeSupplier parent) {

super("csd.export." + supplier.getId(), supplier.getFilterName(), supplier.getDescription(), ChromatogramExportSettings.class, parent, DataType.CSD);
this.supplier = supplier;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2020 Lablicate GmbH.
* Copyright (c) 2008, 2021 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -45,8 +45,6 @@
* AMDIS *.msl<br/>
* JCAMP-DX *.jdx<br/>
* ASCII *.txt<br/>
*
* @author eselmeister
*/
public class MassSpectrumConverter {

Expand Down Expand Up @@ -225,14 +223,15 @@ private static IMassSpectrumImportConverter getMassSpectrumImportConverter(final
* @param converterId
* @return IMassSpectrumExportConverter
*/
@SuppressWarnings("unchecked")
private static <T> IMassSpectrumExportConverter<T> getMassSpectrumExportConverter(final String converterId) {

IConfigurationElement element;
element = getConfigurationElement(converterId);
IMassSpectrumExportConverter<T> instance = null;
if(element != null) {
try {
instance = (IMassSpectrumExportConverter)element.createExecutableExtension(Converter.EXPORT_CONVERTER);
instance = (IMassSpectrumExportConverter<T>)element.createExecutableExtension(Converter.EXPORT_CONVERTER);
} catch(CoreException e) {
logger.error(e.getLocalizedMessage(), 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
Expand Down Expand Up @@ -79,7 +79,6 @@ private static IProcessingInfo<IScanXIR> getScan(final File file, boolean overvi
IProcessingInfo<IScanXIR> processingInfo;
IScanConverterSupport converterSupport = getScanConverterSupport();
try {
@SuppressWarnings("deprecation")
List<String> availableConverterIds = converterSupport.getAvailableConverterIds(file);
for(String converterId : availableConverterIds) {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.chemclipse.chromatogram.msd.classifier.result.IChromatogramClassifierResult;
import org.eclipse.chemclipse.chromatogram.msd.classifier.settings.IChromatogramClassifierSettings;
import org.eclipse.chemclipse.model.exceptions.ChromatogramIsNullException;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.msd.model.core.IChromatogramMSD;
import org.eclipse.chemclipse.msd.model.core.selection.ChromatogramSelectionMSD;
import org.eclipse.chemclipse.msd.model.core.selection.IChromatogramSelectionMSD;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void testConstructor_1() {

chromatogramSelection = null;
chromatogramClassifierSettings = null;
classifier = new TestChromatogramClassifier();
classifier = new TestChromatogramClassifier(DataType.MSD);
IProcessingInfo<IChromatogramClassifierResult> processingInfo = classifier.applyClassifier(chromatogramSelection, chromatogramClassifierSettings, new NullProgressMonitor());
assertTrue(processingInfo.hasErrorMessages());
}
Expand All @@ -60,7 +61,7 @@ public void testConstructor_2() {
assertTrue("ChromatogramIsNullException", false);
}
chromatogramClassifierSettings = null;
classifier = new TestChromatogramClassifier();
classifier = new TestChromatogramClassifier(DataType.MSD);
IProcessingInfo<IChromatogramClassifierResult> processingInfo = classifier.applyClassifier(chromatogramSelection, chromatogramClassifierSettings, new NullProgressMonitor());
assertTrue(processingInfo.hasErrorMessages());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.eclipse.chemclipse.chromatogram.msd.classifier.result.IChromatogramClassifierResult;
import org.eclipse.chemclipse.chromatogram.msd.classifier.settings.IChromatogramClassifierSettings;
import org.eclipse.chemclipse.model.selection.IChromatogramSelection;
import org.eclipse.chemclipse.model.types.DataType;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.IProcessingMessage;
import org.eclipse.chemclipse.processing.core.MessageType;
Expand All @@ -28,6 +29,11 @@
*/
public class TestChromatogramClassifier extends AbstractChromatogramClassifier {

public TestChromatogramClassifier(DataType... dataTypes) {

super(dataTypes);
}

@Override
public IProcessingInfo<IChromatogramClassifierResult> applyClassifier(IChromatogramSelection<?, ?> chromatogramSelection, IChromatogramClassifierSettings chromatogramClassifierSettings, IProgressMonitor monitor) {

Expand All @@ -36,4 +42,4 @@ public IProcessingInfo<IChromatogramClassifierResult> applyClassifier(IChromatog
processingInfo.addMessage(processingMessage);
return processingInfo;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class AmdisPeakDetector_1 extends TestCase {
private IChromatogramMSD chromatogram;
private IChromatogramSelectionMSD chromatogramSelection;
private SettingsAMDIS peakDetectorSettings;
private PeakDetectorAMDIS detector;
private PeakDetectorAMDIS<?, ?, ?> detector;

@Override
protected void setUp() throws Exception {
Expand All @@ -44,7 +44,7 @@ protected void setUp() throws Exception {
chromatogram = (IChromatogramMSD)processingInfo.getProcessingResult();
chromatogramSelection = new ChromatogramSelectionMSD(chromatogram);
peakDetectorSettings = new SettingsAMDIS();
detector = new PeakDetectorAMDIS();
detector = new PeakDetectorAMDIS<>();
}

@Override
Expand Down

0 comments on commit 6fbf668

Please sign in to comment.