当前位置: 首页>>代码示例>>Java>>正文


Java FormatProcessorXML类代码示例

本文整理汇总了Java中org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML的典型用法代码示例。如果您正苦于以下问题:Java FormatProcessorXML类的具体用法?Java FormatProcessorXML怎么用?Java FormatProcessorXML使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FormatProcessorXML类属于org.eclipse.wst.xml.core.internal.provisional.format包,在下文中一共展示了FormatProcessorXML类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addEntryPoint

import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; //导入依赖的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();
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:25,代码来源:ModuleFile.java

示例2: addXmlResultMap

import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; //导入依赖的package包/类
private boolean addXmlResultMap(final IFile xmlMapperFile)
	throws IOException, CoreException, UnsupportedEncodingException, XPathExpressionException
{
	final IStructuredModel model = StructuredModelManager.getModelManager()
		.getModelForEdit(xmlMapperFile);
	if (model == null || !(model instanceof IDOMModel))
	{
		Activator.openDialog(MessageDialog.ERROR, "Cannot move result map to XML mapper",
			"Failed to create a model for the XML mapper "
				+ xmlMapperFile.getProjectRelativePath().toString());
		return false;
	}
	try
	{
		final IDOMDocument mapperDoc = ((IDOMModel)model).getDocument();
		String id = method.getResultsId();
		if (id == null)
		{
			Shell shell = Display.getDefault().getActiveShell();
			InputDialog dialog = new InputDialog(shell, "Enter result map id",
				"Specify id of the resultMap element", "", new IInputValidator()
				{
					@Override
					public String isValid(String newText)
					{
						if (newText.length() == 0)
						{
							return "Please enter result map id.";
						}
						try
						{
							Node domNode = XpathUtil.xpathNode(mapperDoc,
								"//resultMap[@id='" + newText + "']");
							if (domNode != null)
							{
								return "A resultMap with id '" + newText
									+ "' is already defined. Id must be unique.";
							}
						}
						catch (XPathExpressionException e)
						{
							return "Error occurred while looking for a resultMap with the same id. "
								+ "Did you use some unusual characters or something?";
						}
						return null;
					}
				});
			if (dialog.open() == Window.OK)
				id = dialog.getValue();
			else
				return false;
		}

		model.beginRecording(this);
		model.aboutToChangeModel();
		Element root = mapperDoc.getDocumentElement();
		Element element = createResultMapElement(mapperDoc, id);
		root.appendChild(element);
		String delimiter = model.getStructuredDocument().getLineDelimiter();
		root.appendChild(mapperDoc.createTextNode(delimiter));
		new FormatProcessorXML().formatNode(element);
	}
	finally
	{
		if (model != null)
		{
			model.changedModel();
			if (!model.isSharedForEdit() && model.isSaveNeeded())
			{
				model.save();
			}
			model.endRecording(this);
			model.releaseFromEdit();
		}
	}
	return true;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:78,代码来源:MoveResultMapToXmlQuickAssist.java

示例3: addXmlStatement

import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML; //导入依赖的package包/类
private boolean addXmlStatement(IFile xmlMapperFile)
	throws IOException, CoreException, UnsupportedEncodingException, XPathExpressionException
{
	IStructuredModel model = StructuredModelManager.getModelManager()
		.getModelForEdit(xmlMapperFile);
	if (model == null)
	{
		Activator.openDialog(MessageDialog.ERROR, "Cannot move statement to XML mapper",
			"Failed to create a model for the XML mapper "
				+ xmlMapperFile.getProjectRelativePath().toString());
		return false;
	}

	try
	{
		model.beginRecording(this);
		model.aboutToChangeModel();
		if (model instanceof IDOMModel)
		{
			String delimiter = model.getStructuredDocument().getLineDelimiter();
			IDOMDocument mapperDoc = ((IDOMModel)model).getDocument();
			String id = method.getMethodDeclaration().getName().getFullyQualifiedName();
			Node domNode = XpathUtil.xpathNode(mapperDoc, "//*[@id='" + id + "']");
			if (domNode != null)
			{
				Activator.openDialog(MessageDialog.ERROR, "Cannot move statement to XML mapper",
					"An element with id '" + id + "' is already defined in "
						+ xmlMapperFile.getProjectRelativePath().toString());
				return false;
			}
			Element root = mapperDoc.getDocumentElement();
			Element element = createStatementElement(mapperDoc, delimiter);
			root.appendChild(element);
			root.appendChild(mapperDoc.createTextNode(delimiter));
			new FormatProcessorXML().formatNode(element);
		}
	}
	finally
	{
		model.changedModel();
		if (!model.isSharedForEdit() && model.isSaveNeeded())
		{
			model.save();
		}
		model.endRecording(this);
		model.releaseFromEdit();
	}
	return true;
}
 
开发者ID:mybatis,项目名称:mybatipse,代码行数:50,代码来源:MoveStatementToXmlQuickAssist.java


注:本文中的org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。