diff --git a/bundles/org.eclipse.ui.ide/schema/markerSupport.exsd b/bundles/org.eclipse.ui.ide/schema/markerSupport.exsd
index 02e3f15ca26..d9d9ded7f2f 100644
--- a/bundles/org.eclipse.ui.ide/schema/markerSupport.exsd
+++ b/bundles/org.eclipse.ui.ide/schema/markerSupport.exsd
@@ -192,6 +192,26 @@ ON_ANY_IN_SAME_CONTAINER: on any item with the same top level container as the s
+
+
+
+ The application attribute describes how the reference should be applied.
+ i.e. Does it refer to type only, type and subtypes or subtypes only.
+ It is optionally included.
+ If it is not specified it defaults to typeAndSubTypes.
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java
index b86038cdd7d..adcc3a58511 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java
@@ -11,6 +11,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel - Bug 430694
+ * Enda O'Brien, Pilz Ireland - PR #144
******************************************************************************/
package org.eclipse.ui.internal.views.markers;
@@ -71,6 +72,26 @@ public class MarkerSupportInternalUtilities {
*/
public static final String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
+ /**
+ * The application attribute from a configuration element.
+ */
+ public static final String APPLICATION = "application"; //$NON-NLS-1$
+
+ /**
+ * The sub type only attribute value from the application attribute.
+ */
+ public static final String SUB_TYPES_ONLY = "subTypesOnly"; //$NON-NLS-1$
+
+ /**
+ * The type only attribute value from the application attribute.
+ */
+ public static final String TYPE_ONLY = "typeOnly"; //$NON-NLS-1$
+
+ /**
+ * The type and subtype attribute value from the application attribute.
+ */
+ public static final String TYPE_AND_SUBTYPE = "typeAndSubTypes"; //$NON-NLS-1$
+
/**
* The name attribute name from a configuration element.
*/
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java
index 9b1242f4c78..49f25fcdb7a 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java
@@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Enda O'Brien, Pilz Ireland - PR #144
******************************************************************************/
package org.eclipse.ui.views.markers.internal;
@@ -190,9 +191,25 @@ public Collection getMarkerTypes() {
IConfigurationElement[] markerTypeElements = configurationElement.getChildren(MarkerSupportRegistry.MARKER_TYPE_REFERENCE);
for (IConfigurationElement configElement : markerTypeElements) {
String elementName = configElement.getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ID);
- MarkerType[] types = MarkerTypesModel.getInstance().getType(elementName).getAllSubTypes();
- markerTypes.addAll(Arrays.asList(types));
- markerTypes.add(MarkerTypesModel.getInstance().getType(elementName));
+
+ String application = configElement.getAttribute(MarkerSupportInternalUtilities.APPLICATION) == null
+ ? MarkerSupportInternalUtilities.TYPE_AND_SUBTYPE
+ : configElement.getAttribute(MarkerSupportInternalUtilities.APPLICATION);
+
+ switch (application) {
+ case MarkerSupportInternalUtilities.TYPE_ONLY:
+ markerTypes.add(MarkerTypesModel.getInstance().getType(elementName));
+ break;
+ case MarkerSupportInternalUtilities.SUB_TYPES_ONLY:
+ markerTypes.addAll(
+ Arrays.asList(MarkerTypesModel.getInstance().getType(elementName).getAllSubTypes()));
+ break;
+ case MarkerSupportInternalUtilities.TYPE_AND_SUBTYPE:
+ default:
+ markerTypes.addAll(
+ Arrays.asList(MarkerTypesModel.getInstance().getType(elementName).getAllSubTypes()));
+ markerTypes.add(MarkerTypesModel.getInstance().getType(elementName));
+ }
}
if (markerTypes.isEmpty()) {
MarkerType[] types = MarkerTypesModel.getInstance().getType(IMarker.PROBLEM).getAllSubTypes();
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/NoApplicationAttribTestView.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/NoApplicationAttribTestView.java
new file mode 100644
index 00000000000..a60b374fc75
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/NoApplicationAttribTestView.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2024 Enda O'Brien and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which accompanies this distribution,
+ * and is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Enda O'Brien, Pilz Ireland - PR #144
+ *******************************************************************************/
+package org.eclipse.ui.tests;
+
+import org.eclipse.ui.views.markers.MarkerSupportView;
+
+/**
+ * A test view that does not define the markerTypeReference application
+ * attribute in its content generator (CONTENT_GEN_ID).
+ *
+ */
+public class NoApplicationAttribTestView extends MarkerSupportView {
+ public static final String ID = "org.eclipse.ui.tests.noApplicationAttribTestView";
+
+ static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.noApplicationAttribTestViewContentGenerator";
+
+ public NoApplicationAttribTestView() {
+ super(CONTENT_GEN_ID);
+ }
+
+}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/SubTypeOnlyTestView.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/SubTypeOnlyTestView.java
new file mode 100644
index 00000000000..6701562072b
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/SubTypeOnlyTestView.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2024 Enda O'Brien and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which accompanies this distribution,
+ * and is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Enda O'Brien, Pilz Ireland - PR #144
+ *******************************************************************************/
+package org.eclipse.ui.tests;
+
+import org.eclipse.ui.views.markers.MarkerSupportView;
+
+/**
+ * A test view that defines a markerTypeReference application attribute of
+ * subTypesOnly in it content generator (CONTENT_GEN_ID).
+ */
+public class SubTypeOnlyTestView extends MarkerSupportView {
+ public static final String ID = "org.eclipse.ui.tests.subTypeOnlyTestView";
+
+ static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.subTypeOnlyTestViewContentGenerator";
+
+ public SubTypeOnlyTestView() {
+ super(CONTENT_GEN_ID);
+ }
+
+}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeAndSubTypeTestView.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeAndSubTypeTestView.java
new file mode 100644
index 00000000000..b7c2990e6bc
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeAndSubTypeTestView.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2024 Enda O'Brien and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which accompanies this distribution,
+ * and is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Enda O'Brien, Pilz Ireland - PR #144
+ *******************************************************************************/
+package org.eclipse.ui.tests;
+
+import org.eclipse.ui.views.markers.MarkerSupportView;
+
+/**
+ * A test view that defines a markerTypeReference application attribute of
+ * typeAndSubTypes in it content generator (CONTENT_GEN_ID).
+ */
+public class TypeAndSubTypeTestView extends MarkerSupportView {
+ public static final String ID = "org.eclipse.ui.tests.typeAndSubTypeTestView";
+
+ static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.typeAndSubTypeTestViewContentGenerator";
+
+ public TypeAndSubTypeTestView() {
+ super(CONTENT_GEN_ID);
+ }
+
+}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeOnlyTestView.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeOnlyTestView.java
new file mode 100644
index 00000000000..a571845293e
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeOnlyTestView.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2024 Enda O'Brien and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which accompanies this distribution,
+ * and is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Enda O'Brien, Pilz Ireland - PR #144
+ *******************************************************************************/
+package org.eclipse.ui.tests;
+
+import org.eclipse.ui.views.markers.MarkerSupportView;
+
+/**
+ * A test view that defines a markerTypeReference application attribute of
+ * typeOnly in it content generator (CONTENT_GEN_ID).
+ *
+ */
+public class TypeOnlyTestView extends MarkerSupportView {
+
+ public static final String ID = "org.eclipse.ui.tests.typeOnlyTestView";
+
+ static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.typeOnlyTestViewContentGenerator";
+
+ public TypeOnlyTestView() {
+ super(CONTENT_GEN_ID);
+ }
+
+}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/InternalTestSuite.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/InternalTestSuite.java
index d0b5f349c67..fe2b505df10 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/InternalTestSuite.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/internal/InternalTestSuite.java
@@ -25,6 +25,7 @@
import org.eclipse.ui.tests.markers.MarkerSupportRegistryTests;
import org.eclipse.ui.tests.markers.MarkerSupportViewTest;
import org.eclipse.ui.tests.markers.MarkerTesterTest;
+import org.eclipse.ui.tests.markers.MarkerTypeTests;
import org.eclipse.ui.tests.markers.MarkerViewTests;
import org.eclipse.ui.tests.markers.MarkerViewUtilTest;
import org.eclipse.ui.tests.markers.ResourceMappingMarkersTest;
@@ -68,5 +69,6 @@
LargeFileLimitsPreferenceHandlerTest.class,
WorkbookEditorsHandlerTest.class,
ScopeAreaTest.class,
+ MarkerTypeTests.class
})
public class InternalTestSuite {}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTypeTests.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTypeTests.java
new file mode 100644
index 00000000000..9f03f537bb1
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTypeTests.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2024 Enda O'Brien and others.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License 2.0 which accompanies this distribution,
+ * and is available at https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors: Enda O'Brien, Pilz Ireland - PR #144
+ *******************************************************************************/
+package org.eclipse.ui.tests.markers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.views.markers.ExtendedMarkersView;
+import org.eclipse.ui.internal.views.markers.MarkerContentGenerator;
+import org.eclipse.ui.tests.NoApplicationAttribTestView;
+import org.eclipse.ui.tests.SubTypeOnlyTestView;
+import org.eclipse.ui.tests.TypeAndSubTypeTestView;
+import org.eclipse.ui.tests.TypeOnlyTestView;
+import org.eclipse.ui.views.markers.MarkerSupportView;
+import org.eclipse.ui.views.markers.internal.ContentGeneratorDescriptor;
+import org.eclipse.ui.views.markers.internal.MarkerType;
+import org.eclipse.ui.views.markers.internal.MarkerTypesModel;
+import org.junit.Test;
+
+public class MarkerTypeTests {
+
+ static final String PROBLEM_MARKER = "org.eclipse.core.resources.problemmarker";
+
+ @Test
+ public void canIncludeTypeOnly() throws Exception {
+ MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView(TypeOnlyTestView.ID);
+
+ MarkerContentGenerator generator = getMarkerContentGenerator(view);
+ Collection filterDialogTypes = getMarkerTypes(generator);
+
+ assertEquals(1, filterDialogTypes.size());
+ assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId()).findFirst().get());
+ }
+
+ @Test
+ public void canIncludeTypeAndSubTypes() throws Exception {
+ MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView(TypeAndSubTypeTestView.ID);
+
+ MarkerContentGenerator generator = getMarkerContentGenerator(view);
+ Collection filterDialogTypes = getMarkerTypes(generator);
+
+ Collection markerTypes = new HashSet<>();
+ markerTypes.add(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER));
+ markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes()));
+
+ assertEquals(markerTypes.size(), filterDialogTypes.size());
+ assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId())
+ .filter(s -> s.equals(PROBLEM_MARKER)).findFirst().get());
+
+ for (MarkerType type : markerTypes) {
+ assertTrue(filterDialogTypes.contains(type));
+ }
+ }
+
+ @Test
+ public void canIncludeSubtypesOnly() throws Exception {
+ MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView(SubTypeOnlyTestView.ID);
+
+ MarkerContentGenerator generator = getMarkerContentGenerator(view);
+ Collection filterDialogTypes = getMarkerTypes(generator);
+
+ Collection markerTypes = new HashSet<>();
+ markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes()));
+
+ assertEquals(markerTypes.size(), filterDialogTypes.size());
+ assertTrue(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId())
+ .filter(s -> s.equals(PROBLEM_MARKER)).findFirst().isEmpty());
+ for (MarkerType type : markerTypes) {
+ assertTrue(filterDialogTypes.contains(type));
+ }
+ }
+
+ @Test
+ public void typeAndSubTypesIsDefault() throws Exception {
+ MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage().showView(NoApplicationAttribTestView.ID);
+
+ MarkerContentGenerator generator = getMarkerContentGenerator(view);
+ Collection filterDialogTypes = getMarkerTypes(generator);
+
+ Collection markerTypes = new HashSet<>();
+ markerTypes.add(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER));
+ markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes()));
+
+ assertEquals(markerTypes.size(), filterDialogTypes.size());
+ assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId())
+ .filter(s -> s.equals(PROBLEM_MARKER)).findFirst().get());
+
+ for (MarkerType type : markerTypes) {
+ assertTrue(filterDialogTypes.contains(type));
+ }
+ }
+
+ public static MarkerContentGenerator getMarkerContentGenerator(MarkerSupportView view) {
+ MarkerContentGenerator generator = null;
+ try {
+ Field fieldGenerator = ExtendedMarkersView.class.getDeclaredField("generator");
+ fieldGenerator.setAccessible(true);
+ generator = (MarkerContentGenerator) fieldGenerator.get(view);
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ }
+ return generator;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Collection getMarkerTypes(MarkerContentGenerator generator) {
+ Collection selectedTypesCollection = null;
+ try {
+ Field generatorDescriptor = MarkerContentGenerator.class.getDeclaredField("generatorDescriptor");
+ generatorDescriptor.setAccessible(true);
+
+ ContentGeneratorDescriptor contentGeneratorDescriptor = (ContentGeneratorDescriptor) generatorDescriptor
+ .get(generator);
+
+ Field markerTypesField = ContentGeneratorDescriptor.class.getDeclaredField("markerTypes");
+ markerTypesField.setAccessible(true);
+
+ selectedTypesCollection = (Collection) markerTypesField.get(contentGeneratorDescriptor);
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ }
+ return selectedTypesCollection;
+ }
+}
diff --git a/tests/org.eclipse.ui.tests/plugin.xml b/tests/org.eclipse.ui.tests/plugin.xml
index 3c15b5d245a..814b4507d30 100644
--- a/tests/org.eclipse.ui.tests/plugin.xml
+++ b/tests/org.eclipse.ui.tests/plugin.xml
@@ -190,7 +190,26 @@
class="org.eclipse.ui.tests.api.workbenchpart.ViewWithCreateControlsException"
id="org.eclipse.ui.tests.api.workbenchpart.ViewWithCreateControlsException">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+