You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(18) |
Aug
(33) |
Sep
(30) |
Oct
(27) |
Nov
(59) |
Dec
(30) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(67) |
Feb
(44) |
Mar
(70) |
Apr
(73) |
May
(119) |
Jun
(31) |
Jul
(92) |
Aug
(86) |
Sep
(76) |
Oct
(152) |
Nov
(156) |
Dec
(85) |
2008 |
Jan
(111) |
Feb
(121) |
Mar
(107) |
Apr
(102) |
May
(45) |
Jun
(65) |
Jul
(62) |
Aug
(133) |
Sep
(56) |
Oct
(56) |
Nov
(17) |
Dec
(15) |
2009 |
Jan
(10) |
Feb
(5) |
Mar
(10) |
Apr
(14) |
May
(49) |
Jun
(94) |
Jul
(67) |
Aug
(23) |
Sep
(9) |
Oct
(92) |
Nov
(26) |
Dec
(51) |
2010 |
Jan
(105) |
Feb
(83) |
Mar
(52) |
Apr
(59) |
May
(68) |
Jun
(71) |
Jul
(127) |
Aug
(49) |
Sep
(91) |
Oct
(27) |
Nov
(33) |
Dec
(26) |
2011 |
Jan
(26) |
Feb
(45) |
Mar
(26) |
Apr
(28) |
May
(17) |
Jun
(15) |
Jul
(45) |
Aug
(33) |
Sep
(50) |
Oct
(22) |
Nov
(10) |
Dec
(21) |
2012 |
Jan
(33) |
Feb
(24) |
Mar
(36) |
Apr
(60) |
May
(60) |
Jun
(43) |
Jul
(114) |
Aug
(19) |
Sep
(35) |
Oct
(24) |
Nov
(64) |
Dec
(12) |
2013 |
Jan
(54) |
Feb
(58) |
Mar
(51) |
Apr
(46) |
May
(21) |
Jun
(29) |
Jul
(25) |
Aug
(25) |
Sep
(13) |
Oct
(7) |
Nov
(14) |
Dec
(27) |
2014 |
Jan
(10) |
Feb
(7) |
Mar
(16) |
Apr
(14) |
May
(19) |
Jun
(8) |
Jul
(15) |
Aug
(11) |
Sep
(5) |
Oct
(11) |
Nov
(11) |
Dec
(4) |
2015 |
Jan
(52) |
Feb
(27) |
Mar
(22) |
Apr
(17) |
May
(2) |
Jun
(2) |
Jul
(2) |
Aug
(2) |
Sep
(2) |
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(1) |
Jul
(3) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(2) |
Jun
(2) |
Jul
(2) |
Aug
(2) |
Sep
(1) |
Oct
(2) |
Nov
(1) |
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
(3) |
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: <mg...@us...> - 2006-10-12 17:01:34
|
Revision: 154 http://svn.sourceforge.net/obo/?rev=154&view=rev Author: mgibson Date: 2006-10-12 10:01:27 -0700 (Thu, 12 Oct 2006) Log Message: ----------- hmmm - im in svn trouble here - trying to work it out Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java Modified: phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java 2006-10-12 15:06:22 UTC (rev 153) +++ phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java 2006-10-12 17:01:27 UTC (rev 154) @@ -29,8 +29,7 @@ import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharacterI; -import phenote.datamodel.Ontology; -import phenote.datamodel.SearchParamsI; +//import phenote.datamodel.Ontology; import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; import phenote.gui.selection.SelectionManager; @@ -40,19 +39,19 @@ /** The jcombobox that does auto completion - i had to do some tricks(hacks) to get it working with mouse over which doesnt come naturally to jcombobox */ -class AutoComboBox extends JComboBox { +class AbstractAutoCompList extends JComboBox { - private Ontology ontology; + //private Ontology ontology; private boolean changingCompletionList = false; private boolean keyTyped = false; private String previousInput = ""; private boolean doCompletion = true; // should we keep state of currentOboClass which is null if not a valid one? // default combo box.getSelectedItem sortof does this imperfectly - private OBOClass currentOboClass=null; - private OBOProperty currentRel=null; + //private OBOClass currentOboClass=null; + //private OBOProperty currentRel=null; private DefaultComboBoxModel defaultComboBoxModel; - private SearchParamsI searchParams; + //private SearchParamsI searchParams; private boolean inTestMode = false; //private AutoTextFieldEditor autoTextFieldEditor; private AutoTextField autoTextField; @@ -62,31 +61,31 @@ /** if false then model is not edited */ private boolean editModel; private CompletionListListener compListListener = new CompletionListListener(); + private CompListSearcher compListSearcher; - /** @param editModel if false then ACB doesnt edit model directly (post comp) */ - AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { + /** @param editModel if false then ACB doesnt edit model directly (post comp) + can abstract classes have constructors - if not init() */ + protected AbstractAutoCompList(CompListSearcher s,boolean editModel) { // this inner class enables retrieving of JList for mouse over // this will probably throw errors if non metal look & feel is used setUI(new MetalListComboUI()); - //setFont(new Font("Courier",Font.PLAIN,12)); - - setOntology(ontology); - searchParams = sp; // singleton access? part of ontology? setEditable(true); + setPreferredSize(new Dimension(350,22)); AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); this.setEditor(autoTextFieldEditor); - setPreferredSize(new Dimension(350,22)); - + //setFont(new Font("Courier",Font.PLAIN,12)); + //setOntology(ontology); + //searchParams = sp; // singleton access? part of ontology? + compListSearcher = s; enableTermInfoListening(true); // default //addCompletionListListener(compList); - //if (editModel) // ComboBoxActionListener edits the model this.editModel = editModel; addActionListener(new ComboBoxActionListener()); } - void setOntology(Ontology o) { ontology = o; } + //void setOntology(Ontology o) { ontology = o; } //void setSearchParams(SearchParamsI sp) { searchParams = sp; } @@ -103,7 +102,7 @@ setText(text,doCompletion); } - // text from selecting table doesnt do completion, TestPhenote does + /** text from selecting table doesnt do completion, TestPhenote does */ void setText(String text, boolean doCompletion) { this.doCompletion = doCompletion; this.keyTyped = doCompletion; // key has to be typed for completion @@ -111,48 +110,7 @@ this.doCompletion = true; // set back to default } - /** rename setTerm? */ - void setOboClass(OBOClass term) { - if (term == null) { - log().error("Attempt to set term to null"); - return; // debug stack trace? - } - currentOboClass = term; - setText(term.getName(),false); // no completion - } - /** for relationships (post comp rel) */ - void setRel(OBOProperty rel) { - if (rel == null) { - log().error("Attempt to set term to null"); - return; // debug stack trace? - } - currentRel = rel; - setText(rel.toString(),false); // eventually .getName() - } - - /** Throws exception if there isnt a current obo class, if the user - has typed something that isnt yet a term - hasnt selected a term */ - OBOClass getCurrentOboClass() throws Exception { - if (currentOboClass == null) throw new Exception("term is null"); - if (!currentOboClass.getName().equals(getText())) - throw new Exception("(obo class "+currentOboClass+" and input "+getText()+ - " dont match)"); - return currentOboClass; - } - - /** Throws exception if there isnt a current relation - for relation lists - (post comp), if the user - has typed something that isnt yet a rel - hasnt selected a rel */ - OBOProperty getCurrentRelation() throws Exception { - if (currentRel == null) throw new Exception("term is null"); - if (!currentRel.toString().equals(getText())) - throw new Exception("(relation "+currentRel+" and input "+getText()+ - " dont match)"); - return currentRel; - - } - /** Return text in text field */ String getText() { //return (String)getSelectedItem(); @@ -164,54 +122,7 @@ setText(""); } - - /** This gets obo class selected in completion list - not from text box - Returns null if nothing selected - can happen amidst changing selection - also used by PostCompGui - this doesnt necasarily stay current with user input hmmm.... - throws OboException if dont have valid term */ - OBOClass getSelectedCompListOboClass() throws OboException { - Object obj = getSelectedObject(); // throws oboex - return oboClassDowncast(obj); // throws oboex - } - - private class OboException extends Exception { - private OboException() { super(); } - private OboException(String s) { super(s); } - } - -// private OBOClass getCompListOboClass(int index) { -// Object obj = defaultComboBoxModel.getElementAt(index); -// return oboClassDowncast(obj); -// } - - // strings get in somehow - need to figure out where they are coming from - private OBOClass oboClassDowncast(Object obj) throws OboException { - if (obj == null) throw new OboException(); - if ( ! (obj instanceof OBOClass)) { - //log.info("Item in completion list not obo class "+obj.getClass()); - throw new OboException("Item in completion list not obo class "+obj.getClass()); - } - return (OBOClass)obj; - } - - private OBOProperty oboPropertyDowncast(Object obj) throws OboException { - if (obj == null) throw new OboException(); - if ( ! (obj instanceof OBOProperty)) { - //log.info("Item in completion list not obo class "+obj.getClass()); - throw new OboException("Item in completion list not obo prop "+obj.getClass()); - } - return (OBOProperty)obj; - } - - /** returns currently selected relation, for auto combos of relations, - throws obo ex if there is no current relation */ - private OBOProperty getSelectedRelation() throws OboException { - Object obj = getSelectedObject(); // throws oboex - return oboPropertyDowncast(obj); // throws oboex - } - - private Object getSelectedObject() throws OboException { + protected Object getSelectedObject() throws OboException { if (defaultComboBoxModel == null) throw new OboException(); // ?? Object obj = defaultComboBoxModel.getSelectedItem(); if (obj == null) throw new OboException(); @@ -225,7 +136,7 @@ private class AutoTextFieldEditor extends BasicComboBoxEditor { private AutoTextFieldEditor() { - autoTextField = new AutoTextField(); + autoTextField = new AutoTextField(); // outer instance var for testing editor = autoTextField; // protected editor var from BCBE addDocumentListener(new AutoDocumentListener()); getTextField().addKeyListener(new AutoKeyListener()); @@ -346,11 +257,10 @@ // this is a vector of OBOClasses // i think ultimately we will need to wrap the OBOClass to be able to // have more control over the string - cut off w ... & [syn][obs] tags - Vector v; - if (isRelationshipList()) - v = ontology.getStringMatchRelations(input); - else - v = getTerms(input); + // returns a vector of CompletionTerms (checks if relations) + Vector v = getTerms(input); // abstract method + //if (isRelationshipList()) v = ontology.getStringMatchRelations(input); + //else v = getTerms(input); // throws IllegalStateException, Attempt to mutate in notification // this tries to change text field amidst notification hmmmm..... changingCompletionList = true; @@ -389,13 +299,18 @@ /** call Ontology to get a Vector of OBOClass's that contain "in" in ontology */ - private Vector<OBOClass> getTerms(String in) { - // or CompletionList.getCompletionList(getOntology()) ?? - //CompletionList cl = CompletionList.getCompletionList(); - //return cl.getCompletionTerms(getOntology(),in,searchParams); - return ontology.getSearchTerms(in,searchParams); // vector of OBOClass's - } +// private Vector<OBOClass> getTermsOld(String in) { +// // or CompletionList.getCompletionList(getOntology()) ?? +// //CompletionList cl = CompletionList.getCompletionList(); +// //return cl.getCompletionTerms(getOntology(),in,searchParams); +// return ontology.getSearchTerms(in,searchParams); // vector of OBOClass's +// } + // Vector<CompletionTerm>? CompletionItem? + protected abstract Vector getTerms(String input); +// if (isRelationshipList()) return termSearcher.getStringMatchRelations(input); +// else return termSearcher.getStringMatchTerms(input);} + private class AutoDocumentListener implements DocumentListener { public void changedUpdate(DocumentEvent e) { doCompletion(); } public void insertUpdate(DocumentEvent e) { doCompletion(); } @@ -522,7 +437,7 @@ // for this not to be so? returns null if no oboclass? // TERM if (isTermList()) { - try { currentOboClass = getSelectedCompListOboClass(); } + try { currentOboClass = getSelectedOboClass(); } // happens on return on invalid term name catch (OboException e) { return; } // error msg? //if (oboClass == null) return; currentOboClass = oboClass; @@ -536,10 +451,6 @@ // EDIT MODEL if (editModel) editModel(); -// CharacterI c = getSelectedCharacter(); // from selectionManager -// CharFieldEnum cfe = charField.getCharFieldEnum(); -// UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); -// EditManager.inst().updateModel(this,ut); } } @@ -562,7 +473,16 @@ } } +class OboException extends Exception { + private OboException() { super(); } + private OboException(String s) { super(s); } +} + // GARBAGE +// CharacterI c = getSelectedCharacter(); // from selectionManager +// CharFieldEnum cfe = charField.getCharFieldEnum(); +// UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); +// EditManager.inst().updateModel(this,ut); //private Ontology getOntology() { return ontology; } /** Return true if input String matches name of OBOClass in @@ -578,7 +498,7 @@ // //return defaultComboBoxModel.getIndexOf(input) != -1; // // have to go through all OBOClasses and extract there names - bummer // // most likely input is selected one check that first -// OBOClass selectedClass = getSelectedCompListOboClass(); +// OBOClass selectedClass = getSelectedOboClass(); // if (selectedClass != null && input.equals(selectedClass.getName())) // return true; // // selected failed(is this possible?) - try everything in the list then... This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-12 15:06:49
|
Revision: 153 http://svn.sourceforge.net/obo/?rev=153&view=rev Author: mgibson Date: 2006-10-12 08:06:22 -0700 (Thu, 12 Oct 2006) Log Message: ----------- well this was a big refactoring much needed - so up til now ive gotten away with butting datamodel objects - oboClass & OBOProperty in atuo combo box's vector of items - this worked as the toString method gave back the name of the term. but now that we want more than just the name - [syn] [obs] marker, cut off if too long, relations toString was funny - it became apparent phenote needed actual view completion wrappers of its model - which are CompletionTerm & CompletionRelation - and i repackaged - new package phenote.gui.field for all fieldy things in gui - AutoComboBox is now AbstractAutoCompList with 2 subclasses RelationCompList and TermCompList for relation & terms also moved searching ontolo terms to new class CompListSearcher from Ontology - which outputs the view objects for searching not model. presently the only manifestation of these changes is that relations wont show id as well as name (silly toString method for oboProp) but more is coming. renamed TermPanel field.FieldPanel tested out and things look ok (test suite ok) - but wouldnt be surprised if another bug or 2 comes up Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/fly/FlyCharacter.java phenote/trunk/src/java/phenote/datamodel/Ontology.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java phenote/trunk/src/java/phenote/gui/GridBagUtil.java phenote/trunk/src/java/phenote/gui/TermInfo.java phenote/trunk/src/java/phenote/main/Phenote.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java phenote/trunk/src/java/test/phenote/gui/TestPhenote.java Added Paths: ----------- phenote/trunk/src/java/phenote/datamodel/OntologyException.java phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/SearchParamsI.java phenote/trunk/src/java/phenote/gui/field/ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java phenote/trunk/src/java/phenote/gui/field/CompletionRelation.java phenote/trunk/src/java/phenote/gui/field/CompletionTerm.java phenote/trunk/src/java/phenote/gui/field/FieldPanel.java phenote/trunk/src/java/phenote/gui/field/PostCompGui.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java phenote/trunk/src/java/phenote/gui/field/SearchParamsI.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java Removed Paths: ------------- phenote/trunk/src/java/phenote/datamodel/SearchParamsI.java phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java phenote/trunk/src/java/phenote/gui/SearchParamPanel.java phenote/trunk/src/java/phenote/gui/TermPanel.java Modified: phenote/trunk/src/java/phenote/dataadapter/fly/FlyCharacter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/fly/FlyCharacter.java 2006-10-10 17:20:06 UTC (rev 152) +++ phenote/trunk/src/java/phenote/dataadapter/fly/FlyCharacter.java 2006-10-12 15:06:22 UTC (rev 153) @@ -5,6 +5,7 @@ import phenote.datamodel.CharacterI; import phenote.datamodel.Character; import phenote.datamodel.OntologyManager; +import phenote.datamodel.OntologyManager.TermNotFoundException; public class FlyCharacter implements FlyCharacterI { @@ -75,13 +76,15 @@ String id = termParts[1].trim(); if (id == null || id.equals("")) throw new TermException("Failed to get term id "+id); - OBOClass oc = OntologyManager.inst().getOboClass(id); - if (oc == null) + try { + OBOClass oc = OntologyManager.inst().getOboClass(id); // ex + if (!oc.getName().equals(name)) + throw new TermException("Data name "+name+" and ontology name "+oc.getName()+ + "are inconsistent for id "+id); + return oc; + } catch (TermNotFoundException e) { throw new TermException("Couldnt find ontology term for id "+id); - if (!oc.getName().equals(name)) - throw new TermException("Data name "+name+" and ontology name "+oc.getName()+ - "are inconsistent for id "+id); - return oc; + } } private class TermException extends Exception { Modified: phenote/trunk/src/java/phenote/datamodel/Ontology.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-10 17:20:06 UTC (rev 152) +++ phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-12 15:06:22 UTC (rev 153) @@ -63,107 +63,112 @@ public String getName() { return name; } - /** returns null if dont have class for id */ - public OBOClass getOboClass(String id) { - return oboSession.getTerm(id); + /** returns null if dont have class for id, throws OntologyException if id is not + found */ + public OBOClass getOboClass(String id) throws OntologyException { + OBOClass oc = oboSession.getTerm(id); + if (oc == null) throw new OntologyException(id +" id not found in ontology "+name); + return oc; } /** Returns true if ontology holds obo class */ boolean hasOboClass(OBOClass oboClass) { // if this is too slow can do optimizations with prefixes - return getOboClass(oboClass.getID()) != null; + try {getOboClass(oboClass.getID()); } + catch (OntologyException e) { return false; } + return true; // no exception - it has it } - /** Returns a Vector of OBOClass from ontology that contain input string - constrained by compParams. compParams specifies syns,terms,defs,& obs - should input be just part of search params? - its a vector as thats what ComboBox requires - put in separate class? */ - public Vector<OBOClass> getSearchTerms(String input,SearchParamsI searchParams) { - Vector<OBOClass> searchTerms = new Vector<OBOClass>(); - if (input == null || input.equals("")) - return searchTerms; +// /** Returns a Vector of OBOClass from ontology that contain input string +// constrained by compParams. compParams specifies syns,terms,defs,& obs +// should input be just part of search params? +// its a vector as thats what ComboBox requires +// put in separate class? */ +// public Vector<OBOClass> getSearchTerms(String input,SearchParamsI searchParams) { +// Vector<OBOClass> searchTerms = new Vector<OBOClass>(); +// if (input == null || input.equals("")) +// return searchTerms; - // gets term set for currently selected ontology - //Set ontologyTermList = getCurrentOntologyTermSet(); - List<OBOClass> ontologyTermList = getSortedTerms(); // non obsolete - searchTerms = getSearchTerms(input,ontologyTermList,searchParams); +// // gets term set for currently selected ontology +// //Set ontologyTermList = getCurrentOntologyTermSet(); +// List<OBOClass> ontologyTermList = getSortedTerms(); // non obsolete +// searchTerms = getSearchTerms(input,ontologyTermList,searchParams); - // if obsoletes set then add them in addition to regulars - if (searchParams.searchObsoletes()) { - ontologyTermList = getSortedObsoleteTerms(); - Vector obsoletes = getSearchTerms(input,ontologyTermList,searchParams); - searchTerms.addAll(obsoletes); - } - return searchTerms; - } +// // if obsoletes set then add them in addition to regulars +// if (searchParams.searchObsoletes()) { +// ontologyTermList = getSortedObsoleteTerms(); +// Vector obsoletes = getSearchTerms(input,ontologyTermList,searchParams); +// searchTerms.addAll(obsoletes); +// } +// return searchTerms; +// } - /** helper fn for getSearchTerms(String,SearhParamsI) */ - private Vector<OBOClass> getSearchTerms(String input, List<OBOClass> ontologyTermList, - SearchParamsI searchParams) { - // need a unique list - UniqueTermList has quick check for uniqueness, checking - // whole list is very very slow - how is it possible to get a dup term? i forget? - // the dup term was a BUG! in synonym - woops - SearchTermList uniqueTermList = new SearchTermList(); - //Vector searchTerms = new Vector(); - if (ontologyTermList == null) - return uniqueTermList.getVector();//searchTerms; +// /** helper fn for getSearchTerms(String,SearhParamsI) */ +// private Vector<OBOClass> getSearchTerms(String input, List<OBOClass> ontologyTermList, +// SearchParamsI searchParams) { +// // need a unique list - UniqueTermList has quick check for uniqueness, checking +// // whole list is very very slow - how is it possible to get a dup term? i forget? +// // the dup term was a BUG! in synonym - woops +// SearchTermList uniqueTermList = new SearchTermList(); +// //Vector searchTerms = new Vector(); +// if (ontologyTermList == null) +// return uniqueTermList.getVector();//searchTerms; - boolean ignoreCase = true; // param? - if (ignoreCase) - input = input.toLowerCase(); +// boolean ignoreCase = true; // param? +// if (ignoreCase) +// input = input.toLowerCase(); - // i think iterators are more efficient than get(i) ?? - Iterator<OBOClass> iter = ontologyTermList.iterator(); - while (iter.hasNext()) { - // toString extracts name from OBOClass - OBOClass oboClass = iter.next(); - String originalTerm = oboClass.getName();//toString(); +// // i think iterators are more efficient than get(i) ?? +// Iterator<OBOClass> iter = ontologyTermList.iterator(); +// while (iter.hasNext()) { +// // toString extracts name from OBOClass +// OBOClass oboClass = iter.next(); +// String originalTerm = oboClass.getName();//toString(); - boolean termAdded = false; +// boolean termAdded = false; - if (searchParams.searchTerms()) { - // adds originalTerm to searchTerms if match (1st if exact) - termAdded = compareAndAddTerm(input,originalTerm,oboClass,uniqueTermList); - if (termAdded) - continue; - } +// if (searchParams.searchTerms()) { +// // adds originalTerm to searchTerms if match (1st if exact) +// termAdded = compareAndAddTerm(input,originalTerm,oboClass,uniqueTermList); +// if (termAdded) +// continue; +// } - if (searchParams.searchSynonyms()) { - Set synonyms = oboClass.getSynonyms(); - for (Iterator i = synonyms.iterator(); i.hasNext() &&!termAdded; ) { - String syn = i.next().toString(); - //log().debug("syn "+syn+" for "+originalTerm); - termAdded = compareAndAddTerm(input,syn,oboClass,uniqueTermList); - //if (termAdded) continue; // woops continues this for not the outer! - } - } - if (termAdded) continue; +// if (searchParams.searchSynonyms()) { +// Set synonyms = oboClass.getSynonyms(); +// for (Iterator i = synonyms.iterator(); i.hasNext() &&!termAdded; ) { +// String syn = i.next().toString(); +// //log().debug("syn "+syn+" for "+originalTerm); +// termAdded = compareAndAddTerm(input,syn,oboClass,uniqueTermList); +// //if (termAdded) continue; // woops continues this for not the outer! +// } +// } +// if (termAdded) continue; - if (searchParams.searchDefinitions()) { - String definition = oboClass.getDefinition(); - if (definition != null & !definition.equals("")) - termAdded = compareAndAddTerm(input,definition,oboClass,uniqueTermList); - if (termAdded) - continue; // not really necesary as its last - } +// if (searchParams.searchDefinitions()) { +// String definition = oboClass.getDefinition(); +// if (definition != null & !definition.equals("")) +// termAdded = compareAndAddTerm(input,definition,oboClass,uniqueTermList); +// if (termAdded) +// continue; // not really necesary as its last +// } - } - return uniqueTermList.getVector();//searchTerms; - } +// } +// return uniqueTermList.getVector();//searchTerms; +// } - public Vector<OBOProperty> getStringMatchRelations(String input) { - Vector<OBOProperty> matches = new Vector<OBOProperty>(); - for (OBOProperty rel : getSortedRelations()) { - if (rel.toString().contains(input)) - matches.add(rel); - } - return matches; - } +// public Vector<OBOProperty> getStringMatchRelations(String input) { +// Vector<OBOProperty> matches = new Vector<OBOProperty>(); +// for (OBOProperty rel : getSortedRelations()) { +// if (rel.toString().contains(input)) +// matches.add(rel); +// } +// return matches; +// } - private List<OBOProperty> getSortedRelations() { + public List<OBOProperty> getSortedRelations() { if (sortedRelations == null) { //sortedRelations=new ArrayList<OBOProperty>(); not Comparable! List sorRel = new ArrayList(); @@ -184,78 +189,20 @@ } } - /** User input is already lower cased, this potentially adds oboClass to - * searchTerms if input & compareTerm match. Puts it first if exact. - * for term names comp = obo, for syns comp is the syn. - Returns true if term is a match & either gets added or already is added - * Also checks if term is in list already - not needed - woops! - Theres a speed issue here - the vector needs to be unique. if check every time - with whole list very very slow. 2 alternatives to try. - 1) have separate hash for checking uniqueness (downside 2 data structures). - could make a data structure that had both map & vector - 2) use LinkedHashSet, which does uniqueness & maintains order of insertion - nice - its 1 data structure BUT exact matches go 1st, no way in linked hash set - to insert 1st elements so would need to keep separate list of exact matches, which - i guess there can be more than one with synonyms (do syns count for exact matches? - should they?) - downside of #2 is need Vector for combo box - - this wont fly for having different display strings for syn & obs as compareTerm - can be syn obs term or def and its lost here - i think these methods need to be moved to gui.TermSearcher that utilizes Ontology - but produces CompListTerms */ - private boolean compareAndAddTerm(String input, String compareTerm, OBOClass oboClass, - SearchTermList searchTermList) { - - String oboTerm = oboClass.getName(); - String lowerComp = compareTerm; - boolean ignoreCase = true; // discard? param for? - if (ignoreCase) - lowerComp = compareTerm.toLowerCase(); - - //boolean doContains = true; // discard? param for? - // exact match goes first in list - if (lowerComp.equals(input)) { - searchTermList.addTermFirst(oboClass); // adds if not present - return true; - } - // new paradigm - put starts with first - else if (lowerComp.startsWith(input)) { - searchTermList.addTerm(oboClass); - return true; - } - // Contains - else if (contains(lowerComp,input) && !termFilter(lowerComp)) { - searchTermList.addContainsTerm(oboClass); - return true; - } - return false; - } - - // 1.5 has a contains! use when we shift - private boolean contains(String term, String input) { - return term.contains(input); // 1.5!! - //return term.indexOf(input) != -1; - } - /** Oboedit getTerms returns some terms with obo: prefix that should be filtered - * out. Returns true if starts with obo: */ - private boolean termFilter(String term) { - return term.startsWith("obo:"); - } - /** non obsolete terms - sorted */ - private List<OBOClass> getSortedTerms() { + public List<OBOClass> getSortedTerms() { return sortedTerms; } - private List<OBOClass> getSortedObsoleteTerms() { + public List<OBOClass> getSortedObsoleteTerms() { return sortedObsoleteTerms; } private OBOSession getOboSession() { return oboSession; } - private List<OBOClass> getSortedTerms(Set terms) { + public List<OBOClass> getSortedTerms(Set terms) { List<OBOClass> sortedTerms = new ArrayList<OBOClass>(); sortedTerms.addAll(terms); Collections.sort(sortedTerms); @@ -270,37 +217,6 @@ public String getSource() { return source; } - /** does unique check w map - dont need unique check - it was a bug in synonyms - how silly! - but actually this data structure will be handy for putting starts with - before contains! UniqueTermList -> SearchTermList*/ - private class SearchTermList { - private Vector<OBOClass> searchTerms = new Vector<OBOClass>(); - //private Map<OBOClass,OBOClass> uniqueCheck = new HashMap<OBOClass,OBOClass>(); - // list of terms that are contained but NOT startsWith - private Vector<OBOClass> containTerms = new Vector<OBOClass>(); - private void addTerm(OBOClass oboClass) { - addTerm(oboClass,false); - } - private void addTermFirst(OBOClass oboClass) { - addTerm(oboClass,true); - } - private void addTerm(OBOClass oboClass,boolean first) { - //if (uniqueCheck.containsKey(oboClass)) { - //log().debug("dup term in search "+oboClass); - // new Throwable().printStackTrace(); return; } - if (first) searchTerms.add(0,oboClass); - else searchTerms.add(oboClass); - //uniqueCheck.put(oboClass,null); // dont need value - } - /** Add term thats not startsWith but contains */ - private void addContainsTerm(OBOClass oboClass) { - containTerms.add(oboClass); - } - private Vector<OBOClass> getVector() { - searchTerms.addAll(containTerms); - return searchTerms; - } - } public void setFilter(String filterOutString) { @@ -332,6 +248,64 @@ // GARBAGE +// /** User input is already lower cased, this potentially adds oboClass to +// * searchTerms if input & compareTerm match. Puts it first if exact. +// * for term names comp = obo, for syns comp is the syn. +// Returns true if term is a match & either gets added or already is added +// * Also checks if term is in list already - not needed - woops! +// Theres a speed issue here - the vector needs to be unique. if check every time +// with whole list very very slow. 2 alternatives to try. +// 1) have separate hash for checking uniqueness (downside 2 data structures). +// could make a data structure that had both map & vector +// 2) use LinkedHashSet, which does uniqueness & maintains order of insertion +// nice - its 1 data structure BUT exact matches go 1st, no way in linked hash set +// to insert 1st elements so would need to keep separate list of exact matches, which +// i guess there can be more than one with synonyms (do syns count for exact matches? +// should they?) - downside of #2 is need Vector for combo box + +// this wont fly for having different display strings for syn & obs as compareTerm +// can be syn obs term or def and its lost here +// i think these methods need to be moved to gui.TermSearcher that utilizes Ontology +// but produces CompListTerms */ +// private boolean compareAndAddTerm(String input, String compareTerm, OBOClass oboClass, +// SearchTermList searchTermList) { + +// String oboTerm = oboClass.getName(); + +// String lowerComp = compareTerm; +// boolean ignoreCase = true; // discard? param for? +// if (ignoreCase) +// lowerComp = compareTerm.toLowerCase(); + +// //boolean doContains = true; // discard? param for? +// // exact match goes first in list +// if (lowerComp.equals(input)) { +// searchTermList.addTermFirst(oboClass); // adds if not present +// return true; +// } +// // new paradigm - put starts with first +// else if (lowerComp.startsWith(input)) { +// searchTermList.addTerm(oboClass); +// return true; +// } +// // Contains +// else if (contains(lowerComp,input) && !termFilter(lowerComp)) { +// searchTermList.addContainsTerm(oboClass); +// return true; +// } +// return false; +// } + +// // 1.5 has a contains! use when we shift +// private boolean contains(String term, String input) { +// return term.contains(input); // 1.5!! +// //return term.indexOf(input) != -1; +// } +// /** Oboedit getTerms returns some terms with obo: prefix that should be filtered +// * out. Returns true if starts with obo: */ +// private boolean termFilter(String term) { +// return term.startsWith("obo:"); +// } //if (!searchTerms.contains(oboClass)) {// this takes a long time w long lists! //searchTerms.add(0,oboClass); //if (!searchTerms.contains(oboClass)) searchTerms.add(oboClass); Added: phenote/trunk/src/java/phenote/datamodel/OntologyException.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyException.java (rev 0) +++ phenote/trunk/src/java/phenote/datamodel/OntologyException.java 2006-10-12 15:06:22 UTC (rev 153) @@ -0,0 +1,5 @@ +package phenote.datamodel; + +public class OntologyException extends Exception { + public OntologyException(String m) { super(m); } +} Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-10-10 17:20:06 UTC (rev 152) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-10-12 15:06:22 UTC (rev 153) @@ -51,13 +51,16 @@ public List<CharField> getCharFieldList() { return charFieldList; } /** Returns ontology with name, null if not found */ - public static Ontology getOntologyForName(String ontologyName) { // static? + public Ontology getOntologyForName(String ontologyName) + throws OntologyException { // static? for (CharField cf : inst().getCharFieldList()) { if (cf.hasOntology(ontologyName)) return cf.getOntologyForName(ontologyName); } - System.out.println("ERROR: no ontology found for name "+ontologyName); - return null; + String m = "no ontology found for name "+ontologyName; + log().error(m); + throw new OntologyException(m); + //return null; } @@ -73,18 +76,21 @@ the id prefix AO,GO,PATO... Should this deal with post comp? if ^ then create a post comp term on fly? im not sure if this is the right place for it, maybe method should be renamed - but ill put it here for now */ - public OBOClass getOboClass(String id) { + but ill put it here for now + merge this with getOboClassWithEx? */ + public OBOClass getOboClass(String id) throws TermNotFoundException { OBOClass oboClass; // this seems to be the sole reason for ontology list - silly! Iterator<Ontology> iter = allOntologyList.iterator(); while (iter.hasNext()) { Ontology o = iter.next(); - oboClass = o.getOboClass(id); + try { oboClass = o.getOboClass(id); } + catch (OntologyException e) { continue; } if (oboClass != null) return oboClass; } - return null; // not found - null + //return null; // not found - null -- ex? + throw new TermNotFoundException("ID "+id+" not found in loaded ontologies"); } public OBOClass getTermOrPostComp(String id) throws TermNotFoundException { @@ -94,6 +100,7 @@ return getOboClassWithExcep(id); } + // phase out - put ex in getOboClass! public OBOClass getOboClassWithExcep(String id) throws TermNotFoundException { OBOClass term = getOboClass(id); if (term == null) Deleted: phenote/trunk/src/java/phenote/datamodel/SearchParamsI.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/SearchParamsI.java 2006-10-10 17:20:06 UTC (rev 152) +++ phenote/trunk/src/java/phenote/datamodel/SearchParamsI.java 2006-10-12 15:06:22 UTC (rev 153) @@ -1,14 +0,0 @@ -package phenote.datamodel; - -// package phenote.ontology?? dataadapter? - -public interface SearchParamsI { - - public boolean searchTerms(); - public boolean searchSynonyms(); - public boolean searchDefinitions(); - /** Whether to include obsoletes in searching terms, syns, & definitions - This should be in conjunction with the other 3 */ - public boolean searchObsoletes(); - -} Copied: phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java (from rev 149, phenote/trunk/src/java/phenote/gui/AutoComboBox.java) =================================================================== --- phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/AbstractAutoCompList.java 2006-10-12 15:06:22 UTC (rev 153) @@ -0,0 +1,632 @@ +package phenote.gui; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.Vector; +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JTextField; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.text.Document; +import javax.swing.plaf.basic.BasicComboBoxEditor; +//import javax.swing.plaf.basic.BasicComboBoxUI; +import javax.swing.plaf.ComboBoxUI; +import javax.swing.plaf.metal.MetalComboBoxUI; + +import org.apache.log4j.Logger; + +import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; + +import phenote.datamodel.CharField; +import phenote.datamodel.CharFieldEnum; +import phenote.datamodel.CharacterI; +import phenote.datamodel.Ontology; +import phenote.datamodel.SearchParamsI; +import phenote.edit.EditManager; +import phenote.edit.UpdateTransaction; +import phenote.gui.selection.SelectionManager; +import phenote.gui.selection.UseTermEvent; +import phenote.gui.selection.UseTermListener; + +/** The jcombobox that does auto completion - i had to do some tricks(hacks) to get it + working with mouse over which doesnt come naturally to jcombobox */ + +class AutoComboBox extends JComboBox { + + private Ontology ontology; + private boolean changingCompletionList = false; + private boolean keyTyped = false; + private String previousInput = ""; + private boolean doCompletion = true; + // should we keep state of currentOboClass which is null if not a valid one? + // default combo box.getSelectedItem sortof does this imperfectly + private OBOClass currentOboClass=null; + private OBOProperty currentRel=null; + private DefaultComboBoxModel defaultComboBoxModel; + private SearchParamsI searchParams; + private boolean inTestMode = false; + //private AutoTextFieldEditor autoTextFieldEditor; + private AutoTextField autoTextField; + private CharField charField; + ///** Whether differentia of a post composed term */ + //private boolean isDifferentia = false; + /** if false then model is not edited */ + private boolean editModel; + private CompletionListListener compListListener = new CompletionListListener(); + + /** @param editModel if false then ACB doesnt edit model directly (post comp) */ + AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { + // this inner class enables retrieving of JList for mouse over + // this will probably throw errors if non metal look & feel is used + setUI(new MetalListComboUI()); + //setFont(new Font("Courier",Font.PLAIN,12)); + + setOntology(ontology); + searchParams = sp; // singleton access? part of ontology? + setEditable(true); + AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); + this.setEditor(autoTextFieldEditor); + setPreferredSize(new Dimension(350,22)); + + enableTermInfoListening(true); // default + //addCompletionListListener(compList); + + //if (editModel) // ComboBoxActionListener edits the model + this.editModel = editModel; + addActionListener(new ComboBoxActionListener()); + + } + + void setOntology(Ontology o) { ontology = o; } + + //void setSearchParams(SearchParamsI sp) { searchParams = sp; } + + void setCharField(CharField charField) { this.charField = charField; } + + ///** If true than the auto combo is for setting the differentia in a post comp term, + // if false (default) than no post comp or genus in post comp */ + //void setIsDifferentia(boolean isDiff) { isDifferentia = isDiff; } + + /** Set text in editable text field of j combo (eg from table select) */ + void setText(String text) { + // do not do term completion on externally set text! + boolean doCompletion = false; + setText(text,doCompletion); + } + + // text from selecting table doesnt do completion, TestPhenote does + void setText(String text, boolean doCompletion) { + this.doCompletion = doCompletion; + this.keyTyped = doCompletion; // key has to be typed for completion + getEditor().setItem(text); + this.doCompletion = true; // set back to default + } + + /** rename setTerm? */ + void setOboClass(OBOClass term) { + if (term == null) { + log().error("Attempt to set term to null"); + return; // debug stack trace? + } + currentOboClass = term; + setText(term.getName(),false); // no completion + } + + /** for relationships (post comp rel) */ + void setRel(OBOProperty rel) { + if (rel == null) { + log().error("Attempt to set term to null"); + return; // debug stack trace? + } + currentRel = rel; + setText(rel.toString(),false); // eventually .getName() + } + + /** Throws exception if there isnt a current obo class, if the user + has typed something that isnt yet a term - hasnt selected a term */ + OBOClass getCurrentOboClass() throws Exception { + if (currentOboClass == null) throw new Exception("term is null"); + if (!currentOboClass.getName().equals(getText())) + throw new Exception("(obo class "+currentOboClass+" and input "+getText()+ + " dont match)"); + return currentOboClass; + } + + /** Throws exception if there isnt a current relation - for relation lists + (post comp), if the user + has typed something that isnt yet a rel - hasnt selected a rel */ + OBOProperty getCurrentRelation() throws Exception { + if (currentRel == null) throw new Exception("term is null"); + if (!currentRel.toString().equals(getText())) + throw new Exception("(relation "+currentRel+" and input "+getText()+ + " dont match)"); + return currentRel; + + } + + /** Return text in text field */ + String getText() { + //return (String)getSelectedItem(); + return getEditor().getItem().toString(); // or editor.getText() ? + } + + + void clear() { + setText(""); + } + + + /** This gets obo class selected in completion list - not from text box + Returns null if nothing selected - can happen amidst changing selection + also used by PostCompGui + this doesnt necasarily stay current with user input hmmm.... + throws OboException if dont have valid term */ + OBOClass getSelectedCompListOboClass() throws OboException { + Object obj = getSelectedObject(); // throws oboex + return oboClassDowncast(obj); // throws oboex + } + + private class OboException extends Exception { + private OboException() { super(); } + private OboException(String s) { super(s); } + } + +// private OBOClass getCompListOboClass(int index) { +// Object obj = defaultComboBoxModel.getElementAt(index); +// return oboClassDowncast(obj); +// } + + // strings get in somehow - need to figure out where they are coming from + private OBOClass oboClassDowncast(Object obj) throws OboException { + if (obj == null) throw new OboException(); + if ( ! (obj instanceof OBOClass)) { + //log.info("Item in completion list not obo class "+obj.getClass()); + throw new OboException("Item in completion list not obo class "+obj.getClass()); + } + return (OBOClass)obj; + } + + private OBOProperty oboPropertyDowncast(Object obj) throws OboException { + if (obj == null) throw new OboException(); + if ( ! (obj instanceof OBOProperty)) { + //log.info("Item in completion list not obo class "+obj.getClass()); + throw new OboException("Item in completion list not obo prop "+obj.getClass()); + } + return (OBOProperty)obj; + } + + /** returns currently selected relation, for auto combos of relations, + throws obo ex if there is no current relation */ + private OBOProperty getSelectedRelation() throws OboException { + Object obj = getSelectedObject(); // throws oboex + return oboPropertyDowncast(obj); // throws oboex + } + + private Object getSelectedObject() throws OboException { + if (defaultComboBoxModel == null) throw new OboException(); // ?? + Object obj = defaultComboBoxModel.getSelectedItem(); + if (obj == null) throw new OboException(); + return obj; + } + + + /** BasicComboBoxEditor uses JTextField as its editing component but is + * only available as a protected variable - odd + adds auto doc & auto key listeners to combo box edit field */ + private class AutoTextFieldEditor extends BasicComboBoxEditor { + + private AutoTextFieldEditor() { + autoTextField = new AutoTextField(); + editor = autoTextField; // protected editor var from BCBE + addDocumentListener(new AutoDocumentListener()); + getTextField().addKeyListener(new AutoKeyListener()); + } + + // editor is protected JTextField - wacky + private JTextField getTextField() { + return editor; + } + + private Document getDocument() { + return getTextField().getDocument(); + } + private void addDocumentListener(DocumentListener dl) { + getDocument().addDocumentListener(dl); + } + } + + + /** AutoTextField inner class - ignores set text when in + * changingCompletionList mode - this is the text field for the + combo box */ + private class AutoTextField extends JTextField { + + private AutoTextField() { + super(25); // width + } + + /** dont set text if changing completion list, if changing text turn off + completion, as changing text is coming from outside not user typing + thus wont get completion on user selection, leaving popup hanging */ + public void setText(String text) { + if (changingCompletionList) + return; + // this makes setText(text,true) turn to false (called from TextPhenote) + // but this is needed from mouse release on selection set text + // is called and will cause completion list to come up after sel + // w/o it + doCompletion = false; + super.setText(text); + doCompletion = true; + } + + protected void processKeyEvent(KeyEvent e) { + //boolean fiddle = KeyboardState.shouldProcess(e); + super.processKeyEvent(e); + } + } + + void simulateLKeyStroke() { + autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,KeyEvent.VK_L,'l')); + autoTextField.processKeyEvent(new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,'l')); + } + + void simulateKeyStroke(int keyCode, char c) { + KeyEvent k = new KeyEvent(this,KeyEvent.KEY_PRESSED,0,0,keyCode,c); + autoTextField.processKeyEvent(k); + k.setKeyCode(KeyEvent.KEY_RELEASED); + autoTextField.processKeyEvent(k); + k = new KeyEvent(this,KeyEvent.KEY_TYPED,0,0,KeyEvent.VK_UNDEFINED,c); + autoTextField.processKeyEvent(k); + } + + private class AutoKeyListener extends KeyAdapter { + // keyTyped doesnt seem to catch backspace in 1.5 - but did in 1.4 - odd +// public void keyTyped(KeyEvent e) { +// // return & tab should be ignored, as well as a lot of other things +// keyTyped = true; +// // this may be funny but with key type event the text has not yet be set +// // this catches cases where text changed due select/action - kinda cheap +// previousInput = getText(); +// } + public void keyReleased(KeyEvent e) { + // return & tab should be ignored, as well as a lot of other things + keyTyped = true; + // this may be funny but with key type event the text has not yet be set + // this catches cases where text changed due select/action - kinda cheap + previousInput = getText(); + } + } + + + /** disable completion for item being selected - otherwise a popup comes up after + the selection - probably no harm in keeping this but this may be redundant with + the turning off of doCompletion in inner ATF.setText which is more + comprehensive */ + public void setSelectedItem(Object item) { + doCompletion = false; + super.setSelectedItem(item); + doCompletion = true; + } + + /** If combo box is relationship then the items will be OBOProperties not + OBOClasses */ + private boolean isRelationshipList() { + return charField.isRelationship(); + } + private boolean isTermList() { return !isRelationshipList(); } + + /** MAKE COMPLETION LIST FROM USER INPUT + Populates defaultComboBoxModel with Vector of OBOClasses - OBOClass.toString + is the name of the term - thats why its possible - at least for moment + if we want to put syn in brackets that makes this not possible - certainly + handy */ + private void doCompletion() { + if (!doCompletion) // flag set if text filled in externally (from table sel) + return; + // so AbstractDoc.replace does a remove and then insert, the remove sets + // text to "" and then keyTyped gets set to false, so the insert doesnt go + // through, taking out keyTyped, inputChanged may be sufficient +// if (!keyTyped) // if user hasnt typed anything dont bother +// return; + if (!inputChanged()) // if input is actually same no need to recomp + return; + keyTyped = false; + // too soon - text field doesnt have text yet.... hmmmm.... + String input = getText(); + // this is a vector of OBOClasses + // i think ultimately we will need to wrap the OBOClass to be able to + // have more control over the string - cut off w ... & [syn][obs] tags + Vector v; + if (isRelationshipList()) + v = ontology.getStringMatchRelations(input); + else + v = getTerms(input); + // throws IllegalStateException, Attempt to mutate in notification + // this tries to change text field amidst notification hmmmm..... + changingCompletionList = true; + defaultComboBoxModel = new DefaultComboBoxModel(v); + setModel(defaultComboBoxModel); + changingCompletionList = false; + // showPopup can hang during test but not during real run - bizarre + showPopup(); // only show popup on key events - actually only do comp w key + } + + /** This is cheesy but theres a hanging bug with showPopup that only happens + in test mode - dont know why but doesnt actually matter, so setting flag + to turn off showpopup in test - if hangs in nontest will investigate */ + void setTestMode(boolean inTestMode) { + this.inTestMode = inTestMode; + } + + /** This is cheesy but theres a hanging bug with showPopup that only happens + in test mode - dont know why but doesnt actually matter, so if inTestMode + then dont showpopup - if hangs in nontest will investigate */ + public void showPopup() { + if (inTestMode) + return; + super.showPopup(); + } + + + /** returns true if input changed from previously recorded input */ + private boolean inputChanged() { + String newInput = getText(); + boolean inputChanged = ! previousInput.equals(newInput); + if (inputChanged) + previousInput = newInput; + return inputChanged; + } + + /** call Ontology to get a Vector of OBOClass's that contain "in" + in ontology */ + private Vector<OBOClass> getTerms(String in) { + // or CompletionList.getCompletionList(getOntology()) ?? + //CompletionList cl = CompletionList.getCompletionList(); + //return cl.getCompletionTerms(getOntology(),in,searchParams); + return ontology.getSearchTerms(in,searchParams); // vector of OBOClass's + } + + private class AutoDocumentListener implements DocumentListener { + public void changedUpdate(DocumentEvent e) { doCompletion(); } + public void insertUpdate(DocumentEvent e) { doCompletion(); } + public void removeUpdate(DocumentEvent e) { doCompletion(); } + } + + /** This is touchy stuff - so i want to be able to display info about term in + TermInfo when user mouses over terms in combo boxes JList. This is not + explicitly supported by JComboBox. have to dig into its UI to get JList. + The combo box ui selects items in JList on mouse over, this listener + will listen for those mouse over selections + should this be done with a selection event - or is that + overkill, i guess the question will anyone besides term info + ever care about these mouse over selection - if so make generic */ +// void addCompletionListListener(ListSelectionListener lsl) { +// if (!canGetUIJList()) return; +// getUIJList().addListSelectionListener(lsl); } + void enableTermInfoListening(boolean enable) { + if (!canGetUIJList()) + return; + if (enable) + getUIJList().addListSelectionListener(compListListener); + else + getUIJList().removeListSelectionListener(compListListener); + } + + /** this is for MOUSE OVER TERM INFO - changes selection */ + private class CompletionListListener implements ListSelectionListener { + public void valueChanged(ListSelectionEvent e) { + Object source = e.getSource(); + // hate to cast but it is handy here... and it is in fact a JList + if (!(source instanceof JList)) { + System.out.println("source of combo box mouse over event is not JList "+ + source.getClass()); + return; + } + JList jList = (JList)source; + Object selectedValue = jList.getSelectedValue(); + if (selectedValue == null) + return; + //System.out.println("sel val "+selectedValue.getClass()+" name "+selectedValue); + // the selected item should be an OBOClass + if (!(selectedValue instanceof OBOClass)) { + System.out.println("selected completion term is not obo class " + +selectedValue.getClass()); + return; + } + OBOClass oboClass = (OBOClass)selectedValue; + getSelectionManager().selectTerm(AutoComboBox.this,oboClass,getUseTermListener()); + //setTextFromOboClass(oboClass); + } + } // end of CompletionListListener inner class + + private UseTermListener useTermListener; + private UseTermListener getUseTermListener() { + if (useTermListener == null) useTermListener = new ComboUseTermListener(); + return useTermListener; + } + + private class ComboUseTermListener implements UseTermListener { + public void useTerm(UseTermEvent e) { + setOboClass(e.getTerm()); + if (editModel) editModel(); + } + } + + private SelectionManager getSelectionManager() { + return SelectionManager.inst(); + } + + private CharacterI getSelectedCharacter() { + return getSelectionManager().getSelectedCharacter(); + } + + private boolean canGetUIJList() { + return getUIJList() != null; + } + + /** This may return null if not using Metal/Java UI/Look & Feel as JList comes + from the UI - need to implement getting JList from each UI I guess */ + private JList getUIJList() { + ComboBoxUI comboBoxUI = getUI(); + if (!(comboBoxUI instanceof MetalListComboUI)) { + System.out.println("Cant retrieve JList for look & feel, cant do mouse overs " + +comboBoxUI.getClass()); + return null; + } + return ((MetalListComboUI)comboBoxUI).getJList(); + } + + // for TestPhenote + void doMouseOver(int itemNumber) { + //System.out.println("AutoComboBox.doMouseOver not implemented yet"); + if (!canGetUIJList()) return; + JList jList = getUIJList(); + jList.setSelectedIndex(itemNumber); + } + + private class MetalListComboUI extends MetalComboBoxUI { + private JList getJList() { + return listBox; // protected JList in BasicComboBoxUI + } + } + + + + /** Listens for actions from combo boxes and edits model/character + * actions come from mouse select of term as well as return & tab */ + private class ComboBoxActionListener implements ActionListener { + //private OBOClass previousOboClass=null; + + private ComboBoxActionListener() {} + public void actionPerformed(ActionEvent e) { + editCharField(); + } + + /** edits Character field via EditManager. + checks that text in text field from user + is actually an item in completion list, is an obo term. */ + private void editCharField() { + String input = getText(); + if (input == null) return; // probably doesnt happen + // the input should be from selected obo class shouldnt it? is it possible + // for this not to be so? returns null if no oboclass? + // TERM + if (isTermList()) { + try { currentOboClass = getSelectedCompListOboClass(); } + // happens on return on invalid term name + catch (OboException e) { return; } // error msg? + //if (oboClass == null) return; currentOboClass = oboClass; + } + // RELATIONSHIP + else { + try { currentRel = getSelectedRelation(); } + catch (OboException e) { return; } + } + + // EDIT MODEL + if (editModel) + editModel(); +// CharacterI c = getSelectedCharacter(); // from selectionManager +// CharFieldEnum cfe = charField.getCharFieldEnum(); +// UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); +// EditManager.inst().updateModel(this,ut); + } + } + + private void editModel() { + OBOClass oboClass; + try { oboClass = getCurrentOboClass(); } + catch (Exception e) { return; } // shouldnt happen, error? + if (charField == null) return; // shouldnt happen + CharacterI c = getSelectedCharacter(); // from selectionManager + CharFieldEnum cfe = charField.getCharFieldEnum(); + // isDifferentia boolean? + UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); + EditManager.inst().updateModel(this,ut); + } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } +} + +// GARBAGE + //private Ontology getOntology() { return ontology; } + + /** Return true if input String matches name of OBOClass in + * defaultComboBoxModel - rename this? this isnt used anymore - delete? + */ +// boolean isInCompletionList(String input) { +// if (defaultComboBoxModel == null) +// return false; +// if (input == null) { +// return false; +// } +// // this is wrong as it holds OBOClasses not Strings! +// //return defaultComboBoxModel.getIndexOf(input) != -1; +// // have to go through all OBOClasses and extract there names - bummer +// // most likely input is selected one check that first +// OBOClass selectedClass = getSelectedCompListOboClass(); +// if (selectedClass != null && input.equals(selectedClass.getName())) +// return true; +// // selected failed(is this possible?) - try everything in the list then... +// for (int i=0; i<defaultComboBoxModel.getSize(); i++) { +// if (input.equals(getCompListOboClass(i).getName())) +// return true; +// } +// return false; +// } + + // mac bug workaround where list covers up textfield on < 12 items no scroll + // from http://www.orbital-computer.de/JComboBox/#usage + // it does note this may cause class cast excpetions?? + // it does cause exception when down arror is typed... hmmm... + //setUI(new BasicComboBoxUI()); // now setting metal look & feel for whole app +//String ontology,AutoComboBox cb) { + //private String previousModelValue=null; + //this.ontology = ontology; + //comboBox = cb; + //setTableFromField(ontology); + //t.editModel(); // or charField.editModel? + // CharacterChangeEvent e = new CharacterChangeEvent(t); + // OR CharEditManager.inst().updateModel(c,cfe,input,previousModelValue); + // CEM.handleTransaction(new UT), CEM.updateModel(UT) + // fireChangeEvent(e); + + // check if input is a real term - i think we can get away with checking + // if in present term completion list - not sure + // i think this is replaced by check above - make sure does the same... +// boolean valid = isInCompletionList(oboClass); //input); +// if (!valid) +// return; + + +// doesnt work - would need to subclass editor component i thing - hassle +// // for TestPhenote +// void simulateBackspace() { +// KeyEvent ke = new KeyEvent(this,KeyEvent.VK_DELETE,java.util.Calendar.getInstance().getTimeInMillis(),0,KeyEvent.VK_UNDEFINED,KeyEvent.CHAR_UNDEFINED); +// //patoComboBox.processKeyEvent(ke); +// getEditor().getEditorComponent().processKeyEvent(ke); + +// } +// Document d = e.getDocument(); +// String input; +// try { +// input = d.getText(0,d.getLength()); +// } +// catch (javax.swing.text.BadLocationException ex) { +// System.out.println(ex); +// return; +// } Deleted: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-10 17:20:06 UTC (rev 152) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-12 15:06:22 UTC (rev 153) @@ -1,632 +0,0 @@ -package phenote.gui; - -import java.awt.Dimension; -import java.awt.Font; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.util.Vector; -import javax.swing.JComboBox; -import javax.swing.JList; -import javax.swing.JTextField; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.DefaultComboBoxModel; -import javax.swing.text.Document; -import javax.swing.plaf.basic.BasicComboBoxEditor; -//import javax.swing.plaf.basic.BasicComboBoxUI; -import javax.swing.plaf.ComboBoxUI; -import javax.swing.plaf.metal.MetalComboBoxUI; - -import org.apache.log4j.Logger; - -import org.geneontology.oboedit.datamodel.OBOClass; -import org.geneontology.oboedit.datamodel.OBOProperty; - -import phenote.datamodel.CharField; -import phenote.datamodel.CharFieldEnum; -import phenote.datamodel.CharacterI; -import phenote.datamodel.Ontology; -import phenote.datamodel.SearchParamsI; -import phenote.edit.EditManager; -import phenote.edit.UpdateTransaction; -import phenote.gui.selection.SelectionManager; -import phenote.gui.selection.UseTermEvent; -import phenote.gui.selection.UseTermListener; - -/** The jcombobox that does auto completion - i had to do some tricks(hacks) to get it - working with mouse over which doesnt come naturally to jcombobox */ - -class AutoComboBox extends JComboBox { - - private Ontology ontology; - private boolean changingCompletionList = false; - private boolean keyTyped = false; - private String previousInput = ""; - private boolean doCompletion = true; - // should we keep state of currentOboClass which is null if not a valid one? - // default combo box.getSelectedItem sortof does this imperfectly - private OBOClass currentOboClass=null; - private OBOProperty currentRel=null; - private DefaultComboBoxModel defaultComboBoxModel; - private SearchParamsI searchParams; - private boolean inTestMode = false; - //private AutoTextFieldEditor autoTextFieldEditor; - private AutoTextField autoTextField; - private CharField charField; - ///** Whether differentia of a post composed term */ - //private boolean isDifferentia = false; - /** if false then model is not edited */ - private boolean editModel; - private CompletionListListener compListListener = new CompletionListListener(); - - /** @param editModel if false then ACB doesnt edit model directly (post comp) */ - AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { - // this inner class enables retrieving of JList for mouse over - // this will probably throw errors if non metal look & feel is used - setUI(new MetalListComboUI()); - //setFont(new Font("Courier",Font.PLAIN,12)); - - setOntology(ontology); - searchParams = sp; // singleton access? part of ontology? - setEditable(true); - AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); - this.setEditor(autoTextFieldEditor); - setPreferredSize(new Dimension(350,22)); - - enableTermInfoListening(true); // default - //addCompletionListListener(compList); - - //if (editModel) // ComboBoxActionListener edits the model - this.editModel = editModel; - addActionListener(new ComboBoxActionListener()); - - } - - void setOntology(Ontology o) { ontology = o; } - - //void setSearchParams(SearchParamsI sp) { searchParams = sp; } - - void setCharField(CharField charField) { this.charField = charField; } - - ///** If true than the auto combo is for setting the differentia in a post comp term, - // if false (default) than no post comp or genus in post comp */ - //void setIsDifferentia(boolean isDiff) { isDifferentia = isDiff; } - - /** Set text in editable text field of j combo (eg from table select) */ - void setText(String text) { - // do not do term completion on externally set text! - boolean doCompletion = false; - setText(text,doCompletion); - } - - // text from selecting table doesnt do completion, TestPhenote does - void setText(String text, boolean doCompletion) { - this.doCompletion = doCompletion; - this.keyTyped = doCompletion; // key has to be typed for completion - getEditor().setItem(text); - this.doCompletion = true; // set back to default - } - - /** rename setTerm? */ - void setOboClass(OBOClass term) { - if (term == null) { - log().error("Attempt to set term to null"); - return; // debug stack trace? - } - currentOboClass = term; - setText(term.getName(),false); // no completion - } - - /** for relationships (post comp rel) */ - void setRel(OBOProperty rel) { - if (rel == null) { - log().error("Attempt to set term to null"); - return; // debug stack trace? - } - currentRel = rel; - setText(rel.toString(),false); // eventually .getName() - } - - /** Throws exception if there isnt a current obo class, if the user - has typed something that isnt yet a term - hasnt selected a term */ - OBOClass getCurrentOboClass() throws Exception { - if (currentOboClass == null) throw new Exception("term is null"); - if (!currentOboClass.getName().equals(getText())) - throw new Exception("(obo class "+currentOboClass+" and input "+getText()+ - " dont match)"); - return currentOboClass; - } - - /** Throws exception if there isnt a current relation - for relation lists - (post comp), if the user - has typed something that isnt yet a rel - hasnt selected a rel */ - OBOProperty getCurrentRelation() throws Exception { - if (currentRel == null) throw new Exception("term is null"); - if (!currentRel.toString().equals(getText())) - throw new Exception("(relation "+currentRel+" and input "+getText()+ - " dont match)"); - return currentRel; - - } - - /** Return text in text field */ - String getText() { - //return (String)getSelectedItem(); - return getEditor().getItem().toString(); // or editor.getText() ? - } - - - void clear() { - setText(""); - } - - - /** This gets obo class selected in completion list - not from text box - Returns null if nothing selected - can happen amidst changing selection - also used by PostCompGui - this doesnt necasarily stay current with user input hmmm.... - throws OboException if dont have valid term */ - OBOClass getSelectedCompListOboClass() throws OboException { - Object obj = getSelectedObject(); // throws oboex - return oboClassDowncast(obj); // throws oboex - } - - private class OboException extends Exception { - private OboException() { super(); } - private OboException(String s) { super(s); } - } - -// private OBOClass getCompListOboClass(int index) { -// Object obj = defaultComboBoxModel.getElementAt(index); -// return oboClassDowncast(obj); -// } - - // strings get in somehow - need to figure out where they are coming from - private OBOClass oboClassDowncast(Object obj) throws OboException { - if (obj == null) throw new OboException(); - if ( ! (obj instanceof OBOClass)) { - //log.info("Item in completion list not obo class "+obj.getClass()); - throw new OboException("Item in completion list not obo class "+obj.getClass()); - } - return (OBOClass)obj; - } - - private OBOProperty oboPropertyDowncast(Object obj) throws OboException { - if (obj == null) throw new OboException(); - if ( ! (obj instanceof OBOProperty)) { - //log.info("Item in completion list not obo class "+obj.getClass()); - throw new OboException("Item in completion list not obo prop "+obj.getClass()); - } - return (OBOProperty)obj; - } - - /** returns currently selected relation, for auto combos of relations, - throws obo ex if there is no current relation */ - private OBOProperty getSelectedRelation() throws OboException { - Object obj = getSelectedObject(); // throws oboex - return oboPropertyDowncast(obj); // throws oboex - } - - private Object getSelectedObject() throws OboException { - if (defaultComboBoxModel == null) throw new OboException(); // ?? - Object obj = defaultComboBoxModel.getSelectedItem(); - if (obj == null) throw new OboException(); - return obj; - } - - - /** BasicComboBoxEditor uses JTextField as its editing component but is - * only available as a protected variable - odd - adds auto doc & auto key listeners to combo box edit field */ - private class AutoTextFieldEditor extends BasicComboBoxEditor { - - private AutoTextFieldEditor() { - autoTextField = new AutoTextField(); - editor = autoTextField; // protected editor var from BCBE - addDocumentListener(new AutoDocumentListener()); - getTextField().addKeyListener(new AutoKeyListener()); - } - - // editor is protected JTextField - wacky - private JTextField getTextField() { - return editor; - } - - private Document getDocument() { - return getTextField().getDocument(); - } - private void addDocumentListener(DocumentListener dl) { - getDocument().addDocumentListener(dl); - } - } - - - /** AutoTextField inner class - ignores set text when in - * changingCompletionList mode - this is the text field for the - combo box */ - private class AutoTextField extends JTextField { - - private AutoTextField() { - super(25); // width - } - - /** dont set text if changing completion list, if changing text turn off - completion, as changing text is coming from outside not user typing - thus wont get completion on user selection, leaving popup hanging */ - public void setText(String text) { - if (changingCompletionList) - return; - // this makes setText(text,true) turn to false (called from TextPhenote) - // but this is needed from mouse release on selection set text - // is called and will cause completion list to come up after sel - // w/o it... [truncated message content] |
From: <mg...@us...> - 2006-10-10 17:20:10
|
Revision: 152 http://svn.sourceforge.net/obo/?rev=152&view=rev Author: mgibson Date: 2006-10-10 10:20:06 -0700 (Tue, 10 Oct 2006) Log Message: ----------- moinor doc changes Modified Paths: -------------- phenote/trunk/src/web/javascript/readme Modified: phenote/trunk/src/web/javascript/readme =================================================================== --- phenote/trunk/src/web/javascript/readme 2006-10-10 17:13:35 UTC (rev 151) +++ phenote/trunk/src/web/javascript/readme 2006-10-10 17:20:06 UTC (rev 152) @@ -5,16 +5,18 @@ in theory these shouldnt need to be modified (though ive had my temptations) The 3 scripts are all for term info retrieval from the backend. They should -probably be merged & deleted. The main variant is the back url to get term info +probably be merged & deleted. The main variant is the backend url to get term info from and that url should come from the top page where all mod specific stuff is set, rather than here. Once that is done should be able to merge. These scripts are called with onMouseOver that is in the completion list that is -returned by the server for autocompletion. +returned by the backend server(be it perl servlet or whatnot) for autocompletion. dichty-term-info.js might be old and if so should be deleted? sohel? -term_completer.js is the new dichty base script (or old??). +term_completer.js is the new dichty base script (or old??) should be merged +with ncbo-term-info.js. Sohel that would require you to change your mouseOver +function call from the completion list to getTermInfo - would that be ok? ncbo-term-info.js ----------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-10 17:13:39
|
Revision: 151 http://svn.sourceforge.net/obo/?rev=151&view=rev Author: mgibson Date: 2006-10-10 10:13:35 -0700 (Tue, 10 Oct 2006) Log Message: ----------- web javascript docs begginning - need to merge these scripts! Added Paths: ----------- phenote/trunk/src/web/javascript/readme Added: phenote/trunk/src/web/javascript/readme =================================================================== --- phenote/trunk/src/web/javascript/readme (rev 0) +++ phenote/trunk/src/web/javascript/readme 2006-10-10 17:13:35 UTC (rev 151) @@ -0,0 +1,40 @@ +3 files: dichty-term-info.js ncbo-term-info.js term-completer.js +one sub directory: ajax-lib + +ajax-lib is open source ajax code from scriptaculous that the above files use. +in theory these shouldnt need to be modified (though ive had my temptations) + +The 3 scripts are all for term info retrieval from the backend. They should +probably be merged & deleted. The main variant is the back url to get term info +from and that url should come from the top page where all mod specific stuff is set, +rather than here. Once that is done should be able to merge. + +These scripts are called with onMouseOver that is in the completion list that is +returned by the server for autocompletion. + +dichty-term-info.js might be old and if so should be deleted? sohel? + +term_completer.js is the new dichty base script (or old??). + +ncbo-term-info.js +----------------- +is used for zfin/ncbo. There are some difference to dichty here. +The method is called getTermInfo which is a clearer name then set_ontology or +set_ontology_term. The url is different and as said above should be set in +the top mod specific page not here. + +OntologyName & field are passed as +parameters. Ontology name is needed for cases where theres an ontology chooser +(zfin entity - dichty can ignore this). field is needed so the Use Term button +of TermInfo knows which field to update (its the field the original term came from). + +In the top level html (ncbo.html) the form with the terms is given the name +termForm and that is used instead of forms[0] which can be presumptious if plugging +into a mods web page. + +The checking of the length of the ontologyid array was scrapped as it was unnecasary. + +So these scripts should be merged, and I think the ncbo changes should be incorporated. +Would you agree sohel? + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-10 15:47:06
|
Revision: 150 http://svn.sourceforge.net/obo/?rev=150&view=rev Author: mgibson Date: 2006-10-10 08:47:02 -0700 (Tue, 10 Oct 2006) Log Message: ----------- beginning of docs! Added Paths: ----------- phenote/trunk/src/web/html/readme.html Added: phenote/trunk/src/web/html/readme.html =================================================================== --- phenote/trunk/src/web/html/readme.html (rev 0) +++ phenote/trunk/src/web/html/readme.html 2006-10-10 15:47:02 UTC (rev 150) @@ -0,0 +1,33 @@ +Files: +dichty.html interface.html ncbo.html term_completer.html + +dichty.html: I think this is old and should be deleted - sohel? replaced by interface.html + + +interface.html: +--------------- +This should be renamed dichty-top.html as this is dichty base's new +top level html page. The improvement over dichty.html (amongst other additions) is +that it generically creates fields using the Sever Side Includes(SSI) file +term_completer.html. Also has commit & retrieve buttons, that call javascript functions. + +term_completer.html +------------------- +This is generic server side include stuff for interface.html. It takes vars tag, title, + & url. see interface.html for use. This should be renamed term_completion_field.ssi + or just field.ssi (are all fields term completion - some may be free text) or + field_template.ssi? + + +ncbo.html +--------- +This is the top html page for ncbo/zfin (rename zfin.html?). It should use the new +SSI paradigm and use the term_completer.html SSI stuff. But this does have stuff that +interface/term_completer lacks. That is it has an entity chooser (dichtybase has no +need for one), and a UseTerm button. These require both an ontology name and field +name to be passed into the auto completion function. Also method names are renamed +for clarity sake. + + +So in summary ncbo.html & interface.html need to grab stuff from each other. Both of which +serve as templates for new groups coming up with there own top level page (mod.html) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-06 15:17:48
|
Revision: 149 http://svn.sourceforge.net/obo/?rev=149&view=rev Author: mgibson Date: 2006-10-06 08:17:39 -0700 (Fri, 06 Oct 2006) Log Message: ----------- added a Use Term button to term info in webby phenote. had to do this differently of course than how done in standalone - standalone its done with java objects & event listener - in webby i pass a field string ("ENTITY" or "QUALITY") to ajax/servlet on term comp - which puts out list with onMouseClick with field param for term info servlet/ajax - which sets a DOM variable - then when use term is clicked it checks the dom variable - if theres a better way to do this im open to it - this seems a little hacky to me but it also seems like the way things are done in ajax javascript servlet web world but what do i know also putting starts with terms first in completion list took out unique check for terms - it was only a bug in synonyms that made it necasary - woops - fixed that bug Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java phenote/trunk/src/java/phenote/util/HtmlUtil.java phenote/trunk/src/web/html/ncbo.html phenote/trunk/src/web/javascript/ncbo-term-info.js Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-04 18:49:36 UTC (rev 148) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-06 15:17:39 UTC (rev 149) @@ -325,7 +325,8 @@ } private boolean isTermList() { return !isRelationshipList(); } - /** Populates defaultComboBoxModel with Vector of OBOClasses - OBOClass.toString + /** MAKE COMPLETION LIST FROM USER INPUT + Populates defaultComboBoxModel with Vector of OBOClasses - OBOClass.toString is the name of the term - thats why its possible - at least for moment if we want to put syn in brackets that makes this not possible - certainly handy */ Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-04 18:49:36 UTC (rev 148) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-10-06 15:17:39 UTC (rev 149) @@ -48,6 +48,7 @@ // just in case not in web.xml if (configFile == null || configFile.equals("")) configFile = "/initial-zfin.cfg"; + //boolean DEBUG = true; if (DEBUG) configFile = "/fiddle.cfg"; try { Config.inst().setConfigFile(configFile); // causes parse of file } catch (ConfigException e) { @@ -93,7 +94,8 @@ // "<li onmouseover=\"set_ontology()\" id=\"termId\" onclick=\"set_ontology()\">"+ // "test</li>\n<li onmouseover=\"set_ontology()\" id=\"termId\" onclick=\"set_ontology()\">dude</li></ul>"; String ontol = getOntologyParamString(request); - String list = getCompletionList(userInput, ontol); + String field = getFieldParamString(request); + String list = getCompletionList(userInput, ontol, field); LOG.debug("printing to response writer: " + substring(list, 55) + "..."); out.println(list); } @@ -120,37 +122,45 @@ return req.getParameter("ontologyName"); } + /** field param string specifies what gui field the request came from - this is + used for UseTermInfo button to populate field from term info */ + private String getFieldParamString(HttpServletRequest req) { + return req.getParameter("field"); + } - /** - * TERM INFO request - * i cant tell ya why but term info is done with a get and term completion - * is done with a post - is there rhyme or reason to this? - */ - public void doGet(HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException { - if (true || isTermInfoRequest(request)) { - PrintWriter out = response.getWriter(); - String termId = getTermIdFromTermInfoRequest(request); - String ontologyName = getOntologyParamString(request); - LOG.info("doGet term info param: " + termId + " ont " + ontologyName); + + + /** + * TERM INFO request + * i cant tell ya why but term info is done with a get and term completion + * is done with a post - is there rhyme or reason to this? + */ + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws IOException, ServletException { + if (isTermInfoRequest(request)) { + PrintWriter out = response.getWriter(); + String termId = getTermIdFromTermInfoRequest(request); + String ontologyName = getOntologyParamString(request); + String field = getFieldParamString(request); + LOG.info("doGet term info param: " + termId + " ont " + ontologyName); // out.println("<table><tr><td class=\"label\">Ontology</td> "+ // "<td class=\"data\">"+initDate+"</td></tr>\n"+ // "<tr><td class=\"label\">Term name...</td><td class=\"data\">" // +userInput+"</td></tr></table>"); - Ontology ont = getOntology(ontologyName); - if (ont == null) { - LOG.error("ERROR: Failed to get ontology for " + ontologyName); - return; - } - OBOClass oboClass = getOntology(ontologyName).getOboClass(termId); - if (oboClass == null) { - LOG.error("term info: no obo class found for " + termId); - return; - } - LOG.info("term info " + substring(HtmlUtil.termInfo(oboClass), 60)); - out.println(HtmlUtil.termInfo(oboClass, ontologyName)); - } + Ontology ont = getOntology(ontologyName); + if (ont == null) { + LOG.error("ERROR: Failed to get ontology for " + ontologyName); + return; + } + OBOClass oboClass = getOntology(ontologyName).getOboClass(termId); + if (oboClass == null) { + LOG.error("term info: no obo class found for " + termId); + return; + } + LOG.info("term info " + substring(HtmlUtil.termInfo(oboClass), 60)); + out.println(HtmlUtil.termInfo(oboClass, ontologyName,field)); } + } private String substring(String s, int sz) { sz = (s.length() <= sz) ? s.length() : sz; @@ -166,22 +176,26 @@ } - // List<String>? String[]? or String htmlLiString? - // for now just return html ul-li list w onmouseover - private String getCompletionList(String userInput, String ontol) { - StringBuffer sb = new StringBuffer("<ul>"); - // for now just grab the pato ontology - eventuall redo for multiple/config - Ontology ontology = getOntology(ontol); - if (ontology == null) { - LOG.error("failed to get " + ontol + " from ontology manager"); - return "ontology retrieval failed"; - } - Vector<OBOClass> v = ontology.getSearchTerms(userInput, getSearchParams()); - for (OBOClass oc : v) - sb.append(makeCompListHtmlItem(oc, ontol)); - sb.append("</ul>"); - return sb.toString(); + /** List<String>? String[]? or String htmlLiString? + for now just return html ul-li list w onmouseover + userInput is what user has typed which terms will be queried for + ontol is the name of the ontology that user is querying + field is the gui field user is querying (which may have multiple ontols) */ + private String getCompletionList(String userInput,String ontol,String field) { + StringBuffer sb = new StringBuffer("<ul>"); + // for now just grab the pato ontology - eventuall redo for multiple/config + Ontology ontology = getOntology(ontol); + if (ontology == null) { + LOG.error("failed to get " + ontol + " from ontology manager"); + return "ontology retrieval failed"; } + Vector<OBOClass> v = ontology.getSearchTerms(userInput, getSearchParams()); + for (OBOClass oc : v) + sb.append(makeCompListHtmlItem(oc, ontol, field)); + sb.append("</ul>"); + //System.out.println(sb); + return sb.toString(); + } /** * returns null if ontolName not found @@ -200,13 +214,34 @@ return null; } - private String makeCompListHtmlItem(OBOClass term, String ontol) { - String id = "'" + term.getID() + "'"; - String info = "\"getTermInfo(" + id + ",'" + ontol + "')\""; - return "<li onmouseover=" + info + " id=" + id + " " + - "onclick=" + info + ">" + term.getName() + "</li>\n"; - } + private String makeCompListHtmlItem(OBOClass term, String ontol,String field) { + String id = term.getID(), name=term.getName(); + // pass in id, name & ontology - name for setting field on UseTerm + StringBuffer info = dq(fn("getTermInfo",new String[]{id,name,ontol,field})); + //String info = "\"getTermInfo("+id +","+q(name)+","+ q(ontol) + ")\""; + return "<li onmouseover=" + info + " id=" + q(id) + " " + + "onclick=" + info + ">" + name + "</li>\n"; + } + private static StringBuffer fn(String fnName, String[] params) { + return HtmlUtil.fn(fnName,params); + } +// StringBuffer s = new StringBuffer(fnName).append("(").append(q(params[0])); +// for (int i=1; i<params.length; i++) s.append(",").append(q(params[i])); +// s.append(")"); return s; } + + private static StringBuffer dq(StringBuffer sb) { + return new StringBuffer("\""+sb+"\""); + } + + private static StringBuffer q(StringBuffer sb) { + return new StringBuffer("'"+sb+"'"); + } + + private static String q(String s) { + return "'"+s+"'"; + } + /** * for now search params hard wired - eventually from buttons on web page */ Modified: phenote/trunk/src/java/phenote/util/HtmlUtil.java =================================================================== --- phenote/trunk/src/java/phenote/util/HtmlUtil.java 2006-10-04 18:49:36 UTC (rev 148) +++ phenote/trunk/src/java/phenote/util/HtmlUtil.java 2006-10-06 15:17:39 UTC (rev 149) @@ -19,6 +19,7 @@ // should this be somewhere else? gui.Phenote? */ private static boolean isStandAlone = true; private static String ontologyName; + private static String field; /** Stand alone and web app do different things for term links */ public static void setStandAlone(boolean standAlone) { @@ -34,6 +35,7 @@ if (oboClass.isObsolete()) sb.append("This term is OBSOLETE").append(newLine()); sb.append(bold("TERM: ")).append(oboClass.getName()); + sb.append(nl()).append(bold("ID: ")).append(oboClass.getID()); Set syns = oboClass.getSynonyms(); for (Iterator it = syns.iterator(); it.hasNext(); ) { sb.append(newLine()).append(bold("Synonym: ")).append(it.next()); @@ -54,17 +56,22 @@ return sb.toString(); } - public static String termInfo(OBOClass oboClass, String ontology) { + public static String termInfo(OBOClass oboClass, String ontology,String field) { // funny - revisit for sure - either should pass through all methods // or util should actually be an object - singleton? i think maybe its // an object??? setOntologyName(ontology); + setField(field); return termInfo(oboClass); } + // maybe this should be an object? as this is stateful private static void setOntologyName(String ont) { ontologyName = ont; } + /** string for web to track source of term info for UseTermInfo */ + private static void setField(String f) { field = f; } + private static String getField() { return field; } private static String getOntologyName() { return ontologyName; } @@ -143,23 +150,52 @@ } private static String termLink(LinkedObject term) { - String clickString = getClickString(term.getID()); + String clickString = getClickString(term.getID(),term.getName()); + //System.out.println(clickString); return "<a "+clickString+">"+term.getName()+"</a>"; } - private static String getClickString(String id) { + private static String getClickString(String id,String name) { if (isStandAlone) return "href='"+makePhenoIdLink(id)+"'"; - else - return "href=# "+onClickJavaScript(id); + else // this needs some reworking - causes page refresh and goes to top + return "href=# "+onClickJavaScript(id,name); } - //<A href='#' onClick='getTermInfo(".$_->term_id.")'> - private static String onClickJavaScript(String id) { - // need ontology name???? - return " onClick='getTermInfo(\""+id+"\",\""+getOntologyName()+"\")' "; + /**<A href='#' onClick='getTermInfo("id","name","ontology")'> - added in name for + UseTerm */ + private static StringBuffer onClickJavaScript(String id,String name) { + //String c = ","; + //return " onClick='getTermInfo("+q(id)+c+q(name)+c+q(getOntologyName())+")' "; + StringBuffer sb = new StringBuffer("onClick="); + String ont = getOntologyName(), f = getField(); + StringBuffer fn = fn("getTermInfo",new String[]{id,name,ont,f}); + return sb.append(dq(fn)); } + /** quoter */ + private static String dq(String s) { + return "\""+s+"\""; + } + private static StringBuffer dq(StringBuffer sb) { + return new StringBuffer("\""+sb+"\""); + } + + private static StringBuffer q(StringBuffer sb) { + return new StringBuffer("'"+sb+"'"); + } + private static String q(String s) { + return "'"+s+"'"; + } + + public static StringBuffer fn(String fnName, String[] params) { + StringBuffer s = new StringBuffer(fnName).append("(").append(q(params[0])); + for (int i=1; i<params.length; i++) + s.append(",").append(q(params[i])); + s.append(")"); + return s; + } + /** used internally & by TestPhenote */ public static String makePhenoIdLink(String id) { return PHENOTE_LINK_PREFIX + id; Modified: phenote/trunk/src/web/html/ncbo.html =================================================================== --- phenote/trunk/src/web/html/ncbo.html 2006-10-04 18:49:36 UTC (rev 148) +++ phenote/trunk/src/web/html/ncbo.html 2006-10-06 15:17:39 UTC (rev 149) @@ -29,7 +29,7 @@ } <!-- entityAutoCompleter.options.parameters = "ontologyName=" + ontologyName; --> - entityAutoCompleter.options.defaultParams = "ontologyName=" + ontologyName; + entityAutoCompleter.options.defaultParams = "ontologyName="+ontologyName+"&field=ENTITY"; <!-- alert(entityAutoCompleter.options.defaultParams); --> } @@ -45,7 +45,7 @@ <!-- td width="20%" --> -<form width="20%"> +<form name="termForm" width="20%"> <div id="ontology" width="20%"> <!-- table width="20%" --> @@ -117,27 +117,53 @@ <!-- 'ontologyname_auto_complete', '/phenote-ontology.cgi',{ }) --> <!-- new Ajax.Autocompleter( 'ontologyname', 'ontologyname_auto_complete', '/servlet/PhenoteStub',{ }) --> <!-- new Ajax.Autocompleter( 'ontologyname', 'ontologyname_auto_complete', '/servlet/phenote.servlet.PhenoteServlet',{ }) --> - var complete = new Ajax.Autocompleter( 'qualityInput', 'quality_auto_complete', '../Phenote',{parameters:'ontologyName=quality',paramName: "userInput" }) + var complete = new Ajax.Autocompleter( 'qualityInput', 'quality_auto_complete', '../Phenote',{parameters:'ontologyName=quality&field=QUALITY',paramName: "userInput" }) <!-- complete.options.defaultParams = "ontology=quality"; --> <!-- complete.options.parameters = "ontology=quality"; --> <!-- more params? 'ontology=quality&x=y&...' --> </script> <script type="text/javascript"> - var entityAutoCompleter = new Ajax.Autocompleter( 'entityInput', 'entity_auto_complete', '../Phenote',{parameters:'ontologyName=ZF',paramName: "userInput"}) + var entityAutoCompleter = new Ajax.Autocompleter( 'entityInput', 'entity_auto_complete', '../Phenote',{parameters:'ontologyName=ZF&field=ENTITY',paramName: "userInput"}) </script> <!-- this is set by ncbo-term-info.js but its unclear what its for is this the datamodel???? --> - <input type="hidden" name="ontologyid"> + <input type="hidden" name="termInfoTermId"> + <input type="hidden" name="termInfoTermName"> + <!--what input field haas the user most recently moused over terms --> + <!-- ENTITY or QUALITY, set by ncbo-term-info.js --> + <input type="hidden" name="activeField"> </form> <!-- /td --> <!-- td width="80%" --> <div id="termInfo"></div> + <!-- USE TERM BUTTON --> + <input + type="button" + value="Use Term" + name="use_term_info" + onClick="useTermInfo()" + > + <!-- /td --> + <script type="text/javascript"> + function useTermInfo() { + var field = document.termForm.activeField.value; + var termName = document.termForm.termInfoTermName.value; + //alert('use term info fn called - field '+field+' name '+termName); + <!-- document.termForm.qualityInput.value=document.termForm.termId.value; --> + if (field == "ENTITY") { + document.termForm.entityInput.value = termName; + } + else { + document.termForm.qualityInput.value= termName; + } + } + </script> Modified: phenote/trunk/src/web/javascript/ncbo-term-info.js =================================================================== --- phenote/trunk/src/web/javascript/ncbo-term-info.js 2006-10-04 18:49:36 UTC (rev 148) +++ phenote/trunk/src/web/javascript/ncbo-term-info.js 2006-10-06 15:17:39 UTC (rev 149) @@ -15,38 +15,32 @@ // ontologyid -> termId // ontologyName is the name of the ontology (not a term name!) - function getTermInfo(termId,ontologyName) { +function getTermInfo(termId,termName,ontologyName,field) { - // for some reason 0 doesnt work - //termId = 123; - - //alert("phenote-control.js set_ontology called ontId isNan:"+isNaN(termId)+" ontId: "+termId); - - // isNan is "is Not a Number", ontology id has to be a number - //if ( !isNaN( termId ) ) { -// var pars = 'ontologyid=' + ontologyid; - var pars = 'termId=' + termId +'&ontologyName=' + ontologyName; - + // for some reason 0 doesnt work + //termId = 123; + + //alert("ncbo-term-info.js set_ontology called termId: "+termId+" field "+field); + // isNan is "is Not a Number", ontology id has to be a number + //if ( !isNaN( termId ) ) { //var pars = 'ontologyid=' + ontologyid; + var pars = 'termId='+termId+'&ontologyName='+ontologyName+'&field='+field; - //alert("phenote-control.js calling Ajax.Updater with "+pars); - //this.debug("phenote-control.js calling Ajax.Updater with "+pars); + //alert("ncbo-term-info.js calling Ajax.Updater with "+pars); + //this.debug("ncbo-term-info.js calling Ajax.Updater with "+pars); - // ontologyinfo is the div where the table goes for term info - // note: this is a "get" not a post! (term comp is post) - //var myAjax = new Ajax.Updater('termInfo', url, {method: 'get', parameters: pars, onComplete: document.forms[0].qualityInput.value = '' } ); - // take out wipe out on complete - var myAjax = new Ajax.Updater('termInfo', url, {method: 'get', parameters: pars } ); - // have to have [1] next to form item because the edit subform and - // the main form both have donorid elements - if ( document.forms[0].ontologyid.length > 1 ) { - document.forms[0].ontologyid[1].value = termId; - document.forms[0].ontologyid[2].value = termId; - } - else { - document.forms[0].ontologyid.value = termId; - } - //} - } + // ontologyinfo is the div where the table goes for term info + // note: this is a "get" not a post! (term comp is post) + //var myAjax = new Ajax.Updater('termInfo', url, {method: 'get', parameters: pars, onComplete: document.forms[0].qualityInput.value = '' } ); + // took out wipe out on complete + var myAjax = new Ajax.Updater('termInfo', url, {method: 'get', parameters: pars } ); + //if ( document.forms[0].ontologyid.length > 1 ) { // dont need this + //document.forms[0].ontologyid[1].value = termId; + //document.forms[0].ontologyid[2].value = termId; } else { + document.termForm.termInfoTermId.value = termId; // } + document.termForm.termInfoTermName.value = termName; + document.termForm.activeField.value = field; + //} if isNan taken out +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <so...@us...> - 2006-10-04 18:49:43
|
Revision: 148 http://svn.sourceforge.net/obo/?rev=148&view=rev Author: sohelm Date: 2006-10-04 11:49:36 -0700 (Wed, 04 Oct 2006) Log Message: ----------- latest version Modified Paths: -------------- phenote/trunk/src/web/html/interface.html phenote/trunk/src/web/html/term_completer.html Modified: phenote/trunk/src/web/html/interface.html =================================================================== --- phenote/trunk/src/web/html/interface.html 2006-10-03 23:11:33 UTC (rev 147) +++ phenote/trunk/src/web/html/interface.html 2006-10-04 18:49:36 UTC (rev 148) @@ -12,68 +12,87 @@ <script src="/web/javascript/ajax-lib/effects.js" type="text/javascript"></script> <script src="/web/javascript/ajax-lib/dragdrop.js" type="text/javascript"></script> <script src="/web/javascript/ajax-lib/controls.js" type="text/javascript"></script> +<script src="/web/javascript/ajax-lib/json.js" type="text/javascript"></script> +<script src="/web/javascript/interface.js" type="text/javascript"></script> +<link href="/web/css/term_completer.css" type="text/css" rel="stylesheet"> +<!--link href="/inc/css/style.css" type="text/css" rel="stylesheet"--> </HEAD> <BODY> <table> -<tr height="20%"><td> - +<tr valign="top"><td> <div id="ontology"> - <div style="float: left;"> +<div style="float: left;"> -<link href="/web/css/term_completer.css" type="text/css" rel="stylesheet"> -<form> +<form name="data_table" action="process_phenotype.pl"> + <!-- term_completer.html code start --> <table> <tr> <!--#set var="tag" value="genotype" --> <!--#set var="title" value="Genotype" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/genotype.cgi" --> -<!--#include virtual="term_completer.html" --> +<!--#set var="url" value="/db/cgi-bin/ajax_search/genetics/genotype.pl" --> +<!--#include virtual="/web/html/term_completer.html" --> </tr><tr> -<!--#set var="tag" value="mutant_type" --> -<!--#set var="title" value="Mutant Type" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/genotype.cgi" --> -<!--#include virtual="term_completer.html" --> -</tr><tr> <!--#set var="tag" value="genetic_context" --> <!--#set var="title" value="Genetic Context" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/genotype.cgi" --> -<!--#include virtual="term_completer.html" --> +<!--#set var="url" value="/db/cgi-bin/ajax_search/genetics/genetic_context.pl" --> +<!--#include virtual="/web/html/term_completer.html" --> </tr><tr> <!--#set var="tag" value="entity" --> <!--#set var="title" value="Entity" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/entity.cgi" --> -<!--#include virtual="term_completer.html" --> +<!--#set var="url" value="/db/cgi-bin/ajax_search/genetics/entity.pl" --> +<!--#include virtual="/web/html/term_completer.html" --> </tr><tr> <!--#set var="tag" value="quality" --> <!--#set var="title" value="Quality" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/quality.cgi" --> -<!--#include virtual="term_completer.html" --> +<!--#set var="url" value="/db/cgi-bin/ajax_search/genetics/quality.pl" --> +<!--#include virtual="/web/html/term_completer.html" --> </tr><tr> <!--#set var="tag" value="reference" --> <!--#set var="title" value="Reference" --> -<!--#set var="url" value="/db/cgi-bin/ajax_search/quality.cgi" --> -<!--#include virtual="term_completer.html" --> +<!--#set var="url" value="/db/cgi-bin/ajax_search/genetics/quality.pl" --> +<!--#include virtual="/web/html/term_completer.html" --> </tr><tr> <td> <b>Notes</b> </td> <td> -<TEXTAREA NAME="notes" ROWS="4", COLS="20"> </TEXTAREA> +<TEXTAREA id="notes" NAME="notes" ROWS="4" COLS="20"></TEXTAREA> </td> </tr> </table> - <!-- term_completer.html code ends --> -</form> + </div> <div id="terminfo"></div> +<BR> </div> </td></tr> -<tr height="80%"><td> </td></tr> +<tr><td> +<div id="datatable"> +<CENTER><input type="button" name="Add" value="Add" onClick="insert_row('data')"/> +<input type="button" name="Update" value="Update" onClick="update_row('data')"/> +<input type="button" name="Commit" value="Commit" onClick="commit_data('data')"/> +<input type="button" name="Retrieve" value="Retrieve" onClick="retrieve_data('data')"/> +<input type="button" name="Clear All" value="Clear All" onClick="clear_table_data('data')"/> +<table id="data" class="phenotype"> +<col width="15%"/><col width="10%"/><col width="15%"/><col width="15%"/><col width="15%"/><col width="15%"/><col width="15%"/> + +<TR><TH> </TH><TH>Genotype</TH><TH>Genetic Context</TH><TH>Entity</TH><TH>Quality</TH><TH>Reference</TH><TH>Notes</TH></TR> </table> +</CENTER> +</form> +<div id="results"> + <BR> + +</div> +</div> +</td></tr> +</table> + + </body> </html> Modified: phenote/trunk/src/web/html/term_completer.html =================================================================== --- phenote/trunk/src/web/html/term_completer.html 2006-10-03 23:11:33 UTC (rev 147) +++ phenote/trunk/src/web/html/term_completer.html 2006-10-04 18:49:36 UTC (rev 148) @@ -1,37 +1,22 @@ - - - <td> <b><!--#if expr="\"tag\"" --><!--#echo var="title" --><!--#endif --></b> </td> <td> <input autocomplete="off" id="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->" name="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->" size="26" type="text" value="" /> -</td> + <BR><div class="auto_complete" id="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->_auto_complete"></div> -<input type="hidden" name="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id"> - +<input type="hidden" id="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->_id" name="<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id"> +</td> <script type="text/javascript"> function set_<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->_term(termid){ if ( !isNaN( termid ) ) { var pars = 'termid=' + termid; var myAjax = new Ajax.Updater('terminfo', "<!--#if expr="\"url\"" --><!--#echo var="url" --><!--#endif -->", {method: 'get', parameters: pars } ); - // have to have [1] next to form item because the edit subform and - // the main form both have donorid elements - if ( document.forms[0].termid.length > 1 ) { - document.forms[0].<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id[1].value = termid; - document.forms[0].<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id[2].value = termid; - } - else { - document.forms[0].<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id.value = termid; - } - } + document.data_table.<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->id.value = termid; - + } } new Ajax.Autocompleter( '<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->', '<!--#if expr="\"tag\"" --><!--#echo var="tag" --><!--#endif -->_auto_complete', '<!--#if expr="\"url\"" --><!--#echo var="url" --><!--#endif -->',{ }); -</script> - - - +</script> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-03 23:11:41
|
Revision: 147 http://svn.sourceforge.net/obo/?rev=147&view=rev Author: mgibson Date: 2006-10-03 16:11:33 -0700 (Tue, 03 Oct 2006) Log Message: ----------- auto complete terms now put start with before contains (not startwith) in the completion list Modified Paths: -------------- phenote/trunk/conf/initial-flybase.cfg phenote/trunk/conf/initial-zfin.cfg phenote/trunk/src/java/phenote/datamodel/Ontology.java phenote/trunk/src/java/phenote/main/Phenote.java phenote/trunk/src/java/test/phenote/gui/TestPhenote.java Modified: phenote/trunk/conf/initial-flybase.cfg =================================================================== --- phenote/trunk/conf/initial-flybase.cfg 2006-10-02 18:02:44 UTC (rev 146) +++ phenote/trunk/conf/initial-flybase.cfg 2006-10-03 23:11:33 UTC (rev 147) @@ -15,6 +15,7 @@ <postcomp relationship-ontology="relationship.obo"/> <ontology name="Fly" file="fly_anatomy.obo" /> <ontology name="GO" file="gene_ontology.obo"/> + <ontology name="SP" file="spatial.obo"/> </field> <field name="Quality" file="quality.obo"/> Modified: phenote/trunk/conf/initial-zfin.cfg =================================================================== --- phenote/trunk/conf/initial-zfin.cfg 2006-10-02 18:02:44 UTC (rev 146) +++ phenote/trunk/conf/initial-zfin.cfg 2006-10-03 23:11:33 UTC (rev 147) @@ -16,6 +16,7 @@ <postcomp relationship-ontology="relationship.obo"/> <ontology name="ZF" file="zebrafish_anatomy.obo" filter-out="ZFS:" /> <ontology name="GO" file="gene_ontology.obo"/> + <ontology name="SP" file="spatial.obo"/> </field> <field name="Quality" file="quality.obo"/> Modified: phenote/trunk/src/java/phenote/datamodel/Ontology.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-02 18:02:44 UTC (rev 146) +++ phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-03 23:11:33 UTC (rev 147) @@ -98,11 +98,13 @@ return searchTerms; } + /** helper fn for getSearchTerms(String,SearhParamsI) */ private Vector<OBOClass> getSearchTerms(String input, List<OBOClass> ontologyTermList, SearchParamsI searchParams) { // need a unique list - UniqueTermList has quick check for uniqueness, checking - // whole list is very very slow - UniqueTermList uniqueTermList = new UniqueTermList(); + // whole list is very very slow - how is it possible to get a dup term? i forget? + // the dup term was a BUG! in synonym - woops + SearchTermList uniqueTermList = new SearchTermList(); //Vector searchTerms = new Vector(); if (ontologyTermList == null) return uniqueTermList.getVector();//searchTerms; @@ -120,12 +122,6 @@ boolean termAdded = false; - // SKIP PATO ATTRIBUTES - only want values - or do !contains "value"? - // yes do contains value - as theres other crap to filter too - // apparently curators want to see attribs as well according to Michael - //if (filterAttributes() && isAttribute(originalTerm)) - //continue; - if (searchParams.searchTerms()) { // adds originalTerm to searchTerms if match (1st if exact) termAdded = compareAndAddTerm(input,originalTerm,oboClass,uniqueTermList); @@ -136,14 +132,14 @@ if (searchParams.searchSynonyms()) { Set synonyms = oboClass.getSynonyms(); - for (Iterator i = synonyms.iterator(); i.hasNext(); ) { + for (Iterator i = synonyms.iterator(); i.hasNext() &&!termAdded; ) { String syn = i.next().toString(); - //System.out.println("syn "+syn+" for "+originalTerm); + //log().debug("syn "+syn+" for "+originalTerm); termAdded = compareAndAddTerm(input,syn,oboClass,uniqueTermList); - if (termAdded) - continue; + //if (termAdded) continue; // woops continues this for not the outer! } } + if (termAdded) continue; if (searchParams.searchDefinitions()) { @@ -151,7 +147,7 @@ if (definition != null & !definition.equals("")) termAdded = compareAndAddTerm(input,definition,oboClass,uniqueTermList); if (termAdded) - continue; + continue; // not really necesary as its last } } @@ -188,19 +184,11 @@ } } - // pato subclass? -// private boolean isAttribute(String term) { -// return contains(term.toLowerCase(),"attribute"); -// } - - - - /** User input is already lower cased, this potentially adds oboClass to * searchTerms if input & compareTerm match. Puts it first if exact. * for term names comp = obo, for syns comp is the syn. Returns true if term is a match & either gets added or already is added - * Also checks if term is in list already + * Also checks if term is in list already - not needed - woops! Theres a speed issue here - the vector needs to be unique. if check every time with whole list very very slow. 2 alternatives to try. 1) have separate hash for checking uniqueness (downside 2 data structures). @@ -209,9 +197,14 @@ nice - its 1 data structure BUT exact matches go 1st, no way in linked hash set to insert 1st elements so would need to keep separate list of exact matches, which i guess there can be more than one with synonyms (do syns count for exact matches? - should they?) - downside of #2 is need Vector for combo box */ + should they?) - downside of #2 is need Vector for combo box + + this wont fly for having different display strings for syn & obs as compareTerm + can be syn obs term or def and its lost here + i think these methods need to be moved to gui.TermSearcher that utilizes Ontology + but produces CompListTerms */ private boolean compareAndAddTerm(String input, String compareTerm, OBOClass oboClass, - UniqueTermList uniqueTermList) { + SearchTermList searchTermList) { String oboTerm = oboClass.getName(); @@ -220,28 +213,22 @@ if (ignoreCase) lowerComp = compareTerm.toLowerCase(); - boolean doContains = true; // discard? param for? + //boolean doContains = true; // discard? param for? // exact match goes first in list if (lowerComp.equals(input)) { - //if (!searchTerms.contains(oboClass)) {// this takes a long time w long lists! - //searchTerms.add(0,oboClass); - uniqueTermList.addTermFirst(oboClass); // adds if not present + searchTermList.addTermFirst(oboClass); // adds if not present return true; - //} } + // new paradigm - put starts with first + else if (lowerComp.startsWith(input)) { + searchTermList.addTerm(oboClass); + return true; + } // Contains - else if (doContains) { - if (contains(lowerComp,input) && !termFilter(lowerComp)) { - //if(!searchTerms.contains(oboClass))takes long time!searchTerms.add(oboClass); - uniqueTermList.addTerm(oboClass); // does unique check - return true; - } + else if (contains(lowerComp,input) && !termFilter(lowerComp)) { + searchTermList.addContainsTerm(oboClass); + return true; } -// // Starts with - not doing this for now -// else if (lowerComp.startsWith(input)) { -// if (!searchTerms.contains(oboClass)) -// searchTerms.add(oboClass); -// } return false; } @@ -283,10 +270,14 @@ public String getSource() { return source; } - /** does unique check w map */ - private class UniqueTermList { + /** does unique check w map - dont need unique check - it was a bug in synonyms + how silly! - but actually this data structure will be handy for putting starts with + before contains! UniqueTermList -> SearchTermList*/ + private class SearchTermList { private Vector<OBOClass> searchTerms = new Vector<OBOClass>(); - private Map<OBOClass,OBOClass> uniqueCheck = new HashMap<OBOClass,OBOClass>(); + //private Map<OBOClass,OBOClass> uniqueCheck = new HashMap<OBOClass,OBOClass>(); + // list of terms that are contained but NOT startsWith + private Vector<OBOClass> containTerms = new Vector<OBOClass>(); private void addTerm(OBOClass oboClass) { addTerm(oboClass,false); } @@ -294,13 +285,21 @@ addTerm(oboClass,true); } private void addTerm(OBOClass oboClass,boolean first) { - if (uniqueCheck.containsKey(oboClass)) - return; + //if (uniqueCheck.containsKey(oboClass)) { + //log().debug("dup term in search "+oboClass); + // new Throwable().printStackTrace(); return; } if (first) searchTerms.add(0,oboClass); else searchTerms.add(oboClass); - uniqueCheck.put(oboClass,null); // dont need value + //uniqueCheck.put(oboClass,null); // dont need value } - private Vector<OBOClass> getVector() { return searchTerms; } + /** Add term thats not startsWith but contains */ + private void addContainsTerm(OBOClass oboClass) { + containTerms.add(oboClass); + } + private Vector<OBOClass> getVector() { + searchTerms.addAll(containTerms); + return searchTerms; + } } @@ -333,6 +332,20 @@ // GARBAGE + //if (!searchTerms.contains(oboClass)) {// this takes a long time w long lists! + //searchTerms.add(0,oboClass); + //if (!searchTerms.contains(oboClass)) searchTerms.add(oboClass); + //if(!searchTerms.contains(oboClass))takes long time!searchTerms.add(oboClass); + // SKIP PATO ATTRIBUTES - only want values - or do !contains "value"? + // yes do contains value - as theres other crap to filter too + // apparently curators want to see attribs as well according to Michael + //if (filterAttributes() && isAttribute(originalTerm)) + //continue; + + // pato subclass? +// private boolean isAttribute(String term) { +// return contains(term.toLowerCase(),"attribute"); +// } // part of search params? //private boolean filterAttributes() { return isPato(); } Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-02 18:02:44 UTC (rev 146) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-10-03 23:11:33 UTC (rev 147) @@ -6,6 +6,8 @@ import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.swing.BoxLayout; import javax.swing.JFrame; import javax.swing.JPanel; @@ -30,9 +32,10 @@ public class Phenote { - private static final String VERSION = "0.8 dev"; + private static final String VERSION = "0.8.1 dev"; //private static final String DEFAULT_CONFIG_FILE = Config.DEFAULT_CONFIG_FILE; private static final Logger LOG = Logger.getLogger(Phenote.class); + private static boolean standalone = false; // default for servlet private CharacterTablePanel characterTablePanel; private TermPanel termPanel; @@ -43,6 +46,7 @@ public static void main(String[] args) { + standalone = true; // i think this is ok System.out.println("This is Phenote version "+VERSION); // default mac lok & feel is "Mac OS X", but the JComboBox is buggy try { @@ -161,10 +165,21 @@ frame.getContentPane().add(makeMainPanel()); MenuManager.createMenuManager(frame); frame.setPreferredSize(new Dimension(1000,550)); + if (standalone) // if stand alone exit java on window close + frame.addWindowListener(new WindowExit()); frame.pack(); frame.setVisible(true); } + /** for standalone & webstart - not for servlet as i think it will bring the + whole servlet down */ + private class WindowExit extends WindowAdapter { + public void windowClosing(WindowEvent e) { + if (standalone) + System.exit(0); + } + } + /** main panel contains TermPanel CharTablePanel & TermInfo */ private JPanel makeMainPanel() { JPanel mainPanel = new JPanel(new GridBagLayout()); // ?? Modified: phenote/trunk/src/java/test/phenote/gui/TestPhenote.java =================================================================== --- phenote/trunk/src/java/test/phenote/gui/TestPhenote.java 2006-10-02 18:02:44 UTC (rev 146) +++ phenote/trunk/src/java/test/phenote/gui/TestPhenote.java 2006-10-03 23:11:33 UTC (rev 147) @@ -162,7 +162,7 @@ qualityComboBox.simulateLKeyStroke(); qualityComboBox.setSelectedIndex(2); // this is admittedly presumptious of quality - assertEquals("acute angle",qualityComboBox.getText()); + assertEquals("large volume",qualityComboBox.getText()); System.out.println("comp list sel ok "+qualityComboBox.getText()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-02 18:02:49
|
Revision: 146 http://svn.sourceforge.net/obo/?rev=146&view=rev Author: mgibson Date: 2006-10-02 11:02:44 -0700 (Mon, 02 Oct 2006) Log Message: ----------- post com gui now coming up with rel from preexisting post comp - previoulsy wasnt ppicking it up Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-02 15:49:31 UTC (rev 145) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-02 18:02:44 UTC (rev 146) @@ -121,6 +121,16 @@ setText(term.getName(),false); // no completion } + /** for relationships (post comp rel) */ + void setRel(OBOProperty rel) { + if (rel == null) { + log().error("Attempt to set term to null"); + return; // debug stack trace? + } + currentRel = rel; + setText(rel.toString(),false); // eventually .getName() + } + /** Throws exception if there isnt a current obo class, if the user has typed something that isnt yet a term - hasnt selected a term */ OBOClass getCurrentOboClass() throws Exception { Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-10-02 15:49:31 UTC (rev 145) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-10-02 18:02:44 UTC (rev 146) @@ -235,6 +235,12 @@ else textField.setText(term.getName()); // probably doesnt happen } + /** for auto combos (ontol) for relationships (post comp rel) */ + void setRel(OBOProperty rel) { + if (isCombo) comboBox.setRel(rel); + else textField.setText(rel.getName()); // shouldnt actually happen + } + CharFieldEnum getCharFieldEnum() { return charField.getCharFieldEnum(); } // separate char text field class? Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-10-02 15:49:31 UTC (rev 145) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-10-02 18:02:44 UTC (rev 146) @@ -94,6 +94,7 @@ //genusField.setText(getGenusString(currentTerm)); genusField.setOboClass(getGenusTerm(currentTerm)); //if (modelHasDiff(currentTerm)) + try { relField.setRel(getRel(currentTerm)); } catch (Exception e){} try { diffField.setOboClass(getDiffTerm(currentTerm)); } catch (Exception e) {} // throws if no diff term @@ -145,13 +146,26 @@ /** Throws exception if no diff term - for now only returning one diff term can there be more than one */ private OBOClass getDiffTerm(OBOClass term) throws Exception { + OBORestriction link = getDiffLink(term); // throws Ex + return (OBOClass)link.getParent(); // check downcast? + } + + /** If term is post comp return obo property relationship for differentia + otherwise thorws exception */ + private OBOProperty getRel(OBOClass term) throws Exception { + return getDiffLink(term).getType(); // thorws ex + } + + /** return the oboRestriction link between term and its differentia + exception if there is none. */ + private OBORestriction getDiffLink(OBOClass term) throws Exception { if (!isPostCompTerm(term)) throw new Exception(); for (Object o : term.getParents()) { OBORestriction r = (OBORestriction)o; if (r.completes() && r.getType() != OBOProperty.IS_A) - return (OBOClass)r.getParent(); // check downcast? + return r; } - throw new Exception(); // no diff term found + throw new Exception(); // none found } private void addButtons() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-10-02 15:49:53
|
Revision: 145 http://svn.sourceforge.net/obo/?rev=145&view=rev Author: mgibson Date: 2006-10-02 08:49:31 -0700 (Mon, 02 Oct 2006) Log Message: ----------- got relations working for post comp gui - gets from relationship.obo Ontology & AutoCombBox & char field gui can now deal with OBOProperties as well as obo classes as relationships are obo properties. post com gui no longer hard wired to part_of post comp & relation ontology configured from config file and ontology data adapter loads it of course - but the relation ontology is not a char field - its a part of CharField - CharField.getPostCompRelOntol() but there is a char field enum for Relationship which is set up by post comp gui and utilized by auto combo still a bug - existing post comp rel not read in from main window - will fix soon. Modified Paths: -------------- phenote/trunk/conf/initial-flybase.cfg phenote/trunk/conf/initial-zfin.cfg phenote/trunk/conf/phenote-config.rnc phenote/trunk/conf/phenote-config.xsd phenote/trunk/doc/todo phenote/trunk/jars/phenoteconfigbeans.jar phenote/trunk/src/java/phenote/config/Config.java phenote/trunk/src/java/phenote/config/FieldConfig.java phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java phenote/trunk/src/java/phenote/datamodel/OboUtil.java phenote/trunk/src/java/phenote/datamodel/Ontology.java phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/conf/initial-flybase.cfg =================================================================== --- phenote/trunk/conf/initial-flybase.cfg 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/conf/initial-flybase.cfg 2006-10-02 15:49:31 UTC (rev 145) @@ -12,6 +12,7 @@ <field name="Genetic Context" file="context.obo"/> <field name="Entity"> + <postcomp relationship-ontology="relationship.obo"/> <ontology name="Fly" file="fly_anatomy.obo" /> <ontology name="GO" file="gene_ontology.obo"/> </field> Modified: phenote/trunk/conf/initial-zfin.cfg =================================================================== --- phenote/trunk/conf/initial-zfin.cfg 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/conf/initial-zfin.cfg 2006-10-02 15:49:31 UTC (rev 145) @@ -13,6 +13,7 @@ <field name="Genetic Context" file="context.obo"/> <field name="Entity"> + <postcomp relationship-ontology="relationship.obo"/> <ontology name="ZF" file="zebrafish_anatomy.obo" filter-out="ZFS:" /> <ontology name="GO" file="gene_ontology.obo"/> </field> Modified: phenote/trunk/conf/phenote-config.rnc =================================================================== --- phenote/trunk/conf/phenote-config.rnc 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/conf/phenote-config.rnc 2006-10-02 15:49:31 UTC (rev 145) @@ -36,6 +36,7 @@ attribute type { "free_text" | "ontology" }, ## file is for single ontology - rename ontology_file? attribute file { text }, + postcomp?, ontology* } @@ -46,3 +47,9 @@ attribute file { text }, attribute filter-out { text } } + +postcomp = + element postcomp { + attribute relationship-ontology { text }, + ontology* + } Modified: phenote/trunk/conf/phenote-config.xsd =================================================================== --- phenote/trunk/conf/phenote-config.xsd 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/conf/phenote-config.xsd 2006-10-02 15:49:31 UTC (rev 145) @@ -39,6 +39,7 @@ <xs:element name="field"> <xs:complexType> <xs:sequence> + <xs:element minOccurs="0" ref="x:postcomp"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="x:ontology"/> </xs:sequence> <xs:attribute name="name" use="required"> @@ -78,4 +79,12 @@ <xs:attribute name="filter-out" use="required"/> </xs:complexType> </xs:element> + <xs:element name="postcomp"> + <xs:complexType> + <xs:sequence> + <xs:element minOccurs="0" maxOccurs="unbounded" ref="x:ontology"/> + </xs:sequence> + <xs:attribute name="relationship-ontology" use="required"/> + </xs:complexType> + </xs:element> </xs:schema> Modified: phenote/trunk/doc/todo =================================================================== --- phenote/trunk/doc/todo 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/doc/todo 2006-10-02 15:49:31 UTC (rev 145) @@ -1,3 +1,19 @@ +exit menu button? window close + +starts with + +obsoletes unselectable - but still browsable + +{syn} & {obs} tags in comp list + +syns show syns not term name + +cut down size of string for layout bug + +tab selects currently highlighted + +maybe do starts with before contains? + on load keeps blank character (from before load) around in table - shouldnt auto load from sourcforge or bioportal Modified: phenote/trunk/jars/phenoteconfigbeans.jar =================================================================== (Binary files differ) Modified: phenote/trunk/src/java/phenote/config/Config.java =================================================================== --- phenote/trunk/src/java/phenote/config/Config.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/config/Config.java 2006-10-02 15:49:31 UTC (rev 145) @@ -210,7 +210,12 @@ return fieldList; } + /** should this just be a part of fieldConfigList? and main window would filter it + out when making up fields? rel is for post comp gui - or maybe FieldConfig + should have isPostComp, getPostCompRelFile - yes! */ + //public FieldConfig getRelationshipFieldConfig() { } + /** parse xml file with xml beans (phenoteconfigbeans.xml). Put in own class? */ private void parseXmlFile(String filename) throws ConfigException { try { @@ -288,7 +293,15 @@ CharFieldEnum cfe = CharFieldEnum.getCharFieldEnum(name); //if (cfe == null) ??? FieldConfig fc = new FieldConfig(cfe,name); - // if only one ontology file is an attribute... (convenience) + + // POST COMP, relationship ontol + if (field.getPostcomp() != null) { + fc.setIsPostComp(true); + String relFile = field.getPostcomp().getRelationshipOntology().getStringValue(); + fc.setPostCompRelOntCfg(makeOntologyConfig("Relationship",relFile)); + } + + // ONTOLOGIES if only one ontology file is an attribute... (convenience) if (field.getFile() != null) { String file = field.getFile().getStringValue(); fc.addOntologyConfig(makeOntologyConfig(name,file)); Modified: phenote/trunk/src/java/phenote/config/FieldConfig.java =================================================================== --- phenote/trunk/src/java/phenote/config/FieldConfig.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/config/FieldConfig.java 2006-10-02 15:49:31 UTC (rev 145) @@ -11,6 +11,8 @@ private String label; // Entity field can have multiple ontologies private List<OntologyConfig> ontologyConfigList; + private boolean isPostComp; + private OntologyConfig postCompRelOntCfg; FieldConfig(CharFieldEnum c,OntologyConfig o) { charFieldEnum = c; @@ -59,5 +61,20 @@ ontologyConfigList = new ArrayList<OntologyConfig>(1); return ontologyConfigList; } - + + // POST COMP config... + void setIsPostComp(boolean isPostComp) { + this.isPostComp = isPostComp; + } + public boolean isPostComp() { + return isPostComp; + } + void setPostCompRelOntCfg(OntologyConfig oc) { + postCompRelOntCfg = oc; + } + + /** If isPostComp() return relationship ontology filename */ + public OntologyConfig getPostCompRelOntCfg() { + return postCompRelOntCfg; + } } Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-10-02 15:49:31 UTC (rev 145) @@ -50,8 +50,9 @@ for (FieldConfig fieldConfig : config.getFieldConfigList()) { CharFieldEnum fce = fieldConfig.getCharFieldEnum(); CharField cf = new CharField(fce); + + // ONTOLOGIES if (fieldConfig.hasOntologies()) { - //cf = new CharField(fce,o); for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { Ontology o = loadOntology(oc); @@ -65,12 +66,28 @@ else { cf.setName(fieldConfig.getLabel()); } + + // POST COMP + if (fieldConfig.isPostComp()) { + cf.setPostCompAllowed(true); + try { + //Ontology o = loadRelationshipOntology(fieldConfig.getPostCompRelOntCfg()); + Ontology o = loadOntology(fieldConfig.getPostCompRelOntCfg()); + cf.setPostCompRelOntol(o); + } catch (FileNotFoundException e) { + LOG.error(e.getMessage()+" ignoring ontology, fix config! "); + } + } ontologyManager.addField(cf); } + //loadRelationshipOntology(); + loadingOntologies = false; } + + /** Load up/cache Sets for all ontologies used, anatomyOntologyTermSet * and patoOntologyTermSet -- move to dataadapter/OntologyDataAdapter... */ private Ontology loadOntology(OntologyConfig ontCfg) throws FileNotFoundException { @@ -81,6 +98,14 @@ return ontology; } +// private void loadRelationshipOntology() { hmmmmmm +// // for now - todo configure! post comp relationship-ontology +// // FieldConfig rfc = config.getRelationshipFieldConfig(); +// //CharFieldEnum relEnum = rfc.getCharFieldEnum(); +// CharFieldEnum relEnum = CharFieldEnum.RELATIONSHIP; +// CharField cf = new CharField(relEnum); +// } + private void loadOboSession(Ontology o,String filename) throws FileNotFoundException { URL url = findFile(filename); // throws FileNotFoundEx OBOSession oboSession = getOboSession(url); Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-10-02 15:49:31 UTC (rev 145) @@ -18,6 +18,8 @@ private List<Ontology> ontologyList = new ArrayList<Ontology>(3); private CharFieldEnum charFieldEnum; // or subclass private String name; + private boolean postCompAllowed=false; + private Ontology postCompRelOntol; public CharField(CharFieldEnum c) { charFieldEnum = c; @@ -43,6 +45,10 @@ public CharFieldEnum getCharFieldEnum() { return charFieldEnum; } + public boolean isRelationship() { + return charFieldEnum == CharFieldEnum.RELATIONSHIP; + } + boolean isGeneticContext() { return charFieldEnum == CharFieldEnum.GENETIC_CONTEXT; } public List<Ontology> getOntologyList() { return ontologyList; } @@ -81,14 +87,21 @@ return null; } - /** whether this field allows for post composition - from config (todo) */ + // set whether post composition allowed (from config) */ + public void setPostCompAllowed(boolean pca) { + postCompAllowed = pca; + } + + /** whether this field allows for post composition - from config */ public boolean postCompAllowed() { - // return postCompAllowed; //eventually - return charFieldEnum == CharFieldEnum.ENTITY; // for now + return postCompAllowed; } - // set whether post composition allowed (from config) */ - // public void setPostCompAllowed(boolean allowed) { postCompAllowed = allowed; } + public void setPostCompRelOntol(Ontology o) { + postCompRelOntol = o; + } + + public Ontology getPostCompRelOntol() { return postCompRelOntol; } } // is this getting silly? abstract? --> char field value i think Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2006-10-02 15:49:31 UTC (rev 145) @@ -1,68 +1,71 @@ package phenote.datamodel; - // separate class? labels? methods? subclasses? - // is this taking enums too far? or a good use of them? - // would it be nice to have a class that wrapped String and OBOClass? - // and all possible field values? or would that be annoying? - public enum CharFieldEnum { +// labels? methods? subclasses? +// is this taking enums too far? or a good use of them? +public enum CharFieldEnum { - PUB("Pub") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setPub(v.getName()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getPub(),c,this); - } - }, - LUMP("Genotype") { // genotype? default? - public void setValue(CharacterI c, CharFieldValue v) { - c.setGenotype(v.getName()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getGenotype(),c,this); - } - }, - GENETIC_CONTEXT("Genetic Context") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setGeneticContext(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getGeneticContext(),c,this); - } - }, - ENTITY("Entity") { - public void setValue(CharacterI c, CharFieldValue v) { + PUB("Pub") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setPub(v.getName()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getPub(),c,this); + } + }, + LUMP("Genotype") { // genotype? default? + public void setValue(CharacterI c, CharFieldValue v) { + c.setGenotype(v.getName()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getGenotype(),c,this); + } + }, + GENETIC_CONTEXT("Genetic Context") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setGeneticContext(v.getOboClass()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getGeneticContext(),c,this); + } + }, + ENTITY("Entity") { + public void setValue(CharacterI c, CharFieldValue v) { c.setEntity(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getEntity(),c,this); - } - }, - QUALITY("Quality") { - public void setValue(CharacterI c, CharFieldValue v) { + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getEntity(),c,this); + } + }, + QUALITY("Quality") { + public void setValue(CharacterI c, CharFieldValue v) { c.setQuality(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getQuality(),c,this); - } - }; - - - // CHAR FIELD ENUM vars & methods (make its own class!) - private final String name; - private CharFieldEnum(String name) { this.name = name; } - public String toString() { return name; } - public abstract void setValue(CharacterI c, CharFieldValue v); - public abstract CharFieldValue getValue(CharacterI c); - - // unclear if we need this??? need it in generic field config - public static CharFieldEnum getCharFieldEnum(String fieldString) { - for ( CharFieldEnum cfe : CharFieldEnum.values()) { - if (cfe.name.equalsIgnoreCase(fieldString)) - return cfe; - } - System.out.println("ERROR: No Char Field found for string "+fieldString); - return null; } - + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getQuality(),c,this); + } + }, + /** Its questionable if relationship belongs here ??? */ + RELATIONSHIP("Relationship") { + public void setValue(CharacterI c, CharFieldValue v) {} + public CharFieldValue getValue(CharacterI c) { return null; } }; + + + // CHAR FIELD ENUM vars & methods (make its own class!) + private final String name; + private CharFieldEnum(String name) { this.name = name; } + public String toString() { return name; } + public abstract void setValue(CharacterI c, CharFieldValue v); + public abstract CharFieldValue getValue(CharacterI c); + + // unclear if we need this??? need it in generic field config + public static CharFieldEnum getCharFieldEnum(String fieldString) { + for ( CharFieldEnum cfe : CharFieldEnum.values()) { + if (cfe.name.equalsIgnoreCase(fieldString)) + return cfe; + } + System.out.println("ERROR: No Char Field found for string "+fieldString); + return null; + } + +}; Modified: phenote/trunk/src/java/phenote/datamodel/OboUtil.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OboUtil.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/datamodel/OboUtil.java 2006-10-02 15:49:31 UTC (rev 145) @@ -14,8 +14,8 @@ public static OBOClass makePostCompTerm(OBOClass genus, OBOProperty rel, OBOClass diff) { - String nm = pcString(genus.getName(),diff.getName()); - String id = pcString(genus.getID(),diff.getID()); + String nm = pcString(genus.getName(),rel.getName(),diff.getName()); + String id = pcString(genus.getID(),rel.getName(),diff.getID()); OBOClass postComp = new OBOClassImpl(nm,id); OBOProperty ISA = OBOProperty.IS_A; OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genus); @@ -26,9 +26,9 @@ postComp.addParent(dRel); return postComp; } - private static String pcString(String g, String d) { + private static String pcString(String g, String r, String d) { // for now hard wire to part_of - return g+"^part_of("+d+")"; + return g+"^"+r+"("+d+")"; } Modified: phenote/trunk/src/java/phenote/datamodel/Ontology.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/datamodel/Ontology.java 2006-10-02 15:49:31 UTC (rev 145) @@ -3,6 +3,7 @@ import java.util.ArrayList; //import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -10,7 +11,10 @@ import java.util.Set; import java.util.Vector; +import org.apache.log4j.Logger; + import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; import org.geneontology.oboedit.datamodel.OBOSession; /** rename Ontology? - yes - this isnt a completion list - a completion list is a @@ -23,6 +27,7 @@ private OBOSession oboSession; private List<OBOClass> sortedTerms; private List<OBOClass> sortedObsoleteTerms; + private List<OBOProperty> sortedRelations; private String filterOutString; /** well this stuff is specific to ontologies from files (eg obo), perhaps there needs to be some sort of wrapper or subclass? need to think about this... @@ -45,6 +50,7 @@ } private void makeSortedLists(OBOSession oboSession) { + //log().debug("name "+name+" terms "+oboSession.getTerms()+" propVals "+oboSession.getPropertyValues()+" rels "+oboSession.getRelationshipTypes()); sortedTerms = getSortedTerms(oboSession.getTerms()); sortedObsoleteTerms = getSortedTerms(oboSession.getObsoleteTerms()); } @@ -92,7 +98,7 @@ return searchTerms; } - private Vector getSearchTerms(String input, List<OBOClass> ontologyTermList, + private Vector<OBOClass> getSearchTerms(String input, List<OBOClass> ontologyTermList, SearchParamsI searchParams) { // need a unique list - UniqueTermList has quick check for uniqueness, checking // whole list is very very slow @@ -152,20 +158,41 @@ return uniqueTermList.getVector();//searchTerms; } - // pato subclass? - private boolean isAttribute(String term) { - return contains(term.toLowerCase(),"attribute"); + public Vector<OBOProperty> getStringMatchRelations(String input) { + Vector<OBOProperty> matches = new Vector<OBOProperty>(); + for (OBOProperty rel : getSortedRelations()) { + if (rel.toString().contains(input)) + matches.add(rel); + } + return matches; } - - // part of search params? - //private boolean filterAttributes() { return isPato(); } - // make enum!! - private boolean isPato() { - //return ont == PATO; - // for now - eventually config somehow - return name.equals("Pato"); + private List<OBOProperty> getSortedRelations() { + if (sortedRelations == null) { + //sortedRelations=new ArrayList<OBOProperty>(); not Comparable! + List sorRel = new ArrayList(); + // if (oboSession == null) ? shouldnt happen + sorRel.addAll(oboSession.getRelationshipTypes()); + Collections.sort(sorRel,new RelComparator()); + sortedRelations = sorRel; // ? + } + return sortedRelations; } + + private class RelComparator<OBOProperty> implements Comparator<OBOProperty> { + public int compare(OBOProperty r1, OBOProperty r2) { + return r1.toString().compareTo(r2.toString()); + } + public boolean equals(OBOProperty r1, OBOProperty r2) { + return r1.toString().equals(r2.toString()); + } + } + + // pato subclass? +// private boolean isAttribute(String term) { +// return contains(term.toLowerCase(),"attribute"); +// } + @@ -296,12 +323,26 @@ return filteredList; } + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } // GARBAGE + // part of search params? + //private boolean filterAttributes() { return isPato(); } +// // make enum!! +// private boolean isPato() { +// //return ont == PATO; +// // for now - eventually config somehow +// return name.equals("Pato"); +// } + // public Ontology(String name,OBOSession oboSession) { // this.name = name; // this.oboSession = oboSession; Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-10-02 15:49:31 UTC (rev 145) @@ -24,6 +24,7 @@ import org.apache.log4j.Logger; import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; @@ -49,6 +50,7 @@ // should we keep state of currentOboClass which is null if not a valid one? // default combo box.getSelectedItem sortof does this imperfectly private OBOClass currentOboClass=null; + private OBOProperty currentRel=null; private DefaultComboBoxModel defaultComboBoxModel; private SearchParamsI searchParams; private boolean inTestMode = false; @@ -59,6 +61,7 @@ //private boolean isDifferentia = false; /** if false then model is not edited */ private boolean editModel; + private CompletionListListener compListListener = new CompletionListListener(); /** @param editModel if false then ACB doesnt edit model directly (post comp) */ AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { @@ -74,7 +77,8 @@ this.setEditor(autoTextFieldEditor); setPreferredSize(new Dimension(350,22)); - addCompletionListListener(new CompletionListListener()); + enableTermInfoListening(true); // default + //addCompletionListListener(compList); //if (editModel) // ComboBoxActionListener edits the model this.editModel = editModel; @@ -127,6 +131,18 @@ return currentOboClass; } + /** Throws exception if there isnt a current relation - for relation lists + (post comp), if the user + has typed something that isnt yet a rel - hasnt selected a rel */ + OBOProperty getCurrentRelation() throws Exception { + if (currentRel == null) throw new Exception("term is null"); + if (!currentRel.toString().equals(getText())) + throw new Exception("(relation "+currentRel+" and input "+getText()+ + " dont match)"); + return currentRel; + + } + /** Return text in text field */ String getText() { //return (String)getSelectedItem(); @@ -138,66 +154,66 @@ setText(""); } - //private Ontology getOntology() { return ontology; } - /** Return true if input String matches name of OBOClass in - * defaultComboBoxModel - rename this? this isnt used anymore - delete? - */ -// boolean isInCompletionList(String input) { -// if (defaultComboBoxModel == null) -// return false; -// if (input == null) { -// return false; -// } -// // this is wrong as it holds OBOClasses not Strings! -// //return defaultComboBoxModel.getIndexOf(input) != -1; -// // have to go through all OBOClasses and extract there names - bummer -// // most likely input is selected one check that first -// OBOClass selectedClass = getSelectedCompListOboClass(); -// if (selectedClass != null && input.equals(selectedClass.getName())) -// return true; -// // selected failed(is this possible?) - try everything in the list then... -// for (int i=0; i<defaultComboBoxModel.getSize(); i++) { -// if (input.equals(getCompListOboClass(i).getName())) -// return true; -// } -// return false; -// } - /** This gets obo class selected in completion list - not from text box Returns null if nothing selected - can happen amidst changing selection also used by PostCompGui - this doesnt necasarily stay current with user input hmmm....*/ - OBOClass getSelectedCompListOboClass() { - if (defaultComboBoxModel == null) - return null; - Object obj = defaultComboBoxModel.getSelectedItem(); - if (obj == null) - return null; - // need to check obj for null if nothing selected!!! - return oboClassDowncast(obj); + this doesnt necasarily stay current with user input hmmm.... + throws OboException if dont have valid term */ + OBOClass getSelectedCompListOboClass() throws OboException { + Object obj = getSelectedObject(); // throws oboex + return oboClassDowncast(obj); // throws oboex } - private OBOClass getCompListOboClass(int index) { - Object obj = defaultComboBoxModel.getElementAt(index); - return oboClassDowncast(obj); + + private class OboException extends Exception { + private OboException() { super(); } + private OboException(String s) { super(s); } } - private OBOClass oboClassDowncast(Object obj) { - if (obj == null) - return null; +// private OBOClass getCompListOboClass(int index) { +// Object obj = defaultComboBoxModel.getElementAt(index); +// return oboClassDowncast(obj); +// } + + // strings get in somehow - need to figure out where they are coming from + private OBOClass oboClassDowncast(Object obj) throws OboException { + if (obj == null) throw new OboException(); if ( ! (obj instanceof OBOClass)) { - System.out.println("Item in completion list not obo class "+obj.getClass()); - return null; + //log.info("Item in completion list not obo class "+obj.getClass()); + throw new OboException("Item in completion list not obo class "+obj.getClass()); } return (OBOClass)obj; } + private OBOProperty oboPropertyDowncast(Object obj) throws OboException { + if (obj == null) throw new OboException(); + if ( ! (obj instanceof OBOProperty)) { + //log.info("Item in completion list not obo class "+obj.getClass()); + throw new OboException("Item in completion list not obo prop "+obj.getClass()); + } + return (OBOProperty)obj; + } + + /** returns currently selected relation, for auto combos of relations, + throws obo ex if there is no current relation */ + private OBOProperty getSelectedRelation() throws OboException { + Object obj = getSelectedObject(); // throws oboex + return oboPropertyDowncast(obj); // throws oboex + } + + private Object getSelectedObject() throws OboException { + if (defaultComboBoxModel == null) throw new OboException(); // ?? + Object obj = defaultComboBoxModel.getSelectedItem(); + if (obj == null) throw new OboException(); + return obj; + } + + /** BasicComboBoxEditor uses JTextField as its editing component but is * only available as a protected variable - odd adds auto doc & auto key listeners to combo box edit field */ private class AutoTextFieldEditor extends BasicComboBoxEditor { - private AutoTextFieldEditor() { autoTextField = new AutoTextField(); editor = autoTextField; // protected editor var from BCBE @@ -292,6 +308,13 @@ doCompletion = true; } + /** If combo box is relationship then the items will be OBOProperties not + OBOClasses */ + private boolean isRelationshipList() { + return charField.isRelationship(); + } + private boolean isTermList() { return !isRelationshipList(); } + /** Populates defaultComboBoxModel with Vector of OBOClasses - OBOClass.toString is the name of the term - thats why its possible - at least for moment if we want to put syn in brackets that makes this not possible - certainly @@ -312,7 +335,11 @@ // this is a vector of OBOClasses // i think ultimately we will need to wrap the OBOClass to be able to // have more control over the string - cut off w ... & [syn][obs] tags - Vector<OBOClass> v = getTerms(input); + Vector v; + if (isRelationshipList()) + v = ontology.getStringMatchRelations(input); + else + v = getTerms(input); // throws IllegalStateException, Attempt to mutate in notification // this tries to change text field amidst notification hmmmm..... changingCompletionList = true; @@ -372,13 +399,19 @@ should this be done with a selection event - or is that overkill, i guess the question will anyone besides term info ever care about these mouse over selection - if so make generic */ - void addCompletionListListener(ListSelectionListener lsl) { +// void addCompletionListListener(ListSelectionListener lsl) { +// if (!canGetUIJList()) return; +// getUIJList().addListSelectionListener(lsl); } + void enableTermInfoListening(boolean enable) { if (!canGetUIJList()) return; - getUIJList().addListSelectionListener(lsl); + if (enable) + getUIJList().addListSelectionListener(compListListener); + else + getUIJList().removeListSelectionListener(compListListener); } - // this is for mouse over term info i believe - changes selection + /** this is for MOUSE OVER TERM INFO - changes selection */ private class CompletionListListener implements ListSelectionListener { public void valueChanged(ListSelectionEvent e) { Object source = e.getSource(); @@ -476,21 +509,26 @@ if (input == null) return; // probably doesnt happen // the input should be from selected obo class shouldnt it? is it possible // for this not to be so? returns null if no oboclass? - OBOClass oboClass = getSelectedCompListOboClass(); - if (oboClass == null) return; /// happens on return on invalid term name - currentOboClass = oboClass; + // TERM + if (isTermList()) { + try { currentOboClass = getSelectedCompListOboClass(); } + // happens on return on invalid term name + catch (OboException e) { return; } // error msg? + //if (oboClass == null) return; currentOboClass = oboClass; + } + // RELATIONSHIP + else { + try { currentRel = getSelectedRelation(); } + catch (OboException e) { return; } + } - // if not editing model then return - if (!editModel) return; - - // EDIT MODEL - if (charField == null) return; // shouldnt happen - CharacterI c = getSelectedCharacter(); // from selectionManager - CharFieldEnum cfe = charField.getCharFieldEnum(); - //OBOClass previousOboClass = cfe.getValue(c).getOboClass(); - // isDifferentia boolean? - UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); - EditManager.inst().updateModel(this,ut); + // EDIT MODEL + if (editModel) + editModel(); +// CharacterI c = getSelectedCharacter(); // from selectionManager +// CharFieldEnum cfe = charField.getCharFieldEnum(); +// UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); +// EditManager.inst().updateModel(this,ut); } } @@ -514,6 +552,32 @@ } // GARBAGE + //private Ontology getOntology() { return ontology; } + + /** Return true if input String matches name of OBOClass in + * defaultComboBoxModel - rename this? this isnt used anymore - delete? + */ +// boolean isInCompletionList(String input) { +// if (defaultComboBoxModel == null) +// return false; +// if (input == null) { +// return false; +// } +// // this is wrong as it holds OBOClasses not Strings! +// //return defaultComboBoxModel.getIndexOf(input) != -1; +// // have to go through all OBOClasses and extract there names - bummer +// // most likely input is selected one check that first +// OBOClass selectedClass = getSelectedCompListOboClass(); +// if (selectedClass != null && input.equals(selectedClass.getName())) +// return true; +// // selected failed(is this possible?) - try everything in the list then... +// for (int i=0; i<defaultComboBoxModel.getSize(); i++) { +// if (input.equals(getCompListOboClass(i).getName())) +// return true; +// } +// return false; +// } + // mac bug workaround where list covers up textfield on < 12 items no scroll // from http://www.orbital-computer.de/JComboBox/#usage // it does note this may cause class cast excpetions?? Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-10-02 15:49:31 UTC (rev 145) @@ -17,6 +17,7 @@ import org.apache.log4j.Logger; import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; @@ -99,12 +100,17 @@ AutoComboBox getAutoComboBox() { if (isCombo) return comboBox; - return null; + return null; // ex? } // hasOntology? boolean isCombo() { return isCombo; } + void enableTermInfoListening(boolean enable) { + if (!isCombo()) return; + getAutoComboBox().enableTermInfoListening(enable); + } + /** Set the gui from the model (selection) */ void setValueFromChar(CharacterI character) { if (character == null) { @@ -289,6 +295,11 @@ return comboBox.getCurrentOboClass(); // throws Ex } + OBOProperty getCurrentRelation() throws Exception { + if (!isCombo) throw new Exception("Free text field has no Relation"); + return comboBox.getCurrentRelation(); // throws Ex + } + private Logger log; private Logger log() { if (log == null) log = Logger.getLogger(getClass()); Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-26 16:26:32 UTC (rev 144) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-10-02 15:49:31 UTC (rev 145) @@ -23,6 +23,7 @@ import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; import phenote.datamodel.OboUtil; +import phenote.datamodel.Ontology; import phenote.datamodel.SearchParamsI; import phenote.edit.CharChangeEvent; import phenote.edit.CharChangeListener; @@ -42,6 +43,8 @@ private CharField charField; private JDialog dialog; private CharFieldGui genusField; + //private RelationshipFieldGui relField; ?? + private CharFieldGui relField; private CharFieldGui diffField; PostCompGui(CharField charField,SearchParamsI searchParams) { @@ -60,6 +63,14 @@ genusField = new CharFieldGui(charField,compTermPanel,"Genus",false,false); // Relationship?? stripped down ontology? + CharField relChar = new CharField(CharFieldEnum.RELATIONSHIP); + // Ontology o = OntologyManager.getRelationshipOntology() ?? getRelCharField? + Ontology o = charField.getPostCompRelOntol(); + relChar.addOntology(o); + relField = new CharFieldGui(relChar,compTermPanel,"Relationship",false,false); + relField.enableTermInfoListening(false); // turn off term info for rels + // relField = new RelFieldGui(relChar,compTermPanel,"Relationship"); + // relField = new RelationshipFieldGui(compTermPanel); diffField = new CharFieldGui(charField,compTermPanel,"Differentia",false,false); @@ -178,23 +189,12 @@ private OBOClass makePostCompTerm() throws Exception { // check that we have a valid genus & differentia - // this is no good - not getting terms that came from main window OBOClass genusTerm = genusField.getCurrentOboClass(); // throws Ex OBOClass diffTerm = diffField.getCurrentOboClass(); // throws Ex -// String nm = pcString(genusTerm.getName(),diffTerm.getName()); -// String id = pcString(genusTerm.getID(),diffTerm.getID()); -// OBOClass postComp = new OBOClassImpl(nm,id); -// OBOProperty ISA = OBOProperty.IS_A; -// OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); -// gRel.setCompletes(true); // post comp flag -// postComp.addParent(gRel); // // eventually get from obo relationship? - OBOProperty partOf = new OBOPropertyImpl("OBO_REL:part_of","part_of"); - return OboUtil.makePostCompTerm(genusTerm,partOf,diffTerm); -// OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); -// dRel.setCompletes(true); // post comp -// postComp.addParent(dRel); -// return postComp; + //OBOProperty partOf = new OBOPropertyImpl("OBO_REL:part_of","part_of"); + OBOProperty rel = relField.getCurrentRelation(); + return OboUtil.makePostCompTerm(genusTerm,rel,diffTerm); } private void commitTerm(OBOClass postComp) { @@ -217,3 +217,15 @@ } } + +// String nm = pcString(genusTerm.getName(),diffTerm.getName()); +// String id = pcString(genusTerm.getID(),diffTerm.getID()); +// OBOClass postComp = new OBOClassImpl(nm,id); +// OBOProperty ISA = OBOProperty.IS_A; +// OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); +// gRel.setCompletes(true); // post comp flag +// postComp.addParent(gRel); +// OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); +// dRel.setCompletes(true); // post comp +// postComp.addParent(dRel); +// return postComp; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-26 16:26:43
|
Revision: 144 http://svn.sourceforge.net/obo/?rev=144&view=rev Author: mgibson Date: 2006-09-26 09:26:32 -0700 (Tue, 26 Sep 2006) Log Message: ----------- fixed char selection from table to post comp gui - theres a disable listeners flag in char field gui now which disables listening to model changes and editing model and listening to selection as for post comp it needs to be done at the post comp gui level - maybe the flag shgould be called postCompGuiMode or NonInteractiveMode? Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-26 14:48:47 UTC (rev 143) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-26 16:26:32 UTC (rev 144) @@ -43,22 +43,25 @@ private TermPanel termPanel; private JComboBox ontologyChooserCombo; private String label; - private boolean editModel = true; - private boolean doPostComp = true; + private boolean enableListeners = true; + private boolean addCompButton = true; CharFieldGui(CharField charField, TermPanel tp) {/*Container parent,*/ init(charField,tp); } - /** @param editModel - whether charFieldGui edits model directly - for post comp it - doesnt - @param doPostComp if false override configuration and dont show post comp button*/ - CharFieldGui(CharField cf,TermPanel tp,String label,boolean editModel, - boolean doPostComp) { + /** @param enableListeners - a catchall flag for disabling editing model, listening + to model edits, & litening to selection - postcompGui handles these and sets + this false, in main window this is true - rename? more flags? subclass? + postCompGui mode? + @param addCompButton if false override configuration and dont show + post comp button */ + CharFieldGui(CharField cf,TermPanel tp,String label,boolean enableListeners, + boolean addCompButton) { this.label = label; - this.editModel = editModel; - this.doPostComp = doPostComp; // post comp button + this.enableListeners = enableListeners; + this.addCompButton = addCompButton; // post comp button init(cf,tp); } @@ -71,15 +74,16 @@ else initCombo(charField);//,parent); - // do just for text field - or both??? listens for selection (eg from table) - SelectionManager.inst().addCharSelectionListener(new FieldCharSelectListener()); + // listens for selection (eg from table) - not for PostCompGui + if (enableListeners) + SelectionManager.inst().addCharSelectionListener(new FieldCharSelectListener()); // listen for model changes (eg TermInfo commit) // this needs renaming. if not editing model then its a post comp window, and // post comp windows also listen for char changes in PostCompGui not in there - // char field guis. either add a new param or rename "editModel" - hmmm + // char field guis. either add a new param or rename "enableListeners" - hmmm // or subclass CharFieldGui?? hmmmmm.... - if (editModel) + if (enableListeners) EditManager.inst().addCharChangeListener(new FieldCharChangeListener()); } @@ -139,18 +143,18 @@ if (charField.hasMoreThanOneOntology()) initOntologyChooser(charField); - // editModel - if false then ACB wont directly edit model (post comp) + // enableListeners - if false then ACB wont directly edit model (post comp) comboBox = new AutoComboBox(charField.getFirstOntology(), - termPanel.getSearchParams(),editModel); + termPanel.getSearchParams(),enableListeners); termPanel.addFieldGui(comboBox); comboBox.setCharField(charField); // POST COMPOSITION button - only get post comp button if both configged for it - // AND doPostComp flag is true - PostCompGui sets to false - no post comp of + // AND addCompButton flag is true - PostCompGui sets to false - no post comp of // post comp yet - and if so probably would do in same window not multiple // windows anyways - if (charField.postCompAllowed() && doPostComp) { + if (charField.postCompAllowed() && addCompButton) { JButton postCompButton = new JButton("Comp"); // ??? postCompButton.addActionListener(new PostCompListener()); termPanel.addPostCompButton(postCompButton); @@ -188,13 +192,13 @@ } - /** key listener for free text fields */ + /** key listener for free text fields for Cmd-V pasting for macs */ private class TextKeyListener extends java.awt.event.KeyAdapter { public void keyPressed(java.awt.event.KeyEvent e) { // on a mac Command-V is paste. this aint so with java/metal look&feel if (e.getKeyChar() == 'v' && e.getKeyModifiersText(e.getModifiers()).equals("Command")) { - System.out.println("got cmd V paste"); + //log().debug("got cmd V paste"); //System.getClipboard Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard(); try { Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-26 14:48:47 UTC (rev 143) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-26 16:26:32 UTC (rev 144) @@ -29,6 +29,8 @@ import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; import phenote.main.Phenote; +import phenote.gui.selection.CharSelectionEvent; +import phenote.gui.selection.CharSelectionListener; import phenote.gui.selection.SelectionManager; /** A window for post composition and other wacky stuff that goes beyond the basic @@ -62,7 +64,7 @@ diffField = new CharFieldGui(charField,compTermPanel,"Differentia",false,false); - setGuiFromModel(); + setGuiFromSelectedModel(); dialog.add(compTermPanel); addButtons(); @@ -71,9 +73,10 @@ dialog.setVisible(true); EditManager.inst().addCharChangeListener(new CompCharChangeListener()); + SelectionManager.inst().addCharSelectionListener(new CompCharSelectListener()); } - private void setGuiFromModel() { + private void setGuiFromSelectedModel() { OBOClass currentTerm = getModelTerm(); if (currentTerm == null) return; @@ -88,10 +91,16 @@ /** If model has changed (main window fiddling - hmmm) set gui */ private class CompCharChangeListener implements CharChangeListener { public void charChanged(CharChangeEvent e) { - setGuiFromModel(); + setGuiFromSelectedModel(); } } + private class CompCharSelectListener implements CharSelectionListener { + public void characterSelected(CharSelectionEvent e) { + setGuiFromSelectedModel(); + } + } + private OBOClass getModelTerm() { // there should be convenience method for this CharacterI c = SelectionManager.inst().getSelectedCharacter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-26 14:48:55
|
Revision: 143 http://svn.sourceforge.net/obo/?rev=143&view=rev Author: mgibson Date: 2006-09-26 07:48:47 -0700 (Tue, 26 Sep 2006) Log Message: ----------- fixed bug with post comp gui and model edits - its char field guis were listening to edits to the model (via use term & main window entity field) and editing themselves - which they shouldnt for post comp - so edit listening is disabled in post comps char field gui and post comp gui itself listens for edits and then sets the genus & diff fields accordingly - well just the genus field as edits from the main window wont affect the diff field Modified Paths: -------------- phenote/trunk/src/java/phenote/datamodel/CharacterI.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java phenote/trunk/src/java/phenote/gui/TermInfo.java Modified: phenote/trunk/src/java/phenote/datamodel/CharacterI.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2006-09-25 23:18:55 UTC (rev 142) +++ phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2006-09-26 14:48:47 UTC (rev 143) @@ -19,7 +19,7 @@ public boolean hasPub(); public String getGenotype(); public OBOClass getEntity(); - public OBOClass getQuality(); // OBOClass? + public OBOClass getQuality(); public boolean hasGeneticContext(); public OBOClass getGeneticContext(); Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-25 23:18:55 UTC (rev 142) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-26 14:48:47 UTC (rev 143) @@ -58,7 +58,7 @@ boolean doPostComp) { this.label = label; this.editModel = editModel; - this.doPostComp = doPostComp; + this.doPostComp = doPostComp; // post comp button init(cf,tp); } @@ -75,7 +75,12 @@ SelectionManager.inst().addCharSelectionListener(new FieldCharSelectListener()); // listen for model changes (eg TermInfo commit) - EditManager.inst().addCharChangeListener(new FieldCharChangeListener()); + // this needs renaming. if not editing model then its a post comp window, and + // post comp windows also listen for char changes in PostCompGui not in there + // char field guis. either add a new param or rename "editModel" - hmmm + // or subclass CharFieldGui?? hmmmmm.... + if (editModel) + EditManager.inst().addCharChangeListener(new FieldCharChangeListener()); } private class FieldCharChangeListener implements CharChangeListener { Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-25 23:18:55 UTC (rev 142) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-26 14:48:47 UTC (rev 143) @@ -24,6 +24,8 @@ import phenote.datamodel.CharFieldEnum; import phenote.datamodel.OboUtil; import phenote.datamodel.SearchParamsI; +import phenote.edit.CharChangeEvent; +import phenote.edit.CharChangeListener; import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; import phenote.main.Phenote; @@ -67,6 +69,8 @@ dialog.pack(); dialog.setLocationRelativeTo(owner); dialog.setVisible(true); + + EditManager.inst().addCharChangeListener(new CompCharChangeListener()); } private void setGuiFromModel() { @@ -81,6 +85,13 @@ } + /** If model has changed (main window fiddling - hmmm) set gui */ + private class CompCharChangeListener implements CharChangeListener { + public void charChanged(CharChangeEvent e) { + setGuiFromModel(); + } + } + private OBOClass getModelTerm() { // there should be convenience method for this CharacterI c = SelectionManager.inst().getSelectedCharacter(); Modified: phenote/trunk/src/java/phenote/gui/TermInfo.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-25 23:18:55 UTC (rev 142) +++ phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-26 14:48:47 UTC (rev 143) @@ -88,7 +88,8 @@ return termInfoPanel; } - /** Commits currently browsed term when useTermButton is pressed */ + /** Fires use term event to use term listener with currently browsed term when + useTermButton is pressed */ private class UseTermActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { //commitTerm(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-25 23:19:06
|
Revision: 142 http://svn.sourceforge.net/obo/?rev=142&view=rev Author: mgibson Date: 2006-09-25 16:18:55 -0700 (Mon, 25 Sep 2006) Log Message: ----------- post comp fields are now properly listening to term info term selection events from auto combo mouse over now include a UseTermListener (from the combo box) - when term infos use term button is clicked it sends the obo class to its use term listener - the auto combo box then sets its obo class and if its in the main window edits the model (doesnt edit in post comp - waits for ok button) Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/TermInfo.java phenote/trunk/src/java/phenote/gui/selection/SelectionManager.java phenote/trunk/src/java/phenote/gui/selection/TermSelectionEvent.java Added Paths: ----------- phenote/trunk/src/java/phenote/gui/selection/UseTermEvent.java phenote/trunk/src/java/phenote/gui/selection/UseTermListener.java Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-25 20:31:31 UTC (rev 141) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-25 23:18:55 UTC (rev 142) @@ -21,6 +21,8 @@ import javax.swing.plaf.ComboBoxUI; import javax.swing.plaf.metal.MetalComboBoxUI; +import org.apache.log4j.Logger; + import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.CharField; @@ -31,6 +33,8 @@ import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; import phenote.gui.selection.SelectionManager; +import phenote.gui.selection.UseTermEvent; +import phenote.gui.selection.UseTermListener; /** The jcombobox that does auto completion - i had to do some tricks(hacks) to get it working with mouse over which doesnt come naturally to jcombobox */ @@ -103,7 +107,12 @@ this.doCompletion = true; // set back to default } + /** rename setTerm? */ void setOboClass(OBOClass term) { + if (term == null) { + log().error("Attempt to set term to null"); + return; // debug stack trace? + } currentOboClass = term; setText(term.getName(),false); // no completion } @@ -391,11 +400,24 @@ return; } OBOClass oboClass = (OBOClass)selectedValue; - SelectionManager.inst().selectTerm(AutoComboBox.this,oboClass); + getSelectionManager().selectTerm(AutoComboBox.this,oboClass,getUseTermListener()); //setTextFromOboClass(oboClass); } } // end of CompletionListListener inner class + private UseTermListener useTermListener; + private UseTermListener getUseTermListener() { + if (useTermListener == null) useTermListener = new ComboUseTermListener(); + return useTermListener; + } + + private class ComboUseTermListener implements UseTermListener { + public void useTerm(UseTermEvent e) { + setOboClass(e.getTerm()); + if (editModel) editModel(); + } + } + private SelectionManager getSelectionManager() { return SelectionManager.inst(); } @@ -469,13 +491,26 @@ // isDifferentia boolean? UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); EditManager.inst().updateModel(this,ut); - - // oh my this is presumptious - assumes only editor, but now theres post - // comp gui - should get previous from char itself! of course silly - //previousOboClass = oboClass; // for undo } } + private void editModel() { + OBOClass oboClass; + try { oboClass = getCurrentOboClass(); } + catch (Exception e) { return; } // shouldnt happen, error? + if (charField == null) return; // shouldnt happen + CharacterI c = getSelectedCharacter(); // from selectionManager + CharFieldEnum cfe = charField.getCharFieldEnum(); + // isDifferentia boolean? + UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); + EditManager.inst().updateModel(this,ut); + } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } // GARBAGE Modified: phenote/trunk/src/java/phenote/gui/TermInfo.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-25 20:31:31 UTC (rev 141) +++ phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-25 23:18:55 UTC (rev 142) @@ -37,6 +37,8 @@ import phenote.gui.selection.SelectionManager; import phenote.gui.selection.TermSelectionEvent; import phenote.gui.selection.TermSelectionListener; +import phenote.gui.selection.UseTermEvent; +import phenote.gui.selection.UseTermListener; public class TermInfo { @@ -46,6 +48,7 @@ private TermHyperlinkListener termHyperlinkListener; // current obo class being navigated private OBOClass currentOboClass; + private UseTermListener useTermListener; public TermInfo(TermPanel termPanel) { @@ -88,7 +91,10 @@ /** Commits currently browsed term when useTermButton is pressed */ private class UseTermActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { - commitTerm(); + //commitTerm(); + if (useTermListener == null) return; // error? shouldnt happen + if (currentOboClass == null) return; // shouldnt happen + useTermListener.useTerm(new UseTermEvent(TermInfo.this,currentOboClass)); } } @@ -110,28 +116,36 @@ private class InfoTermSelectionListener implements TermSelectionListener { public boolean termSelected(TermSelectionEvent e) { setTextFromOboClass(e.getOboClass()); + // This sets who now listens to use term button clicks (only 1 listener) + setUseTermListener(e.getUseTermListener()); return true; } } - /** put present term into current character - not used yet...*/ - private void commitTerm() { - CharacterI ch = SelectionManager.inst().getSelectedCharacter(); - if (ch == null) { // can this happen? - System.out.println("ERROR: no character selected to update"); - return; - } - if (currentOboClass == null) { // can this happen? - System.out.println("ERROR: no term in term info to add to character"); - return; - } + private void setUseTermListener(UseTermListener utl) { + useTermListener = utl; + } - CharFieldEnum cfe = OntologyManager.inst().getCharFieldEnumForOboClass(currentOboClass); +// /** put present term into current character - not used yet... +// this is now policy of the UseTermListener(AutoComboBox) TermInfo just sends out +// UseTermEvent and UTL/ACB decides what to do with it */ +// private void commitTerm() { +// CharacterI ch = SelectionManager.inst().getSelectedCharacter(); +// if (ch == null) { // can this happen? +// System.out.println("ERROR: no character selected to update"); +// return; +// } +// if (currentOboClass == null) { // can this happen? +// System.out.println("ERROR: no term in term info to add to character"); +// return; +// } + +// CharFieldEnum cfe = OntologyManager.inst().getCharFieldEnumForOboClass(currentOboClass); - UpdateTransaction ut = new UpdateTransaction(ch,cfe,currentOboClass); - EditManager.inst().updateModel(this,ut); - //previousOboClass = currentOboClass; - } +// UpdateTransaction ut = new UpdateTransaction(ch,cfe,currentOboClass); +// EditManager.inst().updateModel(this,ut); +// //previousOboClass = currentOboClass; +// } /** for testing */ void simulateHyperlinkEvent(HyperlinkEvent e) { Modified: phenote/trunk/src/java/phenote/gui/selection/SelectionManager.java =================================================================== --- phenote/trunk/src/java/phenote/gui/selection/SelectionManager.java 2006-09-25 20:31:31 UTC (rev 141) +++ phenote/trunk/src/java/phenote/gui/selection/SelectionManager.java 2006-09-25 23:18:55 UTC (rev 142) @@ -33,8 +33,8 @@ // void addCharacterSelectionListener(CharacterSelectionListener l) {} - public void selectTerm(Object source, OBOClass oboClass) { - TermSelectionEvent e = makeTermEvent(source,oboClass); + public void selectTerm(Object source, OBOClass oboClass,UseTermListener l) { + TermSelectionEvent e = makeTermEvent(source,oboClass,l); Iterator<TermSelectionListener> it = termListenerList.iterator(); while(it.hasNext()) it.next().termSelected(e); @@ -42,8 +42,8 @@ // void selectTerm(String termName) {} ??? - private TermSelectionEvent makeTermEvent(Object src, OBOClass oc) { - return new TermSelectionEvent(src,oc); + private TermSelectionEvent makeTermEvent(Object src, OBOClass oc,UseTermListener l) { + return new TermSelectionEvent(src,oc,l); } public CharacterI getSelectedCharacter() { Modified: phenote/trunk/src/java/phenote/gui/selection/TermSelectionEvent.java =================================================================== --- phenote/trunk/src/java/phenote/gui/selection/TermSelectionEvent.java 2006-09-25 20:31:31 UTC (rev 141) +++ phenote/trunk/src/java/phenote/gui/selection/TermSelectionEvent.java 2006-09-25 23:18:55 UTC (rev 142) @@ -7,11 +7,15 @@ public class TermSelectionEvent extends EventObject { private OBOClass oboClass; + private UseTermListener useTermListener; - TermSelectionEvent(Object source, OBOClass oboClass) { + TermSelectionEvent(Object source, OBOClass oboClass, UseTermListener utl) { super(source); this.oboClass = oboClass; + useTermListener = utl; } public OBOClass getOboClass() { return oboClass; } + + public UseTermListener getUseTermListener() { return useTermListener; } } Added: phenote/trunk/src/java/phenote/gui/selection/UseTermEvent.java =================================================================== --- phenote/trunk/src/java/phenote/gui/selection/UseTermEvent.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/selection/UseTermEvent.java 2006-09-25 23:18:55 UTC (rev 142) @@ -0,0 +1,20 @@ +package phenote.gui.selection; + +import java.util.EventObject; + +import org.geneontology.oboedit.datamodel.OBOClass; + +/** im not sure if this belongs in selection package - a use term listener listens + for UseTermEvents - this is from the term browser saying basically the user wants + to use this term - in the main window that means editing the model, in the postcomp + window that means setting the text either for genus of differentia (which waits + for an ok to actually edit the model */ + +public class UseTermEvent extends EventObject { + private OBOClass term; + public UseTermEvent(Object source,OBOClass term) { + super(source); + this.term = term; + } + public OBOClass getTerm() { return term; } +} Added: phenote/trunk/src/java/phenote/gui/selection/UseTermListener.java =================================================================== --- phenote/trunk/src/java/phenote/gui/selection/UseTermListener.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/selection/UseTermListener.java 2006-09-25 23:18:55 UTC (rev 142) @@ -0,0 +1,11 @@ +package phenote.gui.selection; + +/** im not sure if this belongs in selection package - a use term listener listens + for UseTermEvents - this is from the term browser saying basically the user wants + to use this term - in the main window that means editing the model, in the postcomp + window that means setting the text either for genus of differentia (which waits + for an ok to actually edit the model */ + +public interface UseTermListener { + public void useTerm(UseTermEvent e); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-09-25 20:31:33
|
Revision: 141 http://svn.sourceforge.net/obo/?rev=141&view=rev Author: balhoff Date: 2006-09-25 13:31:31 -0700 (Mon, 25 Sep 2006) Log Message: ----------- Added reading and writing of genetic context terms in pheno-xml. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-25 18:46:49 UTC (rev 140) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-25 20:31:31 UTC (rev 141) @@ -77,15 +77,29 @@ } private CharacterI newCharacterFromPhenotypeManifestation(PhenotypeManifestation pm) { - + OntologyManager ontologyManager = OntologyManager.inst(); CharacterI character = new Character(); ManifestIn mi = pm.getManifestIn(); if (mi != null) { - String genotype = mi.getGenotype(); - if (genotype != null) { + String genotype = mi.getGenotype(); + if (genotype != null) { character.setGenotype(genotype); + } + List<Typeref> typerefList = mi.getTyperefList(); + if ((typerefList != null) && (typerefList.size() > 0)) { + // only load the first typeref + Typeref typeref = typerefList.get(0); + String geneticContextID = typeref.getAbout(); + if (geneticContextID != null) { + try { + character.setGeneticContext(ontologyManager.getOboClassWithExcep(geneticContextID)); + } + catch (TermNotFoundException e) { + System.out.println("Genetic context term not found " + e); + } + } + } } - } Phenotype phenotype = pm.getPhenotype(); PhenotypeCharacter phenotypeCharacter = null; if (phenotype != null) { @@ -95,7 +109,6 @@ phenotypeCharacter = phenotypeCharacters.get(0); } } - OntologyManager ontologyManager = OntologyManager.inst(); String entityID = null; String qualityID = null; if (phenotypeCharacter != null) { @@ -145,7 +158,6 @@ } public void commit(CharacterListI charList) { - if (file == null) file = getFileFromUser(previousFile); if (file == null) @@ -193,24 +205,32 @@ private void addCharAndGenotypeToPhenoset(CharacterI chr, Phenoset phenoset) { - String genotype = chr.getGenotype(); PhenotypeManifestation pm = phenoset.addNewPhenotypeManifestation(); - addGenotype(genotype,phenoset,pm); + addGenotypeAndContext(chr, phenoset, pm); addPhenotype(chr,pm); addPub(chr, pm); } - private void addGenotype(String genotype,Phenoset ps,PhenotypeManifestation pm) { + private void addGenotypeAndContext(CharacterI chr, Phenoset ps, PhenotypeManifestation pm) { + String genotype = chr.getGenotype(); + addGenotypeToPhenoset(genotype, ps); + ManifestIn mi = pm.addNewManifestIn(); + mi.setGenotype(genotype); + if (chr.hasGeneticContext()) { + Typeref typeref = mi.addNewTyperef(); + typeref.setAbout(chr.getGeneticContext().getID()); + } + } + + private void addGenotypeToPhenoset(String genotype, Phenoset ps) { // check if we've already added this genotype, if so dont need to add again if (!genotypesAlreadyAdded.contains(genotype)) { Genotype gt = ps.addNewGenotype(); gt.setName(genotype); genotypesAlreadyAdded.add(genotype); } - ManifestIn mi = pm.addNewManifestIn(); - mi.setGenotype(genotype); } - + private void addPhenotype(CharacterI chr, PhenotypeManifestation pm) { Phenotype p = pm.addNewPhenotype(); PhenotypeCharacter pc = p.addNewPhenotypeCharacter(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-09-25 18:46:51
|
Revision: 140 http://svn.sourceforge.net/obo/?rev=140&view=rev Author: balhoff Date: 2006-09-25 11:46:49 -0700 (Mon, 25 Sep 2006) Log Message: ----------- Added reading of pub from pheno-xml (in provenance element). Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-25 17:56:50 UTC (rev 139) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-25 18:46:49 UTC (rev 140) @@ -53,66 +53,7 @@ if (file == null) return; previousFile = file; PhenosetDocument doc = PhenosetDocument.Factory.parse(file); - Phenoset phenoset = doc.getPhenoset(); - List<PhenotypeManifestation> phenotypeManifestations = phenoset.getPhenotypeManifestationList(); - CharacterListI charList = new CharacterList(); - for (PhenotypeManifestation aManifestation : phenotypeManifestations) { - CharacterI character = new Character(); - ManifestIn mi = aManifestation.getManifestIn(); - if (mi != null) { - String genotype = mi.getGenotype(); - if (genotype != null) { - character.setGenotype(genotype); - } - } - Phenotype phenotype = aManifestation.getPhenotype(); - PhenotypeCharacter phenotypeCharacter = null; - if (phenotype != null) { - List<PhenotypeCharacter> phenotypeCharacters = phenotype.getPhenotypeCharacterList(); - if ((phenotypeCharacters != null) && (phenotypeCharacters.size() > 0)) { - // we only load the first character in the phenotype for now - phenotypeCharacter = phenotypeCharacters.get(0); - } - } - OntologyManager ontologyManager = OntologyManager.inst(); - String entityID = null; - String qualityID = null; - if (phenotypeCharacter != null) { - Bearer bearer = phenotypeCharacter.getBearer(); - if (bearer != null) { - Typeref typeref = bearer.getTyperef(); - if (typeref != null) { - entityID = typeref.getAbout(); - } - } - List<Quality> qualityList = phenotypeCharacter.getQualityList(); - if ((qualityList != null) && (qualityList.size() > 0)) { - // we only load the first quality for now - Quality quality = qualityList.get(0); - Typeref qualityTyperef = quality.getTyperef(); - if (qualityTyperef != null) { - qualityID = qualityTyperef.getAbout(); - } - } - } - if (entityID != null) { - try { - character.setEntity(ontologyManager.getOboClassWithExcep(entityID)); - } - catch (TermNotFoundException e) { - System.out.println("Entity term not found " + e); - } - } - if (qualityID != null) { - try { - character.setQuality(ontologyManager.getOboClassWithExcep(qualityID)); - } - catch (TermNotFoundException e) { - System.out.println("Quality term not found " + e); - } - } - charList.add(character); - } + CharacterListI charList = newCharacterListFromPhenosetDocument(doc); CharacterListManager.inst().setCharacterList(this,charList); } catch (XmlException e) { @@ -123,7 +64,86 @@ } file = null; // null it for next load/commit } + + private CharacterListI newCharacterListFromPhenosetDocument(PhenosetDocument doc) { + Phenoset phenoset = doc.getPhenoset(); + List<PhenotypeManifestation> phenotypeManifestations = phenoset.getPhenotypeManifestationList(); + CharacterListI charList = new CharacterList(); + for (PhenotypeManifestation aManifestation : phenotypeManifestations) { + CharacterI newCharacter = newCharacterFromPhenotypeManifestation(aManifestation); + charList.add(newCharacter); + } + return charList; + } + + private CharacterI newCharacterFromPhenotypeManifestation(PhenotypeManifestation pm) { + CharacterI character = new Character(); + ManifestIn mi = pm.getManifestIn(); + if (mi != null) { + String genotype = mi.getGenotype(); + if (genotype != null) { + character.setGenotype(genotype); + } + } + Phenotype phenotype = pm.getPhenotype(); + PhenotypeCharacter phenotypeCharacter = null; + if (phenotype != null) { + List<PhenotypeCharacter> phenotypeCharacters = phenotype.getPhenotypeCharacterList(); + if ((phenotypeCharacters != null) && (phenotypeCharacters.size() > 0)) { + // we only load the first character in the phenotype for now + phenotypeCharacter = phenotypeCharacters.get(0); + } + } + OntologyManager ontologyManager = OntologyManager.inst(); + String entityID = null; + String qualityID = null; + if (phenotypeCharacter != null) { + Bearer bearer = phenotypeCharacter.getBearer(); + if (bearer != null) { + Typeref typeref = bearer.getTyperef(); + if (typeref != null) { + entityID = typeref.getAbout(); + } + } + List<Quality> qualityList = phenotypeCharacter.getQualityList(); + if ((qualityList != null) && (qualityList.size() > 0)) { + // we only load the first quality for now + Quality quality = qualityList.get(0); + Typeref qualityTyperef = quality.getTyperef(); + if (qualityTyperef != null) { + qualityID = qualityTyperef.getAbout(); + } + } + } + if (entityID != null) { + try { + character.setEntity(ontologyManager.getOboClassWithExcep(entityID)); + } + catch (TermNotFoundException e) { + System.out.println("Entity term not found " + e); + } + } + if (qualityID != null) { + try { + character.setQuality(ontologyManager.getOboClassWithExcep(qualityID)); + } + catch (TermNotFoundException e) { + System.out.println("Quality term not found " + e); + } + } + List<Provenance> provenanceList = pm.getProvenanceList(); + if ((provenanceList != null) && (provenanceList.size() > 0)) { + // only load the first provenance for now + Provenance provenance = provenanceList.get(0); + String id = provenance.getId(); + if (id != null) { + character.setPub(id); + } + } + return character; + } + public void commit(CharacterListI charList) { if (file == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-09-25 17:57:06
|
Revision: 139 http://svn.sourceforge.net/obo/?rev=139&view=rev Author: balhoff Date: 2006-09-25 10:56:50 -0700 (Mon, 25 Sep 2006) Log Message: ----------- Added writing of pub to pheno-xml. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-22 19:35:49 UTC (rev 138) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-25 17:56:50 UTC (rev 139) @@ -21,6 +21,7 @@ import org.bioontologies.obd.schema.pheno.PhenosetDocument; import org.bioontologies.obd.schema.pheno.PhenotypeManifestationDocument.PhenotypeManifestation; import org.bioontologies.obd.schema.pheno.TyperefDocument.Typeref; +import org.bioontologies.obd.schema.pheno.ProvenanceDocument.Provenance; //import org.bioontologies.obd.schema.pheno.*.*; import phenote.datamodel.CharacterI; @@ -35,7 +36,7 @@ public class PhenoXmlAdapter implements DataAdapterI { - private Set genotypesAlreadyAdded = new HashSet<String>(); + private Set<String> genotypesAlreadyAdded = new HashSet<String>(); private File previousFile; private File file; @@ -176,6 +177,7 @@ PhenotypeManifestation pm = phenoset.addNewPhenotypeManifestation(); addGenotype(genotype,phenoset,pm); addPhenotype(chr,pm); + addPub(chr, pm); } private void addGenotype(String genotype,Phenoset ps,PhenotypeManifestation pm) { @@ -212,4 +214,10 @@ System.out.println("Character "+chr+" has no quality"); } } + + private void addPub(CharacterI chr, PhenotypeManifestation pm) { + if (!chr.hasPub()) return; // no pub, early return + Provenance provenance = pm.addNewProvenance(); + provenance.setId(chr.getPub()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-22 19:35:52
|
Revision: 138 http://svn.sourceforge.net/obo/?rev=138&view=rev Author: mgibson Date: 2006-09-22 12:35:49 -0700 (Fri, 22 Sep 2006) Log Message: ----------- putting post comp window centered on main window Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-22 17:08:47 UTC (rev 137) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-22 19:35:49 UTC (rev 138) @@ -65,6 +65,7 @@ dialog.add(compTermPanel); addButtons(); dialog.pack(); + dialog.setLocationRelativeTo(owner); dialog.setVisible(true); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-22 17:08:56
|
Revision: 137 http://svn.sourceforge.net/obo/?rev=137&view=rev Author: mgibson Date: 2006-09-22 10:08:47 -0700 (Fri, 22 Sep 2006) Log Message: ----------- pheno syntax now reads in post comp - new class obo util constructs post comp terms. ontology manager actually recognizes post comp ids GO:123^part_of(AO:234) and on the fly makes a post comp term out of it - not sure if that belongs in ont manager? Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/gui/PostCompGui.java phenote/trunk/src/java/phenote/main/CommandLine.java Added Paths: ----------- phenote/trunk/src/java/phenote/datamodel/OboUtil.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-09-22 14:58:39 UTC (rev 136) +++ phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-09-22 17:08:47 UTC (rev 137) @@ -153,7 +153,7 @@ else if (tag.equals("GC")) character.setGeneticContext(om.getOboClassWithExcep(value)); // throws ex else if (tag.equals("E")) - character.setEntity(om.getOboClassWithExcep(value)); + character.setEntity(om.getTermOrPostComp(value)); else if (tag.equals("Q")) character.setQuality(om.getOboClassWithExcep(value)); else // throw exception? or let rest of char go through? Added: phenote/trunk/src/java/phenote/datamodel/OboUtil.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OboUtil.java (rev 0) +++ phenote/trunk/src/java/phenote/datamodel/OboUtil.java 2006-09-22 17:08:47 UTC (rev 137) @@ -0,0 +1,35 @@ +package phenote.datamodel; + +import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.OBORestriction; +import org.geneontology.oboedit.datamodel.impl.OBOClassImpl; +import org.geneontology.oboedit.datamodel.impl.OBOPropertyImpl; +import org.geneontology.oboedit.datamodel.impl.OBORestrictionImpl; + + +// or should this go in datamodel? + +public class OboUtil { + + public static OBOClass makePostCompTerm(OBOClass genus, OBOProperty rel, + OBOClass diff) { + String nm = pcString(genus.getName(),diff.getName()); + String id = pcString(genus.getID(),diff.getID()); + OBOClass postComp = new OBOClassImpl(nm,id); + OBOProperty ISA = OBOProperty.IS_A; + OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genus); + gRel.setCompletes(true); // post comp flag + postComp.addParent(gRel); + OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,rel,diff); + dRel.setCompletes(true); // post comp + postComp.addParent(dRel); + return postComp; + } + private static String pcString(String g, String d) { + // for now hard wire to part_of + return g+"^part_of("+d+")"; + } + + +} Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-09-22 14:58:39 UTC (rev 136) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-09-22 17:08:47 UTC (rev 137) @@ -3,10 +3,17 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.log4j.Logger; + import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.impl.OBOPropertyImpl; import phenote.datamodel.CharFieldEnum; +import phenote.datamodel.OboUtil; /** Manages all of the ontology. Eventually will get config info (xml? OntologyConfig?) and set itself up from that. Should there be an ontology package - whats funny @@ -64,7 +71,9 @@ /** Searches all ontologies for id - this could be even more savvy and utilize the id prefix AO,GO,PATO... - Should this deal with post comp? if ^ then create a post comp term on fly? */ + Should this deal with post comp? if ^ then create a post comp term on fly? + im not sure if this is the right place for it, maybe method should be renamed + but ill put it here for now */ public OBOClass getOboClass(String id) { OBOClass oboClass; // this seems to be the sole reason for ontology list - silly! @@ -78,6 +87,13 @@ return null; // not found - null } + public OBOClass getTermOrPostComp(String id) throws TermNotFoundException { + if (isPostComp(id)) + return getPostComp(id); + else + return getOboClassWithExcep(id); + } + public OBOClass getOboClassWithExcep(String id) throws TermNotFoundException { OBOClass term = getOboClass(id); if (term == null) @@ -89,6 +105,45 @@ private TermNotFoundException(String m) { super(m); } } + private boolean isPostComp(String id) { + if (id == null) return false; + return id.contains("^"); + } + + /** parse string GO:123^part_of(AO:345) into post comp obo class */ + private OBOClass getPostComp(String id) throws TermNotFoundException { + Pattern pat = Pattern.compile("([^\\^]+)\\^([^\\(]*)\\(([^\\)]*)\\)"); + Matcher m = pat.matcher(id); + boolean found = m.find(); + if (!found) throw new TermNotFoundException("Invalid post comp expression "+id); + String genus,rel,diff; + try { + //log().debug("pattern found for "+id+"? "+found+" g0 "+m.group(0)+" g1 "+m.group(1)+" g2 "+m.group(2)+" g3 "+m.group(3)); + genus = m.group(1); + rel = m.group(2); + diff = m.group(3); + } catch (RuntimeException e) { // IllegalState, IndexOutOfBounds + throw new TermNotFoundException("Invalid post comp expression "+id); + } + + OBOClass gTerm = getOboClassWithExcep(genus); // throws ex + // OBOProperty = getOboRelationshipProperty(rel) - from rel obo - todo + OBOProperty p = new OBOPropertyImpl("OBO_REL:"+rel,rel); + OBOClass dTerm = getOboClassWithExcep(diff); + + return OboUtil.makePostCompTerm(gTerm,p,dTerm); + } + +// /** util fn! */ +// private OBOClass makePostCompTerm(OBOClass genus, String relation, OBOClass diff) { +// String nm = pcString(genus.getName(),diff.getName()); +// String id = pcString(genus.getID(),diff.getID()); +// OBOClass postComp = new OBOClassImpl(nm,id); +// OBOProperty ISA = OBOProperty.IS_A; +// OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); +// return postComp; +// } + /** for obo class find its char field enum via ontology & char field */ public CharFieldEnum getCharFieldEnumForOboClass(OBOClass oboClass) { for (CharField cf : charFieldList) { @@ -101,6 +156,12 @@ return null; // this shouldnt happen - err msg? } + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } + } // i think char field now does this Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-22 14:58:39 UTC (rev 136) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-22 17:08:47 UTC (rev 137) @@ -22,6 +22,7 @@ import phenote.datamodel.CharacterI; import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; +import phenote.datamodel.OboUtil; import phenote.datamodel.SearchParamsI; import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; @@ -159,19 +160,20 @@ // this is no good - not getting terms that came from main window OBOClass genusTerm = genusField.getCurrentOboClass(); // throws Ex OBOClass diffTerm = diffField.getCurrentOboClass(); // throws Ex - String nm = pcString(genusTerm.getName(),diffTerm.getName()); - String id = pcString(genusTerm.getID(),diffTerm.getID()); - OBOClass postComp = new OBOClassImpl(nm,id); - OBOProperty ISA = OBOProperty.IS_A; - OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); - gRel.setCompletes(true); // post comp flag - postComp.addParent(gRel); - // eventually get from obo relationship? +// String nm = pcString(genusTerm.getName(),diffTerm.getName()); +// String id = pcString(genusTerm.getID(),diffTerm.getID()); +// OBOClass postComp = new OBOClassImpl(nm,id); +// OBOProperty ISA = OBOProperty.IS_A; +// OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); +// gRel.setCompletes(true); // post comp flag +// postComp.addParent(gRel); +// // eventually get from obo relationship? OBOProperty partOf = new OBOPropertyImpl("OBO_REL:part_of","part_of"); - OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); - dRel.setCompletes(true); // post comp - postComp.addParent(dRel); - return postComp; + return OboUtil.makePostCompTerm(genusTerm,partOf,diffTerm); +// OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); +// dRel.setCompletes(true); // post comp +// postComp.addParent(dRel); +// return postComp; } private void commitTerm(OBOClass postComp) { Modified: phenote/trunk/src/java/phenote/main/CommandLine.java =================================================================== --- phenote/trunk/src/java/phenote/main/CommandLine.java 2006-09-22 14:58:39 UTC (rev 136) +++ phenote/trunk/src/java/phenote/main/CommandLine.java 2006-09-22 17:08:47 UTC (rev 137) @@ -120,7 +120,7 @@ /** INPUT FILE COMMAND OPTION */ private class InputFileCommandOption extends CommandOption { private final static String help = - "Specify filename to read in (phenoxml.xml,phenosyntax.syn)"; + "Specify filename to read in (phenoxml.xml,phenosyntax.psx)"; private InputFileCommandOption() { // true -> has argument super("inputFile",'f',true,"filename",help); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-22 14:58:47
|
Revision: 136 http://svn.sourceforge.net/obo/?rev=136&view=rev Author: mgibson Date: 2006-09-22 07:58:39 -0700 (Fri, 22 Sep 2006) Log Message: ----------- fixed post comp bug where previously filled in post comp want coming up in post comp gui 2nd time around - AutoComboBox now keeps obo class as state - and has method to retrieve it - throws exception if not consistent with current user input Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-21 14:49:13 UTC (rev 135) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-22 14:58:39 UTC (rev 136) @@ -42,6 +42,9 @@ private boolean keyTyped = false; private String previousInput = ""; private boolean doCompletion = true; + // should we keep state of currentOboClass which is null if not a valid one? + // default combo box.getSelectedItem sortof does this imperfectly + private OBOClass currentOboClass=null; private DefaultComboBoxModel defaultComboBoxModel; private SearchParamsI searchParams; private boolean inTestMode = false; @@ -50,6 +53,8 @@ private CharField charField; ///** Whether differentia of a post composed term */ //private boolean isDifferentia = false; + /** if false then model is not edited */ + private boolean editModel; /** @param editModel if false then ACB doesnt edit model directly (post comp) */ AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { @@ -67,8 +72,9 @@ addCompletionListListener(new CompletionListListener()); - if (editModel) // ComboBoxActionListener edits the model - addActionListener(new ComboBoxActionListener()); + //if (editModel) // ComboBoxActionListener edits the model + this.editModel = editModel; + addActionListener(new ComboBoxActionListener()); } @@ -97,6 +103,21 @@ this.doCompletion = true; // set back to default } + void setOboClass(OBOClass term) { + currentOboClass = term; + setText(term.getName(),false); // no completion + } + + /** Throws exception if there isnt a current obo class, if the user + has typed something that isnt yet a term - hasnt selected a term */ + OBOClass getCurrentOboClass() throws Exception { + if (currentOboClass == null) throw new Exception("term is null"); + if (!currentOboClass.getName().equals(getText())) + throw new Exception("(obo class "+currentOboClass+" and input "+getText()+ + " dont match)"); + return currentOboClass; + } + /** Return text in text field */ String getText() { //return (String)getSelectedItem(); @@ -136,7 +157,8 @@ /** This gets obo class selected in completion list - not from text box Returns null if nothing selected - can happen amidst changing selection - also used by PostCompGui */ + also used by PostCompGui + this doesnt necasarily stay current with user input hmmm....*/ OBOClass getSelectedCompListOboClass() { if (defaultComboBoxModel == null) return null; @@ -434,10 +456,13 @@ // for this not to be so? returns null if no oboclass? OBOClass oboClass = getSelectedCompListOboClass(); if (oboClass == null) return; /// happens on return on invalid term name + currentOboClass = oboClass; - if (charField == null) return; // shouldnt happen + // if not editing model then return + if (!editModel) return; - + // EDIT MODEL + if (charField == null) return; // shouldnt happen CharacterI c = getSelectedCharacter(); // from selectionManager CharFieldEnum cfe = charField.getCharFieldEnum(); //OBOClass previousOboClass = cfe.getValue(c).getOboClass(); @@ -470,43 +495,14 @@ // CEM.handleTransaction(new UT), CEM.updateModel(UT) // fireChangeEvent(e); - - // can this happen? yes when user hits return on text - actually i think this - // is the test for being in the completion list isnt it? -// boolean DEBUG = true; - // bug - on first return input is the user text not the term selected yet! -// if (!input.equals(oboClass.getName())) { -// if (DEBUG) -// System.out.println("User input ["+input+"] and list selection dont match "+ -// "selection: "+oboClass.getName()); -// return; -// } - // check if input is a real term - i think we can get away with checking // if in present term completion list - not sure // i think this is replaced by check above - make sure does the same... // boolean valid = isInCompletionList(oboClass); //input); // if (!valid) -// return; +// return; -// /** Sets table value from field. checks that text in text field from user -// is actually an item in completion list, is an obo term. */ -// private void setTableFromField(String ontology) { -// String input = comboBox.getText();//getInput(ontology); - -// // check if input is a real term - i think we can get away with checking -// // if in present term completion list - not sure -// boolean valid = comboBox.isInCompletionList(input); -// if (!valid) -// return; -// // its valid - set the field -// // no no no - edit model, send out model changed event -// setTableColumn(ontology,input); -// } -// } - - // doesnt work - would need to subclass editor component i thing - hassle // // for TestPhenote // void simulateBackspace() { Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-21 14:49:13 UTC (rev 135) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-22 14:58:39 UTC (rev 136) @@ -14,6 +14,8 @@ import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent; +import org.apache.log4j.Logger; + import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.CharField; @@ -213,6 +215,11 @@ else return textField.getText(); } + void setOboClass(OBOClass term) { + if (isCombo) comboBox.setOboClass(term); + else textField.setText(term.getName()); // probably doesnt happen + } + CharFieldEnum getCharFieldEnum() { return charField.getCharFieldEnum(); } // separate char text field class? @@ -259,14 +266,25 @@ } } - /** This is for ontology char fields, freetext returns null. returns obo class - selected in AutoComboBox if there is one */ - OBOClass getSelectedOboClass() throws Exception { +// /** This is for ontology char fields, freetext returns null. returns obo class +// selected in AutoComboBox if there is one +// this is problematic - it can get term that was selected a while ago */ +// OBOClass getSelectedOboClass() throws Exception { +// if (!isCombo) throw new Exception("Free text field has no OBO Class"); +// OBOClass term = comboBox.getSelectedCompListOboClass(); +// if (term == null) throw new Exception("No term selected"); +// return term; +// } + OBOClass getCurrentOboClass() throws Exception { if (!isCombo) throw new Exception("Free text field has no OBO Class"); - OBOClass term = comboBox.getSelectedCompListOboClass(); - if (term == null) throw new Exception("No term selected"); - return term; + return comboBox.getCurrentOboClass(); // throws Ex } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } // private void addDocumentListener(DocumentListener dl) { Modified: phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java 2006-09-21 14:49:13 UTC (rev 135) +++ phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java 2006-09-22 14:58:39 UTC (rev 136) @@ -39,7 +39,7 @@ private JTable characterTable; private CharacterTableModel characterTableModel; private TermPanel termPanel; - private JButton newButton; + //private JButton newButton; private JButton copyButton; private JButton deleteButton; private JButton commitButton; @@ -83,7 +83,7 @@ ActionListener al = new ButtonActionListener(); - newButton = addButton("New",al,buttonPanel); + addButton("New",al,buttonPanel); //newButton = copyButton = addButton("Copy",al,buttonPanel); deleteButton = addButton("Delete",al,buttonPanel); // should we only add if have data adapter - or disable at least? Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-21 14:49:13 UTC (rev 135) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-22 14:58:39 UTC (rev 136) @@ -14,6 +14,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.OBORestriction; import org.geneontology.oboedit.datamodel.impl.OBOClassImpl; import org.geneontology.oboedit.datamodel.impl.OBOPropertyImpl; import org.geneontology.oboedit.datamodel.impl.OBORestrictionImpl; @@ -36,7 +37,7 @@ private CharField charField; private JDialog dialog; private CharFieldGui genusField; - private CharFieldGui differentiaField; + private CharFieldGui diffField; PostCompGui(CharField charField,SearchParamsI searchParams) { this.charField = charField; @@ -55,15 +56,71 @@ // Relationship?? stripped down ontology? - differentiaField = + diffField = new CharFieldGui(charField,compTermPanel,"Differentia",false,false); + setGuiFromModel(); + dialog.add(compTermPanel); addButtons(); dialog.pack(); dialog.setVisible(true); } + private void setGuiFromModel() { + OBOClass currentTerm = getModelTerm(); + if (currentTerm == null) return; + + //genusField.setText(getGenusString(currentTerm)); + genusField.setOboClass(getGenusTerm(currentTerm)); + //if (modelHasDiff(currentTerm)) + try { diffField.setOboClass(getDiffTerm(currentTerm)); } + catch (Exception e) {} // throws if no diff term + + } + + private OBOClass getModelTerm() { + // there should be convenience method for this + CharacterI c = SelectionManager.inst().getSelectedCharacter(); + return charField.getCharFieldEnum().getValue(c).getOboClass(); + } + + // util fn? + private boolean isPostCompTerm(OBOClass term) { + for (Object o : term.getParents()) { + if ( ((OBORestriction)o).completes() ) + return true; + } + return false; + } + + //private String getGenusStr(OBOClass term){return getGenusTerm(term).getName();} + + /** for non post comp returns term itself */ + private OBOClass getGenusTerm(OBOClass term) { + if (isPostCompTerm(term)) { + for (Object o : term.getParents()) { + OBORestriction r = (OBORestriction)o; + if (r.completes() && r.getType() == OBOProperty.IS_A) + return (OBOClass)r.getParent(); // check downcast? + } + // error msg? + } + return term; + } + + /** Throws exception if no diff term - for now only returning one diff term + can there be more than one */ + private OBOClass getDiffTerm(OBOClass term) throws Exception { + if (!isPostCompTerm(term)) throw new Exception(); + for (Object o : term.getParents()) { + OBORestriction r = (OBORestriction)o; + if (r.completes() && r.getType() != OBOProperty.IS_A) + return (OBOClass)r.getParent(); // check downcast? + } + throw new Exception(); // no diff term found + } + private void addButtons() { JPanel buttonPanel = new JPanel(); JButton ok = new JButton(new OkAction()); @@ -87,8 +144,9 @@ OBOClass pc = makePostCompTerm(); commitTerm(pc); } catch (Exception ex) { - String m = "Post composition failed "+ex.getMessage(); - log().error(m); + String m = "Post composition not fully filled in "; + if (ex.getMessage()!=null) m+=ex.getMessage(); + log().debug(m); // ?? JOptionPane.showMessageDialog(dialog,m,"error",JOptionPane.ERROR_MESSAGE); return; // dont dispose } @@ -98,17 +156,20 @@ private OBOClass makePostCompTerm() throws Exception { // check that we have a valid genus & differentia - OBOClass genusTerm = genusField.getSelectedOboClass(); - OBOClass diffTerm = differentiaField.getSelectedOboClass(); + // this is no good - not getting terms that came from main window + OBOClass genusTerm = genusField.getCurrentOboClass(); // throws Ex + OBOClass diffTerm = diffField.getCurrentOboClass(); // throws Ex String nm = pcString(genusTerm.getName(),diffTerm.getName()); String id = pcString(genusTerm.getID(),diffTerm.getID()); OBOClass postComp = new OBOClassImpl(nm,id); OBOProperty ISA = OBOProperty.IS_A; OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); + gRel.setCompletes(true); // post comp flag postComp.addParent(gRel); // eventually get from obo relationship? OBOProperty partOf = new OBOPropertyImpl("OBO_REL:part_of","part_of"); OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); + dRel.setCompletes(true); // post comp postComp.addParent(dRel); return postComp; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-21 14:49:21
|
Revision: 135 http://svn.sourceforge.net/obo/?rev=135&view=rev Author: mgibson Date: 2006-09-21 07:49:13 -0700 (Thu, 21 Sep 2006) Log Message: ----------- post comp gui disables the post comp button on its char field guis so you cant do post comps of post comps - only one level of post comp i think even when we go multi level we may want to have this all be in one window rather than having to keep bringing up multiple windows so i think we will always want to supress the post comp window button - or have it do an expand collapse instead of a new window in this case - but for now just supress it Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/PostCompGui.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-09-20 19:18:10 UTC (rev 134) +++ phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2006-09-21 14:49:13 UTC (rev 135) @@ -3,6 +3,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.log4j.Logger; import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.Character; @@ -30,6 +31,7 @@ character = ch; } + // WRITE String getPhenoSyntaxString() throws BadCharException { if (phenoSyntaxString == null) { phenoSyntaxString = makeSyntaxString(); @@ -90,6 +92,8 @@ return id.substring(0,colonIndex+1); // +1 retain colon } + + // READ /** Parse syntax line into character */ @@ -156,14 +160,19 @@ System.out.println("pheno syntax tag "+tag+" not recognized (value "+value+")"); } catch (OntologyManager.TermNotFoundException e) { - System.out.println("Term not found for tag "+tag+" value "+value+" in loaded " - +"ontologies - check syntax with ontology files."); + log().error("Term not found for tag "+tag+" value "+value+" in loaded " + +"ontologies - check syntax with ontology files."); return; } } - CharacterI getCharacter() { return character; } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-09-20 19:18:10 UTC (rev 134) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-09-21 14:49:13 UTC (rev 135) @@ -63,7 +63,8 @@ } /** Searches all ontologies for id - this could be even more savvy and utilize - the id prefix AO,GO,PATO... */ + the id prefix AO,GO,PATO... + Should this deal with post comp? if ^ then create a post comp term on fly? */ public OBOClass getOboClass(String id) { OBOClass oboClass; // this seems to be the sole reason for ontology list - silly! Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-20 19:18:10 UTC (rev 134) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-21 14:49:13 UTC (rev 135) @@ -42,6 +42,7 @@ private JComboBox ontologyChooserCombo; private String label; private boolean editModel = true; + private boolean doPostComp = true; CharFieldGui(CharField charField, TermPanel tp) {/*Container parent,*/ @@ -49,10 +50,13 @@ } /** @param editModel - whether charFieldGui edits model directly - for post comp it - doesnt */ - CharFieldGui(CharField cf,TermPanel tp,String label,boolean editModel) { + doesnt + @param doPostComp if false override configuration and dont show post comp button*/ + CharFieldGui(CharField cf,TermPanel tp,String label,boolean editModel, + boolean doPostComp) { this.label = label; this.editModel = editModel; + this.doPostComp = doPostComp; init(cf,tp); } @@ -135,8 +139,11 @@ comboBox.setCharField(charField); - // POST COMPOSITION button - if (charField.postCompAllowed()) { + // POST COMPOSITION button - only get post comp button if both configged for it + // AND doPostComp flag is true - PostCompGui sets to false - no post comp of + // post comp yet - and if so probably would do in same window not multiple + // windows anyways + if (charField.postCompAllowed() && doPostComp) { JButton postCompButton = new JButton("Comp"); // ??? postCompButton.addActionListener(new PostCompListener()); termPanel.addPostCompButton(postCompButton); Modified: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-20 19:18:10 UTC (rev 134) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-21 14:49:13 UTC (rev 135) @@ -50,12 +50,13 @@ TermPanel compTermPanel = new TermPanel(false); // (searchParams)? compTermPanel.setSearchParams(searchParams); - // false - dont edit model - genusField = new CharFieldGui(charField,compTermPanel,"Genus",false); + // false - dont edit model, false - no post comp button + genusField = new CharFieldGui(charField,compTermPanel,"Genus",false,false); // Relationship?? stripped down ontology? - differentiaField = new CharFieldGui(charField,compTermPanel,"Differentia",false); + differentiaField = + new CharFieldGui(charField,compTermPanel,"Differentia",false,false); dialog.add(compTermPanel); addButtons(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-20 19:18:13
|
Revision: 134 http://svn.sourceforge.net/obo/?rev=134&view=rev Author: mgibson Date: 2006-09-20 12:18:10 -0700 (Wed, 20 Sep 2006) Log Message: ----------- woops forgot to add new post comp gui class post comp gui reuses charfield guis - added params to char field gui to make them usable by post comp - like disabling editing of model which happens on OK button in post comp Added Paths: ----------- phenote/trunk/src/java/phenote/gui/PostCompGui.java Added: phenote/trunk/src/java/phenote/gui/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/PostCompGui.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/PostCompGui.java 2006-09-20 19:18:10 UTC (rev 134) @@ -0,0 +1,134 @@ +package phenote.gui; + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import org.apache.log4j.Logger; + +import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.impl.OBOClassImpl; +import org.geneontology.oboedit.datamodel.impl.OBOPropertyImpl; +import org.geneontology.oboedit.datamodel.impl.OBORestrictionImpl; + +import phenote.datamodel.CharacterI; +import phenote.datamodel.CharField; +import phenote.datamodel.CharFieldEnum; +import phenote.datamodel.SearchParamsI; +import phenote.edit.EditManager; +import phenote.edit.UpdateTransaction; +import phenote.main.Phenote; +import phenote.gui.selection.SelectionManager; + +/** A window for post composition and other wacky stuff that goes beyond the basic + stuff in field (eg relational quality?) + may want to be able to give up frame to put inline as well as window? + as window may be configurable or scrapped */ +class PostCompGui { + + private CharField charField; + private JDialog dialog; + private CharFieldGui genusField; + private CharFieldGui differentiaField; + + PostCompGui(CharField charField,SearchParamsI searchParams) { + this.charField = charField; + init(searchParams); + } + + private void init(SearchParamsI searchParams) { + // dialog wont be focusable if owner is not showing or something like that + Frame owner = Phenote.getPhenote().getFrame(); + dialog = new JDialog(owner,charField.getName()+" Post Composition"); + TermPanel compTermPanel = new TermPanel(false); // (searchParams)? + compTermPanel.setSearchParams(searchParams); + + // false - dont edit model + genusField = new CharFieldGui(charField,compTermPanel,"Genus",false); + + // Relationship?? stripped down ontology? + + differentiaField = new CharFieldGui(charField,compTermPanel,"Differentia",false); + + dialog.add(compTermPanel); + addButtons(); + dialog.pack(); + dialog.setVisible(true); + } + + private void addButtons() { + JPanel buttonPanel = new JPanel(); + JButton ok = new JButton(new OkAction()); + buttonPanel.add(ok); + JButton cancel = new JButton(new CancelAction()); + buttonPanel.add(cancel); + dialog.add(buttonPanel,BorderLayout.SOUTH); + } + + private class CancelAction extends AbstractAction { + private CancelAction() { super("Cancel"); } + public void actionPerformed(ActionEvent e) { + //dialog.close(); + dialog.dispose(); + } + } + private class OkAction extends AbstractAction { + private OkAction() { super("OK"); } + public void actionPerformed(ActionEvent e) { + try { + OBOClass pc = makePostCompTerm(); + commitTerm(pc); + } catch (Exception ex) { + String m = "Post composition failed "+ex.getMessage(); + log().error(m); + JOptionPane.showMessageDialog(dialog,m,"error",JOptionPane.ERROR_MESSAGE); + return; // dont dispose + } + dialog.dispose(); // keep up if failure? + } + } + + private OBOClass makePostCompTerm() throws Exception { + // check that we have a valid genus & differentia + OBOClass genusTerm = genusField.getSelectedOboClass(); + OBOClass diffTerm = differentiaField.getSelectedOboClass(); + String nm = pcString(genusTerm.getName(),diffTerm.getName()); + String id = pcString(genusTerm.getID(),diffTerm.getID()); + OBOClass postComp = new OBOClassImpl(nm,id); + OBOProperty ISA = OBOProperty.IS_A; + OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); + postComp.addParent(gRel); + // eventually get from obo relationship? + OBOProperty partOf = new OBOPropertyImpl("OBO_REL:part_of","part_of"); + OBORestrictionImpl dRel = new OBORestrictionImpl(postComp,partOf,diffTerm); + postComp.addParent(dRel); + return postComp; + } + + private void commitTerm(OBOClass postComp) { + CharacterI c = SelectionManager.inst().getSelectedCharacter(); + CharFieldEnum cfe = charField.getCharFieldEnum(); + //OBOClass previousOboClass = cfe.getValue(c).getOboClass(); + UpdateTransaction ut = new UpdateTransaction(c,cfe,postComp); + EditManager.inst().updateModel(this,ut); + } + + private String pcString(String g, String d) { + // for now hard wire to part_of + return g+"^part_of("+d+")"; + } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-20 19:16:54
|
Revision: 133 http://svn.sourceforge.net/obo/?rev=133&view=rev Author: mgibson Date: 2006-09-20 12:16:39 -0700 (Wed, 20 Sep 2006) Log Message: ----------- its a bit crude at this point but i got postcomposition working on a rudimentery level - post comp is done in a separate window - we'll see what folks think of that -need to get rid of comp button in comp window -doesnt yet bring up current post comp from main window if present - phen syn adapter doesnt read post comp (write works) - need to be configurable - and configure differentia ontologies - relationship is hard wired to part_of - need list and loadable from relationship ontology Modified Paths: -------------- phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java phenote/trunk/src/java/phenote/datamodel/Character.java phenote/trunk/src/java/phenote/edit/UpdateTransaction.java phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/TermInfo.java phenote/trunk/src/java/phenote/gui/TermPanel.java phenote/trunk/src/java/phenote/main/Phenote.java Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-09-20 19:16:39 UTC (rev 133) @@ -7,6 +7,12 @@ // or just Field? or CharField? eventually separate class? // associates enum & ontologies +// CharField doesnt handle instance data, just specifies what ontologies are +// associated with what parts of the generic character +// CharFieldValue handles instance data +// CharField gets specified in the configuration - but oddly enough it better +// no contradit CharacterI - as in OBOClasses better have ontologies - this is +// funny i think public class CharField { private List<Ontology> ontologyList = new ArrayList<Ontology>(3); @@ -74,6 +80,15 @@ } return null; } + + /** whether this field allows for post composition - from config (todo) */ + public boolean postCompAllowed() { + // return postCompAllowed; //eventually + return charFieldEnum == CharFieldEnum.ENTITY; // for now + } + + // set whether post composition allowed (from config) */ + // public void setPostCompAllowed(boolean allowed) { postCompAllowed = allowed; } } // is this getting silly? abstract? --> char field value i think Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2006-09-20 19:16:39 UTC (rev 133) @@ -6,7 +6,11 @@ /** At the moment char field values can be Strings (genotype) and OBOClasses, and possibly more coming (Genotype?). This class attempts to hide the details of the actual data structure of the value for the field - could be String or OBOClass but can - still deal with both the same - at least thats the idea... */ + still deal with both the same - at least thats the idea... + post composition brings up some interesting issues...??? + should this be merged with CharField? im forgetting the rationale for having it be + separate??? oh wait CharField is the generic field, CharFieldValue is an actual + instance of data within the CharField - linked via CharFieldEnum & Character*/ public class CharFieldValue { private OBOClass oboClassValue=null; @@ -15,6 +19,7 @@ private CharFieldEnum charFieldEnum; // private CharField??? private CharacterI character; + //private boolean isDifferentia; // ?? public CharFieldValue(String s,CharacterI c, CharFieldEnum e) { stringValue = s; @@ -30,6 +35,12 @@ charFieldEnum = e; } + // hmmmmm.... needed if post comp done inframe +// public CharFieldValue(OBOClass o,CharacterI c,CharFieldEnum e, boolean isDifferentia) { +// this(o,c,e); +// this.isDifferentia = isDifferentia; +// } + // maybe this should be called getString??? why getName??? public String getName() { if (!isOboClass) @@ -39,7 +50,7 @@ return ""; // null? } - OBOClass getOboClass() { return oboClassValue; } + public OBOClass getOboClass() { return oboClassValue; } public void editModel() { if (charFieldEnum == null) Modified: phenote/trunk/src/java/phenote/datamodel/Character.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Character.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/datamodel/Character.java 2006-09-20 19:16:39 UTC (rev 133) @@ -3,16 +3,20 @@ import org.geneontology.oboedit.datamodel.OBOClass; /** Characters are the EAV building blocks of a Phenotype. Previously this - was called a Phenotype which was a misnomer */ + was called a Phenotype which was a misnomer + Should the Character datamodel be a generic list of CharFieldValues? + That can be free text or from ontologies? hmmmm..... im starting to think + this datamodel is too hardwired - hmmmm....*/ public class Character implements CharacterI, Cloneable { + // List<CharFieldValue> charFields??? or List<CharField> // private String entity=""; // private String quality=""; // private String geneticContext=""; private String pub; private String genotype=""; // eventually Genotype class // OboClass? OntologyTerm?... - private OBOClass entity; // CharFieldValue? + private OBOClass entity; // CharFieldValue??? private OBOClass quality; private OBOClass geneticContext; Modified: phenote/trunk/src/java/phenote/edit/UpdateTransaction.java =================================================================== --- phenote/trunk/src/java/phenote/edit/UpdateTransaction.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/edit/UpdateTransaction.java 2006-09-20 19:16:39 UTC (rev 133) @@ -18,6 +18,7 @@ public UpdateTransaction(CharacterI c, CharFieldEnum e, String newVal, String old) { newValue = new CharFieldValue(newVal,c,e); + // change this to get old from model - dont need to pass in oldValue = new CharFieldValue(old,c,e); // character = c; // charFieldEnum = e; @@ -27,11 +28,21 @@ // public UpdateTransaction(CharFieldValue new, CharFieldValue old) ? - public UpdateTransaction(CharacterI c, CharFieldEnum e, OBOClass newVal, OBOClass old) { + /** actually maybe dont need to pas in old val - just query for it */ + public UpdateTransaction(CharacterI c,CharFieldEnum e,OBOClass newVal) { newValue = new CharFieldValue(newVal,c,e); - oldValue = new CharFieldValue(old,c,e); + //oldValue = new CharFieldValue(old,c,e); + oldValue = e.getValue(c); } + // hmmmmmmm.... +// /** if isDifferentia is true than update is for differentia of a post composed term*/ +// public UpdateTransaction(CharacterI c, CharFieldEnum e, boolean isDifferentia, +// OBOClass newVal, OBOClass old) { +// newValue = new CharFieldValue(newVal,c,e,isDifferentia); +// oldValue = new CharFieldValue(old,c,e,isDifferentia); +// } + public void editModel() { newValue.editModel(); //charFieldEnum.setValue(character,newValue); Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-09-20 19:16:39 UTC (rev 133) @@ -37,7 +37,6 @@ class AutoComboBox extends JComboBox { - //private String ontology; // --> enum! private Ontology ontology; private boolean changingCompletionList = false; private boolean keyTyped = false; @@ -49,12 +48,15 @@ //private AutoTextFieldEditor autoTextFieldEditor; private AutoTextField autoTextField; private CharField charField; + ///** Whether differentia of a post composed term */ + //private boolean isDifferentia = false; - AutoComboBox(Ontology ontology,SearchParamsI sp) { + /** @param editModel if false then ACB doesnt edit model directly (post comp) */ + AutoComboBox(Ontology ontology,SearchParamsI sp,boolean editModel) { // this inner class enables retrieving of JList for mouse over // this will probably throw errors if non metal look & feel is used + setUI(new MetalListComboUI()); //setFont(new Font("Courier",Font.PLAIN,12)); - setUI(new MetalListComboUI()); setOntology(ontology); searchParams = sp; // singleton access? part of ontology? @@ -65,15 +67,9 @@ addCompletionListListener(new CompletionListListener()); - // just for genetic context for now? or everything? - addActionListener(new ComboBoxActionListener()); + if (editModel) // ComboBoxActionListener edits the model + addActionListener(new ComboBoxActionListener()); - // mac bug workaround where list covers up textfield on < 12 items no scroll - // from http://www.orbital-computer.de/JComboBox/#usage - // it does note this may cause class cast excpetions?? - // it does cause exception when down arror is typed... hmmm... - //setUI(new BasicComboBoxUI()); // now setting metal look & feel for whole app - } void setOntology(Ontology o) { ontology = o; } @@ -81,6 +77,10 @@ //void setSearchParams(SearchParamsI sp) { searchParams = sp; } void setCharField(CharField charField) { this.charField = charField; } + + ///** If true than the auto combo is for setting the differentia in a post comp term, + // if false (default) than no post comp or genus in post comp */ + //void setIsDifferentia(boolean isDiff) { isDifferentia = isDiff; } /** Set text in editable text field of j combo (eg from table select) */ void setText(String text) { @@ -111,32 +111,33 @@ //private Ontology getOntology() { return ontology; } /** Return true if input String matches name of OBOClass in - * defaultComboBoxModel - rename this? + * defaultComboBoxModel - rename this? this isnt used anymore - delete? */ - boolean isInCompletionList(String input) { - if (defaultComboBoxModel == null) - return false; - if (input == null) { - return false; - } - // this is wrong as it holds OBOClasses not Strings! - //return defaultComboBoxModel.getIndexOf(input) != -1; - // have to go through all OBOClasses and extract there names - bummer - // most likely input is selected one check that first - OBOClass selectedClass = getSelectedCompListOboClass(); - if (selectedClass != null && input.equals(selectedClass.getName())) - return true; - // selected failed(is this possible?) - try everything in the list then... - for (int i=0; i<defaultComboBoxModel.getSize(); i++) { - if (input.equals(getCompListOboClass(i).getName())) - return true; - } - return false; - } +// boolean isInCompletionList(String input) { +// if (defaultComboBoxModel == null) +// return false; +// if (input == null) { +// return false; +// } +// // this is wrong as it holds OBOClasses not Strings! +// //return defaultComboBoxModel.getIndexOf(input) != -1; +// // have to go through all OBOClasses and extract there names - bummer +// // most likely input is selected one check that first +// OBOClass selectedClass = getSelectedCompListOboClass(); +// if (selectedClass != null && input.equals(selectedClass.getName())) +// return true; +// // selected failed(is this possible?) - try everything in the list then... +// for (int i=0; i<defaultComboBoxModel.getSize(); i++) { +// if (input.equals(getCompListOboClass(i).getName())) +// return true; +// } +// return false; +// } /** This gets obo class selected in completion list - not from text box - Returns null if nothing selected - can happen amidst changing selection */ - private OBOClass getSelectedCompListOboClass() { + Returns null if nothing selected - can happen amidst changing selection + also used by PostCompGui */ + OBOClass getSelectedCompListOboClass() { if (defaultComboBoxModel == null) return null; Object obj = defaultComboBoxModel.getSelectedItem(); @@ -346,6 +347,7 @@ getUIJList().addListSelectionListener(lsl); } + // this is for mouse over term info i believe - changes selection private class CompletionListListener implements ListSelectionListener { public void valueChanged(ListSelectionEvent e) { Object source = e.getSource(); @@ -412,22 +414,14 @@ - /** Listens for actions from combo boxes and puts terms into table - * actions come from mouse select of term as well as return & tab - change this - should only modify character - could be done in ACB except - gt text field which isnt done here anyways - then send out CharacterChangeEvent - for table to get and refresh itself */ + /** Listens for actions from combo boxes and edits model/character + * actions come from mouse select of term as well as return & tab */ private class ComboBoxActionListener implements ActionListener { - //private String previousModelValue=null; - private OBOClass previousOboClass=null; + //private OBOClass previousOboClass=null; - private ComboBoxActionListener() {//String ontology,AutoComboBox cb) { - //this.ontology = ontology; - //comboBox = cb; - } + private ComboBoxActionListener() {} public void actionPerformed(ActionEvent e) { editCharField(); - //setTableFromField(ontology); } /** edits Character field via EditManager. @@ -443,18 +437,33 @@ if (charField == null) return; // shouldnt happen - CharacterI c = getSelectedCharacter(); + + CharacterI c = getSelectedCharacter(); // from selectionManager CharFieldEnum cfe = charField.getCharFieldEnum(); - UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass,previousOboClass); + //OBOClass previousOboClass = cfe.getValue(c).getOboClass(); + // isDifferentia boolean? + UpdateTransaction ut = new UpdateTransaction(c,cfe,oboClass); EditManager.inst().updateModel(this,ut); - previousOboClass = oboClass; // for undo + // oh my this is presumptious - assumes only editor, but now theres post + // comp gui - should get previous from char itself! of course silly + //previousOboClass = oboClass; // for undo } } } // GARBAGE + // mac bug workaround where list covers up textfield on < 12 items no scroll + // from http://www.orbital-computer.de/JComboBox/#usage + // it does note this may cause class cast excpetions?? + // it does cause exception when down arror is typed... hmmm... + //setUI(new BasicComboBoxUI()); // now setting metal look & feel for whole app +//String ontology,AutoComboBox cb) { + //private String previousModelValue=null; + //this.ontology = ontology; + //comboBox = cb; + //setTableFromField(ontology); //t.editModel(); // or charField.editModel? // CharacterChangeEvent e = new CharacterChangeEvent(t); // OR CharEditManager.inst().updateModel(c,cfe,input,previousModelValue); Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-09-20 19:16:39 UTC (rev 133) @@ -7,12 +7,15 @@ import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; +import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.event.DocumentListener; import javax.swing.event.DocumentEvent; +import org.geneontology.oboedit.datamodel.OBOClass; + import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharacterI; @@ -37,16 +40,30 @@ private CharField charField; private TermPanel termPanel; private JComboBox ontologyChooserCombo; + private String label; + private boolean editModel = true; + + CharFieldGui(CharField charField, TermPanel tp) {/*Container parent,*/ + init(charField,tp); + } - CharFieldGui(CharField charField,Container parent, TermPanel tp) { - this.charField = charField; + /** @param editModel - whether charFieldGui edits model directly - for post comp it + doesnt */ + CharFieldGui(CharField cf,TermPanel tp,String label,boolean editModel) { + this.label = label; + this.editModel = editModel; + init(cf,tp); + } + + private void init(CharField cf, TermPanel tp) { + charField = cf; termPanel = tp; if (!charField.hasOntologies()) - initTextField(charField.getName(),parent); + initTextField(charField.getName());//,parent); //else if (charField.hasOneOntology()) else - initCombo(charField,parent); + initCombo(charField);//,parent); // do just for text field - or both??? listens for selection (eg from table) SelectionManager.inst().addCharSelectionListener(new FieldCharSelectListener()); @@ -73,7 +90,7 @@ // hasOntology? boolean isCombo() { return isCombo; } - /** Set the gui from the model */ + /** Set the gui from the model (selection) */ void setValueFromChar(CharacterI character) { if (character == null) { System.out.println("ERROR: setting to null character"); @@ -91,50 +108,73 @@ } + private String getLabel() { + if (label == null) { + if (charField.hasMoreThanOneOntology()) + label = charField.getName(); + else + label = charField.getFirstOntology().getName(); + } + return label; + } - - private void initCombo(CharField charField, Container parent) { + private void initCombo(CharField charField) { //, Container parent) { isCombo = true; String name = charField.getFirstOntology().getName(); - JLabel label = termPanel.addLabel(name,parent,charField.hasMoreThanOneOntology()); - // if has more than one ontology(entity) than add ontology choose list - if (charField.hasMoreThanOneOntology()) { - label.setText(charField.getName()); - initOntologyChooser(charField,parent); - } + JLabel label = termPanel.addLabel(getLabel(),charField.hasMoreThanOneOntology()); - // assume 1 ontology for now... - //initCombo(charField.getFirstOntology(),parent); - // CHANGE THIS TO DO MULTIPLE ONTOLOGIES IF NEED BE - comboBox = new AutoComboBox(charField.getFirstOntology(),termPanel.getSearchParams()); - termPanel.addFieldGui(comboBox,parent); + // if has more than one ontology(entity) then add ontology choose list + if (charField.hasMoreThanOneOntology()) + initOntologyChooser(charField); + + // editModel - if false then ACB wont directly edit model (post comp) + comboBox = new AutoComboBox(charField.getFirstOntology(), + termPanel.getSearchParams(),editModel); + termPanel.addFieldGui(comboBox); + comboBox.setCharField(charField); + + // POST COMPOSITION button + if (charField.postCompAllowed()) { + JButton postCompButton = new JButton("Comp"); // ??? + postCompButton.addActionListener(new PostCompListener()); + termPanel.addPostCompButton(postCompButton); + // keep this here for now - may reinstate - this is inpanel post comp +// // todo -> get pc differentia ontologies from config, >1 add chooser +// AutoComboBox postCompCombo = +// new AutoComboBox(charField.getFirstOntology(),termPanel.getSearchParams()); +// // postCompCombo.setVisible(false); // initial state hidden - layout? +// postCompCombo.setCharField(charField); +// postCompCombo.setIsDifferentia(true); // differentia of genus in post comp +// termPanel.addFieldGui(postCompCombo); + } } - private void initOntologyChooser(CharField charField,Container parent) { + private void initOntologyChooser(CharField charField) { ontologyChooserCombo = new JComboBox(); // add listener.... for (Ontology o : charField.getOntologyList()) { ontologyChooserCombo.addItem(o.getName()); } ontologyChooserCombo.addActionListener(new OntologyChooserListener()); - termPanel.addOntologyChooser(ontologyChooserCombo,parent); + termPanel.addOntologyChooser(ontologyChooserCombo); } - private void initTextField(String label,Container parent) { + private void initTextField(String label) { isCombo = false; - termPanel.addLabel(label,parent); + termPanel.addLabel(label); textField = new JTextField(25); textField.setEditable(true); // addGenericDocumentListener... textField.getDocument().addDocumentListener(new TextFieldDocumentListener()); - termPanel.addFieldGui(textField,parent); + termPanel.addFieldGui(textField); textField.addKeyListener(new TextKeyListener()); } + /** key listener for free text fields */ private class TextKeyListener extends java.awt.event.KeyAdapter { public void keyPressed(java.awt.event.KeyEvent e) { // on a mac Command-V is paste. this aint so with java/metal look&feel @@ -169,7 +209,7 @@ CharFieldEnum getCharFieldEnum() { return charField.getCharFieldEnum(); } // separate char text field class? - /** This is where the model gets updated */ + /** This is where the model gets updated (for free text fields) */ private class TextFieldDocumentListener implements DocumentListener { private String previousVal = null; public void changedUpdate(DocumentEvent e) { updateModel(); } @@ -182,6 +222,7 @@ //characterTablePanel.setSelectedGenotype(genotype); CharacterI c = SelectionManager.inst().getSelectedCharacter(); // i believe this isnt using oboClass as we just have string + // of course it isnt this is free text String v = getText(); UpdateTransaction ut = new UpdateTransaction(c,getCharFieldEnum(),v,previousVal); EditManager.inst().updateModel(CharFieldGui.this,ut); @@ -203,6 +244,22 @@ } } + /** I think post-comp should only be closeable if its empty (in expand collapse + inframe case - now window) */ + private class PostCompListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + new PostCompGui(charField,termPanel.getSearchParams()); + } + } + + /** This is for ontology char fields, freetext returns null. returns obo class + selected in AutoComboBox if there is one */ + OBOClass getSelectedOboClass() throws Exception { + if (!isCombo) throw new Exception("Free text field has no OBO Class"); + OBOClass term = comboBox.getSelectedCompListOboClass(); + if (term == null) throw new Exception("No term selected"); + return term; + } } // private void addDocumentListener(DocumentListener dl) { Modified: phenote/trunk/src/java/phenote/gui/TermInfo.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-09-20 19:16:39 UTC (rev 133) @@ -46,7 +46,6 @@ private TermHyperlinkListener termHyperlinkListener; // current obo class being navigated private OBOClass currentOboClass; - private OBOClass previousOboClass=null; // for undo - not implemented yet public TermInfo(TermPanel termPanel) { @@ -129,9 +128,9 @@ CharFieldEnum cfe = OntologyManager.inst().getCharFieldEnumForOboClass(currentOboClass); - UpdateTransaction ut = new UpdateTransaction(ch,cfe,currentOboClass,previousOboClass); + UpdateTransaction ut = new UpdateTransaction(ch,cfe,currentOboClass); EditManager.inst().updateModel(this,ut); - previousOboClass = currentOboClass; + //previousOboClass = currentOboClass; } /** for testing */ Modified: phenote/trunk/src/java/phenote/gui/TermPanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermPanel.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/gui/TermPanel.java 2006-09-20 19:16:39 UTC (rev 133) @@ -11,6 +11,7 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.text.Document; +import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; @@ -36,10 +37,20 @@ private List<CharFieldGui> charFieldGuiList = new ArrayList<CharFieldGui>(8); private SearchParamPanel searchParamPanel; // searchParamManager? private OntologyManager ontologyManager = OntologyManager.inst(); + private JPanel fieldPanel; + private SearchParamsI searchParams; public TermPanel() { - init(); + this(true); + //initAllOntologies(); } + // false for post comp panel + public TermPanel(boolean doAllOntologies) { + fieldPanel = new JPanel(new GridBagLayout()); + add(fieldPanel); // default flow layout? + if (doAllOntologies) + initAllOntologies(); + } /** from selection in plump table - hmmm mvc - get from model change event - should ACB listen for event and change themselves? - oh wait this is for selection @@ -49,51 +60,56 @@ fieldGui.setValueFromChar(character); } - private void init() { - JPanel fieldPanel = new JPanel(new GridBagLayout()); + private void initAllOntologies() { for (CharField charField : ontologyManager.getCharFieldList()) { SearchParamsI s = getSearchParamPanel().getSearchParams(); - CharFieldGui gui = new CharFieldGui(charField,fieldPanel,this); // adds to panel + CharFieldGui gui = new CharFieldGui(charField,this); // adds to panel charFieldGuiList.add(gui); } - add(fieldPanel); - - // search param panel + // search param panel - maybe search panel should be added to main frame? add(getSearchParamPanel().getPanel()); } SearchParamsI getSearchParams() { - return getSearchParamPanel().getSearchParams(); + if (searchParams == null) + searchParams = getSearchParamPanel().getSearchParams(); + return searchParams; } + void setSearchParams(SearchParamsI sp) { searchParams = sp; } + SearchParamPanel getSearchParamPanel() { if (searchParamPanel == null) searchParamPanel = new SearchParamPanel(); return searchParamPanel; } - JLabel addLabel(String labelString,Container parent) { - return addLabel(labelString,parent,false); // false - no ont chooser + JLabel addLabel(String labelString) {//,Container parent) { + return addLabel(labelString,false); // false - no ont chooser } - JLabel addLabel(String labelString,Container parent,boolean hasOntChooser) { + JLabel addLabel(String labelString,boolean hasOntChooser) { JLabel label = new JLabel(labelString); GridBagConstraints gbc = makeLabelConstraint(hasOntChooser); - parent.add(label,gbc); + fieldPanel.add(label,gbc); return label; } /** if a field has more than one ontology than theres a combo to choose the ontology*/ - void addOntologyChooser(JComboBox ontologyChooser,Container parent) { - parent.add(ontologyChooser,makeOntologyChooserConstraint()); + void addOntologyChooser(JComboBox ontologyChooser) { + fieldPanel.add(ontologyChooser,makeOntologyChooserConstraint()); } - void addFieldGui(JComponent comp,Container parent) { - parent.add(comp,makeFieldConstraint()); + void addFieldGui(JComponent comp) { + fieldPanel.add(comp,makeFieldConstraint()); } + void addPostCompButton(JButton pc) { + fieldPanel.add(pc,makePostCompConstraint()); + } + private int gridbagRow = 0; boolean ontologyChooserPresent = false; private GridBagConstraints makeLabelConstraint(boolean hasOntChooser) { @@ -115,13 +131,18 @@ return GridBagUtil.makeWidthConstraint(x,gridbagRow++,1,3,width); } + // put button at end of regular row? or beginning of pc row? + private GridBagConstraints makePostCompConstraint() { + return GridBagUtil.makeWidthConstraint(3,gridbagRow-1,1,3,2); // width 1 + } - // for test and term info to listen - move to test code? + // for test to listen - move to test code? AutoComboBox getEntityComboBox() { return getComboBox(CharFieldEnum.ENTITY); } + // for testing - move to test? private AutoComboBox getComboBox(CharFieldEnum cfe) { for (CharFieldGui cfg : charFieldGuiList) if (cfg.getCharFieldEnum() == cfe) Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-09-14 17:17:57 UTC (rev 132) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-09-20 19:16:39 UTC (rev 133) @@ -3,6 +3,7 @@ // package phenote.main? import java.awt.Dimension; +import java.awt.Frame; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.BoxLayout; @@ -38,6 +39,7 @@ private static Phenote phenote; private TermInfo termInfo; private CommandLine commandLine = CommandLine.inst(); + private JFrame frame; public static void main(String[] args) { @@ -152,8 +154,10 @@ return configFile; } + public Frame getFrame() { return frame; } + private void makeWindow() { - JFrame frame = new JFrame("Phenote "+VERSION); // this may be changed to applet... + frame = new JFrame("Phenote "+VERSION); // this may be changed to applet... frame.getContentPane().add(makeMainPanel()); MenuManager.createMenuManager(frame); frame.setPreferredSize(new Dimension(1000,550)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-09-14 17:18:06
|
Revision: 132 http://svn.sourceforge.net/obo/?rev=132&view=rev Author: balhoff Date: 2006-09-14 10:17:57 -0700 (Thu, 14 Sep 2006) Log Message: ----------- Had incorrectly used local variable for file in load(), instead of file instance variable of PhenoXmlAdapter. Fixed. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 17:06:15 UTC (rev 131) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 17:17:57 UTC (rev 132) @@ -46,7 +46,9 @@ public void load() { try { - File file = getFileFromUser(previousFile); + if (file == null) { + file = getFileFromUser(previousFile); + } if (file == null) return; previousFile = file; PhenosetDocument doc = PhenosetDocument.Factory.parse(file); @@ -118,6 +120,7 @@ catch (IOException e) { System.out.println("PhenoXml read failure " + e); } + file = null; // null it for next load/commit } public void commit(CharacterListI charList) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2006-09-14 17:06:19
|
Revision: 131 http://svn.sourceforge.net/obo/?rev=131&view=rev Author: balhoff Date: 2006-09-14 10:06:15 -0700 (Thu, 14 Sep 2006) Log Message: ----------- Added preliminary reading of phenoXML files to PhenoXmlAdapter. This version reads only the information written out by PhenoXmlAdapter, which is currently incomplete. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 16:44:04 UTC (rev 130) +++ phenote/trunk/src/java/phenote/dataadapter/phenoxml/PhenoXmlAdapter.java 2006-09-14 17:06:15 UTC (rev 131) @@ -4,9 +4,11 @@ import java.io.IOException; import java.util.HashSet; import java.util.Set; +import java.util.List; import javax.swing.JFileChooser; +import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlOptions; import org.bioontologies.obd.schema.pheno.BearerDocument.Bearer; @@ -22,9 +24,15 @@ //import org.bioontologies.obd.schema.pheno.*.*; import phenote.datamodel.CharacterI; +import phenote.datamodel.Character; import phenote.datamodel.CharacterListI; +import phenote.datamodel.CharacterList; +import phenote.datamodel.OntologyManager; +import phenote.datamodel.OntologyManager.TermNotFoundException; +import phenote.dataadapter.CharacterListManager; import phenote.dataadapter.DataAdapterI; + public class PhenoXmlAdapter implements DataAdapterI { private Set genotypesAlreadyAdded = new HashSet<String>(); @@ -36,7 +44,81 @@ file = new File(filename); } - public void load() {} + public void load() { + try { + File file = getFileFromUser(previousFile); + if (file == null) return; + previousFile = file; + PhenosetDocument doc = PhenosetDocument.Factory.parse(file); + Phenoset phenoset = doc.getPhenoset(); + List<PhenotypeManifestation> phenotypeManifestations = phenoset.getPhenotypeManifestationList(); + CharacterListI charList = new CharacterList(); + for (PhenotypeManifestation aManifestation : phenotypeManifestations) { + CharacterI character = new Character(); + ManifestIn mi = aManifestation.getManifestIn(); + if (mi != null) { + String genotype = mi.getGenotype(); + if (genotype != null) { + character.setGenotype(genotype); + } + } + Phenotype phenotype = aManifestation.getPhenotype(); + PhenotypeCharacter phenotypeCharacter = null; + if (phenotype != null) { + List<PhenotypeCharacter> phenotypeCharacters = phenotype.getPhenotypeCharacterList(); + if ((phenotypeCharacters != null) && (phenotypeCharacters.size() > 0)) { + // we only load the first character in the phenotype for now + phenotypeCharacter = phenotypeCharacters.get(0); + } + } + OntologyManager ontologyManager = OntologyManager.inst(); + String entityID = null; + String qualityID = null; + if (phenotypeCharacter != null) { + Bearer bearer = phenotypeCharacter.getBearer(); + if (bearer != null) { + Typeref typeref = bearer.getTyperef(); + if (typeref != null) { + entityID = typeref.getAbout(); + } + } + List<Quality> qualityList = phenotypeCharacter.getQualityList(); + if ((qualityList != null) && (qualityList.size() > 0)) { + // we only load the first quality for now + Quality quality = qualityList.get(0); + Typeref qualityTyperef = quality.getTyperef(); + if (qualityTyperef != null) { + qualityID = qualityTyperef.getAbout(); + } + } + } + if (entityID != null) { + try { + character.setEntity(ontologyManager.getOboClassWithExcep(entityID)); + } + catch (TermNotFoundException e) { + System.out.println("Entity term not found " + e); + } + } + if (qualityID != null) { + try { + character.setQuality(ontologyManager.getOboClassWithExcep(qualityID)); + } + catch (TermNotFoundException e) { + System.out.println("Quality term not found " + e); + } + } + charList.add(character); + } + CharacterListManager.inst().setCharacterList(this,charList); + } + catch (XmlException e) { + System.out.println("Failed to load file as phenoxml " + e); + } + catch (IOException e) { + System.out.println("PhenoXml read failure " + e); + } + } public void commit(CharacterListI charList) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2006-09-14 16:44:11
|
Revision: 130 http://svn.sourceforge.net/obo/?rev=130&view=rev Author: mgibson Date: 2006-09-14 09:44:04 -0700 (Thu, 14 Sep 2006) Log Message: ----------- writeback from command line is now working: -f is inputfile, -w is write file phenote -f fly.psx -w fly.xml will read in fly.psx pheno syntax and write out the file fly.xml in pheno xml .psx is recognized as pheno syntax, .xml as pheno xml -f fly.xml doesnt do anything yet as there is not yet a pheno xml reader - but that is coming soon from jim! Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/FileMenu.java phenote/trunk/src/java/phenote/main/CommandLine.java phenote/trunk/src/java/phenote/main/Phenote.java Modified: phenote/trunk/src/java/phenote/gui/FileMenu.java =================================================================== --- phenote/trunk/src/java/phenote/gui/FileMenu.java 2006-09-14 15:40:27 UTC (rev 129) +++ phenote/trunk/src/java/phenote/gui/FileMenu.java 2006-09-14 16:44:04 UTC (rev 130) @@ -19,7 +19,7 @@ } private void init() { - LoadActionListener actionListener = new LoadActionListener(); + LoadSaveActionListener actionListener = new LoadSaveActionListener(); loadMenuItem = new JMenuItem("Load Data"); loadMenuItem.setEnabled(Config.inst().hasDataAdapters()); @@ -35,7 +35,7 @@ } - private class LoadActionListener implements ActionListener { + private class LoadSaveActionListener implements ActionListener { public void actionPerformed(ActionEvent e) { if (!Config.inst().hasDataAdapters()) { System.out.println("no data adapter to load with"); Modified: phenote/trunk/src/java/phenote/main/CommandLine.java =================================================================== --- phenote/trunk/src/java/phenote/main/CommandLine.java 2006-09-14 15:40:27 UTC (rev 129) +++ phenote/trunk/src/java/phenote/main/CommandLine.java 2006-09-14 16:44:04 UTC (rev 130) @@ -103,7 +103,20 @@ return adapter; } + /** If output/write was specified on the command line this returns the + * correctly-initialized write data adapter for it. Note that the + * adapter returned may be the same object as that returned by + * <code>getReadAdapter()</code> + * @return null if no read adapter specified on command line. */ + DataAdapterI getWriteAdapter() throws Exception { + // LOG.debug("CommandLine: getWriteAdapter called\n"); + IOOptions ioo = getWriteOptions(); + DataAdapterI adapter = ioo.getAdapter(); + adapter.setAdapterValue(ioo.getAdapterValue()); + return adapter; + } + /** INPUT FILE COMMAND OPTION */ private class InputFileCommandOption extends CommandOption { private final static String help = Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2006-09-14 15:40:27 UTC (rev 129) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2006-09-14 16:44:04 UTC (rev 130) @@ -18,6 +18,8 @@ import phenote.config.Config; import phenote.config.ConfigException; +import phenote.datamodel.CharacterListI; +import phenote.dataadapter.CharacterListManager; import phenote.dataadapter.OntologyDataAdapter; import phenote.gui.CharacterTablePanel; import phenote.gui.GridBagUtil; @@ -54,9 +56,11 @@ try { DOMConfigurator.configure(Config.inst().getLogConfigUrl()); } catch (FileNotFoundException e) { LOG.error(e.getMessage()); } phenote.initOntologies(); - phenote.loadFromCommandLine(); // cant load data til ontologies loaded i think - - phenote.initGui(); + phenote.loadFromCommandLine(); // aft ontols, reads from cmd line if specified + if (phenote.commandLine.writeIsSpecified()) + phenote.writeFromCommandLine(); + else // init gui if not writing (& reading) from cmd line + phenote.initGui(); } /** private constructor -> singleton */ @@ -77,9 +81,20 @@ private void loadFromCommandLine() { //LOG.debug("read spec "+commandLine.readIsSpecified()); if (!commandLine.readIsSpecified()) return; + // LOG.info("Reading "+blah+" from command line"); try { commandLine.getReadAdapter().load(); } catch (Exception e) { LOG.error("Failed to do load via command line "+e); } } + + private void writeFromCommandLine() { + if (!commandLine.writeIsSpecified()) return; + try { commandLine.getWriteAdapter().commit(getCharList()); } + catch (Exception e) { LOG.error("Failed to do write via command line "+e); } + } + + private CharacterListI getCharList() { + return CharacterListManager.inst().getCharacterList(); + } public void initGui() { makeWindow(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |