mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
6781 fix use of invoke later
This commit is contained in:
parent
4950e0e165
commit
59df1bb378
@ -63,10 +63,9 @@ class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
List<BlackboardArtifact> listOfArtifacts = new ArrayList<>();
|
||||
if (!isCancelled()) {
|
||||
try {
|
||||
listOfArtifacts.addAll(get());
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, get()));
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
logger.log(Level.SEVERE, "Exception while trying to get list of artifacts for Domain details for artifact type: "
|
||||
+ artifactType.getDisplayName() + " and domain: " + domain, ex);
|
||||
@ -74,7 +73,5 @@ class ArtifactsWorker extends SwingWorker<List<BlackboardArtifact>, Void> {
|
||||
//Worker was cancelled after previously finishing its background work, exception ignored to cut down on non-helpful logging
|
||||
}
|
||||
}
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.ArtifactSearchResultEvent(artifactType, listOfArtifacts));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -118,10 +118,7 @@ final class DiscoveryDialog extends javax.swing.JDialog {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
getSelectedFilterPanel().setLastGroupingAttributeType(groupByCombobox.getItemAt(groupByCombobox.getSelectedIndex()));
|
||||
});
|
||||
|
||||
getSelectedFilterPanel().setLastGroupingAttributeType(groupByCombobox.getItemAt(groupByCombobox.getSelectedIndex()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -129,9 +126,7 @@ final class DiscoveryDialog extends javax.swing.JDialog {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
getSelectedFilterPanel().setLastSortingMethod(orderByCombobox.getItemAt(orderByCombobox.getSelectedIndex()));
|
||||
});
|
||||
getSelectedFilterPanel().setLastSortingMethod(orderByCombobox.getItemAt(orderByCombobox.getSelectedIndex()));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -139,9 +134,7 @@ final class DiscoveryDialog extends javax.swing.JDialog {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
getSelectedFilterPanel().setLastGroupSortingAlg(groupSortingComboBox.getItemAt(groupSortingComboBox.getSelectedIndex()));
|
||||
});
|
||||
getSelectedFilterPanel().setLastGroupSortingAlg(groupSortingComboBox.getItemAt(groupSortingComboBox.getSelectedIndex()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -125,24 +125,24 @@ final class DomainArtifactsTabPanel extends JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handleArtifactSearchResultEvent(DiscoveryEventUtils.ArtifactSearchResultEvent artifactresultEvent) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (artifactType == artifactresultEvent.getArtifactType()) {
|
||||
if (artifactType == artifactresultEvent.getArtifactType()) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
listPanel.removeListSelectionListener(listener);
|
||||
listPanel.addArtifacts(artifactresultEvent.getListOfArtifacts());
|
||||
status = ArtifactRetrievalStatus.POPULATED;
|
||||
setEnabled(!listPanel.isEmpty());
|
||||
listPanel.addSelectionListener(listener);
|
||||
listPanel.selectFirst();
|
||||
revalidate();
|
||||
repaint();
|
||||
try {
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().unregister(this);
|
||||
} catch (IllegalArgumentException notRegistered) {
|
||||
logger.log(Level.INFO, "Attempting to unregister tab which was not registered");
|
||||
// attempting to remove a tab that was never registered
|
||||
}
|
||||
status = ArtifactRetrievalStatus.POPULATED;
|
||||
setEnabled(!listPanel.isEmpty());
|
||||
validate();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,22 +96,21 @@ final class DomainDetailsPanel extends JPanel {
|
||||
* Run the worker which retrieves the list of artifacts for the domain to
|
||||
* populate the details area.
|
||||
*/
|
||||
@ThreadConfined(type = ThreadConfined.ThreadType.AWT)
|
||||
private void runDomainWorker() {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
||||
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
||||
if (detailsWorker != null && !detailsWorker.isDone()) {
|
||||
detailsWorker.cancel(true);
|
||||
}
|
||||
DomainArtifactsTabPanel selectedTab = (DomainArtifactsTabPanel) selectedComponent;
|
||||
if (selectedTab.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
||||
selectedTab.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING);
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().register(selectedTab);
|
||||
detailsWorker = new ArtifactsWorker(selectedTab.getArtifactType(), domain);
|
||||
detailsWorker.execute();
|
||||
}
|
||||
Component selectedComponent = jTabbedPane1.getSelectedComponent();
|
||||
if (selectedComponent instanceof DomainArtifactsTabPanel) {
|
||||
if (detailsWorker != null && !detailsWorker.isDone()) {
|
||||
detailsWorker.cancel(true);
|
||||
}
|
||||
});
|
||||
DomainArtifactsTabPanel selectedTab = (DomainArtifactsTabPanel) selectedComponent;
|
||||
if (selectedTab.getStatus() == DomainArtifactsTabPanel.ArtifactRetrievalStatus.UNPOPULATED) {
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().register(selectedTab);
|
||||
selectedTab.setStatus(DomainArtifactsTabPanel.ArtifactRetrievalStatus.POPULATING);
|
||||
detailsWorker = new ArtifactsWorker(selectedTab.getArtifactType(), domain);
|
||||
detailsWorker.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,8 +121,8 @@ final class DomainDetailsPanel extends JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handlePopulateDomainTabsEvent(DiscoveryEventUtils.PopulateDomainTabsEvent populateEvent) {
|
||||
domain = populateEvent.getDomain();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
domain = populateEvent.getDomain();
|
||||
resetTabsStatus();
|
||||
selectTab();
|
||||
runDomainWorker();
|
||||
|
@ -70,20 +70,18 @@ final class FileDetailsPanel extends javax.swing.JPanel {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (SwingUtilities.isRightMouseButton(e)) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
instancesList.setSelectedIndex(instancesList.locationToIndex(e.getPoint()));
|
||||
Set<AbstractFile> files = new HashSet<>();
|
||||
files.add(instancesList.getSelectedValue());
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
menu.add(new ViewContextAction(Bundle.ResultsPanel_viewFileInDir_name(), instancesList.getSelectedValue()));
|
||||
menu.add(new ExternalViewerAction(Bundle.ResultsPanel_openInExternalViewer_name(), new FileNode(instancesList.getSelectedValue())));
|
||||
menu.add(ViewFileInTimelineAction.createViewFileAction(instancesList.getSelectedValue()));
|
||||
menu.add(new DiscoveryExtractAction(files));
|
||||
menu.add(AddContentTagAction.getInstance().getMenuForContent(files));
|
||||
menu.add(DeleteFileContentTagAction.getInstance().getMenuForFiles(files));
|
||||
menu.add(AddContentToHashDbAction.getInstance().getMenuForFiles(files));
|
||||
menu.show(instancesList, e.getPoint().x, e.getPoint().y);
|
||||
});
|
||||
instancesList.setSelectedIndex(instancesList.locationToIndex(e.getPoint()));
|
||||
Set<AbstractFile> files = new HashSet<>();
|
||||
files.add(instancesList.getSelectedValue());
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
menu.add(new ViewContextAction(Bundle.ResultsPanel_viewFileInDir_name(), instancesList.getSelectedValue()));
|
||||
menu.add(new ExternalViewerAction(Bundle.ResultsPanel_openInExternalViewer_name(), new FileNode(instancesList.getSelectedValue())));
|
||||
menu.add(ViewFileInTimelineAction.createViewFileAction(instancesList.getSelectedValue()));
|
||||
menu.add(new DiscoveryExtractAction(files));
|
||||
menu.add(AddContentTagAction.getInstance().getMenuForContent(files));
|
||||
menu.add(DeleteFileContentTagAction.getInstance().getMenuForFiles(files));
|
||||
menu.add(AddContentToHashDbAction.getInstance().getMenuForFiles(files));
|
||||
menu.show(instancesList, e.getPoint().x, e.getPoint().y);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -91,14 +89,12 @@ final class FileDetailsPanel extends javax.swing.JPanel {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (!e.getValueIsAdjusting()) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
AbstractFile file = getSelectedFile();
|
||||
if (file != null) {
|
||||
dataContentPanel.setNode(new TableFilterNode(new FileNode(file), false));
|
||||
} else {
|
||||
dataContentPanel.setNode(null);
|
||||
}
|
||||
});
|
||||
AbstractFile file = getSelectedFile();
|
||||
if (file != null) {
|
||||
dataContentPanel.setNode(new TableFilterNode(new FileNode(file), false));
|
||||
} else {
|
||||
dataContentPanel.setNode(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -127,8 +123,8 @@ final class FileDetailsPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handlePopulateInstancesListEvent(DiscoveryEventUtils.PopulateInstancesListEvent populateEvent) {
|
||||
List<AbstractFile> files = populateEvent.getInstances();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
List<AbstractFile> files = populateEvent.getInstances();
|
||||
if (files.isEmpty()) {
|
||||
//if there are no files currently remove the current items without removing listener to cause content viewer to reset
|
||||
instancesListModel.removeAllElements();
|
||||
|
@ -69,10 +69,8 @@ final class GroupListPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
type = searchStartedEvent.getType();
|
||||
groupKeyList.setListData(new GroupKey[0]);
|
||||
});
|
||||
type = searchStartedEvent.getType();
|
||||
groupKeyList.setListData(new GroupKey[0]);
|
||||
}
|
||||
|
||||
@Messages({"GroupsListPanel.noFileResults.message.text=No files were found for the selected filters.\n\n"
|
||||
@ -94,29 +92,27 @@ final class GroupListPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
|
||||
groupMap = searchCompleteEvent.getGroupMap();
|
||||
searchfilters = searchCompleteEvent.getFilters();
|
||||
groupingAttribute = searchCompleteEvent.getGroupingAttr();
|
||||
groupSort = searchCompleteEvent.getGroupSort();
|
||||
resultSortMethod = searchCompleteEvent.getResultSort();
|
||||
groupKeyList.setListData(groupMap.keySet().toArray(new GroupKey[groupMap.keySet().size()]));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
groupMap = searchCompleteEvent.getGroupMap();
|
||||
searchfilters = searchCompleteEvent.getFilters();
|
||||
groupingAttribute = searchCompleteEvent.getGroupingAttr();
|
||||
groupSort = searchCompleteEvent.getGroupSort();
|
||||
resultSortMethod = searchCompleteEvent.getResultSort();
|
||||
groupKeyList.setListData(groupMap.keySet().toArray(new GroupKey[groupMap.keySet().size()]));
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (groupKeyList.getModel().getSize() > 0) {
|
||||
groupKeyList.setSelectedIndex(0);
|
||||
} else if (type == DOMAIN) {
|
||||
JOptionPane.showMessageDialog(DiscoveryTopComponent.getTopComponent(),
|
||||
Bundle.GroupsListPanel_noDomainResults_message_text(),
|
||||
Bundle.GroupsListPanel_noResults_title_text(),
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(DiscoveryTopComponent.getTopComponent(),
|
||||
Bundle.GroupsListPanel_noFileResults_message_text(),
|
||||
Bundle.GroupsListPanel_noResults_title_text(),
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
});
|
||||
if (groupKeyList.getModel().getSize() > 0) {
|
||||
groupKeyList.setSelectedIndex(0);
|
||||
} else if (type == DOMAIN) {
|
||||
JOptionPane.showMessageDialog(DiscoveryTopComponent.getTopComponent(),
|
||||
Bundle.GroupsListPanel_noDomainResults_message_text(),
|
||||
Bundle.GroupsListPanel_noResults_title_text(),
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(DiscoveryTopComponent.getTopComponent(),
|
||||
Bundle.GroupsListPanel_noFileResults_message_text(),
|
||||
Bundle.GroupsListPanel_noResults_title_text(),
|
||||
JOptionPane.PLAIN_MESSAGE);
|
||||
}
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -182,12 +182,12 @@ final class ResultsPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handlePageRetrievedEvent(DiscoveryEventUtils.PageRetrievedEvent pageRetrievedEvent) {
|
||||
//send populateMesage
|
||||
if (pageRetrievedEvent.getType() != DOMAIN) {
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PopulateInstancesListEvent(getInstancesForSelected()));
|
||||
}
|
||||
currentPage = pageRetrievedEvent.getPageNumber();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
//send populateMesage
|
||||
if (pageRetrievedEvent.getType() != DOMAIN) {
|
||||
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PopulateInstancesListEvent(getInstancesForSelected()));
|
||||
}
|
||||
currentPage = pageRetrievedEvent.getPageNumber();
|
||||
updateControls();
|
||||
resetResultViewer();
|
||||
if (null != pageRetrievedEvent.getType()) {
|
||||
@ -214,20 +214,17 @@ final class ResultsPanel extends javax.swing.JPanel {
|
||||
}
|
||||
resultsViewerPanel.revalidate();
|
||||
resultsViewerPanel.repaint();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
void handleCancelBackgroundTasksEvent(DiscoveryEventUtils.CancelBackgroundTasksEvent cancelEvent) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
for (SwingWorker<Void, Void> thumbWorker : resultContentWorkers) {
|
||||
if (!thumbWorker.isDone()) {
|
||||
thumbWorker.cancel(true);
|
||||
}
|
||||
for (SwingWorker<Void, Void> thumbWorker : resultContentWorkers) {
|
||||
if (!thumbWorker.isDone()) {
|
||||
thumbWorker.cancel(true);
|
||||
}
|
||||
resultContentWorkers.clear();
|
||||
});
|
||||
}
|
||||
resultContentWorkers.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -336,14 +333,14 @@ final class ResultsPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handleGroupSelectedEvent(DiscoveryEventUtils.GroupSelectedEvent groupSelectedEvent) {
|
||||
searchFilters = groupSelectedEvent.getFilters();
|
||||
groupingAttribute = groupSelectedEvent.getGroupingAttr();
|
||||
groupSort = groupSelectedEvent.getGroupSort();
|
||||
fileSortMethod = groupSelectedEvent.getResultSort();
|
||||
selectedGroupKey = groupSelectedEvent.getGroupKey();
|
||||
resultType = groupSelectedEvent.getResultType();
|
||||
groupSize = groupSelectedEvent.getGroupSize();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
searchFilters = groupSelectedEvent.getFilters();
|
||||
groupingAttribute = groupSelectedEvent.getGroupingAttr();
|
||||
groupSort = groupSelectedEvent.getGroupSort();
|
||||
fileSortMethod = groupSelectedEvent.getResultSort();
|
||||
selectedGroupKey = groupSelectedEvent.getGroupKey();
|
||||
resultType = groupSelectedEvent.getResultType();
|
||||
groupSize = groupSelectedEvent.getGroupSize();
|
||||
resetResultViewer();
|
||||
setPage(0);
|
||||
});
|
||||
@ -357,9 +354,9 @@ final class ResultsPanel extends javax.swing.JPanel {
|
||||
*/
|
||||
@Subscribe
|
||||
void handleNoResultsEvent(DiscoveryEventUtils.NoResultsEvent noResultsEvent) {
|
||||
groupSize = 0;
|
||||
currentPage = 0;
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
groupSize = 0;
|
||||
currentPage = 0;
|
||||
updateControls();
|
||||
videoThumbnailViewer.clearViewer();
|
||||
imageThumbnailViewer.clearViewer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user