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 47edd94f1a..cde00efd93 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 @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -232,10 +233,16 @@ public class XPathPanelController extends AbstractController firstResult = xpathResultListView.getItems().stream() .filter(wrapper -> wrapper.getNode().equals(node)) - .findFirst() - .ifPresent(item -> selectionEvents.suspendWhile(() -> xpathResultListView.getSelectionModel().select(item))); + .findFirst(); + + // with Java 9, Optional#ifPresentOrElse can be used + if (firstResult.isPresent()) { + selectionEvents.suspendWhile(() -> xpathResultListView.getSelectionModel().select(firstResult.get())); + } else { + xpathResultListView.getSelectionModel().clearSelection(); + } } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/app/AbstractController.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/app/AbstractController.java index 18fe76a941..8c19a10117 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/app/AbstractController.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/app/AbstractController.java @@ -28,9 +28,9 @@ import javafx.fxml.Initializable; * TODO I'm more and more convinced we should avoid that and stop having the controllers * hold a reference to their parent. They should only communicate by exposing properties * their parent binds to, but they shouldn't know about their parent. - * {@link MessageChannel}s can allow us to decouple them event more. + * {@link MessageChannel}s can allow us to decouple them even more. * - *

This class mainly to make the initialization cycle of JavaFX clearer. Children controllers + *

This class mainly exists to make the initialization cycle of JavaFX clearer. Children controllers * are initialized before their parent, but sometimes they should only * perform some actions after its parent has been initialized, e.g. binding * properties that depend on a restored setting or stuff. This is part @@ -44,7 +44,7 @@ import javafx.fxml.Initializable; * @param Type of the parent controller * * @author Clément Fournier - * @since 7.0.0 + * @since 6.11.0 */ public abstract class AbstractController> implements Initializable, SettingsOwner, ApplicationComponent { diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/popups/SimplePopups.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/popups/SimplePopups.java index 2b3a73280a..8c8e357dd7 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/popups/SimplePopups.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/popups/SimplePopups.java @@ -20,6 +20,9 @@ import javafx.scene.control.TextArea; */ public final class SimplePopups { + private static final String LICENSE_FILE_PATH = "/net/sourceforge/pmd/util/fxdesigner/LICENSE"; + + private SimplePopups() { } @@ -32,7 +35,7 @@ public final class SimplePopups { ScrollPane scroll = new ScrollPane(); try { - scroll.setContent(new TextArea(IOUtils.toString(SimplePopups.class.getResourceAsStream("LICENSE"), StandardCharsets.UTF_8))); + scroll.setContent(new TextArea(IOUtils.toString(SimplePopups.class.getResourceAsStream(LICENSE_FILE_PATH), StandardCharsets.UTF_8))); } catch (IOException e) { e.printStackTrace(); } diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java index db2cf5a13e..a0917276b2 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/AstTreeView.java @@ -28,7 +28,7 @@ import javafx.scene.control.TreeView; /** * @author Clément Fournier - * @since 7.0.0 + * @since 6.12.0 */ public class AstTreeView extends TreeView implements NodeSelectionSource { diff --git a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/NodeEditionCodeArea.java b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/NodeEditionCodeArea.java index 2076648a97..612952aaef 100644 --- a/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/NodeEditionCodeArea.java +++ b/pmd-ui/src/main/java/net/sourceforge/pmd/util/fxdesigner/util/controls/NodeEditionCodeArea.java @@ -31,6 +31,7 @@ import net.sourceforge.pmd.util.fxdesigner.app.NodeSelectionSource; import net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil; import net.sourceforge.pmd.util.fxdesigner.util.codearea.AvailableSyntaxHighlighters; import net.sourceforge.pmd.util.fxdesigner.util.codearea.HighlightLayerCodeArea; +import net.sourceforge.pmd.util.fxdesigner.util.codearea.HighlightLayerCodeArea.LayerId; import net.sourceforge.pmd.util.fxdesigner.util.controls.NodeEditionCodeArea.StyleLayerIds; import javafx.application.Platform;