7587 ensure directory tree top component is constructed even when case does not have contents yet

This commit is contained in:
William Schaefer 2021-05-06 16:00:12 -04:00
parent 8cef408da5
commit dad08311af
2 changed files with 17 additions and 11 deletions

View File

@ -116,6 +116,7 @@ import org.sleuthkit.autopsy.coreutils.ThreadUtils;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import org.sleuthkit.autopsy.coreutils.Version; import org.sleuthkit.autopsy.coreutils.Version;
import org.sleuthkit.autopsy.datamodel.hosts.OpenHostsAction; import org.sleuthkit.autopsy.datamodel.hosts.OpenHostsAction;
import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent;
import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.autopsy.events.AutopsyEventException; import org.sleuthkit.autopsy.events.AutopsyEventException;
import org.sleuthkit.autopsy.events.AutopsyEventPublisher; import org.sleuthkit.autopsy.events.AutopsyEventPublisher;
@ -1287,6 +1288,9 @@ public class Case {
*/ */
if (newCurrentCase.hasData()) { if (newCurrentCase.hasData()) {
CoreComponentControl.openCoreWindows(); CoreComponentControl.openCoreWindows();
} else {
//ensure that the DirectoryTreeTopComponent is open so that it's listener can open the core windows including making it visible.
DirectoryTreeTopComponent.findInstance();
} }
/* /*

View File

@ -35,22 +35,22 @@ import org.sleuthkit.autopsy.directorytree.DirectoryTreeTopComponent;
* Read and update case preference file values. * Read and update case preference file values.
*/ */
public final class CasePreferences { public final class CasePreferences {
private static final String SETTINGS_FILE = "CasePreferences.properties"; //NON-NLS private static final String SETTINGS_FILE = "CasePreferences.properties"; //NON-NLS
private static final String KEY_GROUP_BY_DATA_SOURCE = "groupByDataSource"; //NON-NLS private static final String KEY_GROUP_BY_DATA_SOURCE = "groupByDataSource"; //NON-NLS
private static final String VALUE_TRUE = "true"; //NON-NLS private static final String VALUE_TRUE = "true"; //NON-NLS
private static final String VALUE_FALSE = "false"; //NON-NLS private static final String VALUE_FALSE = "false"; //NON-NLS
private static final Logger logger = Logger.getLogger(CasePreferences.class.getName()); private static final Logger logger = Logger.getLogger(CasePreferences.class.getName());
private static Boolean groupItemsInTreeByDataSource = false; private static Boolean groupItemsInTreeByDataSource = false;
/** /**
* Prevent instantiation. * Prevent instantiation.
*/ */
private CasePreferences() { private CasePreferences() {
} }
static { static {
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> { Case.addEventTypeSubscriber(EnumSet.of(Case.Events.CURRENT_CASE), (PropertyChangeEvent evt) -> {
if (evt.getNewValue() != null) { if (evt.getNewValue() != null) {
@ -66,25 +66,27 @@ public final class CasePreferences {
logger.log(Level.SEVERE, "No current case open.", ex); logger.log(Level.SEVERE, "No current case open.", ex);
} }
} }
/** /**
* Get the 'groupItemsInTreeByDataSource' value. This can be true, false, or * Get the 'groupItemsInTreeByDataSource' value. This can be true, false, or
* null. * null.
* *
* @return The value. * @return The value.
*/ */
public static Boolean getGroupItemsInTreeByDataSource() { public static Boolean getGroupItemsInTreeByDataSource() {
return groupItemsInTreeByDataSource; return groupItemsInTreeByDataSource;
} }
/** /**
* Set the 'groupItemsInTreeByDataSource' value to true or false. * Set the 'groupItemsInTreeByDataSource' value to true or false.
* *
* @param value The value to use for the value change. * @param value The value to use for the value change.
*/ */
public static void setGroupItemsInTreeByDataSource(boolean value) { public static void setGroupItemsInTreeByDataSource(boolean value) {
groupItemsInTreeByDataSource = value; groupItemsInTreeByDataSource = value;
DirectoryTreeTopComponent.getDefault().refreshContentTreeSafe(); if (Case.isCaseOpen()) {
DirectoryTreeTopComponent.getDefault().refreshContentTreeSafe();
}
} }
/** /**
@ -120,7 +122,7 @@ public final class CasePreferences {
} }
} }
} }
/** /**
* Reset all values to their default states. * Reset all values to their default states.
*/ */