本文整理汇总了Java中org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel类的典型用法代码示例。如果您正苦于以下问题:Java IDOMModel类的具体用法?Java IDOMModel怎么用?Java IDOMModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDOMModel类属于org.eclipse.wst.xml.core.internal.provisional.document包,在下文中一共展示了IDOMModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromIFile
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的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: completion
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
private List<CompletionItem> completion(String html, int offset) throws CoreException {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
if (!project.exists()) {
project.create(new NullProgressMonitor());
project.open(new NullProgressMonitor());
}
IFile file = project.getFile("test.html");
if (file.exists()) {
file.setContents(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
} else {
file.create(IOUtils.toInputStream(html), 1, new NullProgressMonitor());
}
IDOMModel model = DOMUtils.getModel(project, file);
IDOMElement element = (IDOMElement) DOMUtils.getNodeByOffset(model, offset);
IDOMAttr attr = DOMUtils.getAttrByOffset(element, offset);
String attrName = attr.getName();
CompletionCollector collector = new CompletionCollector(element, attr);
AngularCorePlugin.getBindingManager().collect(element, attrName, file, collector);
return collector.getList();
}
示例3: addEntryPoint
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
/**
* Adds a new entry point to a module.
*
* @param qualifiedTypeName name of the entry point class, which should
* com.google.gwt.core.client.EntryPoint
* @throws Exception if there was a problem modifying or saving the module XML
*/
public void addEntryPoint(final String qualifiedTypeName) throws Exception {
new EditModelOperation() {
@Override
public void editModel(IDOMModel model) {
IDOMDocument editDoc = model.getDocument();
// TODO: create an empty element (no closing </entry-point>)
Element entryPointElement = editDoc.createElement(ENTRY_POINT_TAG_NAME);
entryPointElement.setAttribute(CLASS_ATTRIBUTE_NAME, qualifiedTypeName);
editDoc.getDocumentElement().appendChild(entryPointElement);
// Reformat the XML source to keep it nice and neat
new FormatProcessorXML().formatModel(model);
}
}.run();
}
示例4: getAddLinkers
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
/**
* returns a list of the <add-linker name="[return value]"/>
*
* @return a list of the add linker names.
*/
@Override
public List<String> getAddLinkers() {
final List<String> ret = new ArrayList<String>();
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
ret.addAll(getElementsAttributes(doc, ADD_LINKER, NAME_ATTRIBUTE_NAME, null));
}
}.run();
return ret;
}
示例5: getCompiledName
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public String getCompiledName() {
final String[] compiledName = new String[] {getQualifiedName()};
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
Element moduleElement = doc.getDocumentElement();
String renameTo = moduleElement.getAttribute(RENAME_TO_ATTRIBUTE);
if (renameTo != null) {
compiledName[0] = renameTo;
}
}
}.run();
return compiledName[0];
}
示例6: getEntryPoints
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public List<String> getEntryPoints() {
final List<String> ret = new ArrayList<String>();
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
// Extract the entry point classes
ret.addAll(getElementsAttributes(doc, ENTRY_POINT_TAG_NAME, CLASS_ATTRIBUTE_NAME, null));
}
}.run();
return ret;
}
示例7: getInheritedModules
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public Set<IModule> getInheritedModules(final IJavaProject javaProject) {
final Set<IModule> modules = new HashSet<IModule>();
new ReadModelOperation() {
@Override
protected void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
for (String moduleName : getElementsAttributes(doc, INHERITS_TAG_NAME, NAME_ATTRIBUTE_NAME,
null)) {
// don't look up any modules in jar files, because this is slllloow
AbstractModule module =
(AbstractModule) ModuleUtils.findModule(javaProject, moduleName, false);
if (module != null) {
modules.add(module);
}
}
}
}.run();
return modules;
}
示例8: getPublicPaths
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public List<IPath> getPublicPaths() {
final List<IPath> ret = new ArrayList<IPath>();
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
List<String> publicPathNames =
getElementsAttributes(doc, PUBLIC_PATH_TAG_NAME, PATH_ATTRIBUTE_NAME, "public");
// TODO: if no path attribute, default to . (current directory)
// Convert the public paths to IPath's (relative to the module location)
for (String publicPathName : publicPathNames) {
ret.add(new Path(publicPathName));
}
}
}.run();
return ret;
}
示例9: getSetConfigurationProperty
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
/**
* Returns a list of the <set-configuration-property name="propertyName" value="[return value]"/>.
*
* @return a list of the set configuration values for the property name.
*/
@Override
public List<String> getSetConfigurationProperty(final String propertyName) {
final List<String> ret = new ArrayList<String>();
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
ret.addAll(getElementsAttributes(doc, SET_CONFIGURATION_PROPERTY, propertyName, null));
}
}.run();
return ret;
}
示例10: getSourcePaths
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public List<IPath> getSourcePaths() {
final List<IPath> ret = new ArrayList<IPath>();
new ReadModelOperation() {
@Override
public void readModel(IDOMModel model) {
IDOMDocument doc = model.getDocument();
List<String> sourcePathNames =
getElementsAttributes(doc, SOURCE_PATH_TAG_NAME, PATH_ATTRIBUTE_NAME, "client");
// TODO: if no path attribute, default to . (current directory)
// Convert the source paths to IPath's (relative to the module location)
for (String sourcePathName : sourcePathNames) {
ret.add(new Path(sourcePathName));
}
}
}.run();
return ret;
}
示例11: onApply
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
@Override
public void onApply(IDocument document, ITextViewer viewer)
throws BadLocationException {
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForEdit(
document);
if (model == null) {
return;
}
try {
apply(document, viewer,
(IDOMElement) model.getDocument().getDocumentElement());
} finally {
model.releaseFromEdit();
}
}
示例12: 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();
}
}
示例13: resolveUiBinderNamespacePrefix
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的package包/类
/**
* @see #resolveUiBinderNamespacePrefix(IStructuredDocument)
*/
public static String resolveUiBinderNamespacePrefix(IDOMModel xmlModel) {
Element element = xmlModel.getDocument().getDocumentElement();
if (element == null) {
return null;
}
NamedNodeMap attributes = element.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node item = attributes.item(i);
if (item.getNamespaceURI() == null || item.getNodeValue() == null) {
// This attr cannot be a namespace prefix definition since those attrs
// must be in xmlns's namespace and must have an attr value.
continue;
}
if (item.getNamespaceURI().equals(UiBinderConstants.XMLNS_NAMESPACE)
&& item.getNodeValue().equals(
UiBinderConstants.UI_BINDER_XML_NAMESPACE)) {
return item.getLocalName();
}
}
return null;
}
示例14: extractNamespace
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的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;
}
示例15: getMapperDocument
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; //导入依赖的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;
}