Skip to content

Commit d150d75

Browse files
authored
Rework properties handling in preferences (#193, #191)
Merge pull request #193 from adangel/issue-191-properties
2 parents 33cfb4a + 8de2f19 commit d150d75

File tree

52 files changed

+699
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+699
-469
lines changed

.github/workflows/build.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ jobs:
3434
pmdCiSecretPassphrase: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
3535
githubToken: ${{ secrets.GITHUB_TOKEN }}
3636

37+
- name: Upload screenshots of failed unit tests
38+
uses: actions/upload-artifact@v4
39+
if: ${{ failure() }}
40+
with:
41+
name: screenshots-ubuntu-latest-2024-03
42+
path: net.sourceforge.pmd.eclipse.plugin.test/screenshots
43+
if-no-files-found: ignore
44+
3745

3846
build:
3947
needs: fail-fast-build
@@ -74,3 +82,11 @@ jobs:
7482
deploy: false
7583
pmdCiSecretPassphrase: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
7684
githubToken: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Upload screenshots of failed unit tests
87+
uses: actions/upload-artifact@v4
88+
if: ${{ failure() }}
89+
with:
90+
name: screenshots-${{ matrix.os }}-${{ matrix.targetPlatform }}
91+
path: net.sourceforge.pmd.eclipse.plugin.test/screenshots
92+
if-no-files-found: ignore

ReleaseNotes.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,54 @@ Eclipse Update Site:
77
* Releases: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
88
* Snapshots: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/>
99

10-
## ????: 7.0.1.v????
10+
## ????: 7.1.0.v????
1111

1212
This is a minor release.
1313

1414
### New and noteworthy
1515

1616
### Fixed Issues
17+
* [#191](https://github.com/pmd/pmd-eclipse-plugin/issues/191): Rule Configuration Pref Page - PropertyDescriptor cannot be cast to Comparable
1718
* [#192](https://github.com/pmd/pmd-eclipse-plugin/pull/192): Add japicmp
1819

1920
### API Changes
2021

22+
#### Deprecations
23+
24+
The following classes have been deprecated for removal. Either they were not intended to be public API at all
25+
or they were used to support the UI for rule configuration. With the switch to PMD 7.0.0, these editor
26+
factories are not used anymore.
27+
28+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractEditorFactory`
29+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractMultiValueEditorFactory`
30+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractNumericEditorFactory`
31+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractRealNumberEditor`
32+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.BooleanEditorFactory`
33+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.CharacterEditorFactory`
34+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.DoubleEditorFactory`
35+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.EnumerationEditorFactory`
36+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.FilePicker`
37+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.IntegerEditorFactory`
38+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MethodPicker`
39+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiEnumerationEditorFactory`
40+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiIntegerEditorFactory`
41+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiStringEditorFactory`
42+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.RegexEditorFactory`
43+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.StringEditorFactory`
44+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil`
45+
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.TypeText`
46+
47+
The following members have been deprecated for removal:
48+
49+
* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#NewPropertyDialog(Shell, Map<Class<?>, EditorFactory<?>>, PropertySource, ValueChangeListener)`
50+
* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#NewPropertyDialog(Shell, Map<Class<?>, EditorFactory<?>>, Rule, PropertyDescriptor<?>, ValueChangeListener)`
51+
* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#withOnly(Map<Class<?>, EditorFactory<?>>, Class<?>[])`
52+
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.AbstractRulePanelManager.show(TypeText, Class<?>)`
53+
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.FormArranger#FormArranger(Composite, Map<Class<?>, EditorFactory<?>>, ValueChangeListener, SizeChangeListener)`
54+
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.PerRulePropertyPanelManager#EDITOR_FACTORIES_BY_PROPERTY_TYPE`
55+
56+
See the javadoc for more info and any possible alternatives if available.
57+
2158
### External Contributions
2259

2360
## 22-March-2024: 7.0.0.v20240322-0920-r

net.sourceforge.pmd.eclipse.p2updatesite/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>net.sourceforge.pmd</groupId>
88
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
9-
<version>7.0.1-SNAPSHOT</version>
9+
<version>7.1.0-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

net.sourceforge.pmd.eclipse.plugin.test.fragment/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: PMD eclipse test fragment
44
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin.test.fragment;singleton:=true
5-
Bundle-Version: 7.0.1.qualifier
5+
Bundle-Version: 7.1.0.qualifier
66
Bundle-Vendor: PMD Development Team
77
Fragment-Host: net.sourceforge.pmd.eclipse.plugin
88
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

net.sourceforge.pmd.eclipse.plugin.test.fragment/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>net.sourceforge.pmd</groupId>
88
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
9-
<version>7.0.1-SNAPSHOT</version>
9+
<version>7.1.0-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

net.sourceforge.pmd.eclipse.plugin.test/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
3-
Bundle-Version: 7.0.1.qualifier
3+
Bundle-Version: 7.1.0.qualifier
44
Import-Package: org.apache.commons.io
55
Bundle-Name: PMD Test Plugin
66
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin.test;singleton:=true

net.sourceforge.pmd.eclipse.plugin.test/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>net.sourceforge.pmd</groupId>
88
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
9-
<version>7.0.1-SNAPSHOT</version>
9+
<version>7.1.0-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3+
*/
4+
5+
6+
package net.sourceforge.pmd.eclipse.ui.preferences.br;
7+
8+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
9+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
10+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
11+
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
12+
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
13+
import static org.junit.Assert.assertTrue;
14+
import static org.junit.Assert.fail;
15+
16+
import java.util.ArrayList;
17+
import java.util.List;
18+
import java.util.Locale;
19+
import java.util.concurrent.TimeUnit;
20+
import java.util.stream.Collectors;
21+
22+
import org.eclipse.core.runtime.ILogListener;
23+
import org.eclipse.core.runtime.IStatus;
24+
import org.eclipse.core.runtime.Platform;
25+
import org.eclipse.jface.preference.PreferenceDialog;
26+
import org.eclipse.swt.SWT;
27+
import org.eclipse.swt.widgets.Button;
28+
import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition;
29+
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
30+
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
31+
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
32+
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
33+
import org.eclipse.ui.PlatformUI;
34+
import org.eclipse.ui.dialogs.PreferencesUtil;
35+
import org.hamcrest.Matcher;
36+
import org.junit.After;
37+
import org.junit.Before;
38+
import org.junit.Test;
39+
40+
import net.sourceforge.pmd.eclipse.AbstractSWTBotTest;
41+
42+
public class PMDPreferencePage2Test extends AbstractSWTBotTest {
43+
private List<IStatus> errors;
44+
private ILogListener logListener;
45+
46+
@Before
47+
public void setup() {
48+
errors = new ArrayList<>();
49+
logListener = new ILogListener() {
50+
@Override
51+
public void logging(IStatus status, String plugin) {
52+
if (status.getSeverity() != IStatus.ERROR) {
53+
return;
54+
}
55+
56+
String statusText = status.toString().toLowerCase(Locale.ROOT);
57+
if (statusText.contains("pmd") || statusText.contains("unhandled event loop exception")) {
58+
errors.add(status);
59+
}
60+
}
61+
};
62+
Platform.getLog(PlatformUI.class).addLogListener(logListener);
63+
}
64+
65+
@After
66+
public void cleanup() {
67+
Platform.getLog(PlatformUI.class).removeLogListener(logListener);
68+
}
69+
70+
/**
71+
* Simple smoke test to open the rule configuration preference pages.
72+
* @see PMDPreferencePage2
73+
*/
74+
@Test
75+
public void openPMDRuleConfiguration() {
76+
openPreferences();
77+
SWTBotShell preferencesDialog = bot.shell("Preferences");
78+
SWTBotTreeItem pmdItem = preferencesDialog.bot().tree(0).getTreeItem("PMD");
79+
pmdItem.click();
80+
pmdItem.expand();
81+
pmdItem.getNode("Rule Configuration").click();
82+
83+
84+
Matcher<Button> matcher = allOf(widgetOfType(Button.class),
85+
withMnemonic("Use global rule management"),
86+
withStyle(SWT.CHECK, "SWT.CHECK"));
87+
WaitForObjectCondition<Button> waitForWidget = waitForWidget(matcher);
88+
preferencesDialog.bot().waitUntil(waitForWidget, TimeUnit.SECONDS.toMillis(15));
89+
SWTBotCheckBox globalRuleManagementCheckbox = new SWTBotCheckBox(waitForWidget.get(0), matcher);
90+
globalRuleManagementCheckbox.click();
91+
92+
SWTBotTree ruleTable = preferencesDialog.bot().tree(1);
93+
int rowCount = ruleTable.rowCount();
94+
assertTrue(rowCount > 0);
95+
96+
// select first rule
97+
ruleTable.getAllItems()[0].click();
98+
99+
preferencesDialog.bot().button("Cancel").click();
100+
101+
if (!errors.isEmpty()) {
102+
fail("There are " + errors.size() + " errors:\n"
103+
+ errors.stream().map(IStatus::getMessage).collect(Collectors.joining("\n")));
104+
}
105+
}
106+
107+
private void openPreferences() {
108+
// due to macosx, where the Preferences is not part of the Window menu but the application
109+
// menu, we programmatically open the preferences dialog and not try to find it via the menu.
110+
bot.getDisplay().execute(() -> {
111+
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(bot.shell().widget, null, null, errors);
112+
dialog.open();
113+
});
114+
}
115+
}

net.sourceforge.pmd.eclipse.plugin/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %plugin.name
44
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin;singleton:=true
5-
Bundle-Version: 7.0.1.qualifier
5+
Bundle-Version: 7.1.0.qualifier
66
Bundle-Activator: net.sourceforge.pmd.eclipse.plugin.PMDPlugin
77
Require-Bundle: org.eclipse.core.resources,
88
org.eclipse.jdt.core,

net.sourceforge.pmd.eclipse.plugin/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>net.sourceforge.pmd</groupId>
88
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
9-
<version>7.0.1-SNAPSHOT</version>
9+
<version>7.1.0-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

@@ -156,6 +156,7 @@
156156
<exclude>net.sourceforge.pmd.eclipse.logging.internal</exclude>
157157
<exclude>net.sourceforge.pmd.eclipse.runtime.cmd.internal</exclude>
158158
<exclude>net.sourceforge.pmd.eclipse.ui.actions.internal</exclude>
159+
<exclude>net.sourceforge.pmd.eclipse.ui.preferences.internal</exclude>
159160
<exclude>net.sourceforge.pmd.eclipse.util.internal</exclude>
160161
</excludes>
161162
</parameter>

0 commit comments

Comments
 (0)