Autopsy  4.20.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
EULADialog.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2023 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package com.basistech.df.cybertriage.autopsy.ctoptions.ctcloud;
20 
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;
35 
39 public class EULADialog extends javax.swing.JDialog {
40 
41  private static final Logger LOGGER = Logger.getLogger(EULADialog.class.getName());
42  private static final String EULA_RESOURCE = "EULA.htm";
43 
44  private boolean acceptPressed = false;
45 
49  public EULADialog(java.awt.Frame parent, boolean modal) throws IOException {
50  super(parent, modal);
52  loadEULA();
53  }
54 
55  boolean isAcceptPressed() {
56  return acceptPressed;
57  }
58 
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));
72  }
73  });
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);
78  });
79  }
80 
86  @SuppressWarnings("unchecked")
87  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
88  private void initComponents() {
89  java.awt.GridBagConstraints gridBagConstraints;
90 
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();
95 
96  setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
97  setTitle(org.openide.util.NbBundle.getMessage(EULADialog.class, "EULADialog.title")); // NOI18N
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());
102 
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);
113 
114  paddingPanel.setMaximumSize(new java.awt.Dimension(32767, 0));
115 
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)
121  );
122  paddingPanelLayout.setVerticalGroup(
123  paddingPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124  .addGap(0, 0, Short.MAX_VALUE)
125  );
126 
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);
133 
134  org.openide.awt.Mnemonics.setLocalizedText(acceptButton, org.openide.util.NbBundle.getMessage(EULADialog.class, "EULADialog.acceptButton.text")); // NOI18N
135  acceptButton.setEnabled(false);
136  acceptButton.addActionListener(new java.awt.event.ActionListener() {
137  public void actionPerformed(java.awt.event.ActionEvent evt) {
139  }
140  });
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);
146 
147  org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(EULADialog.class, "EULADialog.cancelButton.text")); // NOI18N
148  cancelButton.addActionListener(new java.awt.event.ActionListener() {
149  public void actionPerformed(java.awt.event.ActionEvent evt) {
151  }
152  });
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);
158 
159  pack();
160  }// </editor-fold>//GEN-END:initComponents
161 
162  private void acceptButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acceptButtonActionPerformed
163  acceptPressed = true;
164  dispose();
165  }//GEN-LAST:event_acceptButtonActionPerformed
166 
167  private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
168  dispose();
169  }//GEN-LAST:event_cancelButtonActionPerformed
170 
171  // Variables declaration - do not modify//GEN-BEGIN:variables
172  private javax.swing.JButton acceptButton;
173  private javax.swing.JPanel viewablePanel;
174  // End of variables declaration//GEN-END:variables
175 }
void acceptButtonActionPerformed(java.awt.event.ActionEvent evt)
void cancelButtonActionPerformed(java.awt.event.ActionEvent evt)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2022 Basis Technology. Generated on: Tue Aug 1 2023
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.