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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023, 2025 Lablicate GmbH.
* Copyright (c) 2023, 2026 Lablicate GmbH.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -78,21 +78,8 @@ public boolean canUndo() {
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

targetSupplier.getTargets().removeAll(targetsToDelete);
update(ExtensionMessages.targetsDeleted);
return Status.OK_STATUS;
}

private void update(String message) {

UpdateNotifierUI.update(display, IChemClipseEvents.TOPIC_IDENTIFICATION_TARGETS_UPDATE_SELECTION, message);
chromatogramSelection.getChromatogram().setDirty(true);
if(targetSupplier instanceof IPeak peak) {
chromatogramSelection.setSelectedPeak(peak);
UpdateNotifierUI.update(display, peak);
} else if(targetSupplier instanceof IScan scan) {
chromatogramSelection.getSelectedScan();
UpdateNotifierUI.update(display, scan);
}
return Status.OK_STATUS;
}

@Override
Expand All @@ -111,7 +98,20 @@ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionE
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

targetSupplier.getTargets().addAll(targetsToDelete);
update(ExtensionMessages.targetsRestored);
notifyTargetsRestored();
return Status.OK_STATUS;
}

private void notifyTargetsRestored() {

UpdateNotifierUI.update(display, IChemClipseEvents.TOPIC_IDENTIFICATION_TARGETS_UPDATE_SELECTION, ExtensionMessages.targetsRestored);
chromatogramSelection.getChromatogram().setDirty(true);
if(targetSupplier instanceof IPeak peak) {
chromatogramSelection.setSelectedPeak(peak);
UpdateNotifierUI.update(display, peak);
} else if(targetSupplier instanceof IScan scan) {
chromatogramSelection.getSelectedScan();
UpdateNotifierUI.update(display, scan);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.eclipse.chemclipse.ux.extension.xxd.ui.dialogs.InternalStandardDialog;
import org.eclipse.chemclipse.ux.extension.xxd.ui.help.HelpContext;
import org.eclipse.chemclipse.ux.extension.xxd.ui.internal.support.TableConfigSupport;
import org.eclipse.chemclipse.ux.extension.xxd.ui.l10n.ExtensionMessages;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeletePeaksOperation;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeleteScanTargetsOperation;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeleteTargetsOperation;
Expand Down Expand Up @@ -460,7 +461,7 @@ private void addKeyEventProcessors(Display display, ITableSettings tableSettings
} else if(matchesKeyPress("Classifier", e)) {
modifyClassifier(display);
} else if(matchesKeyPress("DeleteTargets", e)) {
deleteTargetsAll(e.display);
deleteTargetsAll();
} else if(matchesKeyPress("Unknown", e)) {
addTargetsUnknown(e.display);
} else if(matchesKeyPress("Query", e)) {
Expand Down Expand Up @@ -623,12 +624,12 @@ private void modifyClassifier(Display display) {
}
}

private void deleteTargetsAll(Display display) {
private void deleteTargetsAll() {

for(Object object : tableViewer.get().getStructuredSelection().toList()) {
if(object instanceof ITargetSupplier targetSupplier) {
Set<IIdentificationTarget> targetsToDelete = targetSupplier.getTargets();
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(display, chromatogramSelection, targetSupplier, targetsToDelete);
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(getDisplay(), chromatogramSelection, targetSupplier, targetsToDelete);
deleteTargetsOperation.addContext(UndoContextFactory.getUndoContext());

try {
Expand All @@ -649,7 +650,9 @@ private void deleteTargetsAll(Display display) {
* Send update.
*/
tableViewer.get().refresh();
UpdateNotifierUI.update(display, chromatogramSelection);
chromatogramSelection.getChromatogram().setDirty(true);
UpdateNotifierUI.update(getDisplay(), chromatogramSelection);
UpdateNotifierUI.update(getDisplay(), IChemClipseEvents.TOPIC_IDENTIFICATION_TARGETS_UPDATE_SELECTION, ExtensionMessages.targetsDeleted);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.eclipse.chemclipse.ux.extension.ui.swt.IExtendedPartUI;
import org.eclipse.chemclipse.ux.extension.xxd.ui.Activator;
import org.eclipse.chemclipse.ux.extension.xxd.ui.help.HelpContext;
import org.eclipse.chemclipse.ux.extension.xxd.ui.l10n.ExtensionMessages;
import org.eclipse.chemclipse.ux.extension.xxd.ui.operations.DeleteTargetsOperation;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferencePageLists;
import org.eclipse.chemclipse.ux.extension.xxd.ui.preferences.PreferencePageTargets;
Expand Down Expand Up @@ -706,7 +707,7 @@ private void deleteTargetsSelected(Display display) {
AtomicReference<TargetsListUI> targetList = getActiveTargetList();
List<IIdentificationTarget> selection = targetList.get().getStructuredSelection().toList();
if(getObject() instanceof ITargetSupplier targetSupplier) {
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(display, chromatogramSelection, targetSupplier, selection);
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(getDisplay(), chromatogramSelection, targetSupplier, selection);
deleteTargetsOperation.addContext(UndoContextFactory.getUndoContext());
try {
getOperationHistory().execute(deleteTargetsOperation, null, null);
Expand All @@ -721,7 +722,7 @@ private void deleteTargetsAll(Display display) {

if(chromatogramSelection != null && getObject() instanceof ITargetSupplier targetSupplier) {
Set<IIdentificationTarget> targetsToDelete = targetSupplier.getTargets();
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(display, chromatogramSelection, targetSupplier, targetsToDelete);
DeleteTargetsOperation deleteTargetsOperation = new DeleteTargetsOperation(getDisplay(), chromatogramSelection, targetSupplier, targetsToDelete);
deleteTargetsOperation.addContext(UndoContextFactory.getUndoContext());
try {
getOperationHistory().execute(deleteTargetsOperation, null, null);
Expand All @@ -744,7 +745,7 @@ private void updateTargetsModify(Display display) {

setChromatogramDirty();
updateTargets(display);
UpdateNotifierUI.update(display, IChemClipseEvents.TOPIC_EDITOR_CHROMATOGRAM_UPDATE, "Targets have been deleted.");
UpdateNotifierUI.update(display, IChemClipseEvents.TOPIC_EDITOR_CHROMATOGRAM_UPDATE, ExtensionMessages.targetsDeleted);
}

private void addTarget(Display display, IIdentificationTarget identificationTarget) {
Expand Down