[ui] Minor fixes

* Eclipse compiler needs apparently an additional import for HighlightLayerCodeArea.LayerId
* LICENSE file location no absolute
* Unselect xpath result if another node is selected
This commit is contained in:
Andreas Dangel 2019-02-20 20:25:04 +01:00
parent 95c145898d
commit 22edffbb21
5 changed files with 19 additions and 8 deletions

View File

@ -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<MainDesignerControl
@Override
public void setFocusNode(Node node) {
xpathResultListView.getItems().stream()
Optional<TextAwareNodeWrapper> 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();
}
}

View File

@ -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.
*
* <p>This class mainly to make the initialization cycle of JavaFX clearer. Children controllers
* <p>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 <T> Type of the parent controller
*
* @author Clément Fournier
* @since 7.0.0
* @since 6.11.0
*/
public abstract class AbstractController<T extends AbstractController<?>> implements Initializable, SettingsOwner, ApplicationComponent {

View File

@ -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();
}

View File

@ -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<Node> implements NodeSelectionSource {

View File

@ -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;