本文整理汇总了Java中org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel.releaseFromRead方法的典型用法代码示例。如果您正苦于以下问题:Java IDOMModel.releaseFromRead方法的具体用法?Java IDOMModel.releaseFromRead怎么用?Java IDOMModel.releaseFromRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel
的用法示例。
在下文中一共展示了IDOMModel.releaseFromRead方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSchemaUiBinderElementProposal
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入方法依赖的package包/类
private void removeSchemaUiBinderElementProposal(
IStructuredDocument document, List<ICompletionProposal> proposals) {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
document);
try {
IDOMElement rootElement = (IDOMElement) model.getDocument().getDocumentElement();
if (rootElement == null) {
// There is no root element, so the <ui:UiBinder> is a valid proposal
return;
}
// Remove the proposal whose display string matches the root element's
// name (e.g. "ui:UiBinder")
for (Iterator<ICompletionProposal> it = proposals.iterator(); it.hasNext();) {
ICompletionProposal proposal = it.next();
if (rootElement.getNodeName().equals(proposal.getDisplayString())) {
it.remove();
}
}
} finally {
model.releaseFromRead();
}
}
示例2: getNamedStyleAtOffset
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入方法依赖的package包/类
private String getNamedStyleAtOffset(int offset) {
IDOMModel model = null;
IStructuredDocument document = null;
try {
model = getDomModel();
document = model.getStructuredDocument();
// ensure the offset is clean
if (offset >= document.getLength())
return getNamedStyleAtOffset(document.getLength() - 1);
else if (offset < 0)
return getNamedStyleAtOffset(0);
IStructuredDocumentRegion documentRegion = document.getFirstStructuredDocumentRegion();
while (documentRegion != null && !documentRegion.containsOffset(offset)) {
documentRegion = documentRegion.getNext();
}
if (documentRegion != null) {
// find the ITextRegion's Context at this offset
ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset);
if (interest == null)
return null;
if (offset > documentRegion.getTextEndOffset(interest))
return null;
String regionContext = interest.getType();
if (regionContext == null)
return null;
// find the named style (internal/selectable name) for that
// context
String namedStyle = (String) fContextToStyleMap.get(regionContext);
if (namedStyle != null) {
return namedStyle;
}
}
} catch (IOException e) {
Trace.trace(Trace.SEVERE, "Error while loading DOM.", e);
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return null;
}
开发者ID:angelozerr,项目名称:angular-eclipse,代码行数:42,代码来源:HTMLAngularEditorSyntaxColoringPreferencePage.java
示例3: create
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入方法依赖的package包/类
/**
* Make sure to call {@link #release()} after you are done!
*
* @return a {@link DtdRemover} or null
*/
private static DtdRemover create(ITextViewer textViewer,
int documentPosition) {
IDocumentPartitionerFactory docPartitionerFactory = new IDocumentPartitionerFactory() {
public IDocumentPartitioner createDocumentPartitioner() {
return new StructuredTextPartitionerForUiBinderXml();
}
};
StructuredDocumentCloner structuredDocumentCloner = new StructuredDocumentCloner(
IXMLPartitions.XML_DEFAULT, docPartitionerFactory);
IStructuredDocument clonedDoc = structuredDocumentCloner.clone(textViewer.getDocument());
if (clonedDoc == null) {
return null;
}
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
clonedDoc);
try {
IDOMNode docType = (IDOMNode) model.getDocument().getDoctype();
if (docType == null) {
return null;
}
IStructuredDocumentRegion firstRegion = docType.getFirstStructuredDocumentRegion();
IStructuredDocumentRegion lastRegion = docType.getLastStructuredDocumentRegion();
int firstPos = firstRegion.getStartOffset();
int lastPos = lastRegion.getEndOffset();
int docTypeLen = lastPos - firstPos;
if (docTypeLen == 0 || documentPosition >= firstPos
&& documentPosition <= lastPos) {
return null;
}
try {
clonedDoc.replace(firstPos, docTypeLen,
StringUtilities.repeatCharacter(' ', docTypeLen));
} catch (BadLocationException e) {
GWTPluginLog.logError(e,
"Unexpected bad location while removing doctype");
return null;
}
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return new DtdRemover(new DocumentChangingTextViewer(textViewer,
clonedDoc), documentPosition, structuredDocumentCloner, clonedDoc);
}
示例4: removeSchemaWidgetProposals
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入方法依赖的package包/类
private void removeSchemaWidgetProposals(List<ICompletionProposal> proposals,
IDocument document) {
PackageBasedNamespaceManager packageManager = new PackageBasedNamespaceManager();
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
document);
try {
packageManager.readFromElement(model.getDocument().getDocumentElement());
} finally {
if (model != null) {
model.releaseFromRead();
}
}
Iterator<ICompletionProposal> it = proposals.iterator();
while (it.hasNext()) {
ICompletionProposal proposal = it.next();
if (!(proposal instanceof CustomCompletionProposal)) {
// Schema-generated widget proposals are instances of this class
continue;
}
String displayString = proposal.getDisplayString();
String prefix = XmlUtilities.getPrefix(displayString);
if (prefix == null) {
// Must have a namespace
continue;
}
String packageName = packageManager.getPackageName(prefix);
if (packageName == null) {
// This doesn't map to a widget
continue;
}
String widgetName = XmlUtilities.getUnprefixed(displayString);
if (widgetName.length() == 0
|| !Character.isUpperCase(widgetName.charAt(0))) {
// Not a widget
continue;
}
// Passes our test, it must be a widget!
it.remove();
}
}
示例5: getNamedStyleAtOffset
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入方法依赖的package包/类
private String getNamedStyleAtOffset(int offset) {
IDOMModel model = null;
IStructuredDocument document = null;
try {
model = getDomModel();
document = model.getStructuredDocument();
// ensure the offset is clean
if (offset >= document.getLength())
return getNamedStyleAtOffset(document.getLength() - 1);
else if (offset < 0)
return getNamedStyleAtOffset(0);
IStructuredDocumentRegion documentRegion = document
.getFirstStructuredDocumentRegion();
while (documentRegion != null
&& !documentRegion.containsOffset(offset)) {
documentRegion = documentRegion.getNext();
}
if (documentRegion != null) {
// find the ITextRegion's Context at this offset
ITextRegion interest = documentRegion
.getRegionAtCharacterOffset(offset);
if (interest == null)
return null;
if (offset > documentRegion.getTextEndOffset(interest))
return null;
String regionContext = interest.getType();
if (regionContext == null)
return null;
// find the named style (internal/selectable name) for that
// context
String namedStyle = (String) fContextToStyleMap
.get(regionContext);
if (namedStyle != null) {
return namedStyle;
}
}
} catch (IOException e) {
Trace.trace(Trace.SEVERE, "Error while loading DOM.", e);
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return null;
}
开发者ID:angelozerr,项目名称:angularjs-eclipse,代码行数:46,代码来源:HTMLAngularEditorSyntaxColoringPreferencePage.java