本文整理汇总了Java中org.eclipse.wst.sse.core.internal.provisional.IStructuredModel类的典型用法代码示例。如果您正苦于以下问题:Java IStructuredModel类的具体用法?Java IStructuredModel怎么用?Java IStructuredModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IStructuredModel类属于org.eclipse.wst.sse.core.internal.provisional包,在下文中一共展示了IStructuredModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromIFile
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
private DataflowMavenModel fromIFile(IFile file) throws CoreException {
try {
IStructuredModel structuredModel =
StructuredModelManager.getModelManager().getModelForEdit(file);
if (structuredModel instanceof IDOMModel) {
XPath xpath = XPathFactory.newInstance().newXPath();
xpath.setNamespaceContext(POM_NS_CONTEXT);
return new DataflowMavenModel(
dependencyManager, xpath, file.getProject(), (IDOMModel) structuredModel);
} else {
throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID,
String.format("File %s wasn't a DOM model", file)));
}
} catch (IOException e) {
throw new CoreException(new Status(Status.ERROR, DataflowCorePlugin.PLUGIN_ID,
String.format("Couldn't get a DOM Model for file %s", file), e));
}
}
示例2: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model, int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
if (model != null) {
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
}
return (IDOMNode) node;
}
示例3: getFile
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
* Returns the owner file of the JFace document {@link IDocument}.
*
* @param document
* @return
*/
public static final IFile getFile(IDocument document) {
if (document == null) {
return null;
}
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (model != null) {
return getFile(model);
}
} finally {
if (model != null)
model.releaseFromRead();
}
return null;
}
示例4: customizeDocumentCommand
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
@Override
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
if (!supportsSmartInsert(document)) {
return;
}
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
if (model != null) {
if (command.text != null) {
smartInsertCloseEndEL(command, document, model);
}
}
} finally {
if (model != null)
model.releaseFromRead();
}
}
示例5: smartInsertCloseEndEL
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
private void smartInsertCloseEndEL(DocumentCommand command, IDocument document, IStructuredModel model) {
try {
if (isPreferenceEnabled(AngularUIPreferenceNames.TYPING_COMPLETE_END_EL) && command.text.equals("{") //$NON-NLS-1$
&& document.getLength() > 0 && document.getChar(command.offset - 1) == '{') {
IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset - 1);
command.text += "}}";
command.shiftsCaret = false;
command.caretOffset = command.offset + 1;
command.doit = false;
}
} catch (BadLocationException e) {
}
}
示例6: getModelForResource
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
*
* @param file
* the file to get the model for
* @return the file's JSONModel or null
*/
protected IJSONModel getModelForResource(IFile file) {
IStructuredModel model = null;
IModelManager manager = StructuredModelManager.getModelManager();
try {
model = manager.getModelForRead(file);
// TODO.. HTML validator tries again to get a model a 2nd way
}
catch (Exception e) {
Logger.log(Logger.ERROR_DEBUG, file.getFullPath().toString(), e);
}
if (model instanceof IJSONModel)
return (IJSONModel) model;
if (model != null)
model.releaseFromRead();
return null;
}
示例7: cleanupModel
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
public void cleanupModel(IStructuredModel structuredModel, int start,
int length) {
JSONFormatUtil formatUtil = JSONFormatUtil.getInstance();
if (structuredModel instanceof IJSONModel) {
IJSONDocument doc = ((IJSONModel) structuredModel).getDocument();
IJSONSourceFormatter formatter = JSONSourceFormatterFactory
.getInstance().getSourceFormatter((INodeNotifier) doc);
StringBuilder buf = formatter.cleanup(doc);
if (buf != null) {
int startOffset = ((IndexedRegion) doc).getStartOffset();
int endOffset = ((IndexedRegion) doc).getEndOffset();
formatUtil.replaceSource(doc.getModel(), startOffset, endOffset
- startOffset, buf.toString());
}
}
}
示例8: extractNamespace
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
private String extractNamespace(IFile file)
{
IStructuredModel model = null;
try
{
model = StructuredModelManager.getModelManager().getModelForRead(file);
IDOMModel domModel = (IDOMModel)model;
IDOMDocument domDoc = domModel.getDocument();
Node node = XpathUtil.xpathNode(domDoc, "//mapper/@namespace");
return node == null ? null : node.getNodeValue();
}
catch (Exception e)
{
Activator.log(Status.ERROR, "Error occurred during parsing mapper:" + file.getFullPath(),
e);
}
finally
{
if (model != null)
{
model.releaseFromRead();
}
}
return null;
}
示例9: getMapperDocument
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
public static IDOMDocument getMapperDocument(IFile mapperXmlFile)
{
if (mapperXmlFile == null)
return null;
IStructuredModel model = null;
try
{
model = StructuredModelManager.getModelManager().getModelForRead(mapperXmlFile);
IDOMModel domModel = (IDOMModel)model;
IDOMDocument mapperDocument = domModel.getDocument();
return mapperDocument;
}
catch (Exception e)
{
Activator.log(Status.ERROR, e.getMessage(), e);
}
finally
{
if (model != null)
{
model.releaseFromRead();
}
}
return null;
}
示例10: validateImage
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
* Validate img/@src
*
* @param documentRegion
* @param reporter
* @param model
* @param file
* @param factory
* @param attrValueRegion
* @param resourceType
*/
private void validateImage(IStructuredDocumentRegion documentRegion,
IReporter reporter, IStructuredModel model, IFile file,
MessageFactory factory, WebResourcesTextRegion attrValueRegion,
WebResourcesFinderType resourceType) {
IDOMAttr attr = DOMHelper.getAttrByOffset(model,
documentRegion.getStartOffset()
+ attrValueRegion.getRegion().getStart());
if (attr != null) {
String attrValue = DOMHelper.getAttrValue(documentRegion
.getText(attrValueRegion.getRegion()));
if (URIHelper.isDataURIScheme(attrValue)) {
// see https://en.wikipedia.org/wiki/Data_URI_scheme
// ex : <img
// src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="
// alt="Red dot" />
// TODO : validate format of data uri scheme.
} else {
// ex : <img src="path/to/image.png" />
validateFile(documentRegion, reporter, model, file, factory,
attrValueRegion, resourceType);
}
}
}
示例11: getFile
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
* Returns the owner file of the JFace document {@link IDocument}.
*
* @param document
* @return
*/
public static final IFile getFile(IDocument document) {
if (document == null) {
return null;
}
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager()
.getExistingModelForRead(document);
if (model != null) {
return getFile(model);
}
} finally {
if (model != null)
model.releaseFromRead();
}
return null;
}
示例12: getModel
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
public static ICSSModel getModel(File file) {
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager()
.getExistingModelForRead(file);
if (model == null) {
model = StructuredModelManager.getModelManager()
.getModelForRead(file.getPath(),
new FileInputStream(file), null);
}
return (ICSSModel) model;
} catch (Exception e) {
}
return null;
}
示例13: getNodeByOffset
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
/**
* Returns the SSE DOM Node {@link IDOMNode} by offset from the
* {@link IStructuredModel} SSE mode and null if not found.
*
* @param model
* the SSE model.
* @param offset
* the offset.
* @return
*/
public static final IDOMNode getNodeByOffset(IStructuredModel model,
int offset) {
IndexedRegion node = null;
if (model != null) {
node = model.getIndexedRegion(offset);
if (node instanceof IDOMNode) {
return (IDOMNode) node;
}
int lastOffset = offset;
node = model.getIndexedRegion(offset);
while (node == null && lastOffset >= 0) {
lastOffset--;
node = model.getIndexedRegion(lastOffset);
}
}
return (IDOMNode) node;
}
示例14: customizeDocumentCommand
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
@Override
public void customizeDocumentCommand(IDocument document,
DocumentCommand command) {
if (!supportsSmartInsert(document)) {
return;
}
IStructuredModel model = null;
try {
model = StructuredModelManager.getModelManager()
.getExistingModelForRead(document);
if (model != null) {
if (command.text != null) {
smartInsertCloseEndEL(command, document, model);
}
}
} finally {
if (model != null)
model.releaseFromRead();
}
}
示例15: smartInsertCloseEndEL
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; //导入依赖的package包/类
private void smartInsertCloseEndEL(DocumentCommand command,
IDocument document, IStructuredModel model) {
try {
if (isPreferenceEnabled(AngularUIPreferenceNames.TYPING_COMPLETE_END_EL)
&& command.text.equals("{") && document.getLength() > 0 && document.getChar(command.offset - 1) == '{') { //$NON-NLS-1$
IDOMNode node = (IDOMNode) model
.getIndexedRegion(command.offset - 1);
command.text += "}}";
command.shiftsCaret = false;
command.caretOffset = command.offset + 1;
command.doit = false;
}
} catch (BadLocationException e) {
}
}