Skip to content
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
Expand Up @@ -1379,6 +1379,26 @@ public static boolean isMergePeaksDeleteOrigins() {
return INSTANCE().getBoolean(P_MERGE_PEAKS_DELETE_ORIGINS, DEF_MERGE_PEAKS_DELETE_ORIGINS);
}

public static String getScanIdentifierMSD() {

return INSTANCE().get(P_SCAN_IDENTIFER_MSD);
}

public static void setScanIdentifierMSD(String identifier) {

INSTANCE().set(P_SCAN_IDENTIFER_MSD, identifier);
}

public static String getScanIdentifierWSD() {

return INSTANCE().get(P_SCAN_IDENTIFER_WSD);
}

public static void setScanIdentifierWSD(String identifier) {

INSTANCE().set(P_SCAN_IDENTIFER_WSD, identifier);
}

public static String getListPathImport() {

return INSTANCE().get(P_LIST_PATH_IMPORT, DEF_LIST_PATH_IMPORT);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*******************************************************************************
* Copyright (c) 2026 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Philip Wenig - initial API and implementation
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.support;

import java.io.IOException;

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.model.settings.IProcessSettings;
import org.eclipse.chemclipse.processing.supplier.IProcessSupplier;
import org.eclipse.chemclipse.processing.supplier.IProcessSupplierContext;
import org.eclipse.chemclipse.processing.supplier.IProcessorPreferences;
import org.eclipse.chemclipse.processing.system.ProcessSettingsSupport;
import org.eclipse.chemclipse.ux.extension.ui.methods.SettingsWizard;
import org.eclipse.chemclipse.ux.extension.xxd.ui.Activator;
import org.eclipse.swt.widgets.Shell;

public class ProcessorSettingsSupport {

private static final Logger logger = Logger.getLogger(ProcessorSettingsSupport.class);

public static <S extends IProcessSettings> S getSettings(Shell shell, String identifier) {

S settings = null;
IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext();
IProcessSupplier<S> processSupplier = supplierContext.getSupplier(identifier);
if(processSupplier != null) {
try {
IProcessorPreferences<S> processorPreferences = SettingsWizard.getSettings(shell, ProcessSettingsSupport.getWorkspacePreferences(processSupplier), true);
if(processorPreferences != null) {
settings = processorPreferences.getSettings();
}
} catch(IOException e) {
logger.warn(e);
}
}

return settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.chemclipse.ux.extension.xxd.ui.swt;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -32,23 +31,17 @@
import org.eclipse.chemclipse.msd.identifier.MassSpectrumIdentifier;
import org.eclipse.chemclipse.msd.identifier.settings.IMassSpectrumIdentifierSettings;
import org.eclipse.chemclipse.msd.model.core.IScanMSD;
import org.eclipse.chemclipse.processing.supplier.IProcessSupplier;
import org.eclipse.chemclipse.processing.supplier.IProcessSupplierContext;
import org.eclipse.chemclipse.processing.supplier.IProcessorPreferences;
import org.eclipse.chemclipse.processing.system.ProcessSettingsSupport;
import org.eclipse.chemclipse.rcp.ui.icons.core.ApplicationImageFactory;
import org.eclipse.chemclipse.rcp.ui.icons.core.IApplicationImage;
import org.eclipse.chemclipse.rcp.ui.icons.core.IApplicationImageProvider;
import org.eclipse.chemclipse.support.ui.updates.IUpdateListenerUI;
import org.eclipse.chemclipse.ux.extension.ui.methods.SettingsWizard;
import org.eclipse.chemclipse.ux.extension.xxd.ui.Activator;
import org.eclipse.chemclipse.ux.extension.xxd.ui.internal.runnables.MassSpectrumIdentifierRunnable;
import org.eclipse.chemclipse.ux.extension.xxd.ui.internal.runnables.WaveSpectrumIdentifierRunnable;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.ux.extension.xxd.ui.support.ProcessorSettingsSupport;
import org.eclipse.chemclipse.wsd.model.core.IScanWSD;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
Expand Down Expand Up @@ -77,8 +70,6 @@ public class ScanIdentifierUI extends Composite {
private IMassSpectrumIdentifierSupplier massSpectrumIdentifierSupplier;
private IWaveSpectrumIdentifierSupplier waveSpectrumIdentifierSupplier;

private final IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();

public ScanIdentifierUI(Composite parent, int style) {

super(parent, style);
Expand Down Expand Up @@ -250,11 +241,11 @@ private void activateDefaultIdentifierMSD(List<IMassSpectrumIdentifierSupplier>
/*
* Try to set the selected identifier.
*/
String id = preferenceStore.getString(PreferenceSupplier.P_SCAN_IDENTIFER_MSD);
if(!id.isEmpty()) {
String identifier = PreferenceSupplier.getScanIdentifierMSD();
if(!identifier.isEmpty()) {
exitloop:
for(IMassSpectrumIdentifierSupplier identifierSupplier : identifierSuppliers) {
if(id.equals(identifierSupplier.getId())) {
if(identifier.equals(identifierSupplier.getId())) {
massSpectrumIdentifierSupplier = identifierSupplier;
break exitloop;
}
Expand All @@ -279,11 +270,11 @@ private void activateDefaultIdentifierWSD(List<IWaveSpectrumIdentifierSupplier>
/*
* Try to set the selected identifier.
*/
String id = preferenceStore.getString(PreferenceSupplier.P_SCAN_IDENTIFER_WSD);
if(!id.isEmpty()) {
String identifier = PreferenceSupplier.getScanIdentifierWSD();
if(!identifier.isEmpty()) {
exitloop:
for(IWaveSpectrumIdentifierSupplier identifierSupplier : identifierSuppliers) {
if(id.equals(identifierSupplier.getId())) {
if(identifier.equals(identifierSupplier.getId())) {
waveSpectrumIdentifierSupplier = identifierSupplier;
break exitloop;
}
Expand Down Expand Up @@ -322,7 +313,7 @@ private void createMenuIdentifierMSD(Button button, List<IMassSpectrumIdentifier
public void widgetSelected(SelectionEvent e) {

button.setToolTipText(identifierSupplier.getIdentifierName());
preferenceStore.setValue(PreferenceSupplier.P_SCAN_IDENTIFER_MSD, identifierSupplier.getId());
PreferenceSupplier.setScanIdentifierMSD(identifierSupplier.getId());
massSpectrumIdentifierSupplier = identifierSupplier;
runIdentification();
}
Expand All @@ -349,7 +340,7 @@ private void createMenuIdentifierWSD(Button button, List<IWaveSpectrumIdentifier
public void widgetSelected(SelectionEvent e) {

button.setToolTipText(identifierSupplier.getIdentifierName());
preferenceStore.setValue(PreferenceSupplier.P_SCAN_IDENTIFER_WSD, identifierSupplier.getId());
PreferenceSupplier.setScanIdentifierWSD(identifierSupplier.getId());
waveSpectrumIdentifierSupplier = identifierSupplier;
runIdentification();
}
Expand Down Expand Up @@ -392,29 +383,14 @@ private void runIdentification(Display display, List<IScanMSD> massSpectra, List
private void runIdentificationMSD(Display display, List<IScanMSD> massSpectra, boolean update) {

if(!massSpectra.isEmpty() && massSpectrumIdentifierSupplier != null) {
/*
* Retrieve the settings interactively.
*/
IMassSpectrumIdentifierSettings identifierSettings = null;
IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext();
IProcessSupplier<? extends IMassSpectrumIdentifierSettings> processSupplier = supplierContext.getSupplier(massSpectrumIdentifierSupplier.getId());
if(processSupplier != null) {
try {
IProcessorPreferences<? extends IMassSpectrumIdentifierSettings> processorPreferences = SettingsWizard.getSettings(getShell(), ProcessSettingsSupport.getWorkspacePreferences(processSupplier), true);
if(processorPreferences != null) {
identifierSettings = processorPreferences.getSettings();
}
} catch(IOException e) {
logger.warn(e);
}
}
/*
* Run the identification using the dynamic settings.
*/
IRunnableWithProgress runnable = new MassSpectrumIdentifierRunnable(massSpectra, massSpectrumIdentifierSupplier.getId(), identifierSettings);
ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell());
try {
monitor.run(true, true, runnable);
IMassSpectrumIdentifierSettings identifierSettings = ProcessorSettingsSupport.getSettings(getShell(), massSpectrumIdentifierSupplier.getId());
IRunnableWithProgress runnable = new MassSpectrumIdentifierRunnable(massSpectra, massSpectrumIdentifierSupplier.getId(), identifierSettings);
ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell());
monitor.run(false, true, runnable);
if(update) {
fireUpdate(display);
}
Expand All @@ -430,28 +406,13 @@ private void runIdentificationMSD(Display display, List<IScanMSD> massSpectra, b
private void runIdentificationWSD(Display display, List<IScanWSD> waveSpectra, boolean update) {

if(!waveSpectra.isEmpty() && waveSpectrumIdentifierSupplier != null) {
/*
* Retrieve the settings interactively.
*/
IWaveSpectrumIdentifierSettings identifierSettings = null;
IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext();
IProcessSupplier<? extends IWaveSpectrumIdentifierSettings> processSupplier = supplierContext.getSupplier(waveSpectrumIdentifierSupplier.getId());
if(processSupplier != null) {
try {
IProcessorPreferences<? extends IWaveSpectrumIdentifierSettings> processorPreferences = SettingsWizard.getSettings(getShell(), ProcessSettingsSupport.getWorkspacePreferences(processSupplier), true);
if(processorPreferences != null) {
identifierSettings = processorPreferences.getSettings();
}
} catch(IOException e) {
logger.warn(e);
}
}
/*
* Run the identification using the dynamic settings.
*/
IRunnableWithProgress runnable = new WaveSpectrumIdentifierRunnable(waveSpectra, waveSpectrumIdentifierSupplier.getId(), identifierSettings);
ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell());
try {
IWaveSpectrumIdentifierSettings identifierSettings = ProcessorSettingsSupport.getSettings(getShell(), waveSpectrumIdentifierSupplier.getId());
IRunnableWithProgress runnable = new WaveSpectrumIdentifierRunnable(waveSpectra, waveSpectrumIdentifierSupplier.getId(), identifierSettings);
ProgressMonitorDialog monitor = new ProgressMonitorDialog(display.getActiveShell());
monitor.run(true, true, runnable);
if(update) {
fireUpdate(display);
Expand Down