mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Add script selection to string viewer
Remove obsolete widget
This commit is contained in:
parent
e907601c11
commit
aa8ce94193
@ -55,7 +55,7 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="pageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
@ -74,9 +74,12 @@
|
||||
<Component id="goToPageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="goToPageTextField" min="-2" pref="79" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="205" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="languageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="languageCombo" min="-2" pref="96" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" alignment="1" pref="622" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="622" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
@ -93,7 +96,11 @@
|
||||
<Component id="nextPageButton" alignment="0" min="-2" pref="23" max="-2" attributes="0"/>
|
||||
<Component id="prevPageButton" alignment="0" min="-2" pref="23" max="-2" attributes="0"/>
|
||||
<Component id="goToPageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="goToPageTextField" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
|
||||
<Component id="goToPageTextField" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="languageCombo" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="languageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="401" max="32767" attributes="0"/>
|
||||
@ -252,6 +259,26 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="goToPageTextFieldActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="languageCombo">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="DataContentViewerString.languageCombo.toolTipText" 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="languageComboActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="languageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="DataContentViewerString.languageLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
|
@ -22,6 +22,7 @@ import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JMenuItem;
|
||||
@ -32,6 +33,8 @@ import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataContentViewer;
|
||||
import org.sleuthkit.autopsy.coreutils.StringExtract;
|
||||
import org.sleuthkit.autopsy.coreutils.StringExtract.StringExtractResult;
|
||||
import org.sleuthkit.autopsy.coreutils.StringExtract.StringExtractUnicodeTable;
|
||||
import org.sleuthkit.autopsy.coreutils.StringExtract.StringExtractUnicodeTable.SCRIPT;
|
||||
import org.sleuthkit.autopsy.datamodel.StringContent;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.FsContent;
|
||||
@ -51,6 +54,9 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
private Content dataSource;
|
||||
// for error handling
|
||||
private String className = this.getClass().toString();
|
||||
|
||||
//string extract utility
|
||||
private final StringExtract stringExtract = new StringExtract();
|
||||
|
||||
/** Creates new form DataContentViewerString */
|
||||
public DataContentViewerString() {
|
||||
@ -73,6 +79,12 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
};
|
||||
copyMenuItem.addActionListener(actList);
|
||||
selectAllMenuItem.addActionListener(actList);
|
||||
|
||||
List<SCRIPT> supportedScripts = StringExtract.getSupportedScripts();
|
||||
for (SCRIPT s : supportedScripts) {
|
||||
languageCombo.addItem(s.toString() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
@ -99,6 +111,8 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
prevPageButton = new javax.swing.JButton();
|
||||
goToPageLabel = new javax.swing.JLabel();
|
||||
goToPageTextField = new javax.swing.JTextField();
|
||||
languageCombo = new javax.swing.JComboBox();
|
||||
languageLabel = new javax.swing.JLabel();
|
||||
|
||||
copyMenuItem.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.copyMenuItem.text")); // NOI18N
|
||||
rightClickMenu.add(copyMenuItem);
|
||||
@ -167,6 +181,15 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
}
|
||||
});
|
||||
|
||||
languageCombo.setToolTipText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.languageCombo.toolTipText")); // NOI18N
|
||||
languageCombo.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
languageComboActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
languageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.languageLabel.text")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
@ -190,8 +213,11 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
.addComponent(goToPageLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(goToPageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(205, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(languageLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(languageCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@ -206,7 +232,10 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
.addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(prevPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(goToPageLabel)
|
||||
.addComponent(goToPageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(goToPageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(languageCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(languageLabel)))
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE))
|
||||
);
|
||||
@ -259,6 +288,13 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
setDataView(dataSource, currentOffset, false);
|
||||
}//GEN-LAST:event_goToPageTextFieldActionPerformed
|
||||
|
||||
private void languageComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languageComboActionPerformed
|
||||
|
||||
if (dataSource != null) {
|
||||
setDataView(dataSource, currentOffset, false);
|
||||
}
|
||||
}//GEN-LAST:event_languageComboActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem copyMenuItem;
|
||||
private javax.swing.JLabel currentPageLabel;
|
||||
@ -266,6 +302,8 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
private javax.swing.JTextField goToPageTextField;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JComboBox languageCombo;
|
||||
private javax.swing.JLabel languageLabel;
|
||||
private javax.swing.JButton nextPageButton;
|
||||
private javax.swing.JLabel ofLabel;
|
||||
private javax.swing.JTextPane outputViewPane;
|
||||
@ -303,8 +341,9 @@ public class DataContentViewerString extends javax.swing.JPanel implements DataC
|
||||
|
||||
if (bytesRead > 0) {
|
||||
//text = DataConversion.getString(data, bytesRead, 4);
|
||||
final StringExtract sr = new StringExtract();
|
||||
StringExtractResult res = sr.extract(data, bytesRead, 0);
|
||||
final String selScript = (String) languageCombo.getSelectedItem();
|
||||
stringExtract.setEnabledScript(StringExtractUnicodeTable.scriptForString(selScript));
|
||||
StringExtractResult res = stringExtract.extract(data, bytesRead, 0);
|
||||
text = res.getText();
|
||||
setVisible = true;
|
||||
}
|
||||
|
@ -1,139 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" 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="false"/>
|
||||
<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="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="pageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="currentPageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="ofLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="totalPageLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="prevPageButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="nextPageButton" min="-2" pref="99" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="filePathLabel" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="574" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</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="filePathLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="pageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="currentPageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="ofLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="totalPageLabel" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="prevPageButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="nextPageButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="337" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="nextPageButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.nextPageButton.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="nextPageButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextPane" name="outputViewPane">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Courier New" size="11" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="prevPageButton">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.prevPageButton.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="prevPageButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="totalPageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.totalPageLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="ofLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.ofLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="currentPageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.currentPageLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="pageLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.pageLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="filePathLabel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/corecomponents/Bundle.properties" key="OutputViewPanel.filePathLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2011 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.corecomponents;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.sleuthkit.autopsy.coreutils.StringExtract;
|
||||
import org.sleuthkit.autopsy.datamodel.DataConversion;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.datamodel.TskException;
|
||||
|
||||
/**
|
||||
* Paging view for DataContentViewer.
|
||||
*/
|
||||
public class OutputViewPanel extends javax.swing.JPanel {
|
||||
|
||||
private static long currentOffset = 0;
|
||||
private static final long pageLength = 10240;
|
||||
private final byte[] data = new byte[(int) pageLength];
|
||||
private static int currentPage = 1;
|
||||
private int outputType;
|
||||
private Content dataSource;
|
||||
|
||||
/**
|
||||
* Creates new form OutputViewPanel
|
||||
*
|
||||
* @param outputType type of panel to display: 1 = hex view, 2 = string view
|
||||
*/
|
||||
public OutputViewPanel(int outputType) {
|
||||
initComponents();
|
||||
this.outputType = outputType;
|
||||
this.dataSource = null;
|
||||
|
||||
// clear / reset the fields
|
||||
filePathLabel.setText("");
|
||||
currentPageLabel.setText("");
|
||||
totalPageLabel.setText("");
|
||||
ofLabel.setVisible(false);
|
||||
prevPageButton.setEnabled(false);
|
||||
nextPageButton.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
|
||||
nextPageButton = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
outputViewPane = new javax.swing.JTextPane();
|
||||
prevPageButton = new javax.swing.JButton();
|
||||
totalPageLabel = new javax.swing.JLabel();
|
||||
ofLabel = new javax.swing.JLabel();
|
||||
currentPageLabel = new javax.swing.JLabel();
|
||||
pageLabel = new javax.swing.JLabel();
|
||||
filePathLabel = new javax.swing.JLabel();
|
||||
|
||||
nextPageButton.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.nextPageButton.text")); // NOI18N
|
||||
nextPageButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
nextPageButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
outputViewPane.setFont(new java.awt.Font("Courier New", 0, 11));
|
||||
jScrollPane1.setViewportView(outputViewPane);
|
||||
|
||||
prevPageButton.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.prevPageButton.text")); // NOI18N
|
||||
prevPageButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
prevPageButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
totalPageLabel.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.totalPageLabel.text")); // NOI18N
|
||||
|
||||
ofLabel.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.ofLabel.text")); // NOI18N
|
||||
|
||||
currentPageLabel.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.currentPageLabel.text")); // NOI18N
|
||||
|
||||
pageLabel.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.pageLabel.text")); // NOI18N
|
||||
|
||||
filePathLabel.setText(org.openide.util.NbBundle.getMessage(OutputViewPanel.class, "OutputViewPanel.filePathLabel.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)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 602, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pageLabel)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(currentPageLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(ofLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(totalPageLabel)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(prevPageButton)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(276, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(filePathLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(574, 574, 574))))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(filePathLabel)
|
||||
.addGap(4, 4, 4)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(pageLabel)
|
||||
.addComponent(currentPageLabel)
|
||||
.addComponent(ofLabel)
|
||||
.addComponent(totalPageLabel)
|
||||
.addComponent(prevPageButton)
|
||||
.addComponent(nextPageButton))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void prevPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevPageButtonActionPerformed
|
||||
//@@@ this is part of the code dealing with the data viewer. could be copied/removed to implement the scrollbar
|
||||
currentOffset -= pageLength;
|
||||
currentPage = currentPage - 1;
|
||||
currentPageLabel.setText(Integer.toString(currentPage));
|
||||
setDataView(dataSource, currentOffset, false, outputType);
|
||||
}//GEN-LAST:event_prevPageButtonActionPerformed
|
||||
|
||||
private void nextPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextPageButtonActionPerformed
|
||||
//@@@ this is part of the code dealing with the data viewer. could be copied/removed to implement the scrollbar
|
||||
currentOffset += pageLength;
|
||||
currentPage = currentPage + 1;
|
||||
currentPageLabel.setText(Integer.toString(currentPage));
|
||||
setDataView(dataSource, currentOffset, false, outputType);
|
||||
}//GEN-LAST:event_nextPageButtonActionPerformed
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel currentPageLabel;
|
||||
private javax.swing.JLabel filePathLabel;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JButton nextPageButton;
|
||||
private javax.swing.JLabel ofLabel;
|
||||
private javax.swing.JTextPane outputViewPane;
|
||||
private javax.swing.JLabel pageLabel;
|
||||
private javax.swing.JButton prevPageButton;
|
||||
private javax.swing.JLabel totalPageLabel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
/**
|
||||
* Sets the DataView (The tabbed panel)
|
||||
*
|
||||
* @param dataSource the content that want to be shown
|
||||
* @param offset the starting offset
|
||||
* @param reset whether to reset the dataView or not
|
||||
* @param outputType the type of the output. 1 = hex view, 2 = string view
|
||||
*/
|
||||
public void setDataView(Content dataSource, long offset, boolean reset, int outputType) {
|
||||
try {
|
||||
this.dataSource = dataSource;
|
||||
|
||||
int bytesRead = 0;
|
||||
if (!reset && dataSource.getSize() > 0) {
|
||||
bytesRead = dataSource.read(data, offset, pageLength); // read the data
|
||||
}
|
||||
|
||||
// I set the -1 to for empty node or directory
|
||||
if (reset) {
|
||||
filePathLabel.setText("");
|
||||
}
|
||||
|
||||
// set the data on the bottom and show it
|
||||
String text = "";
|
||||
Boolean setVisible = false;
|
||||
|
||||
if (bytesRead > 0) {
|
||||
//text = DataConversion.getString(data, bytesRead, 4);
|
||||
final StringExtract sr = new StringExtract();
|
||||
StringExtract.StringExtractResult res = sr.extract(data, bytesRead, 0);
|
||||
text = res.getText();
|
||||
setVisible = true;
|
||||
}
|
||||
|
||||
// disable or enable the next button
|
||||
if (offset + pageLength < dataSource.getSize()) {
|
||||
nextPageButton.setEnabled(true);
|
||||
} else {
|
||||
nextPageButton.setEnabled(false);
|
||||
}
|
||||
|
||||
if (offset == 0) {
|
||||
prevPageButton.setEnabled(false);
|
||||
currentPage = 1; // reset the page number
|
||||
} else {
|
||||
prevPageButton.setEnabled(true);
|
||||
}
|
||||
|
||||
// type 1 = hex view
|
||||
if (outputType == 1) {
|
||||
int showLength = bytesRead < pageLength ? bytesRead : (int) pageLength;
|
||||
outputViewPane.setText(DataConversion.byteArrayToHex(data, showLength, offset, outputViewPane.getFont()));
|
||||
outputViewPane.moveCaretPosition(0);
|
||||
}
|
||||
// type 2 = string view
|
||||
if (outputType == 2) {
|
||||
outputViewPane.setText(text);
|
||||
outputViewPane.moveCaretPosition(0);
|
||||
}
|
||||
|
||||
if (setVisible) {
|
||||
int totalPage = (int) (dataSource.getSize() / pageLength) + 1;
|
||||
ofLabel.setVisible(true);
|
||||
totalPageLabel.setText(Integer.toString(totalPage));
|
||||
currentPageLabel.setText(Integer.toString(currentPage));
|
||||
} else {
|
||||
// reset or hide the labels
|
||||
ofLabel.setVisible(false);
|
||||
totalPageLabel.setText("");
|
||||
currentPageLabel.setText("");
|
||||
}
|
||||
} catch (TskException ex) {
|
||||
// TODO: maybe make bubble instead
|
||||
Logger.getLogger(OutputViewPanel.class.getName()).log(Level.WARNING, "Error while trying to set the display on the ouput view panel.", ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -119,6 +119,10 @@ public class StringExtract {
|
||||
return enabledScripts.contains(script);
|
||||
|
||||
}
|
||||
|
||||
public static List<SCRIPT> getSupportedScripts() {
|
||||
return SUPPORTED_SCRIPTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the byte buffer through the string extractor
|
||||
@ -610,7 +614,7 @@ public class StringExtract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get script given byte value
|
||||
* Lookup and get script given byte value of a potential character
|
||||
*
|
||||
* @param value
|
||||
* @return the script type corresponding to the value
|
||||
@ -644,6 +648,11 @@ public class StringExtract {
|
||||
public static int getScriptValue(SCRIPT script) {
|
||||
return script.ordinal();
|
||||
}
|
||||
|
||||
public static SCRIPT scriptForString(String scriptStringVal) {
|
||||
SCRIPT script = SCRIPT.valueOf(scriptStringVal);
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialization, loads unicode tables
|
||||
|
Loading…
x
Reference in New Issue
Block a user