From 9379a7e229670901f16c760cc7c8843bc4eca3ba Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 22 Sep 2020 16:22:53 -0400 Subject: [PATCH 1/3] added card layout to tabbed pane --- .../datasourcesummary/ui/Bundle.properties | 1 + .../ui/DataSourceSummaryTabbedPane.form | 60 +++++++++++++++++ .../ui/DataSourceSummaryTabbedPane.java | 64 ++++++++++++++++--- 3 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties index 689533fdfe..94b497d2ff 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties @@ -41,3 +41,4 @@ RecentFilesPanel.downloadLabel.text=Recent Downloads RecentFilesPanel.attachmentLabel.text=Recent Attachments PastCasesPanel.notableFileLabel.text=Cases with Common Items That Were Tagged as Notable PastCasesPanel.sameIdLabel.text=Past Cases with the Same Device IDs +DataSourceSummaryTabbedPane.noDataSourceLabel.text=No data source has been selected. diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form new file mode 100644 index 0000000000..e0a4832bfe --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form @@ -0,0 +1,60 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java index cee151b68a..73d9f89e92 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java @@ -18,11 +18,11 @@ */ package org.sleuthkit.autopsy.datasourcesummary.ui; +import java.awt.CardLayout; import java.awt.Component; import java.util.Arrays; import java.util.List; import java.util.function.Consumer; -import javax.swing.JTabbedPane; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.IngestJobInfoPanel; import org.sleuthkit.datamodel.DataSource; @@ -40,7 +40,7 @@ import org.sleuthkit.datamodel.DataSource; "DataSourceSummaryTabbedPane_pastCasesTab_title=Past Cases", "DataSourceSummaryTabbedPane_analysisTab_title=Analysis" }) -public class DataSourceSummaryTabbedPane extends JTabbedPane { +public class DataSourceSummaryTabbedPane extends javax.swing.JPanel { /** * Records of tab information (i.e. title, component, function to call on @@ -111,6 +111,9 @@ public class DataSourceSummaryTabbedPane extends JTabbedPane { } private static final long serialVersionUID = 1L; + // needs to match value provided for card layout in designed + private static final String TABBED_PANE = "tabbedPane"; + private static final String NO_DATASOURCE_PANE = "noDataSourcePane"; private final IngestJobInfoPanel ingestHistoryPanel = new IngestJobInfoPanel(); @@ -127,18 +130,27 @@ public class DataSourceSummaryTabbedPane extends JTabbedPane { ); private DataSource dataSource = null; + private CardLayout cardLayout; /** - * Constructs a tabbed pane showing the summary of a data source. + * Creates new form TabPane */ public DataSourceSummaryTabbedPane() { - initComponent(); + initComponents(); + postInit(); } - private void initComponent() { + private void postInit() { + // get the card layout + cardLayout = (CardLayout) this.getLayout(); + + // set up the tabs for (DataSourceTab tab : tabs) { - addTab(tab.getTabTitle(), tab.getComponent()); + tabbedPane.addTab(tab.getTabTitle(), tab.getComponent()); } + + // set this to no datasource initially + cardLayout.show(this, NO_DATASOURCE_PANE); } /** @@ -157,9 +169,13 @@ public class DataSourceSummaryTabbedPane extends JTabbedPane { */ public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; - - for (DataSourceTab tab : tabs) { - tab.getOnDataSource().accept(dataSource); + if (this.dataSource == null) { + cardLayout.show(this, NO_DATASOURCE_PANE); + } else { + for (DataSourceTab tab : tabs) { + tab.getOnDataSource().accept(dataSource); + } + cardLayout.show(this, TABBED_PANE); } } @@ -171,4 +187,34 @@ public class DataSourceSummaryTabbedPane extends JTabbedPane { tab.getOnClose().run(); } } + + /** + * 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") + // //GEN-BEGIN:initComponents + private void initComponents() { + + tabbedPane = new javax.swing.JTabbedPane(); + javax.swing.JPanel noDataSourcePane = new javax.swing.JPanel(); + javax.swing.JLabel noDataSourceLabel = new javax.swing.JLabel(); + + setLayout(new java.awt.CardLayout()); + add(tabbedPane, "tabbedPane"); + + noDataSourcePane.setLayout(new java.awt.BorderLayout()); + + noDataSourceLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + org.openide.awt.Mnemonics.setLocalizedText(noDataSourceLabel, org.openide.util.NbBundle.getMessage(DataSourceSummaryTabbedPane.class, "DataSourceSummaryTabbedPane.noDataSourceLabel.text")); // NOI18N + noDataSourcePane.add(noDataSourceLabel, java.awt.BorderLayout.CENTER); + + add(noDataSourcePane, "noDataSourcePane"); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTabbedPane tabbedPane; + // End of variables declaration//GEN-END:variables } From 6ff5d9f0d539ec5351ee1e0f0a3aa23f82b88adb Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 22 Sep 2020 18:22:29 -0400 Subject: [PATCH 2/3] bug fix --- .../autopsy/datasourcesummary/ui/Bundle.properties-MERGED | 1 + .../autopsy/datasourcesummary/ui/DataSourceSummaryDialog.form | 4 ++-- .../autopsy/datasourcesummary/ui/DataSourceSummaryDialog.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties-MERGED index 9a48089e5d..f03f55df38 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/Bundle.properties-MERGED @@ -94,6 +94,7 @@ RecentFilesPanel.downloadLabel.text=Recent Downloads RecentFilesPanel.attachmentLabel.text=Recent Attachments PastCasesPanel.notableFileLabel.text=Cases with Common Items That Were Tagged as Notable PastCasesPanel.sameIdLabel.text=Past Cases with the Same Device IDs +DataSourceSummaryTabbedPane.noDataSourceLabel.text=No data source has been selected. UserActivityPanel_noDataExists=No communication data exists UserActivityPanel_tab_title=User Activity UserActivityPanel_TopAccountTableModel_accountType_header=Account Type diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.form b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.form index d4edf4b0ee..56b4314181 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.form +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.form @@ -67,7 +67,7 @@ - + @@ -79,7 +79,7 @@ - + diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.java b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.java index 8d2fb8c846..5269bdff67 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.java +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryDialog.java @@ -121,7 +121,7 @@ final class DataSourceSummaryDialog extends javax.swing.JDialog implements Obser closeButton = new javax.swing.JButton(); dataSourceSummarySplitPane = new javax.swing.JSplitPane(); - javax.swing.JTabbedPane dataSourceTabbedPane = dataSourceSummaryTabbedPane; + javax.swing.JPanel dataSourceTabbedPane = dataSourceSummaryTabbedPane; org.openide.awt.Mnemonics.setLocalizedText(closeButton, org.openide.util.NbBundle.getMessage(DataSourceSummaryDialog.class, "DataSourceSummaryDialog.closeButton.text")); // NOI18N closeButton.addActionListener(new java.awt.event.ActionListener() { From 46f3bfe0af68b207f8f5b488531abfc73fc9c28a Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro Date: Tue, 22 Sep 2020 18:42:45 -0400 Subject: [PATCH 3/3] commenting --- .../datasourcesummary/ui/DataSourceSummaryTabbedPane.form | 1 + .../datasourcesummary/ui/DataSourceSummaryTabbedPane.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form index e0a4832bfe..7c01388a52 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.form @@ -11,6 +11,7 @@ + diff --git a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java index 73d9f89e92..55320f7dbb 100644 --- a/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java +++ b/Core/src/org/sleuthkit/autopsy/datasourcesummary/ui/DataSourceSummaryTabbedPane.java @@ -140,6 +140,9 @@ public class DataSourceSummaryTabbedPane extends javax.swing.JPanel { postInit(); } + /** + * Method called right after initComponents during initialization. + */ private void postInit() { // get the card layout cardLayout = (CardLayout) this.getLayout();