Fixed detection problems with ProjectMachineContext
authorChristian Femers <femers@in.tum.de>
Tue, 24 Sep 2019 04:24:18 +0000 (06:24 +0200)
committerChristian Femers <femers@in.tum.de>
Tue, 24 Sep 2019 04:24:18 +0000 (06:24 +0200)
Other problems still remain; e.g. PRE-CLOSE et al. makes the listeners
unable to detect a closed project, because it was not yet marked as
such. There should also be a register of open, but currently unused
projects.

plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/ProjectMachineContext.java

index cf727af..86b9df6 100644 (file)
@@ -124,15 +124,16 @@ public class ProjectMachineContext
 
        private static void resourceChanged(IResourceChangeEvent event)
        {
+//             System.out.println(((ResourceChangeEvent) event).toDebugString());
                ProjectContextEventType eventType = ProjectContextEventType.ofResourceChangeEvent(event.getType());
                if (eventType == null)
                        return;
-               IProject p = event.getResource().getProject();
-               if (p == null)
+               if (event.getResource() == null || event.getResource().getProject() == null)
                        return;
-               MachineContext mc = projectMachineContexts.get(p);
+               MachineContext mc = projectMachineContexts.get(event.getResource().getProject());
                if (mc == null)
                        return;
+//             System.out.println("  " + eventType + " - " + mc.getProject());
                notifyListeners(new ProjectContextEvent(mc, eventType));
        }
 }