Put list cell factories into fxml
This commit is contained in:
@ -16,8 +16,6 @@ import net.sourceforge.pmd.lang.java.ast.TypeNode;
|
||||
import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
|
||||
import net.sourceforge.pmd.util.fxdesigner.model.MetricEvaluator;
|
||||
import net.sourceforge.pmd.util.fxdesigner.model.MetricResult;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.MetricResultListCell;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.ScopeHierarchyTreeCell;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.ScopeHierarchyTreeItem;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
@ -68,8 +66,6 @@ public class NodeInfoPanelController implements Initializable {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
metricResultsListView.setCellFactory(param -> new MetricResultListCell());
|
||||
scopeHierarchyTreeView.setCellFactory(param -> new ScopeHierarchyTreeCell());
|
||||
scopeHierarchyTreeView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal) -> {
|
||||
if (newVal != null && newVal.getValue() instanceof NameDeclaration) {
|
||||
parent.onNameDeclarationSelected((NameDeclaration) newVal.getValue());
|
||||
|
@ -22,7 +22,6 @@ import net.sourceforge.pmd.util.fxdesigner.model.ParseAbortedException;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.codearea.AvailableSyntaxHighlighters;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.codearea.CustomCodeArea;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.codearea.SyntaxHighlighter;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeCell;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeItem;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.settings.AppSetting;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.settings.SettingsOwner;
|
||||
@ -80,7 +79,7 @@ public class SourceEditorController implements Initializable, SettingsOwner {
|
||||
private void initializeSyntaxHighlighting() {
|
||||
|
||||
isSyntaxHighlightingEnabled.bind(codeEditorArea.syntaxHighlightingEnabledProperty());
|
||||
|
||||
|
||||
isSyntaxHighlightingEnabled.addListener(((observable, wasEnabled, isEnabled) -> {
|
||||
if (!wasEnabled && isEnabled) {
|
||||
updateSyntaxHighlighter();
|
||||
@ -99,7 +98,6 @@ public class SourceEditorController implements Initializable, SettingsOwner {
|
||||
|
||||
|
||||
private void initializeASTTreeView() {
|
||||
astTreeView.setCellFactory(param -> new ASTTreeCell());
|
||||
|
||||
astTreeView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal) -> {
|
||||
if (newVal != null && newVal.getValue() != null) {
|
||||
|
@ -20,7 +20,6 @@ import net.sourceforge.pmd.util.fxdesigner.model.XPathEvaluationException;
|
||||
import net.sourceforge.pmd.util.fxdesigner.model.XPathEvaluator;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.codearea.CustomCodeArea;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.codearea.syntaxhighlighting.XPathSyntaxHighlighter;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.controls.XpathViolationListCell;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.settings.AppSetting;
|
||||
import net.sourceforge.pmd.util.fxdesigner.util.settings.SettingsOwner;
|
||||
|
||||
@ -68,7 +67,6 @@ public class XPathPanelController implements Initializable, SettingsOwner {
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
xpathExpressionArea.setSyntaxHighlightingEnabled(new XPathSyntaxHighlighter());
|
||||
xpathResultListView.setCellFactory(param -> new XpathViolationListCell());
|
||||
|
||||
xpathResultListView.getSelectionModel().selectedItemProperty().addListener((obs, oldVal, newVal) -> {
|
||||
if (newVal != null) {
|
||||
|
@ -7,6 +7,9 @@ package net.sourceforge.pmd.util.fxdesigner.util.controls;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
|
||||
import javafx.scene.control.TreeCell;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
|
||||
/**
|
||||
* Formats the cell for AST nodes in the main AST TreeView.
|
||||
@ -27,4 +30,9 @@ public class ASTTreeCell extends TreeCell<Node> {
|
||||
setText(item.toString() + (item.getImage() == null ? "" : " \"" + item.getImage() + "\""));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Callback<TreeView<Node>, ASTTreeCell> callback() {
|
||||
return p -> new ASTTreeCell();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import java.util.Locale;
|
||||
import net.sourceforge.pmd.util.fxdesigner.model.MetricResult;
|
||||
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
|
||||
/**
|
||||
* List cell for a metric result.
|
||||
@ -42,4 +45,9 @@ public class MetricResultListCell extends ListCell<MetricResult> {
|
||||
}
|
||||
|
||||
|
||||
public static Callback<ListView<MetricResult>, MetricResultListCell> callback() {
|
||||
return param -> new MetricResultListCell();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import net.sourceforge.pmd.lang.symboltable.NameDeclaration;
|
||||
import net.sourceforge.pmd.lang.symboltable.Scope;
|
||||
|
||||
import javafx.scene.control.TreeCell;
|
||||
import javafx.scene.control.TreeView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
|
||||
/**
|
||||
@ -69,4 +71,9 @@ public class ScopeHierarchyTreeCell extends TreeCell<Object> {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public static Callback<TreeView<Object>, ScopeHierarchyTreeCell> callback() {
|
||||
return param -> new ScopeHierarchyTreeCell();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,13 @@
|
||||
|
||||
package net.sourceforge.pmd.util.fxdesigner.util.controls;
|
||||
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.util.Callback;
|
||||
|
||||
|
||||
/**
|
||||
* @author Clément Fournier
|
||||
@ -27,4 +31,9 @@ public class XpathViolationListCell extends ListCell<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Callback<ListView<Node>, XpathViolationListCell> callback() {
|
||||
return p -> new XpathViolationListCell();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- One editor, ie source + ast view -->
|
||||
|
||||
<?import net.sourceforge.pmd.util.fxdesigner.util.codearea.CustomCodeArea?>
|
||||
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeCell?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.ContextMenu?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.ToolBar?>
|
||||
<?import javafx.scene.control.TreeView?>
|
||||
@ -58,7 +58,11 @@
|
||||
<center>
|
||||
<TreeView fx:id="astTreeView" prefHeight="200.0"
|
||||
prefWidth="200.0" styleClass="secondary-panel"
|
||||
BorderPane.alignment="CENTER"/>
|
||||
BorderPane.alignment="CENTER">
|
||||
<cellFactory>
|
||||
<ASTTreeCell fx:factory="callback"/>
|
||||
</cellFactory>
|
||||
</TreeView>
|
||||
</center>
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0"
|
||||
|
@ -10,6 +10,10 @@
|
||||
<?import javafx.scene.control.TreeView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.MetricResultListCell?>
|
||||
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.ScopeHierarchyTreeCell?>
|
||||
|
||||
|
||||
<TabPane xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
fx:id="nodeInfoTabPane"
|
||||
@ -57,7 +61,11 @@
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<center>
|
||||
<ListView fx:id="metricResultsListView" styleClass="secondary-panel"
|
||||
BorderPane.alignment="CENTER"/>
|
||||
BorderPane.alignment="CENTER">
|
||||
<cellFactory>
|
||||
<MetricResultListCell fx:factory="callback"/>
|
||||
</cellFactory>
|
||||
</ListView>
|
||||
</center>
|
||||
<top>
|
||||
<ToolBar styleClass="info-title-bar" BorderPane.alignment="CENTER">
|
||||
@ -79,7 +87,11 @@
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<center>
|
||||
<TreeView fx:id="scopeHierarchyTreeView" styleClass="secondary-panel"
|
||||
BorderPane.alignment="CENTER"/>
|
||||
BorderPane.alignment="CENTER">
|
||||
<cellFactory>
|
||||
<ScopeHierarchyTreeCell fx:factory="callback"/>
|
||||
</cellFactory>
|
||||
</TreeView>
|
||||
</center>
|
||||
<top>
|
||||
<ToolBar styleClass="info-title-bar" BorderPane.alignment="CENTER">
|
||||
|
@ -51,7 +51,11 @@
|
||||
AnchorPane.topAnchor="0.0">
|
||||
<content>
|
||||
<ListView
|
||||
fx:id="xpathResultListView"/>
|
||||
fx:id="xpathResultListView">
|
||||
<cellFactory>
|
||||
|
||||
</cellFactory>
|
||||
</ListView>
|
||||
</content>
|
||||
</TitledPane>
|
||||
</children>
|
||||
|
Reference in New Issue
Block a user