Skip to content

Commit

Permalink
Fixed recursion bug for going down the tree looking for invalid taxa …
Browse files Browse the repository at this point in the history
…to a term

May have fixed problem with dialog boxes not listening for the mouse on drag and drop
  • Loading branch information
selewis committed Nov 28, 2016
1 parent bace96b commit ac79096
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 60 deletions.
6 changes: 1 addition & 5 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
10 changes: 0 additions & 10 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,12 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
2 changes: 1 addition & 1 deletion resources/org/paint/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.28
v2.28.1
47 changes: 47 additions & 0 deletions src/org/paint/dialog/AnnotUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.paint.dialog;

import java.util.List;

import org.bbop.framework.GUIManager;
import org.bbop.phylo.annotate.PaintAction;
import org.bbop.phylo.annotate.WithEvidence;
import org.bbop.phylo.model.Bioentity;
import org.bbop.phylo.model.Tree;
import org.bbop.phylo.util.TaxonChecker;
import org.paint.gui.event.AnnotationChangeEvent;
import org.paint.gui.event.EventManager;
import org.paint.main.PaintManager;

public class AnnotUtil {

private static AnnotUtil INSTANCE;

private AnnotUtil() {
}

public static AnnotUtil inst() {
if (INSTANCE == null) {
INSTANCE = new AnnotUtil();
}
return INSTANCE;
}

public void propagateAssociation(Bioentity node, Tree tree, String term, String date) {
boolean valid_for_all_descendents = TaxonChecker.checkTaxons(tree, node, term, false);
if (!valid_for_all_descendents) {
List<String> invalid_taxa = TaxonChecker.getInvalidTaxa(node, term);
TaxonDialog taxon_dialog = new TaxonDialog(GUIManager.getManager().getFrame(), term, invalid_taxa);
valid_for_all_descendents = taxon_dialog.isLost();
}
if (valid_for_all_descendents) {
WithEvidence withs = new WithEvidence(tree, node, term);
int qualifiers = withs.getWithQualifiers();
if (qualifiers > 0) {
QualifierDialog qual_dialog = new QualifierDialog(GUIManager.getManager().getFrame(), qualifiers);
qualifiers = qual_dialog.getQualifiers();
}
PaintAction.inst().propagateAssociation(PaintManager.inst().getFamily(), node, term, withs, date, qualifiers);
EventManager.inst().fireAnnotationChangeEvent(new AnnotationChangeEvent(node));
}
}
}
34 changes: 18 additions & 16 deletions src/org/paint/gui/matrix/AnnotMatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.bbop.phylo.tracking.LogEntry;
import org.bbop.phylo.util.OWLutil;
import org.bbop.phylo.util.TaxonChecker;
import org.paint.dialog.AnnotUtil;
import org.paint.dialog.QualifierDialog;
import org.paint.dialog.TaxonDialog;
import org.paint.displaymodel.DisplayBioentity;
Expand Down Expand Up @@ -551,22 +552,23 @@ private class AnnotateActionListener implements ActionListener{

public void actionPerformed(ActionEvent e){
Tree tree = PaintManager.inst().getTree().getTreeModel();
boolean valid_for_all_descendents = TaxonChecker.checkTaxons(tree, ancestor, term, false);
if (!valid_for_all_descendents) {
List<String> invalid_taxa = TaxonChecker.getInvalidTaxa(ancestor, term);
TaxonDialog taxon_dialog = new TaxonDialog(GUIManager.getManager().getFrame(), term, invalid_taxa);
valid_for_all_descendents = taxon_dialog.isLost();
}
if (valid_for_all_descendents) {
WithEvidence withs = new WithEvidence(tree, ancestor, term);
int qualifiers = withs.getWithQualifiers();
if (qualifiers > 0) {
QualifierDialog qual_dialog = new QualifierDialog(GUIManager.getManager().getFrame(), qualifiers);
qualifiers = qual_dialog.getQualifiers();
}
PaintAction.inst().propagateAssociation(PaintManager.inst().getFamily(), ancestor, term, withs, null, qualifiers);
EventManager.inst().fireAnnotationChangeEvent(new AnnotationChangeEvent(ancestor));
}
AnnotUtil.inst().propagateAssociation(ancestor, tree, term, null);
// boolean valid_for_all_descendents = TaxonChecker.checkTaxons(tree, ancestor, term, false);
// if (!valid_for_all_descendents) {
// List<String> invalid_taxa = TaxonChecker.getInvalidTaxa(ancestor, term);
// TaxonDialog taxon_dialog = new TaxonDialog(GUIManager.getManager().getFrame(), term, invalid_taxa);
// valid_for_all_descendents = taxon_dialog.isLost();
// }
// if (valid_for_all_descendents) {
// WithEvidence withs = new WithEvidence(tree, ancestor, term);
// int qualifiers = withs.getWithQualifiers();
// if (qualifiers > 0) {
// QualifierDialog qual_dialog = new QualifierDialog(GUIManager.getManager().getFrame(), qualifiers);
// qualifiers = qual_dialog.getQualifiers();
// }
// PaintAction.inst().propagateAssociation(PaintManager.inst().getFamily(), ancestor, term, withs, null, qualifiers);
// EventManager.inst().fireAnnotationChangeEvent(new AnnotationChangeEvent(ancestor));
// }
}

}
Expand Down
22 changes: 11 additions & 11 deletions src/org/paint/gui/matrix/AnnotMatrixModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,17 @@ private void sortTerms(List<Bioentity> nodes, List<String> cellular_list) {

/* Hack alert - hard coded the GO id for cellular process here */
/* Only applies to biological process */
if (aspect_name.equals(AspectSelector.Aspect.BIOLOGICAL_PROCESS.toString())) {
String cellular = "GO:0009987";
for (String term : cellular_list) {
if (!OWLutil.inst().moreSpecific(term, cellular)) {
noncellular_list.add(term);
}
}
for (String term : noncellular_list) {
cellular_list.remove(term);
}
}
// if (aspect_name.equals(AspectSelector.Aspect.BIOLOGICAL_PROCESS.toString())) {
// String cellular = "GO:0009987";
// for (String term : cellular_list) {
// if (!OWLutil.inst().moreSpecific(term, cellular)) {
// noncellular_list.add(term);
// }
// }
// for (String term : noncellular_list) {
// cellular_list.remove(term);
// }
// }

/*
* First an alphabetic sort
Expand Down
70 changes: 53 additions & 17 deletions src/org/paint/gui/matrix/AnnotationTransferHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import javax.swing.TransferHandler;

import org.apache.log4j.Logger;
import org.bbop.framework.GUIManager;
import org.bbop.phylo.annotate.PaintAction;
import org.bbop.phylo.annotate.WithEvidence;
import org.bbop.phylo.model.Bioentity;
import org.bbop.phylo.model.Family;
import org.bbop.phylo.model.Tree;
import org.bbop.phylo.tracking.LogEntry;
import org.bbop.phylo.tracking.LogEntry.LOG_ENTRY_TYPE;
import org.bbop.phylo.util.OWLutil;
import org.bbop.phylo.util.TaxonChecker;
import org.paint.dialog.AnnotUtil;
import org.paint.dialog.QualifierDialog;
import org.paint.dialog.TaxonDialog;
import org.paint.displaymodel.DisplayBioentity;
Expand Down Expand Up @@ -256,22 +260,30 @@ public boolean importData(TransferHandler.TransferSupport support) {
Point p = support.getDropLocation().getDropPoint();
DisplayBioentity node = tree.getClickedInNodeArea(p);

boolean valid_for_all_descendents = TaxonChecker.checkTaxons(tree.getTreeModel(), node, term, false);
if (!valid_for_all_descendents) {
List<String> invalid_taxa = TaxonChecker.getInvalidTaxa(node, term);
TaxonDialog taxon_dialog = new TaxonDialog(GUIManager.getManager().getFrame(), term, invalid_taxa);
valid_for_all_descendents = taxon_dialog.isLost();
}
if (valid_for_all_descendents) {
WithEvidence withs = new WithEvidence(tree.getTreeModel(), node, term);
int qualifiers = withs.getWithQualifiers();
if (qualifiers > 0) {
QualifierDialog qual_dialog = new QualifierDialog(GUIManager.getManager().getFrame(), qualifiers);
qualifiers = qual_dialog.getQualifiers();
}
PaintAction.inst().propagateAssociation(PaintManager.inst().getFamily(), node, term, withs, null, qualifiers);
EventManager.inst().fireAnnotationChangeEvent(new AnnotationChangeEvent(node));
}
AnnotUtil.inst().propagateAssociation(node, tree.getTreeModel(), term, null);
// boolean valid_for_all_descendents = TaxonChecker.checkTaxons(tree.getTreeModel(), node, term, false);
// if (!valid_for_all_descendents) {
// List<String> invalid_taxa = TaxonChecker.getInvalidTaxa(node, term);
// doTaxonDialog taxon_dialog_runner = new doTaxonDialog(term, invalid_taxa);
// Thread t1 = new Thread(taxon_dialog_runner);
// t1.start();
// try {
// t1.join();
// } catch (InterruptedException e) {
// log.info("Not sure what to do here if it ever happens");
// }
// valid_for_all_descendents = taxon_dialog_runner.valid();
// }
// if (valid_for_all_descendents) {
// WithEvidence withs = new WithEvidence(tree.getTreeModel(), node, term);
// int qualifiers = withs.getWithQualifiers();
// if (qualifiers > 0) {
// QualifierDialog qual_dialog = new QualifierDialog(GUIManager.getManager().getFrame(), qualifiers);
// qualifiers = qual_dialog.getQualifiers();
// }
// PaintAction.inst().propagateAssociation(PaintManager.inst().getFamily(), node, term, withs, null, qualifiers);
// EventManager.inst().fireAnnotationChangeEvent(new AnnotationChangeEvent(node));
// }
clearVisitedNodes(tree);
return true;
}
Expand Down Expand Up @@ -434,4 +446,28 @@ public void dropActionChanged(DragSourceDragEvent dsde)
{
}
}
}

// private class doTaxonDialog implements Runnable{
// private final String term;
// private final List<String> invalid_taxa;
// private boolean valid_for_all_descendents;
//
// doTaxonDialog(String term, List<String> invalid_taxa) {
// this.term = term;
// this.invalid_taxa = invalid_taxa;
// }
//
// public void run() {
// SwingUtilities.invokeLater(new Runnable() {
// public void run() {
// TaxonDialog taxon_dialog = new TaxonDialog(GUIManager.getManager().getFrame(), term, invalid_taxa);
// valid_for_all_descendents = taxon_dialog.isLost();
// }
// });
// }
//
// public boolean valid() {
// return valid_for_all_descendents;
// }
// }
}

0 comments on commit ac79096

Please sign in to comment.