diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/preferences/PreferenceSupplier.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/preferences/PreferenceSupplier.java index e19f7df013..d9019942a0 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/preferences/PreferenceSupplier.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/preferences/PreferenceSupplier.java @@ -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); diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/support/ProcessorSettingsSupport.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/support/ProcessorSettingsSupport.java new file mode 100644 index 0000000000..1214aea2f4 --- /dev/null +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/support/ProcessorSettingsSupport.java @@ -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 getSettings(Shell shell, String identifier) { + + S settings = null; + IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext(); + IProcessSupplier processSupplier = supplierContext.getSupplier(identifier); + if(processSupplier != null) { + try { + IProcessorPreferences processorPreferences = SettingsWizard.getSettings(shell, ProcessSettingsSupport.getWorkspacePreferences(processSupplier), true); + if(processorPreferences != null) { + settings = processorPreferences.getSettings(); + } + } catch(IOException e) { + logger.warn(e); + } + } + + return settings; + } +} \ No newline at end of file diff --git a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/swt/ScanIdentifierUI.java b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/swt/ScanIdentifierUI.java index 5772788280..15bc103f9d 100644 --- a/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/swt/ScanIdentifierUI.java +++ b/chemclipse/plugins/org.eclipse.chemclipse.ux.extension.xxd.ui/src/org/eclipse/chemclipse/ux/extension/xxd/ui/swt/ScanIdentifierUI.java @@ -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; @@ -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; @@ -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); @@ -250,11 +241,11 @@ private void activateDefaultIdentifierMSD(List /* * 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; } @@ -279,11 +270,11 @@ private void activateDefaultIdentifierWSD(List /* * 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; } @@ -322,7 +313,7 @@ private void createMenuIdentifierMSD(Button button, List massSpectra, List private void runIdentificationMSD(Display display, List massSpectra, boolean update) { if(!massSpectra.isEmpty() && massSpectrumIdentifierSupplier != null) { - /* - * Retrieve the settings interactively. - */ - IMassSpectrumIdentifierSettings identifierSettings = null; - IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext(); - IProcessSupplier processSupplier = supplierContext.getSupplier(massSpectrumIdentifierSupplier.getId()); - if(processSupplier != null) { - try { - IProcessorPreferences 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); } @@ -430,28 +406,13 @@ private void runIdentificationMSD(Display display, List massSpectra, b private void runIdentificationWSD(Display display, List waveSpectra, boolean update) { if(!waveSpectra.isEmpty() && waveSpectrumIdentifierSupplier != null) { - /* - * Retrieve the settings interactively. - */ - IWaveSpectrumIdentifierSettings identifierSettings = null; - IProcessSupplierContext supplierContext = Activator.getProcessSupplierContext(); - IProcessSupplier processSupplier = supplierContext.getSupplier(waveSpectrumIdentifierSupplier.getId()); - if(processSupplier != null) { - try { - IProcessorPreferences 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);