Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2014-04-21 17:06:25 -0400
committerMarc-Andre Laperle2014-05-13 21:13:55 -0400
commiteeffc291d31e449404a41afb75d6f10f0b48f96f (patch)
tree0afcd007c5733826295da664f3e656738c686e8a
parent6920050c8e538e395214e52bec97efe637bc6e3f (diff)
downloadorg.eclipse.linuxtools-eeffc291d31e449404a41afb75d6f10f0b48f96f.tar.gz
org.eclipse.linuxtools-eeffc291d31e449404a41afb75d6f10f0b48f96f.tar.xz
org.eclipse.linuxtools-eeffc291d31e449404a41afb75d6f10f0b48f96f.zip
[tmf] Close event editors on project delete and close
Bug: 433091 Change-Id: I4ede4e232c3d84b89042a3a8e1ed8a0b366ef0bf Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/25377 Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java
index 67779de45c..6c0829a40d 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfProjectRegistry.java
@@ -17,6 +17,7 @@ package org.eclipse.linuxtools.tmf.ui.project.model;
import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IFolder;
@@ -33,6 +34,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.TmfProjectNature;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -154,7 +156,30 @@ public class TmfProjectRegistry implements IResourceChangeListener {
*/
@Override
public void resourceChanged(IResourceChangeEvent event) {
- if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
+ if (event.getType() == IResourceChangeEvent.PRE_DELETE || event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+ if (event.getResource() instanceof IProject) {
+ IProject project = (IProject) event.getResource();
+ try {
+ if (project.hasNature(TmfProjectNature.ID)) {
+ TmfProjectElement tmfProjectElement = registry.get(project);
+ final List<TmfTraceElement> traces = tmfProjectElement.getTracesFolder().getTraces();
+ if (!traces.isEmpty()) {
+ // Close editors in UI Thread
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ for (TmfTraceElement traceElement : traces) {
+ traceElement.closeEditors();
+ }
+ }
+ });
+ }
+ }
+ } catch (CoreException e) {
+ Activator.getDefault().logError("Error handling resource change event for " + project.getName(), e); //$NON-NLS-1$
+ }
+ }
+ } else if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
for (IResourceDelta delta : event.getDelta().getAffectedChildren()) {
if (delta.getResource() instanceof IProject) {
IProject project = (IProject) delta.getResource();

Back to the top