-
Notifications
You must be signed in to change notification settings - Fork 228
579498 filter dialog types #144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jukzi
merged 1 commit into
eclipse-platform:master
from
eobrienPilz:579498_FilterDialogTypes
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| * Contributors: | ||
| * IBM Corporation - initial API and implementation | ||
| * Lars Vogel <[email protected]> - 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. | ||
| */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...g.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/NoApplicationAttribTestView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/SubTypeOnlyTestView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /******************************************************************************* | ||
jukzi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * 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); | ||
| } | ||
|
|
||
| } | ||
29 changes: 29 additions & 0 deletions
29
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeAndSubTypeTestView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
|
|
||
| } |
31 changes: 31 additions & 0 deletions
31
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeOnlyTestView.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
...s/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTypeTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 { | ||
jukzi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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<MarkerType> 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<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
|
||
| Collection<MarkerType> 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<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
|
||
| Collection<MarkerType> 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<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
|
||
| Collection<MarkerType> 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<MarkerType> getMarkerTypes(MarkerContentGenerator generator) { | ||
| Collection<MarkerType> 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<MarkerType>) markerTypesField.get(contentGeneratorDescriptor); | ||
| } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
| } | ||
| return selectedTypesCollection; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.