1212 *******************************************************************************/
1313package org .eclipse .chemclipse .ux .extension .xxd .ui .swt ;
1414
15- import java .io .IOException ;
1615import java .lang .reflect .InvocationTargetException ;
1716import java .util .ArrayList ;
1817import java .util .Arrays ;
3231import org .eclipse .chemclipse .msd .identifier .MassSpectrumIdentifier ;
3332import org .eclipse .chemclipse .msd .identifier .settings .IMassSpectrumIdentifierSettings ;
3433import org .eclipse .chemclipse .msd .model .core .IScanMSD ;
35- import org .eclipse .chemclipse .processing .supplier .IProcessSupplier ;
36- import org .eclipse .chemclipse .processing .supplier .IProcessSupplierContext ;
37- import org .eclipse .chemclipse .processing .supplier .IProcessorPreferences ;
38- import org .eclipse .chemclipse .processing .system .ProcessSettingsSupport ;
3934import org .eclipse .chemclipse .rcp .ui .icons .core .ApplicationImageFactory ;
4035import org .eclipse .chemclipse .rcp .ui .icons .core .IApplicationImage ;
4136import org .eclipse .chemclipse .rcp .ui .icons .core .IApplicationImageProvider ;
4237import org .eclipse .chemclipse .support .ui .updates .IUpdateListenerUI ;
43- import org .eclipse .chemclipse .ux .extension .ui .methods .SettingsWizard ;
44- import org .eclipse .chemclipse .ux .extension .xxd .ui .Activator ;
4538import org .eclipse .chemclipse .ux .extension .xxd .ui .internal .runnables .MassSpectrumIdentifierRunnable ;
4639import org .eclipse .chemclipse .ux .extension .xxd .ui .internal .runnables .WaveSpectrumIdentifierRunnable ;
4740import org .eclipse .chemclipse .ux .extension .xxd .ui .preferences .PreferenceSupplier ;
41+ import org .eclipse .chemclipse .ux .extension .xxd .ui .support .ProcessorSettingsSupport ;
4842import org .eclipse .chemclipse .wsd .model .core .IScanWSD ;
4943import org .eclipse .jface .dialogs .ProgressMonitorDialog ;
5044import org .eclipse .jface .operation .IRunnableWithProgress ;
51- import org .eclipse .jface .preference .IPreferenceStore ;
5245import org .eclipse .swt .SWT ;
5346import org .eclipse .swt .events .SelectionAdapter ;
5447import org .eclipse .swt .events .SelectionEvent ;
@@ -77,8 +70,6 @@ public class ScanIdentifierUI extends Composite {
7770 private IMassSpectrumIdentifierSupplier massSpectrumIdentifierSupplier ;
7871 private IWaveSpectrumIdentifierSupplier waveSpectrumIdentifierSupplier ;
7972
80- private final IPreferenceStore preferenceStore = Activator .getDefault ().getPreferenceStore ();
81-
8273 public ScanIdentifierUI (Composite parent , int style ) {
8374
8475 super (parent , style );
@@ -250,11 +241,11 @@ private void activateDefaultIdentifierMSD(List<IMassSpectrumIdentifierSupplier>
250241 /*
251242 * Try to set the selected identifier.
252243 */
253- String id = preferenceStore . getString ( PreferenceSupplier .P_SCAN_IDENTIFER_MSD );
254- if (!id .isEmpty ()) {
244+ String identifier = PreferenceSupplier .getScanIdentifierMSD ( );
245+ if (!identifier .isEmpty ()) {
255246 exitloop :
256247 for (IMassSpectrumIdentifierSupplier identifierSupplier : identifierSuppliers ) {
257- if (id .equals (identifierSupplier .getId ())) {
248+ if (identifier .equals (identifierSupplier .getId ())) {
258249 massSpectrumIdentifierSupplier = identifierSupplier ;
259250 break exitloop ;
260251 }
@@ -279,11 +270,11 @@ private void activateDefaultIdentifierWSD(List<IWaveSpectrumIdentifierSupplier>
279270 /*
280271 * Try to set the selected identifier.
281272 */
282- String id = preferenceStore . getString ( PreferenceSupplier .P_SCAN_IDENTIFER_WSD );
283- if (!id .isEmpty ()) {
273+ String identifier = PreferenceSupplier .getScanIdentifierWSD ( );
274+ if (!identifier .isEmpty ()) {
284275 exitloop :
285276 for (IWaveSpectrumIdentifierSupplier identifierSupplier : identifierSuppliers ) {
286- if (id .equals (identifierSupplier .getId ())) {
277+ if (identifier .equals (identifierSupplier .getId ())) {
287278 waveSpectrumIdentifierSupplier = identifierSupplier ;
288279 break exitloop ;
289280 }
@@ -322,7 +313,7 @@ private void createMenuIdentifierMSD(Button button, List<IMassSpectrumIdentifier
322313 public void widgetSelected (SelectionEvent e ) {
323314
324315 button .setToolTipText (identifierSupplier .getIdentifierName ());
325- preferenceStore . setValue ( PreferenceSupplier .P_SCAN_IDENTIFER_MSD , identifierSupplier .getId ());
316+ PreferenceSupplier .setScanIdentifierMSD ( identifierSupplier .getId ());
326317 massSpectrumIdentifierSupplier = identifierSupplier ;
327318 runIdentification ();
328319 }
@@ -349,7 +340,7 @@ private void createMenuIdentifierWSD(Button button, List<IWaveSpectrumIdentifier
349340 public void widgetSelected (SelectionEvent e ) {
350341
351342 button .setToolTipText (identifierSupplier .getIdentifierName ());
352- preferenceStore . setValue ( PreferenceSupplier .P_SCAN_IDENTIFER_WSD , identifierSupplier .getId ());
343+ PreferenceSupplier .setScanIdentifierWSD ( identifierSupplier .getId ());
353344 waveSpectrumIdentifierSupplier = identifierSupplier ;
354345 runIdentification ();
355346 }
@@ -392,29 +383,14 @@ private void runIdentification(Display display, List<IScanMSD> massSpectra, List
392383 private void runIdentificationMSD (Display display , List <IScanMSD > massSpectra , boolean update ) {
393384
394385 if (!massSpectra .isEmpty () && massSpectrumIdentifierSupplier != null ) {
395- /*
396- * Retrieve the settings interactively.
397- */
398- IMassSpectrumIdentifierSettings identifierSettings = null ;
399- IProcessSupplierContext supplierContext = Activator .getProcessSupplierContext ();
400- IProcessSupplier <? extends IMassSpectrumIdentifierSettings > processSupplier = supplierContext .getSupplier (massSpectrumIdentifierSupplier .getId ());
401- if (processSupplier != null ) {
402- try {
403- IProcessorPreferences <? extends IMassSpectrumIdentifierSettings > processorPreferences = SettingsWizard .getSettings (getShell (), ProcessSettingsSupport .getWorkspacePreferences (processSupplier ), true );
404- if (processorPreferences != null ) {
405- identifierSettings = processorPreferences .getSettings ();
406- }
407- } catch (IOException e ) {
408- logger .warn (e );
409- }
410- }
411386 /*
412387 * Run the identification using the dynamic settings.
413388 */
414- IRunnableWithProgress runnable = new MassSpectrumIdentifierRunnable (massSpectra , massSpectrumIdentifierSupplier .getId (), identifierSettings );
415- ProgressMonitorDialog monitor = new ProgressMonitorDialog (display .getActiveShell ());
416389 try {
417- monitor .run (true , true , runnable );
390+ IMassSpectrumIdentifierSettings identifierSettings = ProcessorSettingsSupport .getSettings (getShell (), massSpectrumIdentifierSupplier .getId ());
391+ IRunnableWithProgress runnable = new MassSpectrumIdentifierRunnable (massSpectra , massSpectrumIdentifierSupplier .getId (), identifierSettings );
392+ ProgressMonitorDialog monitor = new ProgressMonitorDialog (display .getActiveShell ());
393+ monitor .run (false , true , runnable );
418394 if (update ) {
419395 fireUpdate (display );
420396 }
@@ -430,28 +406,13 @@ private void runIdentificationMSD(Display display, List<IScanMSD> massSpectra, b
430406 private void runIdentificationWSD (Display display , List <IScanWSD > waveSpectra , boolean update ) {
431407
432408 if (!waveSpectra .isEmpty () && waveSpectrumIdentifierSupplier != null ) {
433- /*
434- * Retrieve the settings interactively.
435- */
436- IWaveSpectrumIdentifierSettings identifierSettings = null ;
437- IProcessSupplierContext supplierContext = Activator .getProcessSupplierContext ();
438- IProcessSupplier <? extends IWaveSpectrumIdentifierSettings > processSupplier = supplierContext .getSupplier (waveSpectrumIdentifierSupplier .getId ());
439- if (processSupplier != null ) {
440- try {
441- IProcessorPreferences <? extends IWaveSpectrumIdentifierSettings > processorPreferences = SettingsWizard .getSettings (getShell (), ProcessSettingsSupport .getWorkspacePreferences (processSupplier ), true );
442- if (processorPreferences != null ) {
443- identifierSettings = processorPreferences .getSettings ();
444- }
445- } catch (IOException e ) {
446- logger .warn (e );
447- }
448- }
449409 /*
450410 * Run the identification using the dynamic settings.
451411 */
452- IRunnableWithProgress runnable = new WaveSpectrumIdentifierRunnable (waveSpectra , waveSpectrumIdentifierSupplier .getId (), identifierSettings );
453- ProgressMonitorDialog monitor = new ProgressMonitorDialog (display .getActiveShell ());
454412 try {
413+ IWaveSpectrumIdentifierSettings identifierSettings = ProcessorSettingsSupport .getSettings (getShell (), waveSpectrumIdentifierSupplier .getId ());
414+ IRunnableWithProgress runnable = new WaveSpectrumIdentifierRunnable (waveSpectra , waveSpectrumIdentifierSupplier .getId (), identifierSettings );
415+ ProgressMonitorDialog monitor = new ProgressMonitorDialog (display .getActiveShell ());
455416 monitor .run (true , true , runnable );
456417 if (update ) {
457418 fireUpdate (display );
0 commit comments