Implementation of a DOM element in context of Shared XML Editing XEP-0284 (SXE).
It extends the {@link NodeRecord} functionality by an attribute and childelement hierarchy plus respective utility methods and notification.
5556575859606162636465
public void insertRecord(ElementRecord record) { if (subtreeRecords.contains(record) || rootRecords.contains(record)) { return; } else { ElementRecord tmp; Collection<ElementRecord> children = record .getAllVisibleDescendantElements(); Iterator<ElementRecord> it = rootRecords.iterator(); while (it.hasNext()) {
9101112131415161718
public static DocumentRecord getEmptyDocument( ISXERecordFactory recordFactory) { SXEController controller = new SXEController(recordFactory); DocumentRecord document = recordFactory.createDocument(controller); ElementRecord root = recordFactory.createRoot(document); root.apply(document); return document; }
2021222324252627282930
@Override public ElementRecord createElementRecord(DocumentRecord documentRecord, String ns, String tag) { ElementRecord r = null; if (tag.equals(SVGConstants.SVG_RECT_TAG)) { r = new SVGRectRecord(documentRecord); } else if (tag.equals(SVGConstants.SVG_POLYLINE_TAG)) { r = new SVGPolylineRecord(documentRecord); } else if (tag.equals(SVGConstants.SVG_ELLIPSE_TAG)) {
3738394041424344454647
throw new MalformedRecordException("target rid missing"); NodeRecord target = document.getRecordById(tmp); int version = getInt(RecordEntry.VERSION); ElementRecord parent = null; tmp = getString(RecordEntry.PARENT); if (tmp != null) { parent = document.getElementRecordById(tmp);
545556575859606162636465666768697071
} @Override public void execute() { if (canExecute()) { ElementRecord copy; for (ElementRecord er : recordsToCopy.getRootRecords()) { copy = er.getCopy(true); /* * it is undesirable to add anything with the same primary * weight to the same parent, thus it is reset. */ copy.setPrimaryWeight(null); copiedRecords.add((LayoutElementRecord) copy); } Clipboard.getDefault().setContents(copiedRecords); } }
196197198199200201202203204205206207208209
records.add(copy); records.addAll(getMergedAttributes(toCopy.getVisibleAttributes(), layoutAttributes)); // add all other sub nodes ElementRecord childCopy; for (ElementRecord er : toCopy.getVisibleChildElements()) { childCopy = er.getCopy(); childCopy.setParent(copy); records.add(childCopy); records.addAll(er.getCopiedSubtreeRecords(childCopy)); } return records;
404142434445464748495051525354
@Override public boolean canExecute() { if (recordsToCopy == null || recordsToCopy.isEmpty()) return false; Iterator<ElementRecord> it = recordsToCopy.getRootRecords().iterator(); ElementRecord er; while (it.hasNext()) { er = it.next(); if (!isCopyableNode(er)) return false; if (!er.getParent().isPartOfVisibleDocument()) return false; } return true; }