Java Code Examples for org.jdom2.Parent#removeContent()

The following examples show how to use org.jdom2.Parent#removeContent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DesktopData.java    From Zettelkasten with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method retrieves a bullet element from the given path {@code tp} and
 * copies it into a global Element-variable, so this element is stored for
 * later use. Furthermore, the element retrieve from the treepath {@code tp}
 * is removed from the XML-document
 *
 * @param timestamp the timestamp of the bullet that should be copied to the
 * "clipboard" and deleted afterwards (cut-operation)
 */
public void cutBulletToClip(String timestamp) {
    // retrieve the entry that should be deleted
    Element bullet = findEntryElementFromTimestamp(getCurrentDesktopElement(), timestamp);
    if (bullet != null) {
        // get the entry's parent
        Parent p = bullet.getParent();
        // get the index from "bullet"
        int index = p.indexOf(bullet);
        // if we have a valid index, go on
        if (index != -1) {
            // remove the content and save it to the clipboard-element
            clipbullet = (Element) p.removeContent(index);
            // change modified state
            setModified(true);
        }
    }
}
 
Example 2
Source File: DesktopData.java    From Zettelkasten with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method deletes the selected entry from the desktop.
 *
 * @param timestamp the timestamp of the to be deleted entry
 */
public void deleteEntry(String timestamp) {
    // retrieve the entry that should be deleted
    Element entry = findEntryElementFromTimestamp(getCurrentDesktopElement(), timestamp);
    if (entry != null) {
        // check whether we have any modified entry. if so, delete it, since
        // we no longer need it...
        deleteModifiedEntry(timestamp);
        // get the entry's parent
        Parent p = entry.getParent();
        // remove entry from parent
        p.removeContent(entry);
        // change modified state
        setModified(true);
    }
}
 
Example 3
Source File: DesktopData.java    From Zettelkasten with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method deletes the selected entry from the desktop.
 *
 * @param timestamp the timestamp of the to the selected entry.
 */
public void deleteBullet(String timestamp) {
    // retrieve the entry that should be deleted
    Element bullet = findEntryElementFromTimestamp(getCurrentDesktopElement(), timestamp);
    if (bullet != null) {
        // retrieve all timestamps of those entries which are children of the to be
        // deleted bullet
        String[] timestamps = retrieveBulletTimestamps(bullet);
        // get the entry's parent
        Parent p = bullet.getParent();
        // remove entry from parent
        p.removeContent(bullet);
        // now remove all possible modified entries of that list
        if (timestamps != null && timestamps.length > 0) {
            // iterate all timestamps
            for (String singlets : timestamps) {
                // delete modified entries that already have been deleted due
                // to the removal of the bullet-point
                deleteModifiedEntry(singlets);
            }
        }
        // change modified state
        setModified(true);
    }
}
 
Example 4
Source File: BaseWireFeedGenerator.java    From rome with Apache License 2.0 5 votes vote down vote up
protected void generateForeignMarkup(final Element element, final List<Element> foreignElements) {
    if (foreignElements != null) {
        for (final Element foreignElement : foreignElements) {
            final Parent parent = foreignElement.getParent();
            if (parent != null) {
                parent.removeContent(foreignElement);
            }
            element.addContent(foreignElement);
        }
    }
}