use of org.jdom.Parent in project intellij-community by JetBrains.
the class ShelveChangesManager method createShelveSchemeManager.
@NotNull
private SchemeManager<ShelvedChangeList> createShelveSchemeManager(@NotNull Project project, @Nullable String customPath) {
FilePath customShelfFilePath = customPath != null ? VcsUtil.getFilePath(myPathMacroSubstitutor.expandPath(customPath)) : null;
//don't collapse custom paths
final boolean shouldCollapsePath = !VcsConfiguration.getInstance(myProject).USE_CUSTOM_SHELF_PATH;
return SchemeManagerFactory.getInstance(project).create(customShelfFilePath != null ? customShelfFilePath.getName() : SHELVE_MANAGER_DIR_PATH, new NonLazySchemeProcessor<ShelvedChangeList, ShelvedChangeList>() {
@NotNull
@Override
public ShelvedChangeList readScheme(@NotNull Element element, boolean duringLoad) throws InvalidDataException {
return readOneShelvedChangeList(element);
}
@NotNull
@Override
public Parent writeScheme(@NotNull ShelvedChangeList scheme) throws WriteExternalException {
Element child = new Element(ELEMENT_CHANGELIST);
scheme.writeExternal(child);
if (shouldCollapsePath) {
myPathMacroSubstitutor.collapsePaths(child);
}
return child;
}
}, null, customPath != null ? Paths.get(customPath) : null);
}
use of org.jdom.Parent in project intellij-community by JetBrains.
the class FileStorageCoreUtil method findComponentName.
@Nullable
public static String findComponentName(@NotNull Element element) {
Element componentElement = element;
while (true) {
Parent parent = componentElement.getParent();
if (parent == null || !(parent instanceof Element)) {
break;
}
componentElement = (Element) parent;
}
return StringUtil.nullize(componentElement.getAttributeValue(NAME));
}
use of org.jdom.Parent in project vcell by virtualcell.
the class PathwayXMLHelper method getElementPathString.
private static String getElementPathString(Element childElement) {
StringBuffer buffer = new StringBuffer();
Element element = childElement;
while (element != null) {
if (buffer.length() == 0) {
buffer.append(element.getName());
} else {
buffer.insert(0, element.getName() + "/");
}
Parent parent = element.getParent();
if (parent instanceof Element) {
element = (Element) parent;
} else if (parent instanceof Document) {
return buffer.toString();
} else {
return buffer.toString();
}
}
return buffer.toString();
}
use of org.jdom.Parent in project vcell by virtualcell.
the class VCMLComparator method getPathToRoot.
// utility method, can be moved in the xml util class/package
private static String getPathToRoot(Element e) {
StringBuffer buf = new StringBuffer();
String attName, attVal;
while (e != null) {
// will not work for compound pks, but ok for now.
attName = (String) map.get(e.getName());
if (attName == null)
attName = XMLTags.NameAttrTag;
attVal = e.getAttributeValue(attName);
if (attVal != null) {
buf.append(e.getName() + ": " + attVal + "/");
}
Parent parent = e.getParent();
if (parent instanceof Element) {
e = (Element) parent;
} else if (parent instanceof Document) {
// we reached the root already
return buf.toString();
} else {
// this should not happen, anyway we return what we've got so far
return buf.toString();
}
}
return buf.toString();
}
use of org.jdom.Parent in project vcell by virtualcell.
the class RDFXMLContext method getBaseURI.
public String getBaseURI(Element element) {
String baseURI = getBaseURIFromCache(element);
if (StringUtil.isEmpty(baseURI)) {
baseURI = element.getAttributeValue("base", Namespace.XML_NAMESPACE);
if (StringUtil.isEmpty(baseURI)) {
Parent parent = element.getParent();
// At the root level, element.getParent() returns Document, which is non-null, assign defaultBaseURI to 'baseURI'.
if (parent != null) {
if (parent instanceof Element) {
baseURI = getBaseURI((Element) parent);
} else {
baseURI = defaultBaseURI;
}
} else {
baseURI = defaultBaseURI;
}
}
addBaseURIToCache(element, baseURI);
}
return baseURI;
}
Aggregations