Skip to content

Commit

Permalink
Rework properties handling in preferences (#193, #191)
Browse files Browse the repository at this point in the history
Merge pull request #193 from adangel/issue-191-properties
  • Loading branch information
adangel authored Apr 19, 2024
2 parents 33cfb4a + 8de2f19 commit d150d75
Show file tree
Hide file tree
Showing 52 changed files with 699 additions and 469 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
pmdCiSecretPassphrase: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
githubToken: ${{ secrets.GITHUB_TOKEN }}

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


build:
needs: fail-fast-build
Expand Down Expand Up @@ -74,3 +82,11 @@ jobs:
deploy: false
pmdCiSecretPassphrase: ${{ secrets.PMD_CI_SECRET_PASSPHRASE }}
githubToken: ${{ secrets.GITHUB_TOKEN }}

- name: Upload screenshots of failed unit tests
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: screenshots-${{ matrix.os }}-${{ matrix.targetPlatform }}
path: net.sourceforge.pmd.eclipse.plugin.test/screenshots
if-no-files-found: ignore
39 changes: 38 additions & 1 deletion ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,54 @@ Eclipse Update Site:
* Releases: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/>
* Snapshots: <https://pmd.github.io/pmd-eclipse-plugin-p2-site/snapshot/>

## ????: 7.0.1.v????
## ????: 7.1.0.v????

This is a minor release.

### New and noteworthy

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

### API Changes

#### Deprecations

The following classes have been deprecated for removal. Either they were not intended to be public API at all
or they were used to support the UI for rule configuration. With the switch to PMD 7.0.0, these editor
factories are not used anymore.

* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractMultiValueEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractNumericEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.AbstractRealNumberEditor`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.BooleanEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.CharacterEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.DoubleEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.EnumerationEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.FilePicker`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.IntegerEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MethodPicker`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiEnumerationEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiIntegerEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.MultiStringEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.RegexEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.StringEditorFactory`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil`
* `net.sourceforge.pmd.eclipse.ui.preferences.editors.TypeText`

The following members have been deprecated for removal:

* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#NewPropertyDialog(Shell, Map<Class<?>, EditorFactory<?>>, PropertySource, ValueChangeListener)`
* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#NewPropertyDialog(Shell, Map<Class<?>, EditorFactory<?>>, Rule, PropertyDescriptor<?>, ValueChangeListener)`
* `net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog#withOnly(Map<Class<?>, EditorFactory<?>>, Class<?>[])`
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.AbstractRulePanelManager.show(TypeText, Class<?>)`
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.FormArranger#FormArranger(Composite, Map<Class<?>, EditorFactory<?>>, ValueChangeListener, SizeChangeListener)`
* `net.sourceforge.pmd.eclipse.ui.preferences.panelmanagers.PerRulePropertyPanelManager#EDITOR_FACTORIES_BY_PROPERTY_TYPE`

See the javadoc for more info and any possible alternatives if available.

### External Contributions

## 22-March-2024: 7.0.0.v20240322-0920-r
Expand Down
2 changes: 1 addition & 1 deletion net.sourceforge.pmd.eclipse.p2updatesite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: PMD eclipse test fragment
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin.test.fragment;singleton:=true
Bundle-Version: 7.0.1.qualifier
Bundle-Version: 7.1.0.qualifier
Bundle-Vendor: PMD Development Team
Fragment-Host: net.sourceforge.pmd.eclipse.plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
2 changes: 1 addition & 1 deletion net.sourceforge.pmd.eclipse.plugin.test.fragment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Version: 7.0.1.qualifier
Bundle-Version: 7.1.0.qualifier
Import-Package: org.apache.commons.io
Bundle-Name: PMD Test Plugin
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin.test;singleton:=true
Expand Down
2 changes: 1 addition & 1 deletion net.sourceforge.pmd.eclipse.plugin.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/


package net.sourceforge.pmd.eclipse.ui.preferences.br;

import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import org.eclipse.core.runtime.ILogListener;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swtbot.swt.finder.waits.WaitForObjectCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.hamcrest.Matcher;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import net.sourceforge.pmd.eclipse.AbstractSWTBotTest;

public class PMDPreferencePage2Test extends AbstractSWTBotTest {
private List<IStatus> errors;
private ILogListener logListener;

@Before
public void setup() {
errors = new ArrayList<>();
logListener = new ILogListener() {
@Override
public void logging(IStatus status, String plugin) {
if (status.getSeverity() != IStatus.ERROR) {
return;
}

String statusText = status.toString().toLowerCase(Locale.ROOT);
if (statusText.contains("pmd") || statusText.contains("unhandled event loop exception")) {
errors.add(status);
}
}
};
Platform.getLog(PlatformUI.class).addLogListener(logListener);
}

@After
public void cleanup() {
Platform.getLog(PlatformUI.class).removeLogListener(logListener);
}

/**
* Simple smoke test to open the rule configuration preference pages.
* @see PMDPreferencePage2
*/
@Test
public void openPMDRuleConfiguration() {
openPreferences();
SWTBotShell preferencesDialog = bot.shell("Preferences");
SWTBotTreeItem pmdItem = preferencesDialog.bot().tree(0).getTreeItem("PMD");
pmdItem.click();
pmdItem.expand();
pmdItem.getNode("Rule Configuration").click();


Matcher<Button> matcher = allOf(widgetOfType(Button.class),
withMnemonic("Use global rule management"),
withStyle(SWT.CHECK, "SWT.CHECK"));
WaitForObjectCondition<Button> waitForWidget = waitForWidget(matcher);
preferencesDialog.bot().waitUntil(waitForWidget, TimeUnit.SECONDS.toMillis(15));
SWTBotCheckBox globalRuleManagementCheckbox = new SWTBotCheckBox(waitForWidget.get(0), matcher);
globalRuleManagementCheckbox.click();

SWTBotTree ruleTable = preferencesDialog.bot().tree(1);
int rowCount = ruleTable.rowCount();
assertTrue(rowCount > 0);

// select first rule
ruleTable.getAllItems()[0].click();

preferencesDialog.bot().button("Cancel").click();

if (!errors.isEmpty()) {
fail("There are " + errors.size() + " errors:\n"
+ errors.stream().map(IStatus::getMessage).collect(Collectors.joining("\n")));
}
}

private void openPreferences() {
// due to macosx, where the Preferences is not part of the Window menu but the application
// menu, we programmatically open the preferences dialog and not try to find it via the menu.
bot.getDisplay().execute(() -> {
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(bot.shell().widget, null, null, errors);
dialog.open();
});
}
}
2 changes: 1 addition & 1 deletion net.sourceforge.pmd.eclipse.plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.name
Bundle-SymbolicName: net.sourceforge.pmd.eclipse.plugin;singleton:=true
Bundle-Version: 7.0.1.qualifier
Bundle-Version: 7.1.0.qualifier
Bundle-Activator: net.sourceforge.pmd.eclipse.plugin.PMDPlugin
Require-Bundle: org.eclipse.core.resources,
org.eclipse.jdt.core,
Expand Down
3 changes: 2 additions & 1 deletion net.sourceforge.pmd.eclipse.plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>net.sourceforge.pmd.eclipse.parent</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>7.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -156,6 +156,7 @@
<exclude>net.sourceforge.pmd.eclipse.logging.internal</exclude>
<exclude>net.sourceforge.pmd.eclipse.runtime.cmd.internal</exclude>
<exclude>net.sourceforge.pmd.eclipse.ui.actions.internal</exclude>
<exclude>net.sourceforge.pmd.eclipse.ui.preferences.internal</exclude>
<exclude>net.sourceforge.pmd.eclipse.util.internal</exclude>
</excludes>
</parameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;

import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
import net.sourceforge.pmd.eclipse.util.ResourceManager;
import net.sourceforge.pmd.eclipse.util.internal.SWTUtil;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import net.sourceforge.pmd.eclipse.ui.editors.StyleExtractor;
import net.sourceforge.pmd.eclipse.ui.editors.SyntaxData;
import net.sourceforge.pmd.eclipse.ui.editors.SyntaxManager;
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
import net.sourceforge.pmd.eclipse.util.FontBuilder;
import net.sourceforge.pmd.eclipse.util.internal.SWTUtil;
import net.sourceforge.pmd.lang.Language;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import net.sourceforge.pmd.eclipse.plugin.PMDPlugin;
import net.sourceforge.pmd.eclipse.ui.nls.StringKeys;
import net.sourceforge.pmd.eclipse.ui.preferences.editors.SWTUtil;
import net.sourceforge.pmd.eclipse.util.internal.SWTUtil;

/**
*
Expand Down
Loading

0 comments on commit d150d75

Please sign in to comment.