|
1 | 1 | package com.xwintop.xJavaFxTool.services; |
2 | 2 |
|
| 3 | +import com.jpro.webapi.HTMLView; |
| 4 | +import com.jpro.webapi.WebAPI; |
3 | 5 | import com.xwintop.xJavaFxTool.AppException; |
4 | 6 | import com.xwintop.xJavaFxTool.XJavaFxToolApplication; |
5 | 7 | import com.xwintop.xJavaFxTool.common.logback.ConsoleLogAppender; |
|
17 | 19 | import javafx.event.EventHandler; |
18 | 20 | import javafx.fxml.FXMLLoader; |
19 | 21 | import javafx.scene.Node; |
| 22 | +import javafx.scene.Parent; |
20 | 23 | import javafx.scene.control.Tab; |
21 | 24 | import javafx.scene.control.TabPane; |
22 | 25 | import javafx.scene.control.TextArea; |
|
29 | 32 | import javafx.stage.Stage; |
30 | 33 | import lombok.Data; |
31 | 34 | import lombok.extern.slf4j.Slf4j; |
| 35 | +import org.apache.commons.io.IOUtils; |
32 | 36 | import org.apache.commons.lang3.StringUtils; |
33 | 37 |
|
| 38 | +import java.io.IOException; |
34 | 39 | import java.util.HashMap; |
35 | 40 | import java.util.Locale; |
36 | 41 | import java.util.Map; |
@@ -196,24 +201,32 @@ public static Tab loadIsolatedPluginAsTab(PluginJarInfo plugin, TabPane tabPane, |
196 | 201 | } |
197 | 202 |
|
198 | 203 | public static Tab loadWebViewAsTab(PluginJarInfo plugin, TabPane tabPane, boolean singleWindowBoot) { |
199 | | - WebView browser = new WebView(); |
200 | | - WebEngine webEngine = browser.getEngine(); |
201 | 204 | String url = plugin.getPagePath(); |
202 | 205 | String title = plugin.getTitle(); |
203 | | - |
204 | | -// HTMLView browser = null; |
| 206 | + Parent browser = null; |
205 | 207 | 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 | + } |
209 | 216 | } else { |
210 | 217 | 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 | + |
217 | 230 | } |
218 | 231 |
|
219 | 232 | if (singleWindowBoot) { |
|
0 commit comments