/** */ protected void notifyDocumentTypeChanged() { if (this.document == null) return; IDOMModel model = this.document.getModel(); if (model == null) return; ((DOMModelImpl) model).documentTypeChanged(); }
private boolean hasHTMLFeature(IDOMDocument document) { DocumentTypeAdapter adapter = (DocumentTypeAdapter) document.getAdapterFor(DocumentTypeAdapter.class); if (adapter == null) return false; return adapter.hasFeature(HTMLDocumentTypeConstants.HTML); }
/** * Similar to the call in HTMLContentAssistProcessor. Pass in a node, it * tells you if the document is XML type. * * @param node * */ protected boolean getXML(Node node) { if (node == null) { return false; } Document doc = null; doc = (node.getNodeType() != Node.DOCUMENT_NODE) ? node.getOwnerDocument() : ((Document) node); return (doc instanceof IDOMDocument) && ((IDOMDocument) doc).isXMLType(); }
private String getPublicId(IDOMDocument doc) { if (doc == null) return null; DocumentType doctype = doc.getDoctype(); return (doctype != null) ? doctype.getPublicId() : doc.getDocumentTypeId(); } }
/** * @param label * @param document */ public DesignerCommand(String label, IDOMDocument document) { super(label); this._model = document.getModel(); EditPart part = (EditPart) document.getAdapterFor(EditPart.class); if (part != null) { this._viewer = (IHTMLGraphicalViewer) part.getViewer(); } } /**
public static Element createDescriptionElement(IDOMDocument document, String text) { if (document == null) { return null; } Element span = document.createElement(IHTMLConstants.TAG_SPAN); //$NON-NLS-1$ span.setAttribute( "style", "color:gray;font-style:italic;font-size:normal;"); //$NON-NLS-1$ //$NON-NLS-2$ if (text == null) { span.appendChild(document.createTextNode(PDPlugin .getResourceString("ConverterUtil.Description"))); //$NON-NLS-1$ } else { span.appendChild(document.createTextNode(text)); } return span; } }
Node child = document.getFirstChild(); if (child != null && child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) { String target = child.getNodeName(); IDOMDocumentType docType = (IDOMDocumentType) document.getDoctype(); pi = document.createProcessingInstruction("xml", declaration); //$NON-NLS-1$ document.insertBefore(pi, child); insertBreak(model, child); Node parent = docType.getParentNode(); child = docType; docType = (IDOMDocumentType) document.createDoctype(name); parent.insertBefore(docType, child); parent.removeChild(child); docType = (IDOMDocumentType) document.createDoctype(name); document.insertBefore(docType, child); insertBreak(model, child); String namespaceURI = entry.getNamespaceURI(); if (namespaceURI != null) { Element element = document.getDocumentElement(); if (element != null) { element.setAttribute("xmlns", namespaceURI); //$NON-NLS-1$
if (! model.getDocument().isXMLType()){ model.getDocument(), ref); Element ele = model.getDocument().createElement("jsp:directive.taglib"); ((IDOMElement) ele).setJSPTag(true); ele.setAttribute(ICSSPropertyID.ATTR_URI, uri); nodes[0] = ele; model.getDocument().insertBefore(ele, ref[0]); new HTMLFormatProcessorImpl().formatNode(ele); Attr a = model.getDocument().createAttribute("xmlns:"+prefix); a.setValue(uri); root.setAttributeNode(a);
if (document == null) return; // error IDOMModel model = document.getModel(); if (model == null) return; // error if (oldDocumentType == null || oldDocumentType.getName() != newEntry.getName()) { DOMImplementation impl = document.getImplementation(); if (impl != null) { String name = newEntry.getName();
IDOMDocument doc = ((IDOMModel) model).getDocument(); PropagatingAdapter adapter = (PropagatingAdapter) doc .getAdapterFor(PropagatingAdapter.class); if (adapter != null) { INodeAdapterFactory factory = RefresherFactory.getInstance(); doc.addAdapter(new DocumentPageVariableAdapter(doc)); _viewer.setContents(((IDOMModel) model).getDocument()); } else {
attr = (AttrImpl) this.model.getDocument().createAttribute(name); if (attr != null) { attr.setNameRegion(region); element = (ElementImpl) this.model.getDocument().createElement(tagName);
/** */ public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) { if (eventType != INodeNotifier.STRUCTURE_CHANGED) return; if (notifier == null || !(notifier instanceof IDOMDocument)) return; this.documentType = ((IDOMDocument) notifier).getDoctype(); }
/** * shortcut method. Child class should always use this method to create a * result element. * * @param tagName * @return a new element named tagName */ public Element createElement(String tagName) { return getDestDocument().createElement(tagName); }
/** * create specified taglib declaration as jsp directive element * * @param model * @param uri * @param prefix * @return Element */ public static Element createTaglibDeclaration(IDOMModel model, String uri, String prefix) { Node[] ref = new Node[1]; BodyHelper.findHeaderInsertPosition(ITLDConstants.URI_JSP, "taglib", model.getDocument(), ref); Element ele = model.getDocument().createElement("jsp:directive.taglib"); ((IDOMElement) ele).setJSPTag(true); ele.setAttribute("uri", uri); ele.setAttribute("prefix", prefix); model.getDocument().insertBefore(ele, ref[0]); return ele; }
if (document == null) {return null;} final DocumentType docType = domModel.getDocument().getDoctype(); NodeList rootNodes = domModel.getDocument().getChildNodes();
new PageVariableAdapterFactory()); provider = new DocumentPageVariableAdapter(doc); doc.addAdapter(provider); .pushPageVarProvider(provider); Node child = xmlModel.getDocument().getFirstChild(); PreviewConvertContext context = new PreviewConvertContext(this .getDestDocument());
protected DocumentType createDoctype(EditDoctypeDialog dialog, Document document) { DocumentType result = null; if (document instanceof DocumentImpl) { IDOMDocument documentImpl = (IDOMDocument) document; IDOMDocumentType doctypeImpl = (IDOMDocumentType) documentImpl.createDoctype(dialog.getName()); doctypeImpl.setPublicId(dialog.getPublicId()); doctypeImpl.setSystemId(dialog.getSystemId()); result = doctypeImpl; } return result; }
IDOMModel model = (IDOMModel) manager.getModelForRead(id, stream, null); Element root = model.getDocument().getDocumentElement(); Element resultEle = (Element) DOMUtil.cloneNodeDeepIgnoreError( getDestDocument(), root);
public IStructuredModel createModel(IStructuredModel oldModel) { IStructuredModel model = super.createModel(oldModel); // For JSPs, the ModelQueryAdapter must be "attached" to the document // before content is set in the model, so taglib initization can // take place. // In this "clone model" case, we create a ModelQuery adapter // create a new instance from the old data. Note: I think this // "forced fit" only works here since the implimentaiton of // ModelQueryAdatper does not // have to be released. ModelQueryAdapter modelQueryAdapter = getModelQueryAdapter(model); if (modelQueryAdapter == null) { modelQueryAdapter = getModelQueryAdapter(oldModel); IDOMDocument document = ((IDOMModel) model).getDocument(); document.addAdapter(new JSPModelQueryAdapterImpl(modelQueryAdapter.getCMDocumentCache(), modelQueryAdapter.getModelQuery(), modelQueryAdapter.getIdResolver())); } return model; }
attr = (AttrImpl) this.model.getDocument().createAttribute(name); if (attr != null) attr.setNameRegion(region);