=====================================================================
final TideMSChromatogram tideMSChromatogram = new TideMSChromatogram();
tideMSChromatogram.setFile(saveFile);
final ZipBufferWriter writer = new ZipBufferWriter(saveFile);
// ****
openMSDEditor(tideMSChromatogram);
//***
for(int i = 0; i < usbDevice.getSpectraNumber(); i++) {
usbDevice.acquireMassSpectrum(tideMSChromatogram, writer, i);
}
writer.writeOverviewFolder(tideMSChromatogram);
=====================================================================
private void openMSDEditor(final IChromatogram chromatogram) {
new UIJob("Open MSD Editor") {
@Override
public IStatus runInUIThread(final IProgressMonitor monitor) {
MPart editor = findMSDEditor(chromatogram);
if(editor == null) {
editor = createMSDEditor(chromatogram);
} else {
editor.setObject(chromatogram);
partService.showPart(editor, PartState.ACTIVATE);
}
return Status.OK_STATUS;
}
}.schedule();
}
=====================================================================
private MPart findMSDEditor(final IChromatogram chromatogram) {
final Iterator<MPart> it = partService.getParts().iterator();
while(it.hasNext()) {
final MPart part = it.next();
if(ChromatogramEditorMSD.CONTRIBUTION_URI.equals(part.getContributionURI())) {
final Object obj = part.getObject();
if(obj instanceof IChromatogram) {
final File file1 = ((IChromatogram)obj).getFile();
final File file2 = chromatogram.getFile();
if((file1 != null) && (file2 != null) && file1.getAbsolutePath().equals(file2.getAbsolutePath())) {
return part;
}
}
}
}
return null;
}