[Importer] Improve SchedulingRule
Prevents from conflicts with many scheduling rules.
Change-Id: Ic1219cfe98c1d57be1ca9668547e9cd3d0ea57eb
Signed-off-by: Mickael Istria <mistria@redhat.com>
diff --git a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java
index 1c7d107..53c0d93 100644
--- a/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java
+++ b/bundles/org.eclipse.e4.ui.importer/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.MultiRule;
/**
* This scheduling rule checks that no job with another instance of
@@ -38,7 +39,16 @@
@Override
public boolean contains(ISchedulingRule rule) {
- return rule == this || rule instanceof IResource;
+ if (rule == this || rule instanceof IResource) {
+ return true;
+ } else if (rule instanceof MultiRule) {
+ for (ISchedulingRule child : ((MultiRule)rule).getChildren()) {
+ if (this.contains(child)) {
+ return true;
+ }
+ }
+ }
+ return false;
}
@Override
@@ -50,6 +60,12 @@
otherRule.directory.getName().equals(this.directory.getName());
} else if (rule instanceof IResource) {
return true;
+ } else if (rule instanceof MultiRule) {
+ for (ISchedulingRule child : ((MultiRule)rule).getChildren()) {
+ if (this.isConflicting(child)) {
+ return true;
+ }
+ }
}
return false;