This commit is contained in:
Clément Fournier 2019-01-27 23:30:32 +01:00
parent 5c2b8e0afe
commit 613eb9601c
7 changed files with 21 additions and 18 deletions

View File

@ -16,7 +16,7 @@
<maven.compiler.source>1.${java.version}</maven.compiler.source>
<maven.compiler.target>1.${java.version}</maven.compiler.target>
<build.mr.java8.output>${project.build.directory}/classes-java8</build.mr.java8.output>
<build.mr.java9.output>${project.build.outputDirectory}/META-INF/versions/9</build.mr.java9.output>
<openjfx.version>11</openjfx.version>
@ -65,7 +65,7 @@
</configuration>
</plugin>
<!-- Unpack Java 8 specific code into the root output dir -->
<!-- Unpack Java 8 specific dependencies into the root output dir -->
<!-- Code specific to higher versions is unpacked into META-INF/versions/n -->
<plugin>
@ -73,7 +73,7 @@
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>Unpack java 8 specific deps</id>
<id>layout-java-8-specific-code</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
@ -87,14 +87,14 @@
</execution>
<execution>
<id>Unpack java 9 specific deps</id>
<id>layout-java-9-specific-code</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifact>org.controlsfx:controlsfx:9.0.0</artifact>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/9</outputDirectory>
<outputDirectory>${build.mr.java9.output}</outputDirectory>
<includes>**/*</includes>
</configuration>
</execution>

View File

@ -4,6 +4,8 @@
package net.sourceforge.pmd.util.fxdesigner;
import static net.sourceforge.pmd.util.fxdesigner.util.DesignerIteratorUtil.parentIterator;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@ -28,7 +30,6 @@ import net.sourceforge.pmd.lang.symboltable.Scope;
import net.sourceforge.pmd.lang.symboltable.ScopedNode;
import net.sourceforge.pmd.util.fxdesigner.model.MetricResult;
import net.sourceforge.pmd.util.fxdesigner.util.AbstractController;
import net.sourceforge.pmd.util.fxdesigner.util.DesignerIteratorUtil;
import net.sourceforge.pmd.util.fxdesigner.util.beans.SettingsPersistenceUtil.PersistentProperty;
import net.sourceforge.pmd.util.fxdesigner.util.controls.ScopeHierarchyTreeCell;
import net.sourceforge.pmd.util.fxdesigner.util.controls.ScopeHierarchyTreeItem;
@ -210,7 +211,7 @@ public class NodeInfoPanelController extends AbstractController {
// Otherwise, when you select a node in the scope tree, since focus of the app is shifted to that
// node, the scope hierarchy is reset and you lose the selection - even though obviously the node
// you selected is in its own scope hierarchy so it looks buggy.
int maxDepth = IteratorUtil.count(DesignerIteratorUtil.parentIterator(previousSelection, true));
int maxDepth = IteratorUtil.count(parentIterator(previousSelection, true));
rootScope.tryFindNode(previousSelection.getValue(), maxDepth)
.ifPresent(scopeHierarchyTreeView.getSelectionModel()::select);
}

View File

@ -40,7 +40,7 @@ import net.sourceforge.pmd.util.fxdesigner.util.codearea.AvailableSyntaxHighligh
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.ASTTreeItem;
import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeView;
import net.sourceforge.pmd.util.fxdesigner.util.controls.AstTreeView;
import net.sourceforge.pmd.util.fxdesigner.util.controls.NodeParentageCrumbBar;
import net.sourceforge.pmd.util.fxdesigner.util.controls.ToolbarTitledPane;
@ -69,7 +69,7 @@ public class SourceEditorController extends AbstractController {
@FXML
private MenuButton languageSelectionMenuButton;
@FXML
private ASTTreeView astTreeView;
private AstTreeView astTreeView;
@FXML
private HighlightLayerCodeArea<StyleLayerIds> codeEditorArea;
@FXML
@ -271,7 +271,7 @@ public class SourceEditorController extends AbstractController {
codeEditorArea.styleNodes(node == null ? emptyList() : singleton(node), StyleLayerIds.FOCUS, true);
if (node != null) {
scrollEditorToNode(node);
Platform.runLater(() -> scrollEditorToNode(node));
}
currentFocusNode.setValue(node);

View File

@ -7,7 +7,6 @@ package net.sourceforge.pmd.util.fxdesigner.util.codearea;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

View File

@ -27,7 +27,7 @@ import javafx.scene.control.TreeView;
* @author Clément Fournier
* @since 7.0.0
*/
public class ASTTreeView extends TreeView<Node> {
public class AstTreeView extends TreeView<Node> {
private final Var<Consumer<Node>> onNodeClickedHandler = Var.newSimpleVar(n -> {});
@ -37,7 +37,7 @@ public class ASTTreeView extends TreeView<Node> {
private ASTTreeItem selectedTreeItem;
public ASTTreeView() {
public AstTreeView() {
onNodeClickedHandler.values()
.subscribe(handler -> {

View File

@ -37,6 +37,9 @@ import javafx.util.Callback;
*/
public class NodeParentageCrumbBar extends BreadCrumbBar<Node> {
private static final int DEFAULT_PX_BY_CHAR = 5;
private static final int DEFAULT_CONSTANT_PADDING = 19;
/** Special item used to truncate paths when they're too long. */
private final TreeItem<Node> ellipsisCrumb = new TreeItem<>(null);
/** number of nodes currently behind the ellipsis */
@ -192,14 +195,14 @@ public class NodeParentageCrumbBar extends BreadCrumbBar<Node> {
private Function<Node, Double> getWidthEstimator(int totalNumDisplayedChars, double totalChildrenWidth, int totalNumCrumbs, double constantPadding) {
double safeConstantPadding = Double.isNaN(constantPadding)
? 19 // that's the value on my machine
? DEFAULT_CONSTANT_PADDING // that's the value on my machine
: constantPadding;
double thisPxByChar = totalNumDisplayedChars == 0
? 5.0 // we have no data, too bad
? DEFAULT_PX_BY_CHAR // we have no data, too bad
: (totalChildrenWidth - safeConstantPadding * totalNumCrumbs) / totalNumDisplayedChars;
return node -> node.getXPathNodeName().length() * thisPxByChar + safeConstantPadding;
return node -> node.getXPathNodeName().length() * (thisPxByChar + 1 /*scale it up a bit*/) + safeConstantPadding;
}
}

View File

@ -5,7 +5,7 @@
<?import org.kordamp.ikonli.javafx.FontIcon?>
<?import net.sourceforge.pmd.util.fxdesigner.util.codearea.HighlightLayerCodeArea?>
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.ASTTreeView?>
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.AstTreeView?>
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.NodeParentageCrumbBar?>
<?import net.sourceforge.pmd.util.fxdesigner.util.controls.ToolbarTitledPane?>
<?import javafx.geometry.Insets?>
@ -71,7 +71,7 @@
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<ASTTreeView fx:id="astTreeView" />
<AstTreeView fx:id="astTreeView" />
</ToolbarTitledPane>
</children>