Ejemplo n.º 1
1
  public void unregisterKeyStroke(KeyStroke ks, JComponent c) {

    // component may have already been removed from the hierarchy, we
    // need to look up the container using the componentKeyStrokeMap.

    ComponentKeyStrokePair ckp = new ComponentKeyStrokePair(c, ks);

    Container topContainer = componentKeyStrokeMap.get(ckp);

    if (topContainer == null) { // never heard of this pairing, so bail
      return;
    }

    Hashtable keyMap = containerMap.get(topContainer);
    if (keyMap == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    Object tmp = keyMap.get(ks);
    if (tmp == null) { // this should never happen, but I'm being safe
      Thread.dumpStack();
      return;
    }

    if (tmp instanceof JComponent && tmp == c) {
      keyMap.remove(ks); // remove the KeyStroke from the Map
      // System.out.println("removed a stroke" + ks);
    } else if (tmp
        instanceof Vector) { // this means there is more than one component reg for this key
      Vector v = (Vector) tmp;
      v.removeElement(c);
      if (v.isEmpty()) {
        keyMap.remove(ks); // remove the KeyStroke from the Map
        // System.out.println("removed a ks vector");
      }
    }

    if (keyMap.isEmpty()) { // if no more bindings in this table
      containerMap.remove(topContainer); // remove table to enable GC
      // System.out.println("removed a container");
    }

    componentKeyStrokeMap.remove(ckp);

    // Check for EmbeddedFrame case, they know how to process accelerators even
    // when focus is not in Java
    if (topContainer instanceof EmbeddedFrame) {
      ((EmbeddedFrame) topContainer).unregisterAccelerator(ks);
    }
  }
Ejemplo n.º 2
0
 public void unregisterMenuBar(JMenuBar mb) {
   Container topContainer = getTopAncestor(mb);
   if (topContainer == null) {
     return;
   }
   Hashtable keyMap = containerMap.get(topContainer);
   if (keyMap != null) {
     Vector v = (Vector) keyMap.get(JMenuBar.class);
     if (v != null) {
       v.removeElement(mb);
       if (v.isEmpty()) {
         keyMap.remove(JMenuBar.class);
         if (keyMap.isEmpty()) {
           // remove table to enable GC
           containerMap.remove(topContainer);
         }
       }
     }
   }
 }
Ejemplo n.º 3
0
 public void removeReferencedElement(ModelElement x) throws PropertyVetoException {
   if (_referencedElement == null) return;
   fireVetoableChange("referencedElement", _referencedElement, x);
   _referencedElement.removeElement(x);
 }