Skip to content

Commit 149b29b

Browse files
committed
[E4] Introduce EModelService.findMatchingElements() as Xpath replacement
1 parent a879598 commit 149b29b

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

bundles/org.eclipse.e4.ui.workbench/META-INF/MANIFEST.MF

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-SymbolicName: org.eclipse.e4.ui.workbench;singleton:=true
4-
Bundle-Version: 1.16.100.qualifier
4+
Bundle-Version: 1.17.0.qualifier
55
Bundle-Name: %pluginName
66
Bundle-Vendor: %providerName
77
Bundle-Localization: plugin
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0",
1717
org.eclipse.e4.ui.di;bundle-version="0.9.0",
1818
org.eclipse.emf.ecore.xmi;bundle-version="2.7.0",
1919
org.eclipse.e4.core.di.extensions,
20-
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)"
20+
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
21+
org.eclipse.e4.emf.xpath;bundle-version="0.6.0"
2122
Bundle-ActivationPolicy: lazy
2223
Bundle-RequiredExecutionEnvironment: JavaSE-17
2324
Export-Package: org.eclipse.e4.ui.internal.workbench;

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ModelServiceImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
import java.util.LinkedHashSet;
2828
import java.util.List;
2929
import java.util.Objects;
30+
import java.util.stream.Stream;
3031
import org.eclipse.core.runtime.Assert;
3132
import org.eclipse.core.runtime.IExtensionRegistry;
3233
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
3334
import org.eclipse.e4.core.contexts.IEclipseContext;
3435
import org.eclipse.e4.core.services.events.IEventBroker;
3536
import org.eclipse.e4.core.services.log.Logger;
37+
import org.eclipse.e4.emf.xpath.XPathContextFactory;
3638
import org.eclipse.e4.ui.model.application.MAddon;
3739
import org.eclipse.e4.ui.model.application.MApplication;
3840
import org.eclipse.e4.ui.model.application.MApplicationElement;
@@ -434,6 +436,11 @@ public <T> List<T> findElements(MApplicationElement searchRoot, Class<T> clazz,
434436
return new ArrayList<>(elements);
435437
}
436438

439+
@Override
440+
public <T> Stream<T> findMatchingElements(MApplicationElement searchRoot, String xpath, Class<T> clazz) {
441+
return XPathContextFactory.newInstance().newContext((EObject) searchRoot).stream(xpath, clazz);
442+
}
443+
437444
private <T> Iterable<T> findPerspectiveElements(MUIElement searchRoot, String id,
438445
Class<T> clazz,
439446
List<String> tagsToMatch) {

bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/workbench/modeling/EModelService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.eclipse.e4.ui.workbench.modeling;
1818

1919
import java.util.List;
20+
import java.util.stream.Stream;
2021
import org.eclipse.e4.core.contexts.IEclipseContext;
2122
import org.eclipse.e4.ui.model.application.MApplicationElement;
2223
import org.eclipse.e4.ui.model.application.descriptor.basic.MPartDescriptor;
@@ -279,6 +280,11 @@ <T> List<T> findElements(MUIElement searchRoot, String id, Class<T> clazz,
279280
<T> List<T> findElements(MApplicationElement searchRoot, Class<T> clazz,
280281
int searchFlags, Selector matcher);
281282

283+
/**
284+
* @since 1.17
285+
*/
286+
<T> Stream<T> findMatchingElements(MApplicationElement contextBean, String xpath, Class<T> clazz);
287+
282288
/**
283289
* Returns the first element, recursively searching under the specified search
284290
* root (inclusive)

0 commit comments

Comments
 (0)