Search in sources :

Example 6 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class WebContentSettingsPropertyPage method populateDoctypeValues.

private void populateDoctypeValues() {
    fDocumentTypeIds = new ArrayList();
    // add none first
    fDocumentTypeCombo.add(SELECT_NONE);
    fDocumentTypeIds.add(null);
    HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance();
    Enumeration e = reg.getEntries();
    while (e.hasMoreElements()) {
        HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement();
        String publicId = entry.getPublicId();
        String displayName = entry.getDisplayName();
        displayName = displayName != null ? displayName : publicId;
        fDocumentTypeCombo.add(displayName);
        fDocumentTypeIds.add(publicId);
        if (displayName.length() > maxLengthStringInHTMLDocumentTypeRegistry.length()) {
            maxLengthStringInHTMLDocumentTypeRegistry = displayName;
        }
        if (entry.getSystemId() == null)
            // if HTML entry
            continue;
        if (entry.getSystemId().length() > maxLengthStringInHTMLDocumentTypeRegistry.length())
            maxLengthStringInHTMLDocumentTypeRegistry = entry.getSystemId();
    }
}
Also used : Enumeration(java.util.Enumeration) HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) ArrayList(java.util.ArrayList) HTMLDocumentTypeRegistry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)

Example 7 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class HTMLTagsCompletionProposalComputer method addDocTypeProposal.

/**
 * @param contentAssistRequest
 * @param isXHTML
 */
private void addDocTypeProposal(ContentAssistRequest contentAssistRequest, boolean isXHTML) {
    // if a DocumentElement exists, use that for the root Element name
    // $NON-NLS-1$
    String rootname = "unspecified";
    if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) {
        rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName();
    }
    // decide which entry to use
    HTMLDocumentTypeEntry entry;
    if (isXHTML) {
        entry = HTMLDocumentTypeRegistry.getInstance().getXHTMLDefaultEntry();
    } else {
        entry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry();
    }
    // create the content assist string and proposal
    String proposedText = // $NON-NLS-1$ //$NON-NLS-2$
    "<!DOCTYPE " + rootname + " PUBLIC \"" + entry.getPublicId() + "\" \"" + entry.getSystemId() + // $NON-NLS-1$ //$NON-NLS-2$
    "\">";
    ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 10, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE), // $NON-NLS-1$
    entry.getDisplayName() + " " + HTMLUIMessages.Expandable_label_document_type, null, null, XMLRelevanceConstants.R_DOCTYPE);
    contentAssistRequest.addProposal(proposal);
}
Also used : HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) CustomCompletionProposal(org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)

Example 8 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class ContentSettingsRegistry method setHTMLDocumentTypeRegistryInto.

public static void setHTMLDocumentTypeRegistryInto(ComboList combo) {
    // $NON-NLS-1$
    combo.add(NONE, "");
    HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance();
    Enumeration e = reg.getEntries();
    while (e.hasMoreElements()) {
        HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement();
        String publicId = entry.getPublicId();
        String displayName = entry.getDisplayName();
        if (displayName != null) {
            combo.add(displayName, publicId);
            if (displayName.length() > maxLengthStringInHTMLDocumentTypeRegistry.length())
                maxLengthStringInHTMLDocumentTypeRegistry = displayName;
        } else
            combo.add(publicId, publicId);
        if (publicId.length() > maxLengthStringInHTMLDocumentTypeRegistry.length())
            maxLengthStringInHTMLDocumentTypeRegistry = publicId;
        if (entry.getSystemId() == null)
            // if HTML entry
            continue;
        if (entry.getSystemId().length() > maxLengthStringInHTMLDocumentTypeRegistry.length())
            maxLengthStringInHTMLDocumentTypeRegistry = entry.getSystemId();
    }
    combo.sortByKey(1);
}
Also used : Enumeration(java.util.Enumeration) HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) HTMLDocumentTypeRegistry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)

Aggregations

HTMLDocumentTypeEntry (org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry)8 Enumeration (java.util.Enumeration)4 HTMLDocumentTypeRegistry (org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)4 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)3 Document (org.w3c.dom.Document)2 ArrayList (java.util.ArrayList)1 IDocument (org.eclipse.jface.text.IDocument)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)1 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1