forked from phoedos/pmd
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.MouseButton;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.Priority;
|
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.stage.Modality;
|
import javafx.stage.Modality;
|
||||||
@ -136,12 +135,9 @@ public class XPathPanelController extends AbstractController<MainDesignerControl
|
|||||||
|
|
||||||
exportXpathToRuleButton.setOnAction(e -> showExportXPathToRuleWizard());
|
exportXpathToRuleButton.setOnAction(e -> showExportXPathToRuleWizard());
|
||||||
|
|
||||||
xpathExpressionArea.richChanges()
|
getRuleBuilder().modificationsTicks()
|
||||||
.filter(t -> !t.isIdentity())
|
.successionEnds(XPATH_REFRESH_DELAY)
|
||||||
.successionEnds(XPATH_REFRESH_DELAY)
|
.subscribe(tick -> parent.refreshXPathResults());
|
||||||
// Reevaluate XPath anytime the expression or the XPath version changes
|
|
||||||
.or(xpathVersionProperty().changes())
|
|
||||||
.subscribe(tick -> parent.refreshXPathResults());
|
|
||||||
|
|
||||||
selectionEvents = EventStreams.valuesOf(xpathResultListView.getSelectionModel().selectedItemProperty()).suppressible();
|
selectionEvents = EventStreams.valuesOf(xpathResultListView.getSelectionModel().selectedItemProperty()).suppressible();
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
package net.sourceforge.pmd.util.fxdesigner.model;
|
package net.sourceforge.pmd.util.fxdesigner.model;
|
||||||
|
|
||||||
|
import org.reactfx.EventStream;
|
||||||
|
import org.reactfx.collection.LiveList;
|
||||||
import org.reactfx.value.Var;
|
import org.reactfx.value.Var;
|
||||||
|
|
||||||
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
|
import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil;
|
||||||
@ -54,6 +56,17 @@ public class ObservableXPathRuleBuilder extends ObservableRuleBuilder {
|
|||||||
return xpathExpression;
|
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
|
// TODO: Once the xpath expression changes, we'll need to rebuild the rule
|
||||||
// @Override
|
// @Override
|
||||||
// public Optional<Rule> build() throws IllegalArgumentException {
|
// public Optional<Rule> build() throws IllegalArgumentException {
|
||||||
|
@ -8,6 +8,7 @@ package net.sourceforge.pmd.util.fxdesigner.model;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.reactfx.EventStream;
|
||||||
import org.reactfx.value.Val;
|
import org.reactfx.value.Val;
|
||||||
import org.reactfx.value.Var;
|
import org.reactfx.value.Var;
|
||||||
|
|
||||||
@ -200,4 +201,15 @@ public class PropertyDescriptorSpec implements SettingsOwner {
|
|||||||
public static ObservableList<PropertyDescriptorSpec> observableList() {
|
public static ObservableList<PropertyDescriptorSpec> observableList() {
|
||||||
return FXCollections.observableArrayList(extractor());
|
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