Skip to content

Commit 311ab4e

Browse files
feat(smc): 新增文档链接 (#643)
1 parent ab3c267 commit 311ab4e

File tree

9 files changed

+97
-13
lines changed

9 files changed

+97
-13
lines changed

core/src/main/java/com/tlcsdm/core/javafx/controlsfx/FxAction.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import com.tlcsdm.core.javafx.util.Config;
4343
import com.tlcsdm.core.javafx.util.ConfigureUtil;
4444
import com.tlcsdm.core.javafx.util.JavaFxSystemUtil;
45+
import com.tlcsdm.core.util.CoreConstant;
46+
import com.tlcsdm.core.util.CoreUtil;
4547
import com.tlcsdm.core.util.I18nUtils;
4648
import javafx.event.ActionEvent;
4749
import javafx.scene.Node;
@@ -219,6 +221,24 @@ public static Action openSysConfig(Consumer<ActionEvent> eventHandler) {
219221
return openSysConfig(I18nUtils.get("core.menubar.help.openSysConfigDir"), eventHandler);
220222
}
221223

224+
public static Action api() {
225+
return create("JavaFX", actionEvent -> {
226+
CoreUtil.openWeb(CoreConstant.JAVAFX_API_URL);
227+
}, "/com/tlcsdm/core/static/menubar/jfx.png");
228+
}
229+
230+
public static Action cssApi() {
231+
return create("CSS", actionEvent -> {
232+
CoreUtil.openWeb(CoreConstant.JAVAFX_API_CSS_URL);
233+
}, "/com/tlcsdm/core/static/menubar/css.png");
234+
}
235+
236+
public static Action fxmlApi() {
237+
return create("FXML", actionEvent -> {
238+
CoreUtil.openWeb(CoreConstant.JAVAFX_API_FXML_URL);
239+
}, "/com/tlcsdm/core/static/menubar/fxml.png");
240+
}
241+
222242
public static Action openSysConfig() {
223243
return openSysConfig(actionEvent -> {
224244
VBox vbox = new VBox();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2023 unknowIfGuestInDream
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
* * Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* * Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
* * Neither the name of unknowIfGuestInDream, any associated website, nor the
13+
* names of its contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
* DISCLAIMED. IN NO EVENT SHALL UNKNOWIFGUESTINDREAM BE LIABLE FOR ANY
20+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
package com.tlcsdm.core.util;
29+
30+
/**
31+
* @author: unknowIfGuestInDream
32+
* @date: 2023/8/6 15:45
33+
*/
34+
public class CoreConstant {
35+
36+
/**
37+
* JavaFX API
38+
*/
39+
public static final String JAVAFX_API_URL = "https://openjfx.io/javadoc/17";
40+
41+
/**
42+
* JavaFX CSS API
43+
*/
44+
public static final String JAVAFX_API_CSS_URL = "https://openjfx.io/javadoc/17/javafx.graphics/javafx/scene/doc-files/cssref.html";
45+
46+
/**
47+
* JavaFX FXML API
48+
*/
49+
public static final String JAVAFX_API_FXML_URL = "https://openjfx.io/javadoc/17/javafx.fxml/javafx/fxml/doc-files/introduction_to_fxml.html";
50+
}
379 Bytes
Loading
264 Bytes
Loading
724 Bytes
Loading

frame/src/main/java/com/tlcsdm/frame/FXSampler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import javafx.scene.Node;
6666
import javafx.scene.Scene;
6767
import javafx.scene.control.Label;
68-
import javafx.scene.control.MenuBar;
6968
import javafx.scene.control.TextField;
7069
import javafx.scene.control.TreeCell;
7170
import javafx.scene.control.TreeItem;
@@ -75,6 +74,7 @@
7574
import javafx.scene.layout.AnchorPane;
7675
import javafx.scene.layout.BorderPane;
7776
import javafx.scene.layout.GridPane;
77+
import javafx.scene.layout.HBox;
7878
import javafx.scene.layout.Priority;
7979
import javafx.scene.layout.VBox;
8080
import javafx.scene.paint.Color;
@@ -216,8 +216,8 @@ public void initializeUI() {
216216

217217
// menubar
218218
if (menubarConfigration != null) {
219-
MenuBar menuBar = menubarConfigration.getMenuBar();
220-
bp.setTop(menuBar);
219+
HBox menuBox = menubarConfigration.getMenuBox();
220+
bp.setTop(menuBox);
221221
}
222222

223223
// --- left hand side

frame/src/main/java/com/tlcsdm/frame/service/MenubarConfigration.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727

2828
package com.tlcsdm.frame.service;
2929

30-
import com.tlcsdm.frame.FXSampler;
30+
import javafx.scene.control.Menu;
3131
import javafx.scene.control.MenuBar;
32-
import javafx.stage.Stage;
32+
import javafx.scene.layout.HBox;
33+
import javafx.scene.layout.Priority;
34+
import javafx.scene.layout.Region;
3335

3436
/**
3537
* 菜单栏配置(应用模块实现)
@@ -41,14 +43,18 @@ public interface MenubarConfigration {
4143
MenuBar setMenuBar(MenuBar menuBar);
4244

4345
default MenuBar getMenuBar() {
44-
Stage primaryStage = FXSampler.getStage();
4546
setMenuBar(menuBar);
46-
// 设置菜单条长度
47-
menuBar.setPrefWidth(primaryStage.getWidth());
48-
// 宽度监听设置菜单条长度
49-
menuBar.widthProperty()
50-
.addListener((observable, oldValue, newValue) -> menuBar.setPrefWidth(newValue.doubleValue()));
5147
return menuBar;
5248
}
5349

50+
default HBox getMenuBox() {
51+
MenuBar leftBar = getMenuBar();
52+
MenuBar rightBar = new MenuBar();
53+
rightBar.getMenus().addAll(new Menu("Help"));
54+
Region spacer = new Region();
55+
spacer.getStyleClass().add("menu-bar");
56+
HBox.setHgrow(spacer, Priority.SOMETIMES);
57+
return new HBox(leftBar, spacer);
58+
}
59+
5460
}

qe/src/main/java/com/tlcsdm/qe/provider/QeMenubarConfigrationProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public class QeMenubarConfigrationProvider implements MenubarConfigration {
101101

102102
private final Action openUserData = FxAction.openUserData();
103103

104+
private final Action api = FxAction.api();
105+
private final Action css = FxAction.cssApi();
106+
private final Action fxml = FxAction.fxmlApi();
107+
104108
private final Action about = FxAction.about(actionEvent -> {
105109
Consumer<String> showLink = (string) -> {
106110
if ("openSourceSoftware".equals(string)) {
@@ -167,7 +171,7 @@ public class QeMenubarConfigrationProvider implements MenubarConfigration {
167171
FxActionGroup.file(export, induct, ACTION_SEPARATOR, restart, exit),
168172
FxActionGroup.setting(systemSetting, FxActionGroup.language(chinese, english, japanese)),
169173
FxActionGroup.tool(logConsole, pathWatch, colorPicker, screenshot), FxActionGroup.help(openSysConfig, openLogDir, openUserData, ACTION_SEPARATOR,
170-
contactSupport, submitFeedback, ACTION_SEPARATOR, release, about));
174+
contactSupport, submitFeedback, ACTION_SEPARATOR, api, css, fxml, ACTION_SEPARATOR, release, about));
171175

172176
/**
173177
* 初始化action

smc/src/main/java/com/tlcsdm/smc/provider/SmcMenubarConfigrationProvider.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ public class SmcMenubarConfigrationProvider implements MenubarConfigration {
101101

102102
private final Action openUserData = FxAction.openUserData();
103103

104+
private final Action api = FxAction.api();
105+
private final Action css = FxAction.cssApi();
106+
private final Action fxml = FxAction.fxmlApi();
107+
104108
private final Action about = FxAction.about(actionEvent -> {
105109
Consumer<String> showLink = (string) -> {
106110
if ("openSourceSoftware".equals(string)) {
@@ -167,7 +171,7 @@ public class SmcMenubarConfigrationProvider implements MenubarConfigration {
167171
FxActionGroup.file(export, induct, ACTION_SEPARATOR, restart, exit),
168172
FxActionGroup.setting(systemSetting, FxActionGroup.language(chinese, english, japanese)),
169173
FxActionGroup.tool(logConsole, pathWatch, colorPicker, screenshot), FxActionGroup.help(openSysConfig, openLogDir, openUserData,
170-
ACTION_SEPARATOR, contactSupport, submitFeedback, ACTION_SEPARATOR, release, about));
174+
ACTION_SEPARATOR, contactSupport, submitFeedback, ACTION_SEPARATOR, api, css, fxml, ACTION_SEPARATOR, release, about));
171175

172176
/**
173177
* 初始化action

0 commit comments

Comments
 (0)