Search in sources :

Example 36 with Thing

use of ini.trakem2.tree.Thing in project TrakEM2 by trakem2.

the class TemplateThing method remove.

public boolean remove(boolean check) {
    if (check) {
        if (!Utils.check("Really delete " + this.toString() + (null == al_children || 0 == al_children.size() ? "" : " and all its children?")))
            return false;
    }
    // remove the children, recursively
    if (null != al_children) {
        Object[] children = new Object[al_children.size()];
        // can't delete directly from the al_children because the child will call removeChild on its parent
        al_children.toArray(children);
        for (int i = 0; i < children.length; i++) {
            Object ob = children[i];
            if (ob instanceof DBObject) {
                if (!((DBObject) ob).remove(false)) {
                    Utils.showMessage("Deletion incomplete, check database, for child: " + ob.toString());
                    return false;
                }
            }
        }
    }
    // remove the Thing itself
    if (null != parent && !parent.removeChild(this)) {
        Utils.showMessage("Deletion incomplete, check database, for parent of TemplateThing id=" + id);
        return false;
    }
    return removeFromDatabase();
}
Also used : DBObject(ini.trakem2.persistence.DBObject) DBObject(ini.trakem2.persistence.DBObject)

Aggregations

DBObject (ini.trakem2.persistence.DBObject)16 ProjectThing (ini.trakem2.tree.ProjectThing)15 TemplateThing (ini.trakem2.tree.TemplateThing)9 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 LayerThing (ini.trakem2.tree.LayerThing)8 TreePath (javax.swing.tree.TreePath)8 HashMap (java.util.HashMap)7 Displayable (ini.trakem2.display.Displayable)6 ZDisplayable (ini.trakem2.display.ZDisplayable)6 Thing (ini.trakem2.tree.Thing)6 GenericDialog (ij.gui.GenericDialog)5 Layer (ini.trakem2.display.Layer)5 LayerSet (ini.trakem2.display.LayerSet)5 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 ProjectTree (ini.trakem2.tree.ProjectTree)4 JPopupMenu (javax.swing.JPopupMenu)4 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)4 Project (ini.trakem2.Project)3 Profile (ini.trakem2.display.Profile)3