Tag list view - saving last selected items

Saving last selected view
This commit is contained in:
Jindra Petřík
2022-10-30 10:47:28 +01:00
parent 9e771ae9ed
commit 74ff118c22
16 changed files with 179 additions and 63 deletions

View File

@@ -279,7 +279,10 @@ public final class Configuration {
public static ConfigurationItem<HashMap<String, String>> fontPairingMap = null;
public static ConfigurationItem<HashMap<String, SwfSpecificConfiguration>> swfSpecificConfigs = null;
public static ConfigurationItem<HashMap<String, SwfSpecificCustomConfiguration>> swfSpecificCustomConfigs = null;
@ConfigurationDefaultCalendar(0)
public static ConfigurationItem<Calendar> lastUpdatesCheckDate = null;
@@ -525,6 +528,11 @@ public final class Configuration {
public static ConfigurationItem<String> lastSessionFileTitles = null;
public static ConfigurationItem<String> lastSessionSelection = null;
public static ConfigurationItem<String> lastSessionTagListSelection = null;
@ConfigurationDefaultInt(0)
public static ConfigurationItem<Integer> lastView = null;
@ConfigurationDefaultBoolean(true)
@ConfigurationCategory("ui")
@@ -897,6 +905,26 @@ public final class Configuration {
return swfConf;
}
public static SwfSpecificCustomConfiguration getSwfSpecificCustomConfiguration(String fileName) {
HashMap<String, SwfSpecificCustomConfiguration> map = swfSpecificCustomConfigs.get();
if (map == null) {
map = new HashMap<>();
swfSpecificCustomConfigs.set(map);
}
return map.get(fileName);
}
public static SwfSpecificCustomConfiguration getOrCreateSwfSpecificCustomConfiguration(String fileName) {
SwfSpecificCustomConfiguration swfConf = getSwfSpecificCustomConfiguration(fileName);
if (swfConf == null) {
swfConf = new SwfSpecificCustomConfiguration();
swfSpecificCustomConfigs.get().put(fileName, swfConf);
}
return swfConf;
}
private static String getConfigFile() throws IOException {
return getFFDecHome() + CONFIG_NAME;
@@ -933,6 +961,7 @@ public final class Configuration {
oos.writeObject(config);
} catch (IOException ex) {
//TODO: move this to GUI
ex.printStackTrace();
JOptionPane.showMessageDialog(null, "Cannot save configuration.", "Error", JOptionPane.ERROR_MESSAGE);
Logger.getLogger(Configuration.class.getName()).severe("Configuration directory is read only.");
}

View File

@@ -12,7 +12,8 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.configuration;
import java.io.Serializable;
@@ -27,5 +28,5 @@ public class SwfSpecificConfiguration implements Serializable {
public Map<String, String> fontPairingMap = new HashMap<>();
public String lastSelectedPath = null;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2010-2022 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
package com.jpexs.decompiler.flash.configuration;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author JPEXS
*/
public class SwfSpecificCustomConfiguration implements Serializable {
private Map<String, String> customData = new HashMap<>();
public static final String KEY_LAST_SELECTED_PATH_RESOURCES = "lastSelectedPath.resources";
public static final String KEY_LAST_SELECTED_PATH_TAGLIST = "lastSelectedPath.taglist";
public String getCustomData(String key, String defaultValue) {
if (customData.containsKey(key)) {
return customData.get(key);
}
return defaultValue;
}
public void setCustomData(String key, String value) {
customData.put(key, value);
}
}