mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
Code cleanup, update UI to disable 'across data sources' radio button instead of disabling common files search altogether when open case has one datasource.
This commit is contained in:
parent
640cec499c
commit
c57cb7da8c
@ -31,7 +31,7 @@
|
||||
<Component id="selectDataSourceComboBox" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="searchButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="withinDataSourceRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="allDatasourcesRadio" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="allDataSourcesRadioButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="26" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@ -40,7 +40,7 @@
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="allDatasourcesRadio" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="allDataSourcesRadioButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
|
||||
<Component id="withinDataSourceRadioButton" min="-2" pref="41" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
@ -64,19 +64,19 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="allDatasourcesRadio">
|
||||
<Component class="javax.swing.JRadioButton" name="allDataSourcesRadioButton">
|
||||
<Properties>
|
||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||
<ComponentRef name="dataSourcesButtonGroup"/>
|
||||
</Property>
|
||||
<Property name="selected" type="boolean" value="true"/>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/commonfilesearch/Bundle.properties" key="CommonFilesPanel.allDatasourcesRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
<ResourceString bundle="org/sleuthkit/autopsy/commonfilesearch/Bundle.properties" key="CommonFilesPanel.allDataSourcesRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allDatasourcesRadioActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allDataSourcesRadioButtonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JRadioButton" name="withinDataSourceRadioButton">
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.commonfilesearch;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import static java.awt.event.ItemEvent.SELECTED;
|
||||
import java.sql.ResultSet;
|
||||
@ -78,8 +79,21 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
||||
}
|
||||
this.dataSourcesList = new DataSourceComboBoxModel(dataSourcesNames);
|
||||
initComponents();
|
||||
updateUIButtons();
|
||||
}
|
||||
private void updateUIButtons() {
|
||||
boolean multipleDataSources = this.caseHasMultipleSources();
|
||||
allDataSourcesRadioButton.setEnabled(multipleDataSources);
|
||||
allDataSourcesRadioButton.setSelected(false);
|
||||
if(!multipleDataSources) {
|
||||
withinDataSourceRadioButton.setSelected(true);
|
||||
withinDataSourceSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean caseHasMultipleSources(){
|
||||
return dataSourceMap.size() >= 2;
|
||||
}
|
||||
private void buildDataSourceMap(Map<Long, String> dataSourceMap) throws TskCoreException, NoCurrentCaseException, SQLException {
|
||||
Case currentCase = Case.getOpenCase();
|
||||
SleuthkitCase tskDb = currentCase.getSleuthkitCase();
|
||||
@ -233,7 +247,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
||||
|
||||
dataSourcesButtonGroup = new javax.swing.ButtonGroup();
|
||||
searchButton = new javax.swing.JButton();
|
||||
allDatasourcesRadio = new javax.swing.JRadioButton();
|
||||
allDataSourcesRadioButton = new javax.swing.JRadioButton();
|
||||
withinDataSourceRadioButton = new javax.swing.JRadioButton();
|
||||
selectDataSourceComboBox = new javax.swing.JComboBox<>();
|
||||
|
||||
@ -247,13 +261,13 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
dataSourcesButtonGroup.add(allDatasourcesRadio);
|
||||
allDatasourcesRadio.setSelected(true);
|
||||
org.openide.awt.Mnemonics.setLocalizedText(allDatasourcesRadio, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allDatasourcesRadio.text")); // NOI18N
|
||||
allDatasourcesRadio.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
allDatasourcesRadio.addActionListener(new java.awt.event.ActionListener() {
|
||||
dataSourcesButtonGroup.add(allDataSourcesRadioButton);
|
||||
allDataSourcesRadioButton.setSelected(true);
|
||||
org.openide.awt.Mnemonics.setLocalizedText(allDataSourcesRadioButton, org.openide.util.NbBundle.getMessage(CommonFilesPanel.class, "CommonFilesPanel.allDataSourcesRadioButton.text")); // NOI18N
|
||||
allDataSourcesRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
allDataSourcesRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
allDatasourcesRadioActionPerformed(evt);
|
||||
allDataSourcesRadioButtonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@ -284,13 +298,13 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
||||
.addComponent(selectDataSourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(searchButton)
|
||||
.addComponent(withinDataSourceRadioButton)
|
||||
.addComponent(allDatasourcesRadio))
|
||||
.addComponent(allDataSourcesRadioButton))
|
||||
.addContainerGap(26, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(allDatasourcesRadio)
|
||||
.addComponent(allDataSourcesRadioButton)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(withinDataSourceRadioButton, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
@ -305,24 +319,30 @@ public final class CommonFilesPanel extends javax.swing.JPanel {
|
||||
search();
|
||||
}//GEN-LAST:event_searchButtonActionPerformed
|
||||
|
||||
private void allDatasourcesRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allDatasourcesRadioActionPerformed
|
||||
selectDataSourceComboBox.setEnabled(evt.getID() == SELECTED);
|
||||
private void allDataSourcesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allDataSourcesRadioButtonActionPerformed
|
||||
selectDataSourceComboBox.setEnabled(!allDataSourcesRadioButton.isSelected());
|
||||
singleDataSource = false;
|
||||
|
||||
}//GEN-LAST:event_allDatasourcesRadioActionPerformed
|
||||
}//GEN-LAST:event_allDataSourcesRadioButtonActionPerformed
|
||||
|
||||
private void selectDataSourceComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectDataSourceComboBoxActionPerformed
|
||||
selectedDataSource = selectDataSourceComboBox.getSelectedItem().toString();
|
||||
}//GEN-LAST:event_selectDataSourceComboBoxActionPerformed
|
||||
|
||||
private void withinDataSourceRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_withinDataSourceRadioButtonActionPerformed
|
||||
selectDataSourceComboBox.setEnabled(evt.getID() != SELECTED);
|
||||
singleDataSource = true;
|
||||
withinDataSourceSelected(withinDataSourceRadioButton.isSelected());
|
||||
}//GEN-LAST:event_withinDataSourceRadioButtonActionPerformed
|
||||
|
||||
private void withinDataSourceSelected(boolean selected) {
|
||||
selectDataSourceComboBox.setEnabled(selected);
|
||||
if(selectDataSourceComboBox.isEnabled()) {
|
||||
selectDataSourceComboBox.setSelectedIndex(0);
|
||||
singleDataSource = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JRadioButton allDatasourcesRadio;
|
||||
private javax.swing.JRadioButton allDataSourcesRadioButton;
|
||||
private javax.swing.ButtonGroup dataSourcesButtonGroup;
|
||||
private javax.swing.JButton searchButton;
|
||||
private javax.swing.JComboBox<String> selectDataSourceComboBox;
|
||||
|
@ -19,17 +19,10 @@
|
||||
package org.sleuthkit.autopsy.commonfilesearch;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.EnumSet;
|
||||
import java.util.logging.Level;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CallableSystemAction;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Encapsulates a menu action which triggers the common files search dialog.
|
||||
@ -43,23 +36,8 @@ final class CommonFilesSearchAction extends CallableSystemAction {
|
||||
|
||||
CommonFilesSearchAction() {
|
||||
super();
|
||||
this.setEnabled(true); //this.caseHasMultipleSources());
|
||||
// Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
|
||||
// if (evt.getPropertyName().equals(Case.Events.CURRENT_CASE.toString())) {
|
||||
// this.setEnabled(evt.getNewValue() != null && this.caseHasMultipleSources());
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private boolean caseHasMultipleSources(){
|
||||
try {
|
||||
Case currentCase = Case.getOpenCase();
|
||||
SleuthkitCase tskDb = currentCase.getSleuthkitCase();
|
||||
return tskDb.getDataSources().size() >= 2;
|
||||
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||
LOGGER.log(Level.SEVERE, "Unable to count datasources.", ex);
|
||||
}
|
||||
return false;
|
||||
this.setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
public static synchronized CommonFilesSearchAction getDefault() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user