Auto XPath Expression Update

This commit is contained in:
Akshat Bahety
2018-05-26 09:52:12 +05:30
parent f07f0b8fff
commit 830809e91b
5 changed files with 27 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ public class EventLogController implements Initializable {
private final DesignerRoot designerRoot;
private static final Duration PARSEEXCEPTION_DELAY = Duration.ofMillis(100);
private static final Duration PARSE_EXCEPTION_DELAY = Duration.ofMillis(3000);
@FXML
private TableView<LogEntry> eventLogTableView;
@@ -78,7 +78,7 @@ public class EventLogController implements Initializable {
EventStream<LogEntry> e1 = designerRoot.getLogger().getLog()
.filter(x -> x.getCategory().equals(Category.PARSE_EXCEPTION))
.successionEnds(PARSEEXCEPTION_DELAY);
.successionEnds(PARSE_EXCEPTION_DELAY);
EventStream<LogEntry> e2 = designerRoot.getLogger().getLog()
.filter(x -> !x.getCategory().equals(Category.PARSE_EXCEPTION));
@@ -87,6 +87,13 @@ public class EventLogController implements Initializable {
EventStreams.merge(e1, e2)
.subscribe(t -> eventLogTableView.getItems().add(t));
EventStream<LogEntry> e3 = designerRoot.getLogger().getLog()
.filter(x -> x.getCategory().equals(Category.XPATH_EVALUATION_EXCEPTION))
.successionEnds(PARSE_EXCEPTION_DELAY);
EventStreams.merge(e3)
.subscribe(t -> eventLogTableView.getItems().add(t));
eventLogTableView
.getSelectionModel()

View File

@@ -225,7 +225,12 @@ public class MainDesignerController implements Initializable, SettingsOwner {
public void onRefreshASTClicked() {
sourceEditorController.refreshAST();
xpathPanelController.evaluateXPath(sourceEditorController.getCompilationUnit(),
getLanguageVersion());
getLanguageVersion());
}
public void xPathEvaluate() {
xpathPanelController.evaluateXPath(sourceEditorController.getCompilationUnit(),
getLanguageVersion());
}

View File

@@ -60,7 +60,7 @@ public class SourceEditorController implements Initializable, SettingsOwner {
private ASTManager astManager;
private TreeViewWrapper<Node> treeViewWrapper;
private ASTTreeItem selectedTreeItem;
private Duration timeDuration = Duration.ofMillis(100);
private static final Duration CODE_EDITOR_REFRESH = Duration.ofMillis(100);
public SourceEditorController(DesignerRoot owner, MainDesignerController mainController) {
parent = mainController;
@@ -74,7 +74,6 @@ public class SourceEditorController implements Initializable, SettingsOwner {
public void initialize(URL location, ResourceBundle resources) {
treeViewWrapper = new TreeViewWrapper<>(astTreeView);
astTreeView.setCellFactory(treeView -> new ASTTreeCell(parent));
languageVersionProperty().values()
@@ -88,7 +87,7 @@ public class SourceEditorController implements Initializable, SettingsOwner {
codeEditorArea.richChanges()
.filter(t -> !t.getInserted().equals(t.getRemoved()))
.successionEnds(timeDuration)
.successionEnds(CODE_EDITOR_REFRESH)
.subscribe(richChange -> parent.onRefreshASTClicked());
codeEditorArea.setParagraphGraphicFactory(LineNumberFactory.get(codeEditorArea));

View File

@@ -6,6 +6,7 @@ package net.sourceforge.pmd.util.fxdesigner;
import java.io.IOException;
import java.net.URL;
import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
@@ -72,6 +73,7 @@ public class XPathPanelController implements Initializable, SettingsOwner {
private final ObservableXPathRuleBuilder ruleBuilder = new ObservableXPathRuleBuilder();
private static final Duration XPATH_REFRESH = Duration.ofMillis(3000);
@FXML
private PropertyTableView propertyView;
@@ -105,6 +107,11 @@ public class XPathPanelController implements Initializable, SettingsOwner {
.subscribe(parent::onNodeItemSelected);
Platform.runLater(this::bindToParent);
xpathExpressionArea.richChanges()
.filter(t -> !t.getInserted().equals(t.getRemoved()))
.successionEnds(XPATH_REFRESH)
.subscribe(x -> parent.xPathEvaluate());
}
private void initGenerateXPathFromStackTrace() {

View File

@@ -4,6 +4,7 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
@@ -63,11 +64,13 @@
<bottom>
<ToolBar id="main-toolbar" prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<items>
<Label text="Java Version"/>
<ChoiceBox fx:id="languageChoiceBox" maxHeight="22.0" prefHeight="22.0" prefWidth="115.0">
<padding>
<Insets bottom="-3.0" left="-3.0" right="-3.0" top="-3.0" />
</padding>
</ChoiceBox>
<Label prefHeight="17.0" prefWidth="79.0" text="XPath Version"/>
<ChoiceBox maxHeight="22.0" minHeight="20.0" prefHeight="22.0" prefWidth="115.0" fx:id="xpathVersionChoiceBox">
<padding>
<Insets bottom="-3.0" left="-3.0" right="-3.0" top="-3.0" />