Lines 1-3
Link Here
|
|
|
1 |
|
1 |
/* |
2 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* |
Lines 142-148
Link Here
|
142 |
if (shared) { |
143 |
if (shared) { |
143 |
//first check the document schedule for persistence |
144 |
//first check the document schedule for persistence |
144 |
if (scheduledDocument != null) { |
145 |
if (scheduledDocument != null) { |
145 |
Element el = findElement(scheduledDocument.getDocumentElement(), elementName, namespace); |
146 |
Element el = XMLUtil.findElement(scheduledDocument.getDocumentElement(), elementName, namespace); |
146 |
if (el != null) { |
147 |
if (el != null) { |
147 |
el = (Element) el.cloneNode(true); |
148 |
el = (Element) el.cloneNode(true); |
148 |
} |
149 |
} |
Lines 159-165
Link Here
|
159 |
//TODO shall be have some kind of caching here to prevent frequent IO? |
160 |
//TODO shall be have some kind of caching here to prevent frequent IO? |
160 |
doc = XMLUtil.parse(new InputSource(in), false, true, null, null); |
161 |
doc = XMLUtil.parse(new InputSource(in), false, true, null, null); |
161 |
cachedDoc = doc; |
162 |
cachedDoc = doc; |
162 |
return findElement(doc.getDocumentElement(), elementName, namespace); |
163 |
return XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace); |
163 |
} catch (SAXException ex) { |
164 |
} catch (SAXException ex) { |
164 |
ProblemReporterImpl impl = project.getProblemReporter(); |
165 |
ProblemReporterImpl impl = project.getProblemReporter(); |
165 |
if (!impl.hasReportWithId(BROKEN_NBCONFIG)) { |
166 |
if (!impl.hasReportWithId(BROKEN_NBCONFIG)) { |
Lines 189-195
Link Here
|
189 |
} else { |
190 |
} else { |
190 |
//reuse cached value if available; |
191 |
//reuse cached value if available; |
191 |
if (cachedDoc != null) { |
192 |
if (cachedDoc != null) { |
192 |
return findElement(cachedDoc.getDocumentElement(), elementName, namespace); |
193 |
return XMLUtil.findElement(cachedDoc.getDocumentElement(), elementName, namespace); |
193 |
} |
194 |
} |
194 |
} |
195 |
} |
195 |
} else { |
196 |
} else { |
Lines 203-209
Link Here
|
203 |
Document doc; |
204 |
Document doc; |
204 |
try { |
205 |
try { |
205 |
doc = XMLUtil.parse(new InputSource(new StringReader(str)), false, true, null, null); |
206 |
doc = XMLUtil.parse(new InputSource(new StringReader(str)), false, true, null, null); |
206 |
return findElement(doc.getDocumentElement(), elementName, namespace); |
207 |
return XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace); |
207 |
} catch (SAXException ex) { |
208 |
} catch (SAXException ex) { |
208 |
ex.printStackTrace(); |
209 |
ex.printStackTrace(); |
209 |
} catch (IOException ex) { |
210 |
} catch (IOException ex) { |
Lines 254-260
Link Here
|
254 |
} |
255 |
} |
255 |
} |
256 |
} |
256 |
if (doc != null) { |
257 |
if (doc != null) { |
257 |
Element el = findElement(doc.getDocumentElement(), fragment.getNodeName(), fragment.getNamespaceURI()); |
258 |
Element el = XMLUtil.findElement(doc.getDocumentElement(), fragment.getNodeName(), fragment.getNamespaceURI()); |
258 |
if (el != null) { |
259 |
if (el != null) { |
259 |
doc.getDocumentElement().removeChild(el); |
260 |
doc.getDocumentElement().removeChild(el); |
260 |
} |
261 |
} |
Lines 319-325
Link Here
|
319 |
} |
320 |
} |
320 |
} |
321 |
} |
321 |
if (doc != null) { |
322 |
if (doc != null) { |
322 |
Element el = findElement(doc.getDocumentElement(), elementName, namespace); |
323 |
Element el = XMLUtil.findElement(doc.getDocumentElement(), elementName, namespace); |
323 |
if (el != null) { |
324 |
if (el != null) { |
324 |
doc.getDocumentElement().removeChild(el); |
325 |
doc.getDocumentElement().removeChild(el); |
325 |
} |
326 |
} |
Lines 341-365
Link Here
|
341 |
return true; |
342 |
return true; |
342 |
} |
343 |
} |
343 |
|
344 |
|
344 |
private static Element findElement(Element parent, String name, String namespace) { |
|
|
345 |
Element result = null; |
346 |
NodeList l = parent.getChildNodes(); |
347 |
int len = l.getLength(); |
348 |
for (int i = 0; i < len; i++) { |
349 |
if (l.item(i).getNodeType() == Node.ELEMENT_NODE) { |
350 |
Element el = (Element) l.item(i); |
351 |
if (name.equals(el.getLocalName()) && ((namespace == el.getNamespaceURI()) /*check both namespaces are null*/ || (namespace != null && namespace.equals(el.getNamespaceURI())))) { |
352 |
if (result == null) { |
353 |
result = el; |
354 |
} else { |
355 |
return null; |
356 |
} |
357 |
} |
358 |
} |
359 |
} |
360 |
return result; |
361 |
} |
362 |
|
363 |
static class OpenConfigAction extends AbstractAction { |
345 |
static class OpenConfigAction extends AbstractAction { |
364 |
|
346 |
|
365 |
private FileObject fo; |
347 |
private FileObject fo; |