/** Remove self when referenced document is closed. */
 public boolean semanticEventAfter(SemanticEvent se, String msg) {
   if (Document.MSG_CLOSE == msg && isSet() && getStart().leaf.getDocument() == se.getArg())
     moveq(null); // destroy();
   /*	else if (DocumentPopup.MSG_CREATE_DOCPOPUP==msg && se.getIn()==this) {
   	Browser br = getBrowser();
   	br.eventq(new SemanticEvent(br, "createWidget/SELECTIONPOPUP", se.getArg(), this/*se.getIn()* /, se.getOut()));
   }*/
   return false;
 }
 public boolean semanticEventAfter(SemanticEvent se, String msg) {
   Object arg = se.getArg();
   String winclass = getAttr("winclass");
   if (MSG_NEW == msg && this == arg && winclass != null) {
     Map<String, Object> attrs = (Map) CHashMap.getInstance(getAttr("attrs"));
     Browser br = getBrowser();
     Layer layer =
         (getAttr("doc") == null ? br.getRoot() : br.getCurDocument())
             .getLayer(getAttr("layer", Layer.SCRATCH));
     // System.out.println("system layer behaviors\n\t");
     //		for (Iterator<> i=systemLayer.behaviorIterator(); i.hasNext(); )
     // System.out.println(((Behavior)i.next()).getName()+" ");
     Behavior.getInstance(winclass /*for now -- getName() not right*/, winclass, attrs, layer);
     // if (win.getTitle()==null) win.setTitle(getAttr("title"));    // share TITLE attribute with
     // target VFrame, if it doesn't have one
     // if (lastbbox_==null) lastbbox_=win.getBounds(); else {
     // win.setLocation(lastbbox_.x,lastbbox_.y); win.setSize(lastbbox_.width,lastbbox_.height); }
     // getBrowser().eventq(VFrame.SHOWEVENT, win); -- part of VFrame restore()
   }
   // if (VFrame.SHOWEVENT==msg && this==arg) System.out.println("SHOW on "+winclass);
   return super.semanticEventAfter(se, msg);
 }
  public boolean semanticEventAfter(SemanticEvent se, String msg) {
    // System.out.println("outlineOpen on active_="+active_+", msg="+msg);
    if (Outliner.MSG_MADE == msg) {
      Object o = se.getArg();
      if (o instanceof Node) {
        active_ = true;
        ((Node) o).addObserver(this);
        Browser br = getBrowser();
        br.eventq(new SemanticEvent(br, Executive.MSG_SUMMARY, "ON"));
      }

    } else if (!active_) {
      // nothing -- page fully on screen

    } else if (DocumentPopup.MSG_CREATE_DOCPOPUP == msg
        && se.getIn() != getBrowser().getSelectionSpan()) { // null)) { -- just plain-doc popup
      // System.out.println("**** f/b createMenu "+super.toString()+", in="+se.getIn());
      INode menu = (INode) se.getOut();
      createUI(
          "button",
          "Fully Collapse Outline",
          "event " + OutlineSpan.MSG_CLOSE_ALL,
          menu,
          "SPECIFIC",
          false);
      createUI(
          "button",
          "Fully Open (or Space to smart scroll)",
          "event " + Executive.MSG_SUMMARY + " OFF; event outlineOpenAll",
          menu,
          "SPECIFIC",
          false);

      /*	} else if (msg.startsWith("outline")) {
      		//if (first_/* && false* /) {
      			CLGeneral gs = (CLGeneral)getDocument().getStyleSheet().get("excerpt");
      			if (gs.getSize()!=CLGeneral.INVALID) {
      				gs.setElide(CLGeneral.BOOLINVALID); gs.setSize(CLGeneral.INVALID);
      				for (Iterator<> i=excerptSpans_.iterator(); i.hasNext(); ) ((Span)i.next()).markDirty();  // Span class only marks dirty if set
      			}
      		//}
      */
    } else if (OutlineSpan.MSG_OPEN == msg) {
      Object o = se.getArg();
      if (o instanceof OutlineSpan) outActive_ = (OutlineSpan) o;
      // System.out.println("outlineOpen on "+o+" / "+outActive_.getStart().leaf.getNextLeaf());

    } else if (Executive.MSG_SUMMARY == msg) {
      Object o = se.getArg();
      if (o instanceof String) {
        //			CLGeneral gs = (CLGeneral)getDocument().getStyleSheet().get("excerpt");
        /*			if ("ON".equalsIgnoreCase((String)o)) { gs.setElide(CLGeneral.FALSE); gs.setSize(10); outActive_=null;
        } else { gs.setElide(CLGeneral.BOOLINVALID); gs.setSize(CLGeneral.INVALID); }*/
        StyleSheet ss = getDocument().getStyleSheet();
        if (ssl_ == null) {
          ssl_ = new ArrayList<Object>(6);
          for (StyleSheet ssn = ss; ssn != null; ssn = ssn.getCascade()) {
            Object sse = ssn.get("excerpt");
            if (sse != null) {
              ssl_.add(ssn);
              ssl_.add(sse);
            }
          }
          // if (excerpt_==null) excerpt_ = (CLGeneral)ss.get("excerpt");
        }
        // System.out.println(ss.getName()+" => excerpt "+excerpt_);
        if ("ON".equalsIgnoreCase((String) o)) {
          for (int i = 0, imax = ssl_.size(); i < imax; i += 2)
            ((StyleSheet) ssl_.get(i)).put("excerpt", (ContextListener) ssl_.get(i + 1));
          // ss.put("excerpt", excerpt_);
          outActive_ = null;
          // System.out.println("putting excerpt in "+getDocument().getFirstLeaf()+"
          // "+excerpt_.getSize()+" / "+excerpt_.getElide());
        } else { // ss.remove("excerpt");
          for (int i = 0, imax = ssl_.size(); i < imax; i += 2)
            ((StyleSheet) ssl_.get(i)).remove("excerpt");
        }
        // for (Iterator<> i=excerptSpans_.iterator(); i.hasNext(); ) ((Span)i.next()).markDirty();
        // -- execsum already reformats whole tree
      }
    } else if (Document.MSG_CLOSE == msg) {
      for (int i = 0, imax = ssl_.size(); i < imax; i += 2)
        ((StyleSheet) ssl_.get(i)).put("excerpt", (ContextListener) ssl_.get(i + 1));
      //		getDocument().getStyleSheet().put("excerpt", excerpt_);    // stylesheet shared, so
      // restore!
    }
    return super.semanticEventAfter(se, msg);
  }