From: Peter W. <pw...@us...> - 2006-07-27 12:02:34
|
Update of /cvsroot/cob/COBEditor/src/edu/iastate/ato/gui/packageview In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv19644/src/edu/iastate/ato/gui/packageview Modified Files: PackageTreeEditor.java PackageView2Db.java Log Message: Allows for branch delete of term relations and packages Index: PackageTreeEditor.java =================================================================== RCS file: /cvsroot/cob/COBEditor/src/edu/iastate/ato/gui/packageview/PackageTreeEditor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PackageTreeEditor.java 20 Jul 2006 20:51:12 -0000 1.5 --- PackageTreeEditor.java 27 Jul 2006 12:02:30 -0000 1.6 *************** *** 240,257 **** new DeleteTermRelationAction(theTerm)) ; } ! if(isLeaf && !isMerged) ! { ! if(!isCloned) ! { ! addMenuItem("Delete Term", IconLib.iconDelete, ! new DeleteTermAction(theTerm)) ; ! ! String info = ! "Drag the term and drop it on the term to be merged" ; ! addMenuItem("Merge Term with...", ! IconLib.iconMergeTerm, ! new DoNothingAction(theTerm, info)) ; ! } } } } // end of if (!isObsolete) --- 240,262 ---- new DeleteTermRelationAction(theTerm)) ; } ! if( !isMerged && !isCloned){ ! if(isLeaf) ! { ! addMenuItem("Delete Term", IconLib.iconDelete, ! new DeleteTermAction(theTerm)) ; ! ! String info = ! "Drag the term and drop it on the term to be merged" ; ! addMenuItem("Merge Term with...", ! IconLib.iconMergeTerm, ! new DoNothingAction(theTerm, info)) ; ! ! // Add Branch Relation Delete ! }else{ ! addMenuItem("Delete Branch Relations", IconLib.iconDelete, ! new DeleteRelationBranchAction(theTerm)) ; ! } } + } } // end of if (!isObsolete) *************** *** 667,670 **** --- 672,708 ---- } } + + class DeleteRelationBranchAction extends DefaultDeleteAction + { + DbTermNode theNode ; + + public DeleteRelationBranchAction(DbTermNode theNode) + { + this.theNode = theNode ; + } + + private void deleteRelationRec(DbTermNode tn){ + tn.status = ATOTreeNode.DELETED_UPEDGE ; + for(int i=0; i<tn.getChildCount(); ++i){ + if( tn.getChildAt(i) instanceof DbTermNode){ + deleteRelationRec((DbTermNode)tn.getChildAt(i)); + } + } + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) + { + theNode.status = ATOTreeNode.DELETED_UPEDGE ; + theNode.getHomePackageNode().status = PackageNode.MODIFIED; + + deleteRelationRec(theNode); + + tree.getModel().reload(theNode) ; + ((PackageTree)tree).modified = true; + } + } class DeletePackageAction extends DefaultDeleteAction *************** *** 676,680 **** this.theNode = theNode ; } ! public void actionPerformed(ActionEvent e) { --- 714,728 ---- this.theNode = theNode ; } ! ! ! private void deletePackageRec(PackageNode tn){ ! tn.markDeleted(); ! for(int i=0; i<tn.getChildCount(); ++i){ ! if( tn.getChildAt(i) instanceof PackageNode){ ! deletePackageRec((PackageNode)tn.getChildAt(i)); ! } ! } ! } ! public void actionPerformed(ActionEvent e) { *************** *** 682,699 **** if(theNode.hasSubPackage()) { ! Debug.trace("Cannot delete a package with sub packages. \n" + "Please delete all sub packages and try again") ; return ; ! } ! ! int answer = JOptionPane.showConfirmDialog(null, ! "Are you sure to delete (obsolete) all terms(inclued unexpanded) in the package? \n" + ! "The package itself will be deleted only if it has no term (including obsoleted terms)") ; ! if(answer == JOptionPane.YES_OPTION) ! { ! theNode.markDeleted() ; ! ((PackageNode)theNode.getParent()).status = PackageNode.MODIFIED; ! tree.getModel().reload(theNode.getParent()) ; ! ((PackageTree)tree).modified = true; } } --- 730,761 ---- if(theNode.hasSubPackage()) { ! /*Debug.trace("Cannot delete a package with sub packages. \n" + "Please delete all sub packages and try again") ; + */ + + int answer = JOptionPane.showConfirmDialog(null, + "Are you sure to delete (obsolete) all terms(inclued unexpanded) in the package and subpackages? \n" + + "The package and subpackges themselves will be deleted only if it has no term (including obsoleted terms)") ; + if(answer == JOptionPane.YES_OPTION) + { + theNode.markDeleted() ; + ((PackageNode)theNode.getParent()).status = PackageNode.MODIFIED; + deletePackageRec(theNode); + tree.getModel().reload(theNode.getParent()) ; + ((PackageTree)tree).modified = true; + } return ; ! ! }else{ ! int answer = JOptionPane.showConfirmDialog(null, ! "Are you sure to delete (obsolete) all terms(inclued unexpanded) in the package? \n" + ! "The package itself will be deleted only if it has no term (including obsoleted terms)") ; ! if(answer == JOptionPane.YES_OPTION) ! { ! theNode.markDeleted() ; ! ((PackageNode)theNode.getParent()).status = PackageNode.MODIFIED; ! tree.getModel().reload(theNode.getParent()) ; ! ((PackageTree)tree).modified = true; ! } } } Index: PackageView2Db.java =================================================================== RCS file: /cvsroot/cob/COBEditor/src/edu/iastate/ato/gui/packageview/PackageView2Db.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PackageView2Db.java 15 Jul 2006 22:10:53 -0000 1.5 --- PackageView2Db.java 27 Jul 2006 12:02:31 -0000 1.6 *************** *** 125,128 **** --- 125,130 ---- if(atoNode instanceof PackageNode) { + PackageNode pn = ((PackageNode)atoNode); + //System.out.println("\nDeleting Package: "+pn.getLocalName()); // delete package (don't delete the terms in it) // (the terms should have individual deleted marks) *************** *** 319,322 **** --- 321,325 ---- for(PackageNode pkg : allPackages) { + //System.out.println("Saving: "+pkg.getLocalName()); savePackageNode(pkg); } |