01: /*
02: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
03: * for visualizing and manipulating spatial features with geometry and attributes.
04: *
05: * Copyright (C) 2003 Vivid Solutions
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: *
21: * For more information, contact:
22: *
23: * Vivid Solutions
24: * Suite #1A
25: * 2328 Government Street
26: * Victoria BC V8T 5G5
27: * Canada
28: *
29: * (250)385-6040
30: * www.vividsolutions.com
31: */
32:
33: package com.vividsolutions.jump.workbench.ui;
34:
35: import java.util.Hashtable;
36: import java.util.Iterator;
37:
38: /**
39: * A cache of the state of a DriverPanel. Used to restore a DriverPanel to
40: * a past state, to minimize re-typing for the user. Different DriverPanels
41: * can even use each other's cached values, whenever the cache keys match.
42: * For each DriverDialog, one DriverPanelCache is associated with one Layer.
43: */
44:
45: //<<TODO:DEFECT>> Not sure if this is still working. Didn't it also solve the
46: //following problem: when the user chooses a different file format from the combobox,
47: //the filename he entered gets blanked out? The problem has come back. [Jon Aquino]
48: public class DriverPanelCache {
49: /**
50: * This value is set by the DriverDialog. It always exists.
51: */
52: public static final String DRIVER_CACHE_KEY = "DRIVER";
53:
54: /**
55: * Most AbstractDriverPanels will set this value, but some do not (e.g. those
56: * that retrieve data from the web instead of a file). Thus, it almost always
57: * exists.
58: */
59: public static final String FILE_CACHE_KEY = "FILE";
60: private Hashtable map = new Hashtable();
61:
62: public DriverPanelCache() {
63: }
64:
65: /**
66: * @return the specied value, or null if no such key exists
67: */
68: public Object get(String cacheKey) {
69: return map.get(cacheKey);
70: }
71:
72: public void put(String cacheKey, Object cachedValue) {
73: map.put(cacheKey, cachedValue);
74: }
75:
76: public void addAll(DriverPanelCache otherCache) {
77: for (Iterator i = otherCache.map.keySet().iterator(); i
78: .hasNext();) {
79: String otherCacheKey = (String) i.next();
80: map.put(otherCacheKey, otherCache.get(otherCacheKey));
81: }
82: }
83: }
|