1 19 package org.openide.explorer.propertysheet; 20 21 import java.util.HashMap ; 22 import java.util.Map ; 23 24 25 29 class SelectionAndScrollPositionManager { 30 private static Map <String , String > groupsToNodes = new HashMap <String , String >(); 31 private static Map <String , Integer > namesToPositions = new HashMap <String , Integer >(); 32 private static final Integer zero = new Integer (0); 33 private String lastSelectedGroup = ""; 34 private String nodeName = null; 35 36 41 public void setCurrentNodeName(String name) { 42 nodeName = name; 43 } 44 45 public String getCurrentNodeName() { 46 return nodeName; 47 } 48 49 public String getLastSelectedGroupName() { 50 return lastSelectedGroup; 51 } 52 53 59 public void storeScrollPosition(int pos, String name) { 60 if (pos >= 0) { 61 synchronized (namesToPositions) { 62 namesToPositions.put(name, Integer.valueOf(pos)); 63 } 64 } 65 } 66 67 71 public void storeLastSelectedGroup(String group) { 72 if (nodeName != null) { 73 synchronized (groupsToNodes) { 74 lastSelectedGroup = group; 75 groupsToNodes.put(nodeName, group); 76 } 77 } 78 } 79 80 98 public String getGroupNameForNodeName(String name) { 99 String result = null; 100 101 synchronized (groupsToNodes) { 102 result = groupsToNodes.get(name); 103 } 104 105 if (result == null) { 106 result = lastSelectedGroup; 107 } 108 109 return result; 110 } 111 112 public int getScrollPositionForNodeName(String name) { 113 Integer result = zero; 114 Integer found = namesToPositions.get(name); 115 116 if (found != null) { 117 result = found; 118 } 119 120 return result.intValue(); 121 } 122 } 123 | Popular Tags |