本文整理汇总了Java中org.openide.xml.XMLUtil.appendChildElement方法的典型用法代码示例。如果您正苦于以下问题:Java XMLUtil.appendChildElement方法的具体用法?Java XMLUtil.appendChildElement怎么用?Java XMLUtil.appendChildElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.xml.XMLUtil
的用法示例。
在下文中一共展示了XMLUtil.appendChildElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putSubprojects
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
* Update subprojects of the project.
* Project is left modified and you must save it explicitely.
* @param helper AntProjectHelper instance
* @param subprojects list of paths to subprojects
*/
public static void putSubprojects(AntProjectHelper helper, List<String> subprojects) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
if (subproject != null) {
data.removeChild(subproject);
}
subproject = doc.createElementNS(Util.NAMESPACE, "subprojects"); // NOI18N
XMLUtil.appendChildElement(data, subproject, rootElementsOrder);
Iterator it = subprojects.iterator();
while (it.hasNext()) {
String proj = (String)it.next();
Element projEl = doc.createElementNS(Util.NAMESPACE, "project"); // NOI18N
projEl.appendChild(doc.createTextNode(proj));
subproject.appendChild(projEl);
}
Util.putPrimaryConfigurationData(helper, data);
}
示例2: putBuildXMLSourceFile
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
private static void putBuildXMLSourceFile(AntProjectHelper helper, String antPath) {
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
Element itemsEl = XMLUtil.findElement(viewEl, "items", FreeformProjectType.NS_GENERAL); // NOI18N
if (itemsEl == null) {
itemsEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "items"); // NOI18N
XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
}
Element fileEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "source-file"); // NOI18N
Element el = doc.createElementNS(FreeformProjectType.NS_GENERAL, "location"); // NOI18N
el.appendChild(doc.createTextNode(antPath)); // NOI18N
fileEl.appendChild(el);
XMLUtil.appendChildElement(itemsEl, fileEl, viewItemElementsOrder);
Util.putPrimaryConfigurationData(helper, data);
}
示例3: replaceDependencies
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
* Replaces all original dependencies with the given <code>newDeps</code>.
*
* Checks for dependency cycles, throws {@link CyclicDependencyException} if new dependencies
* introduce dependency cycle and leaves current dependencies untouched.
*/
public void replaceDependencies(final Set<ModuleDependency> newDeps) throws CyclicDependencyException {
Set<ModuleDependency> addedDeps = new HashSet<ModuleDependency>(newDeps);
try {
SortedSet<ModuleDependency> currentDeps = getDirectDependencies();
addedDeps.removeAll(currentDeps);
String warning = getDependencyCycleWarning(addedDeps);
if (warning != null) {
throw new CyclicDependencyException(warning);
}
} catch (IOException x) { // getDirectDependencies
LOG.log(Level.INFO, null, x); // and skip check
}
Element _confData = getConfData();
Document doc = _confData.getOwnerDocument();
Element moduleDependencies = findModuleDependencies(_confData);
_confData.removeChild(moduleDependencies);
moduleDependencies = createModuleElement(doc, ProjectXMLManager.MODULE_DEPENDENCIES);
XMLUtil.appendChildElement(_confData, moduleDependencies, ORDER);
SortedSet<ModuleDependency> sortedDeps = new TreeSet<ModuleDependency>(newDeps);
for (ModuleDependency md : sortedDeps) {
createModuleDependencyElement(moduleDependencies, md, null);
}
project.putPrimaryConfigurationData(_confData);
this.directDeps = sortedDeps;
}
示例4: putContextMenuAction
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
* Update context menu actions. Project is left modified and
* you must save it explicitely. This method stores all IDE actions
* before the custom actions what means that user's customization by hand
* (e.g. order of items) is lost.
* @param helper AntProjectHelper instance
* @param mappings list of <TargetMapping> instances for which the context
* menu actions will be created
*/
public static void putContextMenuAction(AntProjectHelper helper, List<TargetMapping> mappings) {
//assert ProjectManager.mutex().isWriteAccess();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element viewEl = XMLUtil.findElement(data, "view", FreeformProjectType.NS_GENERAL); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "view"); // NOI18N
XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
Element contextMenuEl = XMLUtil.findElement(viewEl, "context-menu", FreeformProjectType.NS_GENERAL); // NOI18N
if (contextMenuEl == null) {
contextMenuEl = doc.createElementNS(FreeformProjectType.NS_GENERAL, "context-menu"); // NOI18N
XMLUtil.appendChildElement(viewEl, contextMenuEl, viewElementsOrder);
}
for (Element ideActionEl : XMLUtil.findSubElements(contextMenuEl)) {
if (!ideActionEl.getLocalName().equals("ide-action")) { // NOI18N
continue;
}
contextMenuEl.removeChild(ideActionEl);
}
for (TargetMapping tm : sortMappings(mappings)) {
if (tm.context != null) {
// ignore context sensitive actions
continue;
}
Element ideAction = doc.createElementNS(FreeformProjectType.NS_GENERAL, "ide-action"); //NOI18N
ideAction.setAttribute("name", tm.name); // NOI18N
XMLUtil.appendChildElement(contextMenuEl, ideAction, contextMenuElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
示例5: insertPublicOrFriend
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/** Position public-packages or friend-packages according to XSD. */
private void insertPublicOrFriend(Element packagesEl) {
XMLUtil.appendChildElement(getConfData(), packagesEl, ORDER);
}
示例6: putSourceViews
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
* Update source views of the project.
* This method should be called always after the putSourceFolders method
* to keep views and folders in sync.
* Project is left modified and you must save it explicitely.
* @param helper AntProjectHelper instance
* @param sources list of SourceFolder instances
* @param style style of source views to update.
* Can be null in which case all styles will be overriden.
* Useful for overriding just one style of source view.
*/
public static void putSourceViews(AntProjectHelper helper, List<SourceFolder> sources, String style) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (viewEl == null) {
viewEl = doc.createElementNS(Util.NAMESPACE, "view"); // NOI18N
XMLUtil.appendChildElement(data, viewEl, rootElementsOrder);
}
Element itemsEl = XMLUtil.findElement(viewEl, "items", Util.NAMESPACE); // NOI18N
if (itemsEl == null) {
itemsEl = doc.createElementNS(Util.NAMESPACE, "items"); // NOI18N
XMLUtil.appendChildElement(viewEl, itemsEl, viewElementsOrder);
}
List<Element> sourceViews = XMLUtil.findSubElements(itemsEl);
Iterator it = sourceViews.iterator();
while (it.hasNext()) {
Element sourceViewEl = (Element)it.next();
if (!sourceViewEl.getLocalName().equals("source-folder")) { // NOI18N
continue;
}
String sourceStyle = sourceViewEl.getAttribute("style"); // NOI18N
if (style == null || style.equals(sourceStyle)) {
itemsEl.removeChild(sourceViewEl);
}
}
Iterator it2 = sources.iterator();
while (it2.hasNext()) {
SourceFolder sf = (SourceFolder)it2.next();
if (sf.style == null || sf.style.length() == 0) {
// perhaps this is principal source folder?
continue;
}
Element sourceFolderEl = doc.createElementNS(Util.NAMESPACE, "source-folder"); // NOI18N
sourceFolderEl.setAttribute("style", sf.style); // NOI18N
Element el;
if (sf.label != null) {
el = doc.createElementNS(Util.NAMESPACE, "label"); // NOI18N
el.appendChild(doc.createTextNode(sf.label)); // NOI18N
sourceFolderEl.appendChild(el);
}
if (sf.location != null) {
el = doc.createElementNS(Util.NAMESPACE, "location"); // NOI18N
el.appendChild(doc.createTextNode(sf.location)); // NOI18N
sourceFolderEl.appendChild(el);
}
if (sf.includes != null) {
el = doc.createElementNS(Util.NAMESPACE, "includes"); // NOI18N
el.appendChild(doc.createTextNode(sf.includes)); // NOI18N
sourceFolderEl.appendChild(el);
}
if (sf.excludes != null) {
el = doc.createElementNS(Util.NAMESPACE, "excludes"); // NOI18N
el.appendChild(doc.createTextNode(sf.excludes)); // NOI18N
sourceFolderEl.appendChild(el);
}
XMLUtil.appendChildElement(itemsEl, sourceFolderEl, viewItemElementsOrder);
}
Util.putPrimaryConfigurationData(helper, data);
}
示例7: addBinding
import org.openide.xml.XMLUtil; //导入方法依赖的package包/类
/**
* Add an action binding to project.xml.
* If there is no required context, the action is also added to the context menu of the project node.
* @param command the command name
* @param scriptPath the path to the generated script
* @param target the name of the target (in scriptPath)
* @param propertyName a property name to hold the selection (or null for no context, in which case remainder should be null)
* @param dir the raw text to use for the directory name
* @param pattern the regular expression to match, or null
* @param format the format to use
* @param separator the separator to use for multiple files, or null for single file only
*/
void addBinding(String command, String scriptPath, String target, String propertyName, String dir, String pattern, String format, String separator) throws IOException {
// XXX cannot use FreeformProjectGenerator since that is currently not a public support SPI from ant/freeform
// XXX should this try to find an existing binding? probably not, since it is assumed that if there was one, we would never get here to begin with
Element data = Util.getPrimaryConfigurationData(helper);
Element ideActions = XMLUtil.findElement(data, "ide-actions", Util.NAMESPACE); // NOI18N
if (ideActions == null) {
//fix for #58442:
ideActions = data.getOwnerDocument().createElementNS(Util.NAMESPACE, "ide-actions"); // NOI18N
XMLUtil.appendChildElement(data, ideActions, rootElementsOrder);
}
Document doc = data.getOwnerDocument();
Element action = doc.createElementNS(Util.NAMESPACE, "action"); // NOI18N
action.setAttribute("name", command); // NOI18N
Element script = doc.createElementNS(Util.NAMESPACE, "script"); // NOI18N
script.appendChild(doc.createTextNode(scriptPath));
action.appendChild(script);
Element targetEl = doc.createElementNS(Util.NAMESPACE, "target"); // NOI18N
targetEl.appendChild(doc.createTextNode(target));
action.appendChild(targetEl);
if (propertyName != null) {
Element context = doc.createElementNS(Util.NAMESPACE, "context"); // NOI18N
Element property = doc.createElementNS(Util.NAMESPACE, "property"); // NOI18N
property.appendChild(doc.createTextNode(propertyName));
context.appendChild(property);
Element folder = doc.createElementNS(Util.NAMESPACE, "folder"); // NOI18N
folder.appendChild(doc.createTextNode(dir));
context.appendChild(folder);
if (pattern != null) {
Element patternEl = doc.createElementNS(Util.NAMESPACE, "pattern"); // NOI18N
patternEl.appendChild(doc.createTextNode(pattern));
context.appendChild(patternEl);
}
Element formatEl = doc.createElementNS(Util.NAMESPACE, "format"); // NOI18N
formatEl.appendChild(doc.createTextNode(format));
context.appendChild(formatEl);
Element arity = doc.createElementNS(Util.NAMESPACE, "arity"); // NOI18N
if (separator != null) {
Element separatorEl = doc.createElementNS(Util.NAMESPACE, "separated-files"); // NOI18N
separatorEl.appendChild(doc.createTextNode(separator));
arity.appendChild(separatorEl);
} else {
arity.appendChild(doc.createElementNS(Util.NAMESPACE, "one-file-only")); // NOI18N
}
context.appendChild(arity);
action.appendChild(context);
} else {
// Add a context menu item, since it applies to the project as a whole.
// Assume there is already a <context-menu> defined, which is quite likely.
Element view = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
if (view != null) {
Element contextMenu = XMLUtil.findElement(view, "context-menu", Util.NAMESPACE); // NOI18N
if (contextMenu != null) {
Element ideAction = doc.createElementNS(Util.NAMESPACE, "ide-action"); // NOI18N
ideAction.setAttribute("name", command); // NOI18N
contextMenu.appendChild(ideAction);
}
}
}
ideActions.appendChild(action);
Util.putPrimaryConfigurationData(helper, data);
ProjectManager.getDefault().saveProject(project);
}