19 package org.sleuthkit.autopsy.casemodule;
21 import java.beans.PropertyChangeEvent;
22 import java.io.IOException;
23 import java.io.InputStream;
24 import java.io.OutputStream;
25 import java.nio.file.Files;
26 import java.nio.file.Path;
27 import java.nio.file.Paths;
28 import java.util.EnumSet;
29 import java.util.Properties;
30 import java.util.logging.Level;
39 private static final String
SETTINGS_FILE =
"CasePreferences.properties";
56 if (evt.getNewValue() != null) {
65 }
catch (NoCurrentCaseException ex) {
66 logger.log(Level.SEVERE,
"No current case open.", ex);
86 groupItemsInTreeByDataSource = value;
97 if (settingsFile.toFile().exists()) {
99 try (InputStream inputStream = Files.newInputStream(settingsFile)) {
100 Properties props =
new Properties();
101 props.load(inputStream);
102 String groupByDataSourceValue = props.getProperty(KEY_GROUP_BY_DATA_SOURCE);
103 if (groupByDataSourceValue != null) {
104 switch (groupByDataSourceValue) {
106 groupItemsInTreeByDataSource =
true;
109 groupItemsInTreeByDataSource =
false;
112 logger.log(Level.WARNING, String.format(
"Unexpected value '%s' for key '%s'. Using 'null' instead.",
113 groupByDataSourceValue, KEY_GROUP_BY_DATA_SOURCE));
114 groupItemsInTreeByDataSource =
false;
118 groupItemsInTreeByDataSource =
false;
120 }
catch (IOException ex) {
121 logger.log(Level.SEVERE,
"Error reading settings file", ex);
130 groupItemsInTreeByDataSource =
false;
138 Properties props =
new Properties();
139 if (groupItemsInTreeByDataSource != null) {
140 props.setProperty(KEY_GROUP_BY_DATA_SOURCE, (groupItemsInTreeByDataSource ? VALUE_TRUE : VALUE_FALSE));
143 try (OutputStream fos = Files.newOutputStream(settingsFile)) {
144 props.store(fos,
"");
145 }
catch (IOException ex) {
146 logger.log(Level.SEVERE,
"Error writing settings file", ex);
static Boolean groupItemsInTreeByDataSource
static final String KEY_GROUP_BY_DATA_SOURCE
static final String VALUE_TRUE
void refreshContentTreeSafe()
static synchronized DirectoryTreeTopComponent getDefault()
static void setGroupItemsInTreeByDataSource(boolean value)
static void saveToStorage(Case currentCase)
static Boolean getGroupItemsInTreeByDataSource()
static void loadFromStorage(Case currentCase)
static final String SETTINGS_FILE
static final String VALUE_FALSE
synchronized static Logger getLogger(String name)
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
String getConfigDirectory()
static final Logger logger
static boolean isCaseOpen()