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;
95 if (settingsFile.toFile().exists()) {
97 try (InputStream inputStream = Files.newInputStream(settingsFile)) {
98 Properties props =
new Properties();
99 props.load(inputStream);
100 String groupByDataSourceValue = props.getProperty(KEY_GROUP_BY_DATA_SOURCE);
101 if (groupByDataSourceValue != null) {
102 switch (groupByDataSourceValue) {
104 groupItemsInTreeByDataSource =
true;
107 groupItemsInTreeByDataSource =
false;
110 logger.log(Level.WARNING, String.format(
"Unexpected value '%s' for key '%s'. Using 'null' instead.",
111 groupByDataSourceValue, KEY_GROUP_BY_DATA_SOURCE));
112 groupItemsInTreeByDataSource = null;
116 groupItemsInTreeByDataSource = null;
118 }
catch (IOException ex) {
119 logger.log(Level.SEVERE,
"Error reading settings file", ex);
128 groupItemsInTreeByDataSource = null;
136 Properties props =
new Properties();
137 if (groupItemsInTreeByDataSource != null) {
138 props.setProperty(KEY_GROUP_BY_DATA_SOURCE, (groupItemsInTreeByDataSource ? VALUE_TRUE : VALUE_FALSE));
141 try (OutputStream fos = Files.newOutputStream(settingsFile)) {
142 props.store(fos,
"");
143 }
catch (IOException ex) {
144 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