diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java index 3fac3825ae..9369c20455 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/XPathPanelController.java @@ -71,7 +71,6 @@ import javafx.scene.control.ToggleGroup; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.stage.Modality; @@ -136,12 +135,9 @@ public class XPathPanelController extends AbstractController showExportXPathToRuleWizard()); - xpathExpressionArea.richChanges() - .filter(t -> !t.isIdentity()) - .successionEnds(XPATH_REFRESH_DELAY) - // Reevaluate XPath anytime the expression or the XPath version changes - .or(xpathVersionProperty().changes()) - .subscribe(tick -> parent.refreshXPathResults()); + getRuleBuilder().modificationsTicks() + .successionEnds(XPATH_REFRESH_DELAY) + .subscribe(tick -> parent.refreshXPathResults()); selectionEvents = EventStreams.valuesOf(xpathResultListView.getSelectionModel().selectedItemProperty()).suppressible(); diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ObservableXPathRuleBuilder.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ObservableXPathRuleBuilder.java index d3c67424c7..ba9bc9bfb6 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ObservableXPathRuleBuilder.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/ObservableXPathRuleBuilder.java @@ -4,6 +4,8 @@ package net.sourceforge.pmd.util.fxdesigner.model; +import org.reactfx.EventStream; +import org.reactfx.collection.LiveList; import org.reactfx.value.Var; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; @@ -54,6 +56,17 @@ public class ObservableXPathRuleBuilder extends ObservableRuleBuilder { return xpathExpression; } + + /** + * Pushes an event every time the rule needs to be re-evaluated. + */ + public EventStream modificationsTicks() { + return nameProperty().values() + .or(xpathVersion.values()) + .or(xpathExpression.values()) + .or(LiveList.changesOf(rulePropertiesProperty())); + } + // TODO: Once the xpath expression changes, we'll need to rebuild the rule // @Override // public Optional build() throws IllegalArgumentException { diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/PropertyDescriptorSpec.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/PropertyDescriptorSpec.java index 73eb92efb7..ea20d0f895 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/PropertyDescriptorSpec.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/model/PropertyDescriptorSpec.java @@ -8,6 +8,7 @@ package net.sourceforge.pmd.util.fxdesigner.model; import java.util.HashMap; import java.util.Map; +import org.reactfx.EventStream; import org.reactfx.value.Val; import org.reactfx.value.Var; @@ -200,4 +201,15 @@ public class PropertyDescriptorSpec implements SettingsOwner { public static ObservableList observableList() { return FXCollections.observableArrayList(extractor()); } + + + /** + * Pushes an event every time the rule owning this property needs to be re-evaluated. + */ + public EventStream modificationTicks() { + return nameProperty().values() + .or(valueProperty().values()) + .or(typeIdProperty().values()); + } + }