mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
7229 modifications to redirect focus when a tab is selected
This commit is contained in:
parent
d459a00e33
commit
11fee59984
@ -135,6 +135,9 @@ public final class DiscoveryEventUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new PopulateDomainTabsEvent.
|
* Construct a new PopulateDomainTabsEvent.
|
||||||
|
*
|
||||||
|
* @param domain The domain this event is for, or empty if no domain is
|
||||||
|
* selected.
|
||||||
*/
|
*/
|
||||||
public PopulateDomainTabsEvent(String domain) {
|
public PopulateDomainTabsEvent(String domain) {
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
@ -236,6 +239,7 @@ public final class DiscoveryEventUtils {
|
|||||||
|
|
||||||
private final List<BlackboardArtifact> listOfArtifacts = new ArrayList<>();
|
private final List<BlackboardArtifact> listOfArtifacts = new ArrayList<>();
|
||||||
private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
|
private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
|
||||||
|
private final boolean grabFocus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ArtifactSearchResultEvent with a list of specified
|
* Construct a new ArtifactSearchResultEvent with a list of specified
|
||||||
@ -243,12 +247,15 @@ public final class DiscoveryEventUtils {
|
|||||||
*
|
*
|
||||||
* @param artifactType The type of results in the list.
|
* @param artifactType The type of results in the list.
|
||||||
* @param listOfArtifacts The list of results retrieved.
|
* @param listOfArtifacts The list of results retrieved.
|
||||||
|
* @param shouldGrabFocus True if the list of artifacts should have
|
||||||
|
* focus, false otherwise.
|
||||||
*/
|
*/
|
||||||
public ArtifactSearchResultEvent(BlackboardArtifact.ARTIFACT_TYPE artifactType, List<BlackboardArtifact> listOfArtifacts) {
|
public ArtifactSearchResultEvent(BlackboardArtifact.ARTIFACT_TYPE artifactType, List<BlackboardArtifact> listOfArtifacts, boolean shouldGrabFocus) {
|
||||||
if (listOfArtifacts != null) {
|
if (listOfArtifacts != null) {
|
||||||
this.listOfArtifacts.addAll(listOfArtifacts);
|
this.listOfArtifacts.addAll(listOfArtifacts);
|
||||||
}
|
}
|
||||||
this.artifactType = artifactType;
|
this.artifactType = artifactType;
|
||||||
|
this.grabFocus = shouldGrabFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,6 +275,17 @@ public final class DiscoveryEventUtils {
|
|||||||
public BlackboardArtifact.ARTIFACT_TYPE getArtifactType() {
|
public BlackboardArtifact.ARTIFACT_TYPE getArtifactType() {
|
||||||
return artifactType;
|
return artifactType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not the artifacts list should grab focus.
|
||||||
|
*
|
||||||
|
* @return True if the list of artifacts should have focus, false
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
public boolean shouldGrabFocus() {
|
||||||
|
return grabFocus;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -278,18 +296,22 @@ public final class DiscoveryEventUtils {
|
|||||||
|
|
||||||
private final List<MiniTimelineResult> results = new ArrayList<>();
|
private final List<MiniTimelineResult> results = new ArrayList<>();
|
||||||
private final String domain;
|
private final String domain;
|
||||||
|
private final boolean grabFocus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new MiniTimelineResultEvent.
|
* Construct a new MiniTimelineResultEvent.
|
||||||
*
|
*
|
||||||
* @param results The list of MiniTimelineResults contained in this
|
* @param results The list of MiniTimelineResults contained in
|
||||||
* event.
|
* this event.
|
||||||
* @param domain The domain the results are for.
|
* @param domain The domain the results are for.
|
||||||
|
* @param shouldGrabFocus True if the list of dates should have focus,
|
||||||
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
public MiniTimelineResultEvent(List<MiniTimelineResult> results, String domain) {
|
public MiniTimelineResultEvent(List<MiniTimelineResult> results, String domain, boolean shouldGrabFocus) {
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
this.results.addAll(results);
|
this.results.addAll(results);
|
||||||
}
|
}
|
||||||
|
this.grabFocus = shouldGrabFocus;
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,6 +332,15 @@ public final class DiscoveryEventUtils {
|
|||||||
public String getDomain() {
|
public String getDomain() {
|
||||||
return domain;
|
return domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether or not the dates list should grab focus.
|
||||||
|
*
|
||||||
|
* @return True if the list of dates should have focus, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean shouldGrabFocus() {
|
||||||
|
return grabFocus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,16 +41,21 @@ class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
|
|||||||
private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
|
private final BlackboardArtifact.ARTIFACT_TYPE artifactType;
|
||||||
private final static Logger logger = Logger.getLogger(ArtifactsWorker.class.getName());
|
private final static Logger logger = Logger.getLogger(ArtifactsWorker.class.getName());
|
||||||
private final String domain;
|
private final String domain;
|
||||||
|
private final boolean grabFocus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ArtifactsWorker.
|
* Construct a new ArtifactsWorker.
|
||||||
*
|
*
|
||||||
* @param artifactType The type of artifact being retrieved.
|
* @param artifactType The type of artifact being retrieved.
|
||||||
* @param domain The domain the artifacts should have as an attribute.
|
* @param domain The domain the artifacts should have as an
|
||||||
|
* attribute.
|
||||||
|
* @param shouldGrabFocus True if the list of artifacts should have focus,
|
||||||
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
ArtifactsWorker(BlackboardArtifact.ARTIFACT_TYPE artifactType, String domain) {
|
ArtifactsWorker(BlackboardArtifact.ARTIFACT_TYPE artifactType, String domain, boolean shouldGrabFocus) {
|
||||||
this.artifactType = artifactType;
|
this.artifactType = artifactType;
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
|
this.grabFocus = shouldGrabFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +66,7 @@ class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
|
|||||||
return domainSearch.getArtifacts(new DomainSearchArtifactsRequest(Case.getCurrentCase().getSleuthkitCase(), domain, artifactType));
|
return domainSearch.getArtifacts(new DomainSearchArtifactsRequest(Case.getCurrentCase().getSleuthkitCase(), domain, artifactType));
|
||||||
} catch (DiscoveryException ex) {
|
} catch (DiscoveryException ex) {
|
||||||
if (ex.getCause() instanceof InterruptedException) {
|
if (ex.getCause() instanceof InterruptedException) {
|
||||||
this.cancel(true);
|
this.cancel(true);
|
||||||
//ignore the exception as it was cancelled while the cache was performing its get and we support cancellation
|
//ignore the exception as it was cancelled while the cache was performing its get and we support cancellation
|
||||||
} else {
|
} else {
|
||||||
throw ex;
|
throw ex;
|
||||||
@ -77,7 +82,7 @@ class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
|
|||||||
if (!isCancelled()) {
|
if (!isCancelled()) {
|
||||||
try {
|
try {
|
||||||
listOfArtifacts.addAll(get());
|
listOfArtifacts.addAll(get());
|
||||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, listOfArtifacts));
|
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, listOfArtifacts, grabFocus));
|
||||||
} catch (InterruptedException | ExecutionException ex) {
|
} catch (InterruptedException | ExecutionException ex) {
|
||||||
logger.log(Level.SEVERE, "Exception while trying to get list of artifacts for Domain details for artifact type: "
|
logger.log(Level.SEVERE, "Exception while trying to get list of artifacts for Domain details for artifact type: "
|
||||||
+ artifactType.getDisplayName() + " and domain: " + domain, ex);
|
+ artifactType.getDisplayName() + " and domain: " + domain, ex);
|
||||||
|
@ -95,6 +95,14 @@ final class DomainArtifactsTabPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign the focus to this panel's list.
|
||||||
|
*/
|
||||||
|
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||||
|
void focusList() {
|
||||||
|
listPanel.grabFocus();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the status of the panel which indicates if it is populated.
|
* Get the status of the panel which indicates if it is populated.
|
||||||
*
|
*
|
||||||
@ -144,6 +152,9 @@ final class DomainArtifactsTabPanel extends JPanel {
|
|||||||
listPanel.selectFirst();
|
listPanel.selectFirst();
|
||||||
removeAll();
|
removeAll();
|
||||||
add(mainSplitPane);
|
add(mainSplitPane);
|
||||||
|
if (artifactresultEvent.shouldGrabFocus()) {
|
||||||
|
focusList();
|
||||||
|
}
|
||||||
revalidate();
|
revalidate();
|
||||||
repaint();
|
repaint();
|
||||||
try {
|
try {
|
||||||
|
@ -81,9 +81,9 @@ final class DomainDetailsPanel extends JPanel {
|
|||||||
selectedTabName = newTabTitle;
|
selectedTabName = newTabTitle;
|
||||||
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
||||||
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
||||||
runDomainWorker((DomainArtifactsTabPanel) selectedComponent);
|
runDomainWorker((DomainArtifactsTabPanel) selectedComponent, true);
|
||||||
} else if (selectedComponent instanceof MiniTimelinePanel) {
|
} else if (selectedComponent instanceof MiniTimelinePanel) {
|
||||||
runMiniTimelineWorker((MiniTimelinePanel) selectedComponent);
|
runMiniTimelineWorker((MiniTimelinePanel) selectedComponent, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,17 +122,24 @@ final class DomainDetailsPanel extends JPanel {
|
|||||||
/**
|
/**
|
||||||
* Run the worker which retrieves the list of artifacts for the domain to
|
* Run the worker which retrieves the list of artifacts for the domain to
|
||||||
* populate the details area.
|
* populate the details area.
|
||||||
|
*
|
||||||
|
* @param domainArtifactsTabPanel The DomainArtifactsTabPanel which has been
|
||||||
|
* selected.
|
||||||
|
* @param shouldGrabFocus True if the list of artifacts should have
|
||||||
|
* focus, false otherwise.
|
||||||
*/
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||||
private void runDomainWorker(DomainArtifactsTabPanel domainArtifactsTabPanel) {
|
private void runDomainWorker(DomainArtifactsTabPanel domainArtifactsTabPanel, boolean shouldGrabFocus) {
|
||||||
if (singleArtifactDomainWorker != null && !singleArtifactDomainWorker.isDone()) {
|
if (singleArtifactDomainWorker != null && !singleArtifactDomainWorker.isDone()) {
|
||||||
singleArtifactDomainWorker.cancel(true);
|
singleArtifactDomainWorker.cancel(true);
|
||||||
}
|
}
|
||||||
if (domainArtifactsTabPanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
if (domainArtifactsTabPanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
||||||
DiscoveryEventUtils.getDiscoveryEventBus().register(domainArtifactsTabPanel);
|
DiscoveryEventUtils.getDiscoveryEventBus().register(domainArtifactsTabPanel);
|
||||||
domainArtifactsTabPanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING);
|
domainArtifactsTabPanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING);
|
||||||
singleArtifactDomainWorker = new ArtifactsWorker(domainArtifactsTabPanel.getArtifactType(), domain);
|
singleArtifactDomainWorker = new ArtifactsWorker(domainArtifactsTabPanel.getArtifactType(), domain, shouldGrabFocus);
|
||||||
singleArtifactDomainWorker.execute();
|
singleArtifactDomainWorker.execute();
|
||||||
|
} else if (domainArtifactsTabPanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATED) {
|
||||||
|
domainArtifactsTabPanel.focusList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -140,11 +147,17 @@ final class DomainDetailsPanel extends JPanel {
|
|||||||
/**
|
/**
|
||||||
* Run the worker which retrieves the list of MiniTimelineResults for the
|
* Run the worker which retrieves the list of MiniTimelineResults for the
|
||||||
* mini timeline view to populate.
|
* mini timeline view to populate.
|
||||||
|
*
|
||||||
|
* @param miniTimelinePanel The MiniTimelinePanel which has been selected.
|
||||||
|
* @param shouldGrabFocus True if the list of dates should have focus,
|
||||||
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
private void runMiniTimelineWorker(MiniTimelinePanel miniTimelinePanel) {
|
private void runMiniTimelineWorker(MiniTimelinePanel miniTimelinePanel, boolean shouldGrabFocus) {
|
||||||
if (miniTimelinePanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
if (miniTimelinePanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
||||||
miniTimelinePanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING, domain);
|
miniTimelinePanel.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING, domain);
|
||||||
new MiniTimelineWorker(domain).execute();
|
new MiniTimelineWorker(domain, shouldGrabFocus).execute();
|
||||||
|
} else if (miniTimelinePanel.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATED) {
|
||||||
|
miniTimelinePanel.focusList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,12 +175,13 @@ final class DomainDetailsPanel extends JPanel {
|
|||||||
//send fade out event
|
//send fade out event
|
||||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.DetailsVisibleEvent(false));
|
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.DetailsVisibleEvent(false));
|
||||||
} else {
|
} else {
|
||||||
|
resetTabsStatus();
|
||||||
domain = populateEvent.getDomain();
|
domain = populateEvent.getDomain();
|
||||||
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
||||||
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
||||||
runDomainWorker((DomainArtifactsTabPanel) selectedComponent);
|
runDomainWorker((DomainArtifactsTabPanel) selectedComponent, false);
|
||||||
} else if (selectedComponent instanceof MiniTimelinePanel) {
|
} else if (selectedComponent instanceof MiniTimelinePanel) {
|
||||||
runMiniTimelineWorker((MiniTimelinePanel) selectedComponent);
|
runMiniTimelineWorker((MiniTimelinePanel) selectedComponent, false);
|
||||||
}
|
}
|
||||||
//send fade in event
|
//send fade in event
|
||||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.DetailsVisibleEvent(true));
|
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.DetailsVisibleEvent(true));
|
||||||
|
@ -101,11 +101,19 @@ final class MiniTimelinePanel extends javax.swing.JPanel {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign the focus to this panel's list.
|
||||||
|
*/
|
||||||
|
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||||
|
void focusList() {
|
||||||
|
dateListPanel.grabFocus();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manually set the status of the panel.
|
* Manually set the status of the panel.
|
||||||
*
|
*
|
||||||
* @param status The ArtifactRetrievalStatus of the panel
|
* @param status The ArtifactRetrievalStatus of the panel
|
||||||
* @param domain The domain the panel is currently reflecting.
|
* @param domain The domain the panel is currently reflecting.
|
||||||
*/
|
*/
|
||||||
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||||
void setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus status, String domain) {
|
void setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus status, String domain) {
|
||||||
@ -143,6 +151,9 @@ final class MiniTimelinePanel extends javax.swing.JPanel {
|
|||||||
dateListPanel.addSelectionListener(dateListener);
|
dateListPanel.addSelectionListener(dateListener);
|
||||||
artifactListPanel.addSelectionListener(artifactListener);
|
artifactListPanel.addSelectionListener(artifactListener);
|
||||||
dateListPanel.selectFirst();
|
dateListPanel.selectFirst();
|
||||||
|
if (miniTimelineResultEvent.shouldGrabFocus()) {
|
||||||
|
focusList();
|
||||||
|
}
|
||||||
removeAll();
|
removeAll();
|
||||||
add(mainSplitPane);
|
add(mainSplitPane);
|
||||||
revalidate();
|
revalidate();
|
||||||
|
@ -33,21 +33,26 @@ import org.sleuthkit.autopsy.discovery.search.DiscoveryException;
|
|||||||
import org.sleuthkit.autopsy.discovery.search.DomainSearch;
|
import org.sleuthkit.autopsy.discovery.search.DomainSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SwingWorker to retrieve a list of artifacts for a specified type and domain.
|
* SwingWorker to retrieve a list of artifacts organized by date for the
|
||||||
|
* miniTimelinePanel for a specific domain.
|
||||||
*/
|
*/
|
||||||
class MiniTimelineWorker extends SwingWorker<Void, Void> {
|
class MiniTimelineWorker extends SwingWorker<Void, Void> {
|
||||||
|
|
||||||
private final static Logger logger = Logger.getLogger(MiniTimelineWorker.class.getName());
|
private final static Logger logger = Logger.getLogger(MiniTimelineWorker.class.getName());
|
||||||
private final String domain;
|
private final String domain;
|
||||||
|
private final boolean grabFocus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a new ArtifactsWorker.
|
* Construct a new MiniTimelineWorker.
|
||||||
*
|
*
|
||||||
* @param artifactType The type of artifact being retrieved.
|
* @param domain The domain the artifacts should have as an
|
||||||
* @param domain The domain the artifacts should have as an attribute.
|
* attribute.
|
||||||
|
* @param shouldGrabFocus True if the list of artifacts should have focus,
|
||||||
|
* false otherwise.
|
||||||
*/
|
*/
|
||||||
MiniTimelineWorker(String domain) {
|
MiniTimelineWorker(String domain, boolean shouldGrabFocus) {
|
||||||
this.domain = domain;
|
this.domain = domain;
|
||||||
|
this.grabFocus = shouldGrabFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -57,7 +62,7 @@ class MiniTimelineWorker extends SwingWorker<Void, Void> {
|
|||||||
DomainSearch domainSearch = new DomainSearch();
|
DomainSearch domainSearch = new DomainSearch();
|
||||||
try {
|
try {
|
||||||
results.addAll(domainSearch.getAllArtifactsForDomain(Case.getCurrentCase().getSleuthkitCase(), domain));
|
results.addAll(domainSearch.getAllArtifactsForDomain(Case.getCurrentCase().getSleuthkitCase(), domain));
|
||||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.MiniTimelineResultEvent(results, domain));
|
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.MiniTimelineResultEvent(results, domain, grabFocus));
|
||||||
} catch (DiscoveryException ex) {
|
} catch (DiscoveryException ex) {
|
||||||
if (ex.getCause() instanceof InterruptedException) {
|
if (ex.getCause() instanceof InterruptedException) {
|
||||||
this.cancel(true);
|
this.cancel(true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user