Exemplo n.º 1
0
  private void setDocumentImpl(final Document node, final HtmlRendererContext rcontext) {
    // Expected to be called in the GUI thread.
    /*
    if (!(node instanceof HTMLDocumentImpl)) {
      throw new IllegalArgumentException("Only nodes of type HTMLDocumentImpl are currently supported. Use DocumentBuilderImpl.");
    }
    */

    if (this.rootNode instanceof HTMLDocumentImpl) {
      final HTMLDocumentImpl prevDocument = (HTMLDocumentImpl) this.rootNode;
      prevDocument.removeDocumentNotificationListener(this.notificationListener);
    }
    if (node instanceof HTMLDocumentImpl) {
      final HTMLDocumentImpl nodeImpl = (HTMLDocumentImpl) node;
      nodeImpl.addDocumentNotificationListener(this.notificationListener);
    }

    if (node instanceof NodeImpl) {
      final NodeImpl nodeImpl = (NodeImpl) node;
      this.rootNode = nodeImpl;
      final NodeImpl fsrn = this.getFrameSetRootNode(nodeImpl);
      final boolean newIfs = fsrn != null;
      if ((newIfs != this.isFrameSet) || (this.getComponentCount() == 0)) {
        this.isFrameSet = newIfs;
        if (newIfs) {
          this.setUpFrameSet(fsrn);
        } else {
          this.setUpAsBlock(rcontext.getUserAgentContext(), rcontext);
        }
      }
      final NodeRenderer nr = this.nodeRenderer;
      if (nr != null) {
        // These subcomponents should take care
        // of revalidation.
        if (newIfs) {
          nr.setRootNode(fsrn);
        } else {
          nr.setRootNode(nodeImpl);
        }
      } else {
        this.invalidate();
        this.validate();
        this.repaint();
      }
    }
  }
Exemplo n.º 2
0
 private void clearDocumentImpl() {
   final HTMLDocumentImpl prevDocument = (HTMLDocumentImpl) this.rootNode;
   if (prevDocument != null) {
     prevDocument.removeDocumentNotificationListener(this.notificationListener);
   }
   final NodeRenderer nr = this.nodeRenderer;
   if (nr != null) {
     nr.setRootNode(null);
   }
   this.rootNode = null;
   this.htmlBlockPanel = null;
   this.nodeRenderer = null;
   this.isFrameSet = false;
   this.removeAll();
   this.revalidate();
   this.repaint();
 }
Exemplo n.º 3
0
 private boolean resetIfFrameSet() {
   final NodeImpl nodeImpl = this.rootNode;
   final NodeImpl fsrn = this.getFrameSetRootNode(nodeImpl);
   final boolean newIfs = fsrn != null;
   if ((newIfs != this.isFrameSet) || (this.getComponentCount() == 0)) {
     this.isFrameSet = newIfs;
     if (newIfs) {
       this.setUpFrameSet(fsrn);
       final NodeRenderer nr = this.nodeRenderer;
       nr.setRootNode(fsrn);
       // Set proper bounds and repaint.
       this.validate();
       this.repaint();
       return true;
     }
   }
   return false;
 }