diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java')
-rw-r--r-- | plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java new file mode 100644 index 0000000..8a2bfdd --- /dev/null +++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/BCResourceChangeListener.java | |||
@@ -0,0 +1,64 @@ | |||
1 | package org.yocto.bc.ui; | ||
2 | |||
3 | import java.util.HashSet; | ||
4 | |||
5 | import org.eclipse.core.resources.IFile; | ||
6 | import org.eclipse.core.resources.IProject; | ||
7 | import org.eclipse.core.resources.IResourceChangeEvent; | ||
8 | import org.eclipse.core.resources.IResourceChangeListener; | ||
9 | import org.eclipse.core.resources.IResource; | ||
10 | import org.eclipse.core.resources.IResourceDelta; | ||
11 | import org.eclipse.core.resources.IResourceDeltaVisitor; | ||
12 | import org.eclipse.core.runtime.*; | ||
13 | import org.yocto.bc.ui.builder.BitbakeCommanderNature; | ||
14 | |||
15 | public class BCResourceChangeListener implements IResourceChangeListener { | ||
16 | |||
17 | public void resourceChanged(IResourceChangeEvent event) { | ||
18 | final HashSet<IResource> removed = new HashSet<IResource>(); | ||
19 | final HashSet<IResource> changed = new HashSet<IResource>(); | ||
20 | switch (event.getType()) { | ||
21 | case IResourceChangeEvent.POST_CHANGE: | ||
22 | try { | ||
23 | event.getDelta().accept(new IResourceDeltaVisitor() { | ||
24 | public boolean visit(IResourceDelta delta) throws CoreException { | ||
25 | IResource res = delta.getResource(); | ||
26 | Boolean visit= true; | ||
27 | if (res instanceof IProject) { | ||
28 | visit = false; | ||
29 | try { | ||
30 | if(((IProject) res).isOpen() && | ||
31 | ((IProject) res).hasNature(BitbakeCommanderNature.NATURE_ID)){ | ||
32 | visit = true; | ||
33 | } | ||
34 | }catch (CoreException e) { | ||
35 | } | ||
36 | } | ||
37 | if (visit && (res instanceof IFile)) | ||
38 | { | ||
39 | switch (delta.getKind()) { | ||
40 | case IResourceDelta.REMOVED: | ||
41 | removed.add(res); | ||
42 | break; | ||
43 | case IResourceDelta.CHANGED: | ||
44 | changed.add(res); | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | return visit; // visit the children | ||
49 | } | ||
50 | }); | ||
51 | //notify all the sessions | ||
52 | Activator.notifyAllBBSession(null, | ||
53 | removed.toArray(new IResource[removed.size()]), | ||
54 | changed.toArray(new IResource[changed.size()])); | ||
55 | |||
56 | }catch (CoreException e) { | ||
57 | e.printStackTrace(); | ||
58 | } | ||
59 | break; | ||
60 | default: | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | } | ||