Skip to content

Commit

Permalink
Don't use a shared file created topic.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender committed Nov 14, 2024
1 parent 39c7523 commit 0e65117
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;
import java.util.List;

import org.eclipse.chemclipse.chromatogram.xxd.calculator.supplier.amdiscalri.io.CalibrationFileWriter;
import org.eclipse.chemclipse.chromatogram.xxd.calculator.supplier.amdiscalri.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
Expand Down Expand Up @@ -82,7 +83,7 @@ private void registerEventBroker(BundleContext bundleContext) {
if(eventBroker != null) {
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, IChemClipseEvents.TOPIC_RI_LIBRARY_ADD_ADD_TO_PROCESS));
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, IChemClipseEvents.TOPIC_RI_LIBRARY_REMOVE_FROM_PROCESS));
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED));
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, CalibrationFileWriter.TOPIC_PROCESSING_FILE_CREATED));
}
}

Expand Down Expand Up @@ -110,10 +111,8 @@ public void handleEvent(Event event) {
if(libraries.contains(library)) {
libraries.remove(library); // REMOVE
}
} else if(IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED.equals(topic)) {
if(PreferenceSupplier.isOpenReportAfterProcessing()) {
SystemEditor.open(file);
}
} else if(CalibrationFileWriter.TOPIC_PROCESSING_FILE_CREATED.equals(topic)) {
SystemEditor.open(file);
}
PreferenceSupplier.setRetentionIndexFiles(libraries);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

public class CalibrationFileWriter {

public static final String TOPIC_PROCESSING_FILE_CREATED = "processing/file/created/amdis/cal"; // $NON-NLS-1$
//
private static final Logger logger = Logger.getLogger(CalibrationFileWriter.class);
private DecimalFormat decimalFormat = ValueFormat.getDecimalFormatEnglish("0.000");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import java.io.IOException;

import org.eclipse.chemclipse.chromatogram.xxd.calculator.supplier.amdiscalri.impl.RetentionIndexExtractor;
import org.eclipse.chemclipse.chromatogram.xxd.calculator.supplier.amdiscalri.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.chromatogram.xxd.calculator.supplier.amdiscalri.settings.IndexExportSettings;
import org.eclipse.chemclipse.converter.exceptions.FileIsNotWriteableException;
import org.eclipse.chemclipse.model.columns.ISeparationColumnIndices;
import org.eclipse.chemclipse.model.core.IChromatogram;
import org.eclipse.chemclipse.model.notifier.UpdateNotifier;
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
import org.eclipse.core.runtime.IProgressMonitor;

public class ChromatogramWriter {
Expand All @@ -40,6 +40,8 @@ public void writeChromatogram(File file, IChromatogram<?> chromatogram, IndexExp
ISeparationColumnIndices separationColumnIndices = retentionIndexExtractor.extract(chromatogram, deriveMissingIndices, useCuratedNames);
CalibrationFileWriter calibrationFileWriter = new CalibrationFileWriter();
calibrationFileWriter.write(file, separationColumnIndices);
UpdateNotifier.update(IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED, file);
if(PreferenceSupplier.isOpenReportAfterProcessing()) {
UpdateNotifier.update(CalibrationFileWriter.TOPIC_PROCESSING_FILE_CREATED, file);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;

import org.eclipse.chemclipse.logging.core.Logger;
import org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.core.PCRExportConverter;
import org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.preferences.PreferenceSupplier;
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
import org.eclipse.chemclipse.support.ui.activator.AbstractActivatorUI;
Expand Down Expand Up @@ -77,7 +78,7 @@ private void registerEventBroker(BundleContext bundleContext) {

IEventBroker eventBroker = getEventBroker(bundleContext);
if(eventBroker != null) {
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED));
registeredEventHandler.add(registerEventHandler(eventBroker, IChemClipseEvents.EVENT_BROKER_DATA, PCRExportConverter.TOPIC_PROCESSING_FILE_CREATED));
}
}

Expand All @@ -91,10 +92,8 @@ public void handleEvent(Event event) {
try {
Object object = event.getProperty(property);
if(object instanceof File file) {
if(IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED.equals(topic)) {
if(PreferenceSupplier.isOpenReport()) {
SystemEditor.open(file);
}
if(PCRExportConverter.TOPIC_PROCESSING_FILE_CREATED.equals(topic)) {
SystemEditor.open(file);
}
}
} catch(Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.chemclipse.pcr.report.supplier.tabular
Export-Package: org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.preferences
Export-Package: org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.core,
org.eclipse.chemclipse.pcr.report.supplier.tabular.excel.preferences
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@
import org.eclipse.chemclipse.pcr.report.supplier.tabular.model.WellComparator;
import org.eclipse.chemclipse.processing.core.IProcessingInfo;
import org.eclipse.chemclipse.processing.core.ProcessingInfo;
import org.eclipse.chemclipse.support.events.IChemClipseEvents;
import org.eclipse.core.runtime.IProgressMonitor;

public class PCRExportConverter extends AbstractPlateExportConverter implements IPlateExportConverter {

public static final String TOPIC_PROCESSING_FILE_CREATED = "processing/file/created/pcr/excel"; // $NON-NLS-1$
//
private static final Logger logger = Logger.getLogger(PCRExportConverter.class);
private static final String DESCRIPTION = "PCR Excel Export";

Expand Down Expand Up @@ -108,7 +109,9 @@ public IProcessingInfo<File> convert(File file, IPlate plate, IProgressMonitor m
processingInfo.addErrorMessage(DESCRIPTION, "Input/Output problem.");
logger.warn(e);
}
UpdateNotifier.update(IChemClipseEvents.TOPIC_PROCESSING_FILE_CREATED, file);
if(PreferenceSupplier.isOpenReport()) {
UpdateNotifier.update(TOPIC_PROCESSING_FILE_CREATED, file);
}
return processingInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public interface IChemClipseEvents {
String TOPIC_LIBRARY_MSD_UPDATE_SELECTION = "library/msd/update/selection";
//
String TOPIC_PROCESSING_INFO_UPDATE = "processinginfo/update";
String TOPIC_PROCESSING_FILE_CREATED = "processing/file/created"; // $NON-NLS-1$
String TOPIC_EDIT_HISTORY_UPDATE = "edithistory/update"; // $NON-NLS-1$
//
String TOPIC_EDITOR_CHROMATOGRAM_UPDATE = "editor/chromatogram/update";
Expand Down

0 comments on commit 0e65117

Please sign in to comment.