Skip to content

Commit 276079e

Browse files
committed
重构界面逻辑
1 parent c5f13a7 commit 276079e

7 files changed

Lines changed: 147 additions & 103 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,36 @@
11
package com.xwintop.xJavaFxTool.newui;
22

33
import com.xwintop.xJavaFxTool.services.index.SystemSettingService;
4+
import javafx.scene.layout.VBox;
45

56
public class NewLauncherController {
67

8+
public VBox pluginCategories;
9+
710
public void openConfigDialog() {
811
SystemSettingService.openSystemSettings("设置");
912
}
13+
14+
public void initialize() {
15+
16+
for (int i = 0; i < 5; i++) {
17+
PluginCategoryController category =
18+
PluginCategoryController.newInstance("最近使用");
19+
20+
addCategory(category);
21+
22+
for (int j = 0; j < 10; j++) {
23+
PluginItemController item =
24+
PluginItemController.newInstance("临时记事本");
25+
26+
category.addItem(item);
27+
}
28+
29+
}
30+
}
31+
32+
private void addCategory(PluginCategoryController category) {
33+
this.pluginCategories.getChildren().add(category.root);
34+
}
35+
1036
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.xwintop.xJavaFxTool.newui;
2+
3+
import com.xwintop.xcore.javafx.helper.FxmlHelper;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.scene.control.Label;
6+
import javafx.scene.layout.FlowPane;
7+
import javafx.scene.layout.VBox;
8+
9+
public class PluginCategoryController {
10+
11+
public static PluginCategoryController newInstance(String categoryName) {
12+
FXMLLoader fxmlLoader = FxmlHelper.loadFromResource(
13+
"/com/xwintop/xJavaFxTool/fxmlView/newui/plugin-category.fxml"
14+
);
15+
PluginCategoryController controller = fxmlLoader.getController();
16+
controller.lblCategoryName.setText(categoryName);
17+
return controller;
18+
}
19+
20+
///////////////////////////////////////////////////////////////
21+
22+
public Label lblCategoryName;
23+
24+
public FlowPane items;
25+
26+
public VBox root;
27+
28+
public void addItem(PluginItemController item) {
29+
this.items.getChildren().add(item.root);
30+
}
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.xwintop.xJavaFxTool.newui;
2+
3+
import com.xwintop.xcore.javafx.helper.FxmlHelper;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.scene.control.Label;
6+
import javafx.scene.layout.VBox;
7+
8+
public class PluginItemController {
9+
10+
public static PluginItemController newInstance(String pluginName) {
11+
FXMLLoader fxmlLoader = FxmlHelper.loadFromResource(
12+
"/com/xwintop/xJavaFxTool/fxmlView/newui/plugin-item.fxml"
13+
);
14+
PluginItemController controller = fxmlLoader.getController();
15+
controller.setPluginName(pluginName);
16+
return controller;
17+
}
18+
19+
///////////////////////////////////////////////////////////////
20+
21+
public Label pluginName;
22+
23+
public VBox root;
24+
25+
public void initialize() {
26+
// 当元素不可见时也从布局流中去掉
27+
this.root.managedProperty().bind(this.root.visibleProperty());
28+
}
29+
30+
public void setPluginName(String pluginName) {
31+
this.pluginName.setText(pluginName);
32+
}
33+
}

src/main/resources/com/xwintop/xJavaFxTool/fxmlView/newui/main.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@
55
-fx-pref-height: 100;
66
-fx-min-height: -fx-pref-height;
77
-fx-background-color: #f4f4f4;
8-
-fx-padding: 5;
8+
-fx-background-radius: 5;
9+
-fx-padding: 5 5 10 5;
10+
-fx-border-color: transparent;
11+
-fx-border-style: dashed;
12+
-fx-border-width: 1;
13+
-fx-border-radius: 5;
914
}
1015

11-
.app-layout .app-item.placeholder {
12-
-fx-background-color: #AADDFF;
16+
.app-layout .app-item:hover {
17+
-fx-border-color: #aaaaaa;
18+
}
19+
20+
.app-layout .app-item .hyperlink {
21+
-fx-padding: 0;
1322
}
1423

1524
.app-layout .app-item .app-item-title {
@@ -18,6 +27,9 @@
1827
-fx-text-fill: #555555;
1928
}
2029

30+
.app-layout .app-item.placeholder {
31+
}
32+
2133
.app-category-title {
2234
-fx-font-weight: bold;
2335
-fx-text-fill: #888888;

src/main/resources/com/xwintop/xJavaFxTool/fxmlView/newui/main.fxml

Lines changed: 6 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

33
<?import javafx.geometry.Insets?>
4-
<?import javafx.scene.control.Hyperlink?>
5-
<?import javafx.scene.control.Label?>
6-
<?import javafx.scene.control.ScrollPane?>
7-
<?import javafx.scene.control.Tab?>
8-
<?import javafx.scene.control.TabPane?>
9-
<?import javafx.scene.control.TextField?>
10-
<?import javafx.scene.image.Image?>
11-
<?import javafx.scene.image.ImageView?>
12-
<?import javafx.scene.layout.FlowPane?>
13-
<?import javafx.scene.layout.HBox?>
14-
<?import javafx.scene.layout.Pane?>
15-
<?import javafx.scene.layout.VBox?>
4+
<?import javafx.scene.control.*?>
5+
<?import javafx.scene.layout.*?>
166
<VBox prefHeight="600" prefWidth="800" spacing="5"
17-
stylesheets="/com/xwintop/xJavaFxTool/fxmlView/newui/main.css"
18-
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/10.0.2-internal"
19-
fx:controller="com.xwintop.xJavaFxTool.newui.NewLauncherController">
7+
stylesheets="/com/xwintop/xJavaFxTool/fxmlView/newui/main.css"
8+
xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/10.0.2-internal"
9+
fx:controller="com.xwintop.xJavaFxTool.newui.NewLauncherController">
2010

2111
<padding>
2212
<Insets topRightBottomLeft="5" />
@@ -32,91 +22,7 @@
3222
<Pane HBox.hgrow="ALWAYS"/>
3323
<Hyperlink onAction="#openConfigDialog" text="设置" />
3424
</HBox>
35-
<VBox spacing="5" styleClass="app-category">
36-
<Label styleClass="app-category-title" text="最近使用" />
37-
<FlowPane hgap="5" styleClass="app-layout" vgap="5">
38-
<VBox spacing="5" styleClass="app-item">
39-
<HBox alignment="CENTER" VBox.vgrow="ALWAYS">
40-
<ImageView fitWidth="40" fitHeight="40">
41-
<image>
42-
<Image url="/images/icon.jpg"/>
43-
</image>
44-
</ImageView>
45-
</HBox>
46-
<VBox>
47-
<Label text="临时记事本临时记事本临时记事本" styleClass="app-item-title"/>
48-
</VBox>
49-
<HBox spacing="10" alignment="CENTER">
50-
<Hyperlink text="打开应用" style="-fx-font-weight: bold"/>
51-
<Pane HBox.hgrow="ALWAYS"/>
52-
<ImageView fitWidth="16" fitHeight="16" style="-fx-cursor: hand">
53-
<image>
54-
<Image url="/images/help.png"/>
55-
</image>
56-
</ImageView>
57-
</HBox>
58-
</VBox>
59-
<Pane styleClass="app-item,placeholder" />
60-
<Pane styleClass="app-item,placeholder" />
61-
</FlowPane>
62-
</VBox>
63-
<VBox spacing="5" styleClass="app-category">
64-
<Label styleClass="app-category-title" text="文本代码" />
65-
<FlowPane hgap="5" styleClass="app-layout" vgap="5">
66-
<Pane styleClass="app-item,placeholder" />
67-
<Pane styleClass="app-item,placeholder" />
68-
<Pane styleClass="app-item,placeholder" />
69-
<Pane styleClass="app-item,placeholder" />
70-
<Pane styleClass="app-item,placeholder" />
71-
<Pane styleClass="app-item,placeholder" />
72-
<Pane styleClass="app-item,placeholder" />
73-
<Pane styleClass="app-item,placeholder" />
74-
<Pane styleClass="app-item,placeholder" />
75-
</FlowPane>
76-
</VBox>
77-
<VBox spacing="5" styleClass="app-category">
78-
<Label styleClass="app-category-title" text="远程服务" />
79-
<FlowPane hgap="5" styleClass="app-layout" vgap="5">
80-
<Pane styleClass="app-item,placeholder" />
81-
<Pane styleClass="app-item,placeholder" />
82-
<Pane styleClass="app-item,placeholder" />
83-
<Pane styleClass="app-item,placeholder" />
84-
<Pane styleClass="app-item,placeholder" />
85-
<Pane styleClass="app-item,placeholder" />
86-
<Pane styleClass="app-item,placeholder" />
87-
<Pane styleClass="app-item,placeholder" />
88-
<Pane styleClass="app-item,placeholder" />
89-
<Pane styleClass="app-item,placeholder" />
90-
</FlowPane>
91-
</VBox>
92-
<VBox spacing="5" styleClass="app-category">
93-
<Label styleClass="app-category-title" text="图像影音" />
94-
<FlowPane hgap="5" styleClass="app-layout" vgap="5">
95-
<Pane styleClass="app-item,placeholder" />
96-
<Pane styleClass="app-item,placeholder" />
97-
<Pane styleClass="app-item,placeholder" />
98-
<Pane styleClass="app-item,placeholder" />
99-
<Pane styleClass="app-item,placeholder" />
100-
<Pane styleClass="app-item,placeholder" />
101-
<Pane styleClass="app-item,placeholder" />
102-
<Pane styleClass="app-item,placeholder" />
103-
<Pane styleClass="app-item,placeholder" />
104-
<Pane styleClass="app-item,placeholder" />
105-
</FlowPane>
106-
</VBox>
107-
<VBox spacing="5" styleClass="app-category">
108-
<Label styleClass="app-category-title" text="数据库" />
109-
<FlowPane hgap="5" styleClass="app-layout" vgap="5">
110-
<Pane styleClass="app-item,placeholder" />
111-
<Pane styleClass="app-item,placeholder" />
112-
<Pane styleClass="app-item,placeholder" />
113-
<Pane styleClass="app-item,placeholder" />
114-
<Pane styleClass="app-item,placeholder" />
115-
<Pane styleClass="app-item,placeholder" />
116-
<Pane styleClass="app-item,placeholder" />
117-
<Pane styleClass="app-item,placeholder" />
118-
<Pane styleClass="app-item,placeholder" />
119-
</FlowPane>
25+
<VBox fx:id="pluginCategories" alignment="TOP_CENTER">
12026
</VBox>
12127
</VBox>
12228
</ScrollPane>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?import javafx.scene.control.Label?>
2+
<?import javafx.scene.layout.FlowPane?>
3+
<?import javafx.scene.layout.VBox?>
4+
<VBox spacing="5" styleClass="app-category"
5+
fx:controller="com.xwintop.xJavaFxTool.newui.PluginCategoryController"
6+
fx:id="root"
7+
xmlns:fx="http://javafx.com/fxml/1">
8+
<Label styleClass="app-category-title" text="最近使用" fx:id="lblCategoryName"/>
9+
<FlowPane hgap="5" styleClass="app-layout" vgap="5" fx:id="items">
10+
</FlowPane>
11+
</VBox>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?import javafx.scene.control.Hyperlink?>
2+
<?import javafx.scene.control.Label?>
3+
<?import javafx.scene.image.Image?>
4+
<?import javafx.scene.image.ImageView?>
5+
<?import javafx.scene.layout.*?>
6+
<VBox spacing="5" styleClass="app-item"
7+
fx:id="root"
8+
fx:controller="com.xwintop.xJavaFxTool.newui.PluginItemController"
9+
xmlns:fx="http://javafx.com/fxml/1">
10+
<HBox alignment="CENTER" VBox.vgrow="ALWAYS">
11+
<ImageView fitWidth="36" fitHeight="36">
12+
<Image url="/images/icon.jpg"/>
13+
</ImageView>
14+
</HBox>
15+
<HBox alignment="CENTER">
16+
<Label fx:id="pluginName" styleClass="app-item-title"/>
17+
</HBox>
18+
<HBox spacing="10" alignment="CENTER" style="-fx-padding: 0 0 5 0">
19+
<Hyperlink text="打开应用" style="-fx-font-weight: bold"/>
20+
<Pane HBox.hgrow="ALWAYS"/>
21+
<ImageView fitWidth="16" fitHeight="16" style="-fx-cursor: hand">
22+
<Image url="/images/help.png"/>
23+
</ImageView>
24+
</HBox>
25+
</VBox>

0 commit comments

Comments
 (0)