Skip to content

Commit 8e427d9

Browse files
committed
1.添加jpro支持
1 parent a2d270e commit 8e427d9

6 files changed

Lines changed: 89 additions & 46 deletions

File tree

build.gradle

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
4-
maven {
5-
allowInsecureProtocol = true
6-
url "https://plugins.gradle.org/m2/"
7-
}
8-
}
1+
//buildscript {
2+
// repositories {
3+
// mavenCentral()
4+
// maven {
5+
// allowInsecureProtocol = true
6+
// url "https://plugins.gradle.org/m2/"
7+
// }
8+
// }
99
// dependencies {
1010
// classpath 'org.openjfx:javafx-plugin:0.1.0'
1111
// }
12-
}
12+
//}
1313

1414
plugins {
1515
id "org.gradlex.extra-java-module-info" version "1.7"
16-
// id "org.beryx.jlink" version "2.26.0"
1716
id "org.openjfx.javafxplugin" version "0.1.0"
18-
id "com.gluonhq.gluonfx-gradle-plugin" version "1.0.22"
1917
id 'idea'
2018
id 'application'
2119
id 'maven-publish'
2220
}
23-
allprojects {
21+
subprojects {
2422
ext {
2523
springBootVersion = "2.7.18"
2624
}
@@ -30,7 +28,7 @@ allprojects {
3028
apply plugin: 'application'
3129
apply plugin: 'maven-publish' // 引入maven插件
3230
apply plugin: 'org.openjfx.javafxplugin'
33-
sourceCompatibility = 17
31+
// sourceCompatibility = 17
3432
test {//跳过测试
3533
enabled = false
3634
}
@@ -58,16 +56,16 @@ allprojects {
5856
annotationProcessor 'org.projectlombok:lombok:1.18.30'
5957
testCompileOnly 'org.projectlombok:lombok:1.18.30'
6058
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
61-
// api 'org.openjfx:javafx-controls:21.0.1'
62-
// api 'org.openjfx:javafx-base:21.0.1'
63-
// api 'org.openjfx:javafx-graphics:21.0.1'
64-
// api 'org.openjfx:javafx-fxml:21.0.1'
65-
// api 'org.openjfx:javafx-swing:21.0.1'
66-
// api 'org.openjfx:javafx-media:21.0.1'
67-
// api 'org.openjfx:javafx-web:21.0.1'
59+
// api 'org.openjfx:javafx-controls:21.0.2'
60+
// api 'org.openjfx:javafx-base:21.0.2'
61+
// api 'org.openjfx:javafx-graphics:21.0.2'
62+
// api 'org.openjfx:javafx-fxml:21.0.2'
63+
// api 'org.openjfx:javafx-swing:21.0.2'
64+
// api 'org.openjfx:javafx-media:21.0.2'
65+
// api 'org.openjfx:javafx-web:21.0.2'
6866
}
6967
javafx {
70-
version = "21.0.1"
68+
version = "21.0.2"
7169
modules = ['javafx.controls', "javafx.graphics", 'javafx.fxml', 'javafx.media', 'javafx.swing', 'javafx.web']
7270
// configuration = 'compileOnly'
7371
}

xJavaFxTool/build.gradle

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
maven {
5+
allowInsecureProtocol = true
6+
url "https://sandec.jfrog.io/artifactory/repo"
7+
}
8+
}
9+
10+
dependencies {
11+
classpath "one.jpro:jpro-gradle-plugin:2024.1.0"
12+
}
13+
}
114
plugins {
215
// id "org.beryx.jlink" version "2.26.0"
316
id 'org.beryx.runtime' version '1.12.7'
4-
id "org.openjfx.javafxplugin" version "0.1.0"
517
id "com.gluonhq.gluonfx-gradle-plugin" version "1.0.22"
618
}
719

20+
apply plugin: 'jpro-gradle-plugin'
21+
822
dependencies {
923
api project(':xcore')
24+
implementation "com.sandec.jpro:jpro-webapi:2024.1.0"
1025
// api project(":littleTools:x-EncryptAndDecrypt")
1126
// api project(":littleTools:x-ZHConverter")
1227
// api project(":littleTools:x-ImageTool")
@@ -87,13 +102,13 @@ version = '1.2.3'
87102
description = 'xJavaFxTool'
88103

89104
compileJava {
90-
options.compilerArgs += ['--module-path', classpath.asPath]
105+
// options.compilerArgs += ['--module-path', classpath.asPath]
91106
}
92107

93108
application {
94109
applicationName = "xJavaFxTool"
95110
mainModule.set("com.xwintop.xJavaFxTool")
96-
mainClass.set("com.xwintop.xJavaFxTool.XJavaFxToolMain")
111+
mainClass.set("com.xwintop.xJavaFxTool.XJavaFxToolApplication")
97112
applicationDefaultJvmArgs = [
98113
// ZGC
99114
"-XX:+UseZGC",
@@ -159,4 +174,12 @@ runtime {
159174
// installerName = application.applicationName
160175
// appVersion = version.toString()
161176
// }
162-
//}
177+
//}
178+
179+
gluonfx {
180+
mainClassName = "com.xwintop.xJavaFxTool.XJavaFxToolMain"
181+
}
182+
183+
jpro {
184+
port = 8080
185+
}

xJavaFxTool/src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.xwintop.xJavaFxTool.controller;
22

3+
import com.jpro.webapi.HTMLView;
4+
import com.jpro.webapi.WebAPI;
35
import com.xwintop.xJavaFxTool.XJavaFxToolApplication;
46
import com.xwintop.xJavaFxTool.controller.index.PluginManageController;
57
import com.xwintop.xJavaFxTool.controller.plugin.PluginCategoryController;
@@ -29,6 +31,8 @@
2931
import javafx.scene.control.Tab;
3032
import javafx.scene.image.Image;
3133
import javafx.scene.image.ImageView;
34+
import javafx.scene.web.WebEngine;
35+
import javafx.scene.web.WebView;
3236
import lombok.Getter;
3337
import lombok.Setter;
3438
import lombok.extern.slf4j.Slf4j;
@@ -82,7 +86,15 @@ private void initView() {
8286
addNodepadAction(null);
8387
}
8488
this.indexService.addWebView(XJavaFxToolApplication.RESOURCE_BUNDLE.getString("feedback"), QQ_URL, null);
85-
this.tongjiWebView.getEngine().load(STATISTICS_URL);
89+
if (WebAPI.isBrowser()) {
90+
String contentIframe2 = "<iframe frameborder=\"0\" style=\"width: 100%; height: 100%;\" src=\"" + STATISTICS_URL + "\"> </iframe>";
91+
HTMLView browser = new HTMLView(contentIframe2);
92+
pluginCategories.getChildren().add(browser);
93+
} else {
94+
WebView browser = new WebView();
95+
WebEngine webEngine = browser.getEngine();
96+
webEngine.load(STATISTICS_URL);
97+
}
8698
this.tabPaneMain.getSelectionModel().select(0);
8799
}
88100

xJavaFxTool/src/main/java/com/xwintop/xJavaFxTool/services/IndexService.java

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.xwintop.xJavaFxTool.services;
22

3+
import com.jpro.webapi.HTMLView;
4+
import com.jpro.webapi.WebAPI;
35
import com.xwintop.xJavaFxTool.AppException;
46
import com.xwintop.xJavaFxTool.XJavaFxToolApplication;
57
import com.xwintop.xJavaFxTool.common.logback.ConsoleLogAppender;
@@ -17,6 +19,7 @@
1719
import javafx.event.EventHandler;
1820
import javafx.fxml.FXMLLoader;
1921
import javafx.scene.Node;
22+
import javafx.scene.Parent;
2023
import javafx.scene.control.Tab;
2124
import javafx.scene.control.TabPane;
2225
import javafx.scene.control.TextArea;
@@ -29,8 +32,10 @@
2932
import javafx.stage.Stage;
3033
import lombok.Data;
3134
import lombok.extern.slf4j.Slf4j;
35+
import org.apache.commons.io.IOUtils;
3236
import org.apache.commons.lang3.StringUtils;
3337

38+
import java.io.IOException;
3439
import java.util.HashMap;
3540
import java.util.Locale;
3641
import java.util.Map;
@@ -196,24 +201,32 @@ public static Tab loadIsolatedPluginAsTab(PluginJarInfo plugin, TabPane tabPane,
196201
}
197202

198203
public static Tab loadWebViewAsTab(PluginJarInfo plugin, TabPane tabPane, boolean singleWindowBoot) {
199-
WebView browser = new WebView();
200-
WebEngine webEngine = browser.getEngine();
201204
String url = plugin.getPagePath();
202205
String title = plugin.getTitle();
203-
204-
// HTMLView browser = null;
206+
Parent browser = null;
205207
if (url.startsWith("http")) {
206-
webEngine.load(url);
207-
// String contentIframe2 = "<iframe frameborder=\"0\" style=\"width: 100%; height: 100%;\" src=\"" + url + "\"> </iframe>";
208-
// browser = new HTMLView(contentIframe2);
208+
if (WebAPI.isBrowser()) {
209+
String contentIframe2 = "<iframe frameborder=\"0\" style=\"width: 100%; height: 100%;\" src=\"" + url + "\"> </iframe>";
210+
browser = new HTMLView(contentIframe2);
211+
} else {
212+
browser = new WebView();
213+
WebEngine webEngine = ((WebView)browser).getEngine();
214+
webEngine.load(url);
215+
}
209216
} else {
210217
PluginContainer pluginContainer = new PluginContainer(plugin);
211-
webEngine.load(pluginContainer.getResource(url).toExternalForm());
212-
// try {
213-
// browser = new HTMLView(IOUtils.toString(pluginContainer.getResource(url).openStream(), "utf-8"));
214-
// } catch (IOException e) {
215-
// throw new RuntimeException(e);
216-
// }
218+
if (WebAPI.isBrowser()) {
219+
try {
220+
browser = new HTMLView(IOUtils.toString(pluginContainer.getResource(url).openStream(), "utf-8"));
221+
} catch (IOException e) {
222+
throw new RuntimeException(e);
223+
}
224+
} else {
225+
browser = new WebView();
226+
WebEngine webEngine = ((WebView)browser).getEngine();
227+
webEngine.load(pluginContainer.getResource(url).toExternalForm());
228+
}
229+
217230
}
218231

219232
if (singleWindowBoot) {

xJavaFxTool/src/main/java/com/xwintop/xJavaFxTool/view/IndexView.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
package com.xwintop.xJavaFxTool.view;
22

3-
import java.util.ResourceBundle;
4-
53
import javafx.fxml.FXML;
64
import javafx.fxml.Initializable;
75
import javafx.scene.control.*;
86
import javafx.scene.layout.VBox;
9-
import javafx.scene.web.WebView;
107
import lombok.Getter;
118
import lombok.Setter;
129

10+
import java.util.ResourceBundle;
11+
1312
@Getter
1413
@Setter
1514
public abstract class IndexView implements Initializable {
@@ -38,8 +37,8 @@ public abstract class IndexView implements Initializable {
3837
@FXML
3938
protected Menu helpMenu;
4039

41-
@FXML
42-
protected WebView tongjiWebView;
40+
// @FXML
41+
// protected WebView tongjiWebView;
4342

4443
@FXML
4544
protected VBox pluginCategories;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<?import javafx.geometry.Insets?>
44
<?import javafx.scene.control.*?>
55
<?import javafx.scene.layout.*?>
6-
<?import javafx.scene.web.WebView?>
76
<AnchorPane prefHeight="654.0" prefWidth="1044.0" stylesheets="/com/xwintop/xJavaFxTool/fxmlView/plugin/main.css"
87
xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1"
98
fx:controller="com.xwintop.xJavaFxTool.controller.IndexController">
@@ -69,7 +68,6 @@
6968
</padding>
7069
</Label>
7170
<TextField fx:id="myTextField" promptText="%selectTextField" styleClass="search-text"/>
72-
<WebView fx:id="tongjiWebView" prefHeight="1.0" prefWidth="1.0" visible="false"/>
7371
<Pane HBox.hgrow="ALWAYS"/>
7472
<Hyperlink onAction="#xwintopLinkOnAction" text="http://gitee.com/xwintop/xJavaFxTool"
7573
textFill="#868686"/>

0 commit comments

Comments
 (0)