1 19 package org.openide.util; 20 21 import java.awt.*; 22 import java.awt.event.*; 23 24 import java.beans.*; 25 26 import java.io.*; 27 28 import javax.swing.*; 29 30 31 35 final class UtilitiesCompositeActionMap extends ActionMap { 36 private Component component; 37 38 public UtilitiesCompositeActionMap(Component c) { 39 this.component = c; 40 } 41 42 public int size() { 43 return keys().length; 44 } 45 46 public Action get(Object key) { 47 Component c = component; 48 49 for (;;) { 50 if (c instanceof JComponent) { 51 javax.swing.ActionMap m = ((JComponent) c).getActionMap(); 52 53 if (m != null) { 54 Action a = m.get(key); 55 56 if (a != null) { 57 return a; 58 } 59 } 60 } 61 62 if (c instanceof Lookup.Provider) { 63 break; 64 } 65 66 c = c.getParent(); 67 68 if (c == null) { 69 break; 70 } 71 } 72 73 return null; 74 } 75 76 public Object [] allKeys() { 77 return keys(true); 78 } 79 80 public Object [] keys() { 81 return keys(false); 82 } 83 84 private Object [] keys(boolean all) { 85 java.util.HashSet <Object > keys = new java.util.HashSet <Object >(); 86 87 Component c = component; 88 89 for (;;) { 90 if (c instanceof JComponent) { 91 javax.swing.ActionMap m = ((JComponent) c).getActionMap(); 92 93 if (m != null) { 94 java.util.List <Object > l; 95 96 if (all) { 97 l = java.util.Arrays.asList(m.allKeys()); 98 } else { 99 l = java.util.Arrays.asList(m.keys()); 100 } 101 102 keys.addAll(l); 103 } 104 } 105 106 if (c instanceof Lookup.Provider) { 107 break; 108 } 109 110 c = c.getParent(); 111 112 if (c == null) { 113 break; 114 } 115 } 116 117 return keys.toArray(); 118 } 119 120 public void remove(Object key) { 124 } 125 126 public void setParent(ActionMap map) { 127 } 128 129 public void clear() { 130 } 131 132 public void put(Object key, Action action) { 133 } 134 135 public ActionMap getParent() { 136 return null; 137 } 138 } 139 | Popular Tags |