This commit is contained in:
Clément Fournier
2017-08-31 14:29:43 +02:00
parent 097ae9cb1f
commit 22ee16b09b
6 changed files with 57 additions and 71 deletions

View File

@@ -5,13 +5,19 @@
package net.sourceforge.pmd.util.fxdesigner;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import net.sourceforge.pmd.PMD;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;
/**
@@ -19,10 +25,6 @@ import javafx.stage.Stage;
*/
public class Designer extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("designer.fxml"));
@@ -30,7 +32,34 @@ public class Designer extends Application {
Scene scene = new Scene(root, 900, 600);
stage.setTitle("PMD Rule Designer (v " + PMD.VERSION + ')');
setIcons(stage);
stage.setScene(scene);
stage.show();
}
private void setIcons(Stage primaryStage) {
ObservableList<Image> icons = primaryStage.getIcons();
final String dirPrefix = "icons/app/";
List<String> imageNames = Arrays.asList("pmd-logo.png",
"pmd-logo_small.png",
"pmd-logo_tiny.png",
"pmd-logo_big.png");
List<Image> images = imageNames.stream()
.map(s -> dirPrefix + s)
.map(s -> getClass().getResourceAsStream(s))
.filter(Objects::nonNull)
.map(Image::new)
.collect(Collectors.toList());
icons.addAll(images);
}
public static void main(String[] args) {
launch(args);
}
}

View File

@@ -14,120 +14,77 @@
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import org.fxmisc.richtext.CodeArea?>
<AnchorPane prefHeight="600.0" prefWidth="900.0" stylesheets="@designer.css" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="net.sourceforge.pmd.util.fxdesigner.DesignerController">
<AnchorPane prefHeight="600.0" prefWidth="900.0" stylesheets="@designer.css" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="net.sourceforge.pmd.util.fxdesigner.DesignerController">
<children>
<BorderPane prefHeight="600.0" prefWidth="900.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<BorderPane prefHeight="600.0" prefWidth="900.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu fx:id="languageMenu" mnemonicParsing="false" text="Language"/>
<Menu fx:id="languageMenu" mnemonicParsing="false" text="Language" />
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete"/>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About"/>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
<center>
<SplitPane fx:id="mainHorizontalSplitPane" dividerPositions="0.6414762741652021" orientation="VERTICAL"
BorderPane.alignment="BOTTOM_CENTER">
<SplitPane fx:id="mainHorizontalSplitPane" dividerPositions="0.6414762741652021" orientation="VERTICAL" BorderPane.alignment="BOTTOM_CENTER">
<items>
<SplitPane dividerPositions="0.5" BorderPane.alignment="CENTER">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<CodeArea fx:id="codeEditorArea" layoutX="-13.0" layoutY="-31.0"
prefHeight="346.0" prefWidth="445.0"
styleClass="code" AnchorPane.bottomAnchor="23.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0"/>
<Button fx:id="refreshASTButton" layoutX="178.0" layoutY="343.0"
mnemonicParsing="false" onAction="#onRefreshASTClicked"
text="Refresh AST" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"/>
<CodeArea fx:id="codeEditorArea" layoutX="-13.0" layoutY="-31.0" prefHeight="346.0" prefWidth="445.0" styleClass="code" AnchorPane.bottomAnchor="23.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
<Button fx:id="refreshASTButton" layoutX="178.0" layoutY="343.0" mnemonicParsing="false" onAction="#onRefreshASTClicked" text="Refresh AST" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TreeView fx:id="astTreeView" layoutX="57.0" layoutY="38.0" prefHeight="200.0"
prefWidth="200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0"/>
<TreeView fx:id="astTreeView" layoutX="57.0" layoutY="38.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
</items>
</SplitPane>
<AnchorPane>
<children>
<TitledPane alignment="BOTTOM_LEFT" prefHeight="220.0" prefWidth="898.0" text="XPath"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"
fx:id="xpathTitlePane">
<TitledPane alignment="BOTTOM_LEFT" prefHeight="220.0" prefWidth="898.0" text="XPath" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" fx:id="xpathTitlePane">
<content>
<SplitPane dividerPositions="0.3169642857142857, 0.6026785714285714">
<SplitPane dividerPositions="0.5, 0.7712">
<items>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0"
prefWidth="100.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<TextArea layoutX="42.0" layoutY="-46.0" prefHeight="200.0"
prefWidth="200.0" promptText="XPath expression..."
styleClass="code" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="20.0"
fx:id="xpathExpressionArea"/>
<Label layoutX="150.0" layoutY="7.0" prefHeight="20.0"
prefWidth="355.0" text="Expression:"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<TextArea layoutX="42.0" layoutY="-46.0" prefHeight="200.0" prefWidth="200.0" promptText="XPath expression..." styleClass="code" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" fx:id="xpathExpressionArea" />
<Label layoutX="150.0" layoutY="7.0" prefHeight="20.0" prefWidth="355.0" text="Expression:" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="10.0"/>
<Insets left="10.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0"
prefWidth="100.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ListView layoutX="34.0" layoutY="24.0" prefHeight="200.0"
prefWidth="200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="20.0"
fx:id="xpathResultListView"/>
<Label layoutX="129.0" layoutY="7.0" prefHeight="20.0"
prefWidth="292.0" text="Matches:"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0" fx:id="xpathResultLabel">
<ListView layoutX="34.0" layoutY="24.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" fx:id="xpathResultListView" />
<Label layoutX="129.0" layoutY="7.0" prefHeight="20.0" prefWidth="292.0" text="Matches:" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" fx:id="xpathResultLabel">
<padding>
<Insets left="10.0"/>
<Insets left="10.0" />
</padding>
</Label>
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0"
prefWidth="100.0">
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
<children>
<ListView layoutX="-9.0" layoutY="-35.0" prefHeight="200.0"
prefWidth="200.0" AnchorPane.bottomAnchor="0.0"
AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="20.0"
fx:id="xpathAttributesListView"/>
<Label layoutX="67.0" layoutY="7.0" prefHeight="21.0"
prefWidth="262.0" text="XPath attributes:"
AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<ListView layoutX="-9.0" layoutY="-35.0" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="20.0" fx:id="xpathAttributesListView" />
<Label layoutX="67.0" layoutY="7.0" prefHeight="21.0" prefWidth="262.0" text="XPath attributes:" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<padding>
<Insets left="10.0"/>
<Insets left="10.0" />
</padding>
</Label>
</children>

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB