19 package com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud;
21 import java.awt.BorderLayout;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.nio.charset.StandardCharsets;
25 import javafx.application.Platform;
26 import javafx.concurrent.Worker.State;
27 import javafx.embed.swing.JFXPanel;
28 import javafx.scene.Scene;
29 import javafx.scene.layout.VBox;
30 import javafx.scene.paint.Color;
31 import javafx.scene.web.WebView;
32 import javax.swing.SwingUtilities;
33 import org.apache.commons.io.IOUtils;
39 class EULADialog
extends javax.swing.JDialog {
41 private static final Logger LOGGER = Logger.
getLogger(EULADialog.class.getName());
42 private static final String EULA_RESOURCE =
"EULA.htm";
44 private boolean acceptPressed =
false;
49 public EULADialog(java.awt.Frame parent,
boolean modal)
throws IOException {
55 boolean isAcceptPressed() {
59 private void loadEULA() throws IOException {
60 InputStream eulaInputStream = EULADialog.class.getResourceAsStream(EULA_RESOURCE);
61 final String htmlString = IOUtils.toString(eulaInputStream, StandardCharsets.UTF_8);
62 final JFXPanel fxPanel =
new JFXPanel();
63 this.viewablePanel.add(fxPanel, BorderLayout.CENTER);
64 Platform.runLater(() -> {
65 WebView webView =
new WebView();
66 webView.setMaxSize(Short.MAX_VALUE, Short.MAX_VALUE);
67 webView.setPrefSize(Short.MAX_VALUE, Short.MAX_VALUE);
68 webView.setMinSize(100, 100);
69 webView.getEngine().getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> {
70 if (newState == State.SUCCEEDED) {
71 SwingUtilities.invokeLater(() -> EULADialog.this.acceptButton.setEnabled(true));
74 webView.getEngine().loadContent(htmlString,
"text/html");
75 VBox root =
new VBox(webView);
76 Scene scene =
new Scene(root, Color.RED);
77 fxPanel.setScene(scene);
86 @SuppressWarnings(
"unchecked")
88 private
void initComponents() {
89 java.awt.GridBagConstraints gridBagConstraints;
91 viewablePanel =
new javax.swing.JPanel();
92 javax.swing.JPanel paddingPanel =
new javax.swing.JPanel();
93 acceptButton =
new javax.swing.JButton();
94 javax.swing.JButton cancelButton =
new javax.swing.JButton();
96 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
97 setTitle(
org.openide.util.NbBundle.getMessage(EULADialog.class,
"EULADialog.title"));
98 setMaximumSize(
new java.awt.Dimension(32767, 32767));
99 setPreferredSize(
new java.awt.Dimension(550, 550));
100 setSize(
new java.awt.Dimension(550, 550));
101 getContentPane().setLayout(
new java.awt.GridBagLayout());
103 viewablePanel.setLayout(
new java.awt.BorderLayout());
104 gridBagConstraints =
new java.awt.GridBagConstraints();
105 gridBagConstraints.gridx = 0;
106 gridBagConstraints.gridy = 0;
107 gridBagConstraints.gridwidth = 3;
108 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
109 gridBagConstraints.weightx = 1.0;
110 gridBagConstraints.weighty = 1.0;
111 gridBagConstraints.insets =
new java.awt.Insets(5, 5, 5, 5);
112 getContentPane().add(viewablePanel, gridBagConstraints);
114 paddingPanel.setMaximumSize(
new java.awt.Dimension(32767, 0));
116 javax.swing.GroupLayout paddingPanelLayout =
new javax.swing.GroupLayout(paddingPanel);
117 paddingPanel.setLayout(paddingPanelLayout);
118 paddingPanelLayout.setHorizontalGroup(
119 paddingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
120 .addGap(0, 0, Short.MAX_VALUE)
122 paddingPanelLayout.setVerticalGroup(
123 paddingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addGap(0, 0, Short.MAX_VALUE)
127 gridBagConstraints =
new java.awt.GridBagConstraints();
128 gridBagConstraints.gridx = 0;
129 gridBagConstraints.gridy = 1;
130 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
131 gridBagConstraints.weightx = 1.0;
132 getContentPane().add(paddingPanel, gridBagConstraints);
134 org.openide.awt.Mnemonics.setLocalizedText(acceptButton,
org.openide.util.NbBundle.getMessage(EULADialog.class,
"EULADialog.acceptButton.text"));
135 acceptButton.setEnabled(
false);
136 acceptButton.addActionListener(
new java.awt.event.ActionListener() {
137 public void actionPerformed(java.awt.event.ActionEvent evt) {
138 acceptButtonActionPerformed(evt);
141 gridBagConstraints =
new java.awt.GridBagConstraints();
142 gridBagConstraints.gridx = 2;
143 gridBagConstraints.gridy = 1;
144 gridBagConstraints.insets =
new java.awt.Insets(0, 0, 5, 5);
145 getContentPane().add(acceptButton, gridBagConstraints);
147 org.openide.awt.Mnemonics.setLocalizedText(cancelButton,
org.openide.util.NbBundle.getMessage(EULADialog.class,
"EULADialog.cancelButton.text"));
148 cancelButton.addActionListener(
new java.awt.event.ActionListener() {
149 public void actionPerformed(java.awt.event.ActionEvent evt) {
150 cancelButtonActionPerformed(evt);
153 gridBagConstraints =
new java.awt.GridBagConstraints();
154 gridBagConstraints.gridx = 1;
155 gridBagConstraints.gridy = 1;
156 gridBagConstraints.insets =
new java.awt.Insets(0, 5, 5, 5);
157 getContentPane().add(cancelButton, gridBagConstraints);
162 private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {
163 acceptPressed =
true;
167 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
172 private javax.swing.JButton acceptButton;
173 private javax.swing.JPanel viewablePanel;
synchronized static Logger getLogger(String name)