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();
}
}
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);
}
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);
}
Aggregations