示例#1
0
              public void run() {
                try {
                  URL dtdURL = dtdNode.getURL();
                  // get the DTD object
                  DTD dtd = getDTD(dtdURL, root);
                  // convert DTD to Schema DOM tree
                  XMLDocument dtddoc = dtd.convertDTD2Schema();

                  URL classURL = URLFactory.newURL(fName);
                  if (classURL == null) {
                    JOptionPane.showMessageDialog(
                        null, "Cannot create URL for " + fName, "Ooops", JOptionPane.ERROR_MESSAGE);
                    //                  ok2go.setValue(false);
                    ok = false;
                  } else { // Let's go on
                    xsn = (XmlSchemaNode) NodeFactory.findOrCreate(XmlSchemaNode.class, classURL);
                    currentPrj.add(xsn, true);
                    xsn.open();
                    // Now the Node is created, let's create its content
                    TextBuffer tb = xsn.acquireTextBuffer();
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    PrintWriter pw = new PrintWriter(baos);
                    dtddoc.print(pw);
                    String content = baos.toString();
                    tb.beginEdit();
                    tb.append(content.toCharArray());
                    tb.endEdit();
                    ok = true;
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
示例#2
0
  /** {@inheritDoc} */
  public int getLength() {
    TextBuffer buffer = _node.acquireTextBuffer();

    try {
      return buffer.getLength();
    } finally {
      if (buffer != null) {
        _node.releaseTextBuffer();
      }
    }
  }
示例#3
0
 // </frag>
 public void open() {
   if (view == null) {
     view = new CustomEditorJPanel();
   }
   if (wn != null) {
     // read the content and feed the Editor with it.
     TextBuffer tb = wn.acquireTextBuffer();
     String content = tb.getString(0, tb.getLength());
     view.setContent(content);
   }
   view.requestFocus();
 }