Refresh XPath results on changes to properties
This commit is contained in:
@ -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,11 +135,8 @@ public class XPathPanelController extends AbstractController<MainDesignerControl
|
||||
|
||||
exportXpathToRuleButton.setOnAction(e -> showExportXPathToRuleWizard());
|
||||
|
||||
xpathExpressionArea.richChanges()
|
||||
.filter(t -> !t.isIdentity())
|
||||
getRuleBuilder().modificationsTicks()
|
||||
.successionEnds(XPATH_REFRESH_DELAY)
|
||||
// Reevaluate XPath anytime the expression or the XPath version changes
|
||||
.or(xpathVersionProperty().changes())
|
||||
.subscribe(tick -> parent.refreshXPathResults());
|
||||
|
||||
selectionEvents = EventStreams.valuesOf(xpathResultListView.getSelectionModel().selectedItemProperty()).suppressible();
|
||||
|
@ -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<Rule> build() throws IllegalArgumentException {
|
||||
|
@ -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<PropertyDescriptorSpec> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user