mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
More refacturing
This commit is contained in:
parent
d1605852d9
commit
e87c91a40d
@ -15,4 +15,3 @@ ExcelExportAction_runXLSXExport_progressCancelActionTitle=Cancelling...
|
||||
ExcelExportAction_runXLSXExport_progressCancelTitle=Cancel
|
||||
# {0} - dataSource
|
||||
ExcelExportAction_runXLSXExport_progressTitle=Exporting {0} to XLSX
|
||||
ExcelExportDialog_title=Data Source Summary Exported
|
||||
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.report.modules.datasourcesummaryexport;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
|
||||
/**
|
||||
* Basic interface for a cell model.
|
||||
*/
|
||||
interface CellModel {
|
||||
|
||||
/**
|
||||
* Describes the horizontal alignment.
|
||||
*/
|
||||
enum HorizontalAlign {
|
||||
LEFT(JLabel.LEFT, HorizontalAlignment.LEFT),
|
||||
CENTER(JLabel.CENTER, HorizontalAlignment.CENTER),
|
||||
RIGHT(JLabel.RIGHT, HorizontalAlignment.RIGHT);
|
||||
|
||||
private final int jlabelAlignment;
|
||||
private final HorizontalAlignment poiAlignment;
|
||||
|
||||
/**
|
||||
* Constructor for a HorizontalAlign enum.
|
||||
*
|
||||
* @param jlabelAlignment The corresponding JLabel horizontal alignment
|
||||
* number.
|
||||
* @param poiAlignment Horizontal alignment for Apache POI.
|
||||
*/
|
||||
HorizontalAlign(int jlabelAlignment, HorizontalAlignment poiAlignment) {
|
||||
this.jlabelAlignment = jlabelAlignment;
|
||||
this.poiAlignment = poiAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The corresponding JLabel horizontal alignment (i.e.
|
||||
* JLabel.LEFT).
|
||||
*/
|
||||
int getJLabelAlignment() {
|
||||
return this.jlabelAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Horizontal alignment for Apache POI.
|
||||
*/
|
||||
HorizontalAlignment getPoiAlignment() {
|
||||
return poiAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The root data object.
|
||||
*/
|
||||
Object getData();
|
||||
|
||||
/**
|
||||
* @return The text to be shown in the cell.
|
||||
*/
|
||||
default String getText() {
|
||||
Object data = getData();
|
||||
return (data == null) ? null : data.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The horizontal alignment for the text in the cell.
|
||||
*/
|
||||
HorizontalAlign getHorizontalAlignment();
|
||||
}
|
@ -25,7 +25,7 @@ import java.util.function.Function;
|
||||
* getJTablePanel. 'T' represents the object that will represent rows in the
|
||||
* table.
|
||||
*/
|
||||
public class ColumnModel<T, C extends DefaultCellModel> {
|
||||
class ColumnModel<T, C extends CellModel> {
|
||||
|
||||
private final String headerTitle;
|
||||
private final Function<T, ? extends C> cellRenderer;
|
||||
@ -38,7 +38,7 @@ public class ColumnModel<T, C extends DefaultCellModel> {
|
||||
* @param cellRenderer The method that generates a CellModel for the column
|
||||
* based on the data.
|
||||
*/
|
||||
public ColumnModel(String headerTitle, Function<T, ? extends C> cellRenderer) {
|
||||
ColumnModel(String headerTitle, Function<T, ? extends C> cellRenderer) {
|
||||
this(headerTitle, cellRenderer, null);
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ public class ColumnModel<T, C extends DefaultCellModel> {
|
||||
* based on the data.
|
||||
* @param width The preferred width of the column.
|
||||
*/
|
||||
public ColumnModel(String headerTitle, Function<T, ? extends C> cellRenderer, Integer width) {
|
||||
ColumnModel(String headerTitle, Function<T, ? extends C> cellRenderer, Integer width) {
|
||||
this.headerTitle = headerTitle;
|
||||
this.cellRenderer = cellRenderer;
|
||||
this.width = width;
|
||||
@ -59,7 +59,7 @@ public class ColumnModel<T, C extends DefaultCellModel> {
|
||||
/**
|
||||
* @return The title for the column.
|
||||
*/
|
||||
public String getHeaderTitle() {
|
||||
String getHeaderTitle() {
|
||||
return headerTitle;
|
||||
}
|
||||
|
||||
@ -67,14 +67,14 @@ public class ColumnModel<T, C extends DefaultCellModel> {
|
||||
* @return The method that generates a CellModel for the column based on the
|
||||
* data.
|
||||
*/
|
||||
public Function<T, ? extends C> getCellRenderer() {
|
||||
Function<T, ? extends C> getCellRenderer() {
|
||||
return cellRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The preferred width of the column (can be null).
|
||||
*/
|
||||
public Integer getWidth() {
|
||||
Integer getWidth() {
|
||||
return width;
|
||||
}
|
||||
}
|
||||
|
@ -19,64 +19,21 @@
|
||||
package org.sleuthkit.autopsy.report.modules.datasourcesummaryexport;
|
||||
|
||||
import java.util.function.Function;
|
||||
import javax.swing.JLabel;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
|
||||
/**
|
||||
* The default cell model.
|
||||
*/
|
||||
class DefaultCellModel<T> {
|
||||
class DefaultCellModel<T> implements CellModel {
|
||||
|
||||
private final T data;
|
||||
private final String text;
|
||||
private HorizontalAlign horizontalAlignment;
|
||||
private final String excelFormatString;
|
||||
|
||||
/**
|
||||
* Describes the horizontal alignment.
|
||||
*/
|
||||
enum HorizontalAlign {
|
||||
LEFT(JLabel.LEFT, HorizontalAlignment.LEFT),
|
||||
CENTER(JLabel.CENTER, HorizontalAlignment.CENTER),
|
||||
RIGHT(JLabel.RIGHT, HorizontalAlignment.RIGHT);
|
||||
|
||||
private final int jlabelAlignment;
|
||||
private final HorizontalAlignment poiAlignment;
|
||||
|
||||
/**
|
||||
* Constructor for a HorizontalAlign enum.
|
||||
*
|
||||
* @param jlabelAlignment The corresponding JLabel horizontal alignment
|
||||
* number.
|
||||
* @param poiAlignment Horizontal alignment for Apache POI.
|
||||
*/
|
||||
HorizontalAlign(int jlabelAlignment, HorizontalAlignment poiAlignment) {
|
||||
this.jlabelAlignment = jlabelAlignment;
|
||||
this.poiAlignment = poiAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The corresponding JLabel horizontal alignment (i.e.
|
||||
* JLabel.LEFT).
|
||||
*/
|
||||
int getJLabelAlignment() {
|
||||
return this.jlabelAlignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Horizontal alignment for Apache POI.
|
||||
*/
|
||||
HorizontalAlignment getPoiAlignment() {
|
||||
return poiAlignment;
|
||||
}
|
||||
}
|
||||
private CellModel.HorizontalAlign horizontalAlignment;
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
* @param data The data to be displayed in the cell.
|
||||
*/
|
||||
public DefaultCellModel(T data) {
|
||||
DefaultCellModel(T data) {
|
||||
this(data, null, null);
|
||||
}
|
||||
|
||||
@ -87,7 +44,7 @@ class DefaultCellModel<T> {
|
||||
* @param stringConverter The means of converting that data to a string or
|
||||
* null to use .toString method on object.
|
||||
*/
|
||||
public DefaultCellModel(T data, Function<T, String> stringConverter) {
|
||||
DefaultCellModel(T data, Function<T, String> stringConverter) {
|
||||
this(data, stringConverter, null);
|
||||
}
|
||||
|
||||
@ -103,9 +60,8 @@ class DefaultCellModel<T> {
|
||||
* NOTE: Only certain data types can be exported. See
|
||||
* ExcelTableExport.createCell() for types.
|
||||
*/
|
||||
public DefaultCellModel(T data, Function<T, String> stringConverter, String excelFormatString) {
|
||||
DefaultCellModel(T data, Function<T, String> stringConverter, String excelFormatString) {
|
||||
this.data = data;
|
||||
this.excelFormatString = excelFormatString;
|
||||
|
||||
if (stringConverter == null) {
|
||||
text = this.data == null ? "" : this.data.toString();
|
||||
@ -114,18 +70,17 @@ class DefaultCellModel<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public String getExcelFormatString() {
|
||||
return this.excelFormatString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HorizontalAlign getHorizontalAlignment() {
|
||||
return horizontalAlignment;
|
||||
}
|
||||
@ -137,7 +92,7 @@ class DefaultCellModel<T> {
|
||||
*
|
||||
* @return As a utility, returns this.
|
||||
*/
|
||||
public DefaultCellModel<T> setHorizontalAlignment(HorizontalAlign alignment) {
|
||||
DefaultCellModel<T> setHorizontalAlignment(CellModel.HorizontalAlign alignment) {
|
||||
this.horizontalAlignment = alignment;
|
||||
return this;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.report.modules.datasourcesummaryexport.DefaultCellModel.HorizontalAlign;
|
||||
import org.sleuthkit.autopsy.report.modules.datasourcesummaryexport.CellModel.HorizontalAlign;
|
||||
|
||||
/**
|
||||
* Class for handling Excel exporting.
|
||||
@ -337,11 +337,11 @@ public class ExcelExport {
|
||||
* @param cellStyle The style to use.
|
||||
* @return The created cell.
|
||||
*/
|
||||
static Cell createCell(WorksheetEnv env, Row row, int colNum, DefaultCellModel cellModel, Optional<CellStyle> cellStyle) {
|
||||
static Cell createCell(WorksheetEnv env, Row row, int colNum, CellModel cellModel, Optional<CellStyle> cellStyle) {
|
||||
CellStyle cellStyleToUse = cellStyle.orElse(env.getDefaultCellStyle());
|
||||
|
||||
if (cellModel.getExcelFormatString() != null || cellModel.getHorizontalAlignment() != null) {
|
||||
cellStyleToUse = env.getCellStyle(new CellStyleKey(cellModel.getExcelFormatString(), cellStyleToUse, cellModel.getHorizontalAlignment()));
|
||||
if (cellModel.getText() != null || cellModel.getHorizontalAlignment() != null) {
|
||||
cellStyleToUse = env.getCellStyle(new CellStyleKey(cellModel.getText(), cellStyleToUse, cellModel.getHorizontalAlignment()));
|
||||
}
|
||||
|
||||
Object cellData = cellModel.getData();
|
||||
|
@ -285,13 +285,13 @@ class ExcelExportAction implements Consumer<DataSource> {
|
||||
dataSource);
|
||||
|
||||
// and show finished dialog
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
/* ELTODO SwingUtilities.invokeLater(() -> {
|
||||
ExcelExportDialog dialog = new ExcelExportDialog(WindowManager.getDefault().getMainWindow(), path);
|
||||
dialog.setResizable(false);
|
||||
dialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow());
|
||||
dialog.setVisible(true);
|
||||
dialog.toFront();
|
||||
});
|
||||
});*/
|
||||
|
||||
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||
logger.log(Level.WARNING, "There was an error attaching report to case.", ex);
|
||||
|
@ -1,111 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="linkTextScrollPane" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="116" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="titleLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="linkTextScrollPane" min="-2" pref="39" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="okButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="titleLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="ExcelExportDialog.titleLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="okButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="ExcelExportDialog.okButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="okButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="linkTextScrollPane">
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="linkText">
|
||||
<Properties>
|
||||
<Property name="editable" type="boolean" value="false"/>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="java.awt.Color.BLUE" type="code"/>
|
||||
</Property>
|
||||
<Property name="lineWrap" type="boolean" value="true"/>
|
||||
<Property name="rows" type="int" value="1"/>
|
||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="null"/>
|
||||
</Property>
|
||||
<Property name="opaque" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.report.modules.datasourcesummaryexport;
|
||||
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.SwingUtilities;
|
||||
import org.openide.util.NbBundle.Messages;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
|
||||
/**
|
||||
* Dialog showing where the data source summary excel export can be located.
|
||||
*/
|
||||
@Messages({
|
||||
"ExcelExportDialog_title=Data Source Summary Exported"
|
||||
})
|
||||
public class ExcelExportDialog extends javax.swing.JDialog {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ExcelExportDialog.class.getName());
|
||||
|
||||
/**
|
||||
* Creates new form ExcelExportDialog
|
||||
*/
|
||||
public ExcelExportDialog(java.awt.Frame parent, File filePath) {
|
||||
super(parent, true);
|
||||
|
||||
initComponents();
|
||||
setTitle(Bundle.ExcelExportDialog_title());
|
||||
|
||||
this.linkText.setText(filePath.getAbsolutePath());
|
||||
this.linkText.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try {
|
||||
Desktop.getDesktop().open(filePath);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.WARNING, "Unable to open: " + filePath.getAbsolutePath(), ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
this.linkText.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.JLabel titleLabel = new javax.swing.JLabel();
|
||||
javax.swing.JButton okButton = new javax.swing.JButton();
|
||||
javax.swing.JScrollPane linkTextScrollPane = new javax.swing.JScrollPane();
|
||||
linkText = new javax.swing.JTextArea();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(titleLabel, org.openide.util.NbBundle.getMessage(ExcelExportDialog.class, "ExcelExportDialog.titleLabel.text")); // NOI18N
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(ExcelExportDialog.class, "ExcelExportDialog.okButton.text")); // NOI18N
|
||||
okButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
okButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
linkText.setEditable(false);
|
||||
linkText.setBackground(null);
|
||||
linkText.setColumns(20);
|
||||
linkText.setForeground(java.awt.Color.BLUE);
|
||||
linkText.setLineWrap(true);
|
||||
linkText.setRows(1);
|
||||
linkText.setWrapStyleWord(true);
|
||||
linkText.setBorder(null);
|
||||
linkText.setOpaque(false);
|
||||
linkTextScrollPane.setViewportView(linkText);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(linkTextScrollPane)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(okButton))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addComponent(titleLabel)
|
||||
.addGap(0, 116, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(titleLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(linkTextScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(okButton)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
|
||||
dispose();
|
||||
}//GEN-LAST:event_okButtonActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JTextArea linkText;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -32,7 +32,7 @@ import org.sleuthkit.autopsy.report.modules.datasourcesummaryexport.ExcelSpecial
|
||||
/**
|
||||
* An excel sheet export of table data.
|
||||
*/
|
||||
public class ExcelTableExport<T, C extends DefaultCellModel> implements ExcelSheetExport, ExcelItemExportable {
|
||||
class ExcelTableExport<T, C extends CellModel> implements ExcelSheetExport, ExcelItemExportable {
|
||||
|
||||
private final String sheetName;
|
||||
private final List<ColumnModel<T, C>> columns;
|
||||
@ -47,7 +47,7 @@ public class ExcelTableExport<T, C extends DefaultCellModel> implements ExcelShe
|
||||
* @param columns The columns of the table.
|
||||
* @param data The data to export.
|
||||
*/
|
||||
public ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data) {
|
||||
ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data) {
|
||||
this(sheetName, columns, data, 0);
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public class ExcelTableExport<T, C extends DefaultCellModel> implements ExcelShe
|
||||
* @param data The data to export.
|
||||
* @param columnIndent The column indent.
|
||||
*/
|
||||
public ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data, int columnIndent) {
|
||||
ExcelTableExport(String sheetName, List<ColumnModel<T, C>> columns, List<T> data, int columnIndent) {
|
||||
this.sheetName = sheetName;
|
||||
this.columns = columns;
|
||||
this.data = data;
|
||||
@ -104,7 +104,7 @@ public class ExcelTableExport<T, C extends DefaultCellModel> implements ExcelShe
|
||||
* @throws ExcelExportException
|
||||
* @return The number of rows (including the header) written.
|
||||
*/
|
||||
private static <T, C extends DefaultCellModel> int renderSheet(
|
||||
private static <T, C extends CellModel> int renderSheet(
|
||||
Sheet sheet,
|
||||
ExcelExport.WorksheetEnv worksheetEnv,
|
||||
int rowStart,
|
||||
@ -127,8 +127,8 @@ public class ExcelTableExport<T, C extends DefaultCellModel> implements ExcelShe
|
||||
T rowData = safeData.get(rowNum);
|
||||
Row row = sheet.createRow(rowNum + rowStart + 1);
|
||||
for (int colNum = 0; colNum < columns.size(); colNum++) {
|
||||
ColumnModel<T, ? extends DefaultCellModel> colModel = columns.get(colNum);
|
||||
DefaultCellModel cellModel = colModel.getCellRenderer().apply(rowData);
|
||||
ColumnModel<T, ? extends CellModel> colModel = columns.get(colNum);
|
||||
CellModel cellModel = colModel.getCellRenderer().apply(rowData);
|
||||
ExcelExport.createCell(worksheetEnv, row, colNum + colStart, cellModel, Optional.empty());
|
||||
}
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="xlsxExportMessage" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="xlsxExportButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="62" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="xlsxExportMessage" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="xlsxExportButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="250" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="xlsxExportButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="ExportPanel.xlsxExportButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="xlsxExportButtonActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="xlsxExportMessage">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties" key="ExportPanel.xlsxExportMessage.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2021 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.report.modules.datasourcesummaryexport;
|
||||
|
||||
/**
|
||||
* The panel that provides options for exporting data source summary data.
|
||||
*/
|
||||
public class ExportPanel extends javax.swing.JPanel {
|
||||
|
||||
private Runnable xlsxExportAction;
|
||||
|
||||
/**
|
||||
* Creates new form ExportPanel
|
||||
*/
|
||||
public ExportPanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the action that handles exporting to excel.
|
||||
*
|
||||
* @return The action that handles exporting to excel.
|
||||
*/
|
||||
public Runnable getXlsxExportAction() {
|
||||
return xlsxExportAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the action that handles exporting to excel.
|
||||
*
|
||||
* @param onXlsxExport The action that handles exporting to excel.
|
||||
*/
|
||||
public void setXlsxExportAction(Runnable onXlsxExport) {
|
||||
this.xlsxExportAction = onXlsxExport;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.JButton xlsxExportButton = new javax.swing.JButton();
|
||||
javax.swing.JLabel xlsxExportMessage = new javax.swing.JLabel();
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(xlsxExportButton, org.openide.util.NbBundle.getMessage(ExportPanel.class, "ExportPanel.xlsxExportButton.text")); // NOI18N
|
||||
xlsxExportButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
xlsxExportButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
org.openide.awt.Mnemonics.setLocalizedText(xlsxExportMessage, org.openide.util.NbBundle.getMessage(ExportPanel.class, "ExportPanel.xlsxExportMessage.text")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(xlsxExportMessage)
|
||||
.addComponent(xlsxExportButton))
|
||||
.addContainerGap(62, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(xlsxExportMessage)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(xlsxExportButton)
|
||||
.addContainerGap(250, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void xlsxExportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xlsxExportButtonActionPerformed
|
||||
if (this.xlsxExportAction != null) {
|
||||
xlsxExportAction.run();
|
||||
}
|
||||
}//GEN-LAST:event_xlsxExportButtonActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user