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

Localized org.eclipse.chemclipse.chromatogram.csd.* #1304

Merged
merged 2 commits into from
Feb 22, 2023
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) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractRetentionIndicesExportConverter implements IRetent
* @throws FileIsNotWriteableException
* @throws IOException
*/
public void validate(final File file) throws FileNotFoundException, FileIsNotWriteableException, IOException {
public void validate(final File file) throws FileIsNotWriteableException, IOException {

/*
* When no file is given.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -34,7 +34,7 @@ public abstract class AbstractRetentionIndicesImportConverter implements IRetent
* @throws IOException
*/
@Override
public void validate(final File retentionIndices) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException {
public void validate(final File retentionIndices) throws FileIsNotReadableException, FileIsEmptyException, IOException {

if(!retentionIndices.exists()) {
throw new FileNotFoundException("The file " + retentionIndices.getAbsoluteFile() + " does not exist.");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -30,7 +30,7 @@ public interface IRetentionIndicesExportConverter {
* @throws FileIsNotWriteableException
* @throws IOException
*/
File convert(File file, IRetentionIndices retentionIndices) throws FileNotFoundException, FileIsNotWriteableException, IOException;
File convert(File file, IRetentionIndices retentionIndices) throws FileIsNotWriteableException, IOException;

/**
* This class checks the file attributes and throws an exception if
Expand All @@ -41,5 +41,5 @@ public interface IRetentionIndicesExportConverter {
* @throws FileIsNotWriteableException
* @throws IOException
*/
void validate(File file) throws FileNotFoundException, FileIsNotWriteableException, IOException;
void validate(File file) throws FileIsNotWriteableException, IOException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -15,9 +15,9 @@
import java.io.FileNotFoundException;
import java.io.IOException;

import org.eclipse.chemclipse.chromatogram.alignment.model.core.IRetentionIndices;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.FileIsEmptyException;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.FileIsNotReadableException;
import org.eclipse.chemclipse.chromatogram.alignment.model.core.IRetentionIndices;

public interface IRetentionIndicesImportConverter {

Expand All @@ -37,7 +37,7 @@ public interface IRetentionIndicesImportConverter {
* @throws FileIsEmptyException
* @throws IOException
*/
IRetentionIndices convert(File retentionIndices) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException;
IRetentionIndices convert(File retentionIndices) throws FileIsNotReadableException, FileIsEmptyException, IOException;

/**
* This method validates the file which contains the retention indices to be
Expand All @@ -50,5 +50,5 @@ public interface IRetentionIndicesImportConverter {
* @throws FileIsEmptyException
* @throws IOException
*/
void validate(File retentionIndices) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException;
void validate(File retentionIndices) throws FileIsNotReadableException, FileIsEmptyException, IOException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -18,17 +18,16 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;

import org.eclipse.chemclipse.chromatogram.alignment.model.core.IRetentionIndices;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.FileIsEmptyException;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.FileIsNotReadableException;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.chromatogram.alignment.converter.exceptions.NoRetentionIndicesConverterAvailableException;
import org.eclipse.chemclipse.chromatogram.alignment.model.core.IRetentionIndices;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;

/**
* This class offers only static methods for file and retention index
Expand Down Expand Up @@ -59,6 +58,7 @@ public class RetentionIndicesConverter {
private static final String IMPORT_CONVERTER = "importConverter";

private RetentionIndicesConverter() {

}

/**
Expand All @@ -76,7 +76,7 @@ private RetentionIndicesConverter() {
* @throws FileIsEmptyException
* @throws IOException
*/
public static IRetentionIndices convert(final File retentionIndices, final String converterId) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException, IOException {
public static IRetentionIndices convert(final File retentionIndices, final String converterId) throws FileIsNotReadableException, FileIsEmptyException, IOException {

IRetentionIndices instance = null;
/*
Expand All @@ -102,17 +102,17 @@ public static IRetentionIndices convert(final File retentionIndices, final Strin
* @throws FileIsEmptyException
* @return {@link IChromatogram}
*/
public static IRetentionIndices convert(final File retentionIndices) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException {
public static IRetentionIndices convert(final File file) throws FileIsNotReadableException, FileIsEmptyException {

Object chromatogramInstance = getRetentionIndices(retentionIndices);
if(chromatogramInstance instanceof IRetentionIndices) {
return (IRetentionIndices)chromatogramInstance;
Object chromatogramInstance = getRetentionIndices(file);
if(chromatogramInstance instanceof IRetentionIndices retentionIndices) {
return retentionIndices;
} else {
return null;
}
}

private static Object getRetentionIndices(final File chromatogram) throws FileNotFoundException, FileIsNotReadableException, FileIsEmptyException {
private static Object getRetentionIndices(final File chromatogram) throws FileIsNotReadableException, FileIsEmptyException {

RetentionIndicesConverterSupport converterSupport = getRetentionIndicesConverterSupport();
try {
Expand Down Expand Up @@ -185,7 +185,7 @@ private static Object getRetentionIndices(final File chromatogram) throws FileNo
* @throws FileIsNotWriteableException
* @throws IOException
*/
public static File convert(final File file, final IRetentionIndices retentionIndices, final String converterId) throws FileNotFoundException, FileIsNotWriteableException, IOException {
public static File convert(final File file, final IRetentionIndices retentionIndices, final String converterId) throws FileIsNotWriteableException, IOException {

File chromFile = null;
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -31,7 +31,8 @@ public class RetentionIndicesConverterSupport implements IRetentionIndicesConver
private List<IRetentionIndicesSupplier> suppliers;

public RetentionIndicesConverterSupport() {
suppliers = new ArrayList<IRetentionIndicesSupplier>();

suppliers = new ArrayList<>();
}

/**
Expand Down Expand Up @@ -76,7 +77,7 @@ public String[] getFilterExtensions() throws NoRetentionIndicesConverterAvailabl
* Otherwise the fileExtension will be listed.
*/
String extension;
ArrayList<String> extensions = new ArrayList<String>();
ArrayList<String> extensions = new ArrayList<>();
for(IRetentionIndicesSupplier supplier : suppliers) {
extension = supplier.getFileExtension();
extensions.add(extension);
Expand All @@ -95,7 +96,7 @@ public String[] getFilterNames() throws NoRetentionIndicesConverterAvailableExce
* If the ArrayList is not empty, return the registered chromatogram
* converter filter names.<br/>
*/
ArrayList<String> filterNames = new ArrayList<String>();
ArrayList<String> filterNames = new ArrayList<>();
for(IRetentionIndicesSupplier supplier : suppliers) {
filterNames.add(supplier.getFilterName());
}
Expand All @@ -109,7 +110,7 @@ public List<String> getAvailableConverterIds(final File retentionIndices) throws
* Test if the suppliers ArrayList is empty.
*/
areConvertersStored();
List<String> availableConverters = new ArrayList<String>();
List<String> availableConverters = new ArrayList<>();
for(IRetentionIndicesSupplier supplier : suppliers) {
if(retentionIndices.getName().endsWith(supplier.getFileExtension())) {
availableConverters.add(supplier.getId());
Expand All @@ -129,7 +130,7 @@ public List<String> getAvailableConverterIds(final File retentionIndices) throws
*/
private void areConvertersStored() throws NoRetentionIndicesConverterAvailableException {

if(suppliers.size() < 1) {
if(suppliers.isEmpty()) {
throw new NoRetentionIndicesConverterAvailableException();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2018 Lablicate GmbH.
* Copyright (c) 2008, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand Down Expand Up @@ -29,7 +29,8 @@ public class RetentionIndices implements IRetentionIndices {
private RetentionIndexComparator retentionIndexComparator;

public RetentionIndices() {
this.retentionIndices = new ArrayList<IRetentionIndex>(10);

this.retentionIndices = new ArrayList<>(10);
retentionIndexComparator = new RetentionIndexComparator();
}

Expand Down Expand Up @@ -79,9 +80,8 @@ private void checkRetentionIndexExists(final IRetentionIndex retentionIndex) thr
*/
private void checkRetentionIndexSortOrder(final IRetentionIndex retentionIndex) throws RetentionIndexValueException {

int previousRetentionTime, nextRetentionTime;
previousRetentionTime = calculatePreviousRetentionTime(retentionIndex);
nextRetentionTime = calculateNextRetentionTime(retentionIndex);
int previousRetentionTime = calculatePreviousRetentionTime(retentionIndex);
int nextRetentionTime = calculateNextRetentionTime(retentionIndex);
/*
* Check now if the indices and retention times are correct.
*/
Expand Down Expand Up @@ -253,7 +253,7 @@ private IRetentionIndex getRetentionIndex(final int entry) throws NoRetentionInd
* retentionIndice list or the list is still empty, no RetentionIndex
* can be returned.
*/
if(this.retentionIndices.size() > 0 && entry <= this.retentionIndices.size()) {
if(!this.retentionIndices.isEmpty() && entry <= this.retentionIndices.size()) {
// Set the new actualRetentionIndex
actualRetentionIndex = entry;
return this.retentionIndices.get(--position);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2021 Lablicate GmbH.
* Copyright (c) 2015, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.csd.filter.core.chromatogram;

import org.eclipse.chemclipse.chromatogram.csd.filter.l10n.Messages;
import org.eclipse.chemclipse.chromatogram.filter.result.IChromatogramFilterResult;
import org.eclipse.chemclipse.chromatogram.filter.settings.IChromatogramFilterSettings;
import org.eclipse.chemclipse.csd.model.core.selection.IChromatogramSelectionCSD;
Expand All @@ -22,8 +23,6 @@
*/
public abstract class AbstractChromatogramFilterCSD implements IChromatogramFilterCSD {

private static final String DESCRIPTION = "Chromatogram Filter";

@Override
public IProcessingInfo<IChromatogramFilterResult> validate(IChromatogramSelectionCSD chromatogramSelection, IChromatogramFilterSettings chromatogramFilterSettings) {

Expand All @@ -45,10 +44,10 @@ private IProcessingInfo<?> validateChromatogramSelection(IChromatogramSelectionC

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
if(chromatogramSelection == null) {
processingInfo.addErrorMessage(DESCRIPTION, "The chromatogram selection is not valid.");
processingInfo.addErrorMessage(Messages.chromatogramFilter, Messages.invalidChromatogramSelection);
} else {
if(chromatogramSelection.getChromatogram() == null) {
processingInfo.addErrorMessage(DESCRIPTION, "The chromatogram is not valid.");
processingInfo.addErrorMessage(Messages.chromatogramFilter, Messages.invalidChromatogram);
}
}
return processingInfo;
Expand All @@ -64,7 +63,7 @@ private IProcessingInfo<?> validateFilterSettings(IChromatogramFilterSettings ch

IProcessingInfo<?> processingInfo = new ProcessingInfo<>();
if(chromatogramFilterSettings == null) {
processingInfo.addErrorMessage(DESCRIPTION, "The filter settings are not valid.");
processingInfo.addErrorMessage(Messages.chromatogramFilter, Messages.invalidFilterSettings);
}
return processingInfo;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2021 Lablicate GmbH.
* Copyright (c) 2015, 2023 Lablicate GmbH.
*
* All rights reserved.
* This program and the accompanying materials are made available under the
Expand All @@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.chemclipse.chromatogram.csd.filter.core.chromatogram;

import org.eclipse.chemclipse.chromatogram.csd.filter.l10n.Messages;
import org.eclipse.chemclipse.chromatogram.filter.settings.IChromatogramFilterSettings;
import org.eclipse.chemclipse.csd.model.core.selection.IChromatogramSelectionCSD;
import org.eclipse.chemclipse.logging.core.Logger;
Expand All @@ -25,18 +26,15 @@
public class ChromatogramFilterCSD {

private static final Logger logger = Logger.getLogger(ChromatogramFilterCSD.class);
private static final String EXTENSION_POINT = "org.eclipse.chemclipse.chromatogram.csd.filter.chromatogramFilterSupplier";
private static final String EXTENSION_POINT = "org.eclipse.chemclipse.chromatogram.csd.filter.chromatogramFilterSupplier"; //$NON-NLS-1$
/*
* These are the attributes of the extension point elements.
*/
private static final String ID = "id";
private static final String DESCRIPTION = "description";
private static final String FILTER_NAME = "filterName";
private static final String FILTER = "filter";
private static final String FILTER_SETTINGS = "filterSettings";
//
private static final String PROCESSING_DESCRIPTION = "Chromatogram Filter";
private static final String NO_CHROMATOGRAM_FILTER_AVAILABLE = "There is no chromatogram filter available.";
private static final String ID = "id"; //$NON-NLS-1$
private static final String DESCRIPTION = "description"; //$NON-NLS-1$
private static final String FILTER_NAME = "filterName"; //$NON-NLS-1$
private static final String FILTER = "filter"; //$NON-NLS-1$
private static final String FILTER_SETTINGS = "filterSettings"; //$NON-NLS-1$

/**
* This class is a singleton. Use only static methods.
Expand Down Expand Up @@ -65,7 +63,7 @@ public static IProcessingInfo<?> applyFilter(IChromatogramSelectionCSD chromatog
processingInfo = chromatogramFilter.applyFilter(chromatogramSelection, chromatogramFilterSettings, monitor);
} else {
processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(PROCESSING_DESCRIPTION, NO_CHROMATOGRAM_FILTER_AVAILABLE);
processingInfo.addErrorMessage(Messages.chromatogramFilter, Messages.noChromatogramFilterAvailable);
}
return processingInfo;
}
Expand All @@ -88,7 +86,7 @@ public static IProcessingInfo<?> applyFilter(IChromatogramSelectionCSD chromatog
processingInfo = chromatogramFilter.applyFilter(chromatogramSelection, monitor);
} else {
processingInfo = new ProcessingInfo<>();
processingInfo.addErrorMessage(PROCESSING_DESCRIPTION, NO_CHROMATOGRAM_FILTER_AVAILABLE);
processingInfo.addErrorMessage(Messages.chromatogramFilter, Messages.noChromatogramFilterAvailable);
}
return processingInfo;
}
Expand Down Expand Up @@ -152,7 +150,7 @@ private static IChromatogramFilterCSD getChromatogramFilter(final String filterI
*/
private static IConfigurationElement getConfigurationElement(final String filterId) {

if("".equals(filterId)) {
if(filterId.isEmpty()) {
return null;
}
IExtensionRegistry registry = Platform.getExtensionRegistry();
Expand Down
Loading