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...> - 2007-10-03 21:52:30
|
Revision: 954 http://obo.svn.sourceforge.net/obo/?rev=954&view=rev Author: mgibson Date: 2007-10-03 14:52:29 -0700 (Wed, 03 Oct 2007) Log Message: ----------- well this was harder than i thought - swing swing so there was a bug with min completion chars being 1 that completion would be blank but i decided really min completion chars should just be scrapped as its buggy in other ways and made irrelevant with the new threading of completion the one purpose it was serving was to hold back on preloading ontologies (optionally) to be able to see whole ontology - by hitting arrow button with no input - as pre loading can be a real drag with many ontols - the post comp gui was doing it evgery time it was brought up - on a slow labtop (birn) it was taking forever so now it loads up ontol with blank input on demand - once the user hits the arrow it goes and gets even better you can look at individual ontologies - wasnt true before but the trick was getting the jlist to not be all blinky - as in come up 1st blank and then a second or 2 later with terms the problem ironically was threading - so in this one case - bringing up completion with no input - and not from typing (delete) phenote actually makes a non threaded call for completions so it wont be all blinky typing to empty input is detected by turning on a flag with typing all other comletions are threaded and cancellable so this make min complete chars irrelevant - and actually probably better not to use - i think i might disable it and take it out of configurations Modified Paths: -------------- phenote/trunk/conf/ncbo.cfg phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java phenote/trunk/src/java/phenote/servlet/PhenoteController.java Modified: phenote/trunk/conf/ncbo.cfg =================================================================== --- phenote/trunk/conf/ncbo.cfg 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/conf/ncbo.cfg 2007-10-03 21:52:29 UTC (rev 954) @@ -56,7 +56,7 @@ <ns:ontology name="MP" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/mammalian_phenotype.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="1" enable="true" desc="To be used when using relational qualities"> + <ns:field name="Add'l Entity" datatag="E2" enable="true" desc="To be used when using relational qualities"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="EHDAA" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/anatomy/gross_anatomy/animal_gross_anatomy/human/human-dev-anat-abstract.obo"/> Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-03 21:52:29 UTC (rev 954) @@ -132,6 +132,8 @@ for (FieldConfig fieldConfig : cfg().getEnbldFieldCfgs()) { for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { + // this actually does repos synching, should only do once per obo file, + // but it wont download something twice as 2nd time it will be in synch String file = findOboUrlString(oc); // throws oex if not found if (!files.contains(file)) { // dont load file twice files.add(file); Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-10-03 21:52:29 UTC (rev 954) @@ -11,6 +11,7 @@ import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; +import javax.swing.AbstractButton; import javax.swing.ComboBoxModel; import javax.swing.InputMap; import javax.swing.JComboBox; @@ -21,6 +22,8 @@ import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.event.ListDataListener; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import javax.swing.plaf.basic.BasicComboBoxEditor; import javax.swing.plaf.basic.BasicComboBoxRenderer; import javax.swing.plaf.basic.ComboPopup; @@ -39,7 +42,7 @@ private JComboBox jComboBox; private boolean changingCompletionList = false; - private boolean doCompletion = true; + private boolean settingTextExternally = false; private CompComboBoxModel compComboBoxModel; private boolean inTestMode = false; private AutoTextField autoTextField; @@ -66,10 +69,14 @@ this.getJComboBox().addActionListener(new ComboBoxActionListener()); compListSearcher = new CompListSearcher(getCharField().getOntologyList()); // init with all terms if config.showAllOnEmptyInput... - if (getMinCompChars() == 0) { - boolean showPopupWithComp = false; // dont show popup - - doCompletion(showPopupWithComp); //we dont have a gui yet, just populating - } + // this can take a while (post comp gui) do on demand with popup menu listener +// if (getMinCompChars() == 0) { +// boolean showPopupWithComp = false; // dont show popup - +// doCompletion(showPopupWithComp); //we dont have a gui yet, just populating +// } + getJComboBox().addPopupMenuListener(new CompPopupMenuListener()); + //if (hasArrowButton()) + //getArrowButton().addActionListener(new ArrowButtonActionListener()); } public void setMinCompChars(int minChars) { minCompChars = minChars; } @@ -114,15 +121,15 @@ /** Set text in editable text field of j combo (eg from table select) */ public void setText(String text) { // do not do term completion on externally set text! - boolean doCompletion = false; - setText(text,doCompletion); + boolean settingTextExternally = true; + setText(text,settingTextExternally); } /** text from selecting table doesnt do completion, TestPhenote does */ - public void setText(String text, boolean doCompletion) { - this.doCompletion = doCompletion; + public void setText(String text, boolean settingTextExternally) { + this.settingTextExternally = settingTextExternally; jComboBox.getEditor().setItem(text); - this.doCompletion = true; // set back to default + this.settingTextExternally = false; // set back to default } /** Return text in text field */ @@ -207,7 +214,7 @@ // 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; + settingTextExternally = true; //this is problematic for syns & such where string is diff than term name // JComboBox sets this text AFTER got event and set to name //super.setText(text); @@ -219,7 +226,7 @@ } else super.setText(getCurrentTermRelName()); // set to term name with syn select - doCompletion = true; + settingTextExternally = false; } protected void processKeyEvent(KeyEvent e) { @@ -251,8 +258,13 @@ } private void doCompletion(boolean showPopup) { + doCompletion(showPopup,true); // thread + } + + /** This completion is threaded */ + private void doCompletion(boolean showPopup, boolean thread) { this.setHasChangedMultipleValues(true); - if (!doCompletion) // flag set if text filled in externally (from table sel) + if (settingTextExternally) // flag set if text filled in externally (from table sel) return; // too soon - text field doesnt have text yet.... hmmmm.... String input = getText(); @@ -262,7 +274,9 @@ // if input is empty will return whole list (if configged) //log().debug("got new completion request for input "+input+" time "+time()); listSearchListener.showPopup = showPopup; - /*List<CompletionTerm> l =*/ getSearchItems(input,listSearchListener); + // fires thread + /*List<CompletionTerm> l =*/ + getSearchItems(input,listSearchListener,thread); //log().debug("got search items for input "+input+" milsec: "+time()); // changingCompletionList = true; // // could just do comboBoxModel.setList(l); ??? @@ -287,8 +301,11 @@ compComboBoxModel = new CompComboBoxModel(results); jComboBox.setModel(compComboBoxModel); changingCompletionList = false; - if (showPopup) //only show popup on key events actually only do com + if (showPopup) { //only show popup on key events actually only do com + doingPopupForCompletion = true; // otherwise doComp endless loop jComboBox.showPopup(); + doingPopupForCompletion = false; + } //jComboBox.revalidate(); //jComboBox.repaint(); //getUIJList().repaint(); @@ -328,7 +345,7 @@ } // no longer returns List<CompletionTerm>, a thread sends list to listener - protected abstract void getSearchItems(String input,SearchListener l); + protected abstract void getSearchItems(String input,SearchListener l,boolean thread); // if (isRelationshipList()) return termSearcher.getStringMatchRelations(input); // else return termSearcher.getStringMatchTerms(input);} @@ -365,7 +382,31 @@ return null; // ex? } + /** This is the button pressed to see the list + so in theory youre not supposed to delve into the innards of the jcombo + but in practice ya need to, need to know when that button is pressed when the + user hasnt entered anything, and AbstractButton is not plaf specific (hopefully) */ + private AbstractButton getArrowButton() { + for (Component c : getJComboBox().getComponents()) { + if (c instanceof AbstractButton) return (AbstractButton)c; + } + return null; // ex? + } + private boolean hasArrowButton() { return getArrowButton() != null; } + + private class ArrowButtonActionListener implements ActionListener { + public void actionPerformed(ActionEvent e) { + log().debug("arrow has been pressed jcombo vis? "+getJComboBox().isPopupVisible()); + if (!getJComboBox().isPopupVisible()) return; + getJComboBox().hidePopup(); // ??? + if (getText() == null || getText().length() == 0) { + doCompletion(true); // --> doNonThreadedCompletion + } + } + } + + // for TestPhenote public void doMouseOver(int itemNumber) { //System.out.println("AutoComboBox.doMouseOver not implemented yet"); @@ -486,6 +527,27 @@ return dimension; } } + + private boolean doingPopupForCompletion = false; + + /** If user hits arrow on completion field with nothing typed in, all terms + should then be listed */ + private class CompPopupMenuListener implements PopupMenuListener { + public void popupMenuCanceled(PopupMenuEvent e) {} + public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {} + public void popupMenuWillBecomeVisible(PopupMenuEvent e) { + //log().debug("popup will become visible "+getText()+" disable? "+doingPopupForCompletion+" popup vis? "+getJComboBox().isPopupVisible()); + if (doingPopupForCompletion) return; + if (getText() != null && getText().length() > 0) + return; + // popup already coming dont do another + boolean showPopup = false; + // dont do threaded as need to wait for results before continuing with popup + // if threaded and popup then its blinky (2 popups, 1st one is blank) + boolean doThreaded = false; + doCompletion(showPopup,doThreaded); + } + } } Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-10-03 21:52:29 UTC (rev 954) @@ -10,6 +10,7 @@ import org.apache.log4j.Logger; import org.geneontology.util.AbstractTaskDelegate; +import org.geneontology.swing.BackgroundUtil; import org.geneontology.util.TaskDelegate; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; @@ -31,7 +32,7 @@ //private boolean searchAll=false; private List<Ontology> ontologyList = new ArrayList<Ontology>(3); private SearchParamsI searchParams = SearchParams.inst(); // singleton - private String previousInput = ""; + private String previousInput = null; private List<CompletionTerm> previousCompList = new ArrayList<CompletionTerm>(); /** Ontology - the initial ontology to search, setOntology changes this, @@ -77,22 +78,27 @@ private CompTaskDelegate compTaskDelegate = null; - /** Returns a List of CompletionTerms from ontology that contain input string - constrained by compParams. compParams specifies syns,terms,defs,& obs + /** Makes a List of CompletionTerms from ontology that contain input string + constrained by compParams. Gives this list to SearchListener, does search + in background thread if thread is true. compParams specifies syns,terms,defs,& obs should input be just part of search params? called by servlet & standalone now */ - public /*List<CompletionTerm>*/ void getStringMatchTermList(String input, - SearchListener lis) { + public void getStringMatchTermList(String input,SearchListener lis,boolean threaded) { //new org.jdesktop.swingworker.SwingWorker(); // kill old task! if (compTaskDelegate!=null) compTaskDelegate.cancel(); - compTaskDelegate = new CompTaskDelegate(input,lis); - org.geneontology.swing.BackgroundUtil.scheduleTask(compTaskDelegate); - + // THREADED + if (threaded) { + compTaskDelegate = new CompTaskDelegate(input,lis); + BackgroundUtil.scheduleTask(compTaskDelegate); + } + // NON THREADED - null task, results sent to listener synchronously + else { + getSearchTermList(input,lis,null); + } } - private class CompTaskDelegate - extends AbstractTaskDelegate<List<CompletionTerm>> { + private class CompTaskDelegate extends AbstractTaskDelegate<List<CompletionTerm>> { private String input; private SearchListener searchListener; @@ -104,57 +110,9 @@ public void execute() { try { - List<CompletionTerm> searchTerms = new ArrayList<CompletionTerm>(); - - // if no input should phenote give no terms? or all terms? - boolean nothingForNothing = false; // get from FieldConfig!! - if (nothingForNothing && isBlank(input)) { - results = searchTerms; // empty - searchListener.newResults(results); - return; - } - - // optimization - if user has only typed one more letter (common case) - // use previous search list - try { - if (input.startsWith(previousInput) - && input.length() == previousInput.length() + 1) { - searchTerms = searchPreviousList(input,previousCompList,this); - } - - else { - // gets term set for currently selected ontology(s) - //Set ontologyTermList = getCurrentOntologyTermSet(); - // THIS IS WRONG! or is it? - for (Ontology ontology : ontologyList) { - Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete - List<CompletionTerm> l = - getSearchTermList(input,ontologyTermList,this); - searchTerms.addAll(l); - - // if obsoletes set then add them in addition to regulars - if (searchParams.searchObsoletes()) { - ontologyTermList = ontology.getSortedObsoleteTerms(); - List<CompletionTerm> obsoletes = - getSearchTermList(input,ontologyTermList,this); - searchTerms.addAll(obsoletes); - } - } - - } - - } - catch (CancelEx x) { return; } // task has been cancelled - - previousInput = input; - previousCompList = searchTerms; - //return searchTerms; - //setResults(searchTerms); - results = searchTerms; - if (!isCancelled()) - searchListener.newResults(results); // send off results - - } catch (RuntimeException x) { + getSearchTermList(input,searchListener,this); + } // TaskDelegates dont yet deal with runtime exceptions + catch (RuntimeException x) { log().error("got runtime exception in completion "+x); } @@ -162,7 +120,69 @@ } // end CompTask inner class + /** task is null for non threaded case. if threaded/nonnull checks to see if task + is cancelled - when done passes results to SearchListener */ + private void getSearchTermList(String input, SearchListener searchListener, + TaskDelegate task) { + List<CompletionTerm> searchTerms = new ArrayList<CompletionTerm>(); + + // if no input should phenote give no terms? or all terms? + boolean nothingForNothing = false; // get from FieldConfig!! + if (nothingForNothing && isBlank(input)) { + //results = searchTerms; // empty + searchListener.newResults(searchTerms); + return; + } + + // optimization - if user has only typed one more letter (common case) + // use previous search list - i think this even works with threaded + try { + if (previousInput != null && input.startsWith(previousInput) + && input.length() == previousInput.length() + 1) { + searchTerms = searchPreviousList(input,previousCompList,task); + } + + else { + // gets term set for currently selected ontology(s) + //Set ontologyTermList = getCurrentOntologyTermSet(); + // THIS IS WRONG! or is it? + for (Ontology ontology : ontologyList) { + Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete + List<CompletionTerm> l = + getOntSearchTermList(input,ontologyTermList,task); + searchTerms.addAll(l); + + // if obsoletes set then add them in addition to regulars + if (searchParams.searchObsoletes()) { + ontologyTermList = ontology.getSortedObsoleteTerms(); + List<CompletionTerm> obsoletes = + getOntSearchTermList(input,ontologyTermList,task); + searchTerms.addAll(obsoletes); + } + } + + } + + } + catch (CancelEx x) { return; } // task has been cancelled + + previousInput = input; + previousCompList = searchTerms; + //return searchTerms; + //setResults(searchTerms); + //results = searchTerms; // does task need results? + if (!isCancelled(task)) + searchListener.newResults(searchTerms); // send off results + } + + /** for non threaded context task will be null and returns false, otherwise + queries task */ + private boolean isCancelled(TaskDelegate task) { + if (task == null) return false; + return task.isCancelled(); + } + private boolean isBlank(String s) { return s == null || s.equals(""); } @@ -170,8 +190,10 @@ private class CancelEx extends Exception {} - /** helper fn for CompTaskDelegate */ - private List<CompletionTerm> getSearchTermList(String input, + + + /** helper fn for CompTaskDelegate, does search for terms from a single ontology */ + private List<CompletionTerm> getOntSearchTermList(String input, Collection<OBOClass> ontologyTermList, TaskDelegate task) throws CancelEx { SearchTermList searchTermList = new SearchTermList(); @@ -182,7 +204,7 @@ for (OBOClass oboClass : ontologyTermList) { //for (int i=0; i<ontologyTermList.size(); i++) { - if (i++ % 50 == 0 && task.isCancelled()) throw new CancelEx(); + if (i++ % 50 == 0 && isCancelled(task)) throw new CancelEx(); CompletionTerm ct = new CompletionTerm(oboClass); // if input is blank then add all terms (list all terms on empty input) // matches records the kind of hit in CompTerm @@ -203,7 +225,7 @@ SearchTermList newList = new SearchTermList(); //for (CompletionTerm ct : prevList) { for (int i=0; i<prevList.size(); i++) { - if (i % 50 == 0 && task.isCancelled()) throw new CancelEx(); + if (i % 50 == 0 && isCancelled(task)) throw new CancelEx(); CompletionTerm ct = prevList.get(i); ct.resetMatchState(); // reusing ct has stale match state from previous search if (ct.matches(input,searchParams)) Modified: phenote/trunk/src/java/phenote/gui/field/RelationCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2007-10-03 21:52:29 UTC (rev 954) @@ -41,7 +41,7 @@ return; // debug stack trace? } currentRel = rel; - setText(rel.getName(),false); // eventually .getName() + setText(rel.getName()); } /** Throws exception if there isnt a current relation - for relation lists (post comp), if the user @@ -91,9 +91,10 @@ just term */ protected void setCharFieldValue(CharFieldValue value) {} - protected void getSearchItems(String input, SearchListener l) { - // for now not threading and just sending results to listener - - // relations are short lists - dont need threaded optimization + /** for now not threading and just sending results to listener - + relations are short lists - dont need threaded optimization + so boolean thread is ignored */ + protected void getSearchItems(String input, SearchListener l, boolean thread) { l.newResults(getCompListSearcher().getStringMatchRelations(input)); } Modified: phenote/trunk/src/java/phenote/gui/field/TermCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-10-03 21:52:29 UTC (rev 954) @@ -116,8 +116,8 @@ } /** now threaded so cant return - set AbAutoCompList when done */ - protected void getSearchItems(String input,SearchListener l) { - /*return*/ getCompListSearcher().getStringMatchTermList(input,l); + protected void getSearchItems(String input,SearchListener l,boolean thread) { + /*return*/ getCompListSearcher().getStringMatchTermList(input,l,thread); } /** @@ -156,7 +156,7 @@ else this.setForegroundColor(this.getEnabledTextColor()); String val = term == null ? "" : term.getName(); - setText(val, false); // no completion + setText(val); // no completion with setText fyi } /** Modified: phenote/trunk/src/java/phenote/servlet/PhenoteController.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2007-10-03 19:15:27 UTC (rev 953) +++ phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2007-10-03 21:52:29 UTC (rev 954) @@ -72,8 +72,11 @@ //List<CompletionTerm> termList = null; SearchListener searchListener = new ContSearchListener(ontologyName,field,form); try { - //termList = its now threaded - term list returned to SearchListener - getCompListSearcher(ontologyName).getStringMatchTermList(userInput,searchListener); + //termList = its now optionally threaded - term list returned to SearchListener + // Christian - set this boolean to false to turn off threading + boolean thread = true; + getCompListSearcher(ontologyName).getStringMatchTermList(userInput,searchListener, + thread); } catch (OntologyException e) { // Todo: Add this error as an error completion list LOG.error(e.getMessage(), e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-10-03 19:15:42
|
Revision: 953 http://obo.svn.sourceforge.net/obo/?rev=953&view=rev Author: balhoff Date: 2007-10-03 12:15:27 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Implemented tracker #1804503, auto-open specimen list and phylogenetic tree when loading new data file. Modified Paths: -------------- phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java phenote/trunk/src/java/phenote/charactertemplate/TreeChooser.java phenote/trunk/src/java/phenote/dataadapter/CharacterListManager.java phenote/trunk/src/java/phenote/dataadapter/LoadSaveManager.java Modified: phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java =================================================================== --- phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java 2007-10-03 17:34:22 UTC (rev 952) +++ phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java 2007-10-03 19:15:27 UTC (rev 953) @@ -4,6 +4,7 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -28,6 +29,8 @@ import phenote.config.Config; import phenote.config.xml.GroupDocument.Group; import phenote.config.xml.TemplatechooserDocument.Templatechooser; +import phenote.dataadapter.CharListChangeEvent; +import phenote.dataadapter.CharListChangeListener; import phenote.dataadapter.CharacterListManager; import phenote.dataadapter.LoadSaveManager; import phenote.datamodel.CharField; @@ -50,7 +53,7 @@ import ca.odell.glazedlists.swing.TableComparatorChooser; import ca.odell.glazedlists.swing.TextComponentMatcherEditor; -public class CharacterTemplateController implements ActionListener, TemplateChoiceListener, CharChangeListener { +public class CharacterTemplateController implements ActionListener, TemplateChoiceListener, CharChangeListener, CharListChangeListener { public static final String SHOW_CHARACTER_TEMPLATE_ACTION = "showCharacterTemplate"; public static final String IMPORT_TEMPLATE_CHARACTERS_ACTION = "importCharacters"; @@ -75,6 +78,7 @@ super(); this.representedGroup = groupName; this.characterListManager = new CharacterListManager(); + CharacterListManager.main().addCharListChangeListener(this); this.editManager = new EditManager(this.characterListManager); this.editManager.addCharChangeListener(this); this.selectionManager = new SelectionManager(); @@ -194,6 +198,27 @@ } } + public void newCharList(CharListChangeEvent e) { + // this is assumed to be coming from the main CharacterListManager + this.tryLoadDefaultDataFile(); + } + + private void tryLoadDefaultDataFile() { + final File file = CharacterListManager.main().getCurrentDataFile(); + if (file == null) { + return; + } + final int dotLocation = file.getName().lastIndexOf("."); + final boolean hasExtension = dotLocation > 0; + final String extension = hasExtension ? file.getName().substring(dotLocation) : ""; + final String baseName = hasExtension ? file.getName().substring(0, dotLocation) : file.getName(); + final String defaultFileName = baseName + "-" + this.representedGroup + extension; + File templatesFile = new File(file.getParent(), defaultFileName); + if (templatesFile.exists()) { + this.getLoadSaveManager().loadData(templatesFile); + } + } + private void setSelectionWithCharacters(List<CharacterI> characters) { this.filterField.setText(""); this.selectionModel.clearSelection(); @@ -295,7 +320,7 @@ this.termInfoPanelContainer.add(termInfo.getComponent()); return component; } catch (Exception e) { - this.getLogger().error("Unable to render interface", e); + this.log().error("Unable to render interface", e); return new JPanel(); } } @@ -321,11 +346,11 @@ Object chooser = adapterClass.newInstance(); return (TemplateChooser)chooser; } catch (ClassNotFoundException e) { - this.getLogger().error(errorMessage, e); + this.log().error(errorMessage, e); } catch (InstantiationException e) { - this.getLogger().error(errorMessage, e); + this.log().error(errorMessage, e); } catch (IllegalAccessException e) { - this.getLogger().error(errorMessage, e); + this.log().error(errorMessage, e); } return null; } @@ -354,7 +379,7 @@ return this.loadSaveManager; } - private Logger getLogger() { + private Logger log() { return Logger.getLogger(this.getClass()); } Modified: phenote/trunk/src/java/phenote/charactertemplate/TreeChooser.java =================================================================== --- phenote/trunk/src/java/phenote/charactertemplate/TreeChooser.java 2007-10-03 17:34:22 UTC (rev 952) +++ phenote/trunk/src/java/phenote/charactertemplate/TreeChooser.java 2007-10-03 19:15:27 UTC (rev 953) @@ -1,6 +1,10 @@ package phenote.charactertemplate; import java.awt.Color; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.io.StringReader; @@ -28,11 +32,14 @@ import org.geneontology.oboedit.datamodel.OBOClass; import org.swixml.SwingEngine; +import phenote.dataadapter.CharListChangeEvent; +import phenote.dataadapter.CharListChangeListener; +import phenote.dataadapter.CharacterListManager; import phenote.datamodel.CharFieldValue; import phenote.datamodel.CharacterI; import phenote.util.FileUtil; -public class TreeChooser extends AbstractTemplateChooser { +public class TreeChooser extends AbstractTemplateChooser implements CharListChangeListener { private JFrame window; private TreeViewer treeViewer; @@ -40,6 +47,11 @@ private JLabel newickFieldLabel; // initialized by swix private JPanel treeViewerContainer; // initialized by swix + public TreeChooser() { + super(); + CharacterListManager.main().addCharListChangeListener(this); + } + public void showChooser() { this.getWindow().setVisible(true); } @@ -54,7 +66,7 @@ public Collection<CharacterI> getChosenTemplates(Collection<CharacterI> candidates) { if (this.getCharField() == null) { - this.getLogger().error("CharField not set for TreeChooser - no matching templates."); + this.log().error("CharField not set for TreeChooser - no matching templates."); return Collections.emptyList(); } final Collection<String> chosenTermIDs = this.getChosenTermIDs(); @@ -89,6 +101,11 @@ } } + public void newCharList(CharListChangeEvent e) { + // this is assumed to be coming from the main CharacterListManager + this.tryLoadDefaultDataFile(); + } + private Set<String> getChosenTermIDs() { final Set<String> termIDs = new HashSet<String>(); final Set<Node> nodes = this.getTreeViewer().getTreePane().getSelectedNodes(); @@ -127,7 +144,7 @@ JComponent component = (JComponent)swix.render(FileUtil.findUrl("tree_chooser.xml")); return component; } catch (Exception e) { - this.getLogger().error("Unable to render interface", e); + this.log().error("Unable to render interface", e); return new JPanel(); } } @@ -143,12 +160,35 @@ return Utils.rootTheTree(importer.importNextTree()); } catch (IOException e) { // this is unlikely since we're using a StringReader - this.getLogger().error("Can't read tree, newick text must be null", e); + this.log().error("Can't read tree, newick text must be null", e); return null; } } - private Logger getLogger() { + private void tryLoadDefaultDataFile() { + final File file = CharacterListManager.main().getCurrentDataFile(); + if (file == null) { + return; + } + final int dotLocation = file.getName().lastIndexOf("."); + final boolean hasExtension = dotLocation > 0; + final String baseName = hasExtension ? file.getName().substring(0, dotLocation) : file.getName(); + final String defaultFileName = baseName + ".tre"; + File treeFile = new File(file.getParent(), defaultFileName); + if (treeFile.exists()) { + // the tree must be on the first line and contain no linebreaks + try { + String newick = (new BufferedReader(new FileReader(treeFile))).readLine(); + this.setNewickTree(newick); + } catch (FileNotFoundException e) { + log().error("Could open tree file", e); + } catch (IOException e) { + log().error("Could open tree file", e); + } + } + } + + private Logger log() { return Logger.getLogger(this.getClass()); } Modified: phenote/trunk/src/java/phenote/dataadapter/CharacterListManager.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/CharacterListManager.java 2007-10-03 17:34:22 UTC (rev 952) +++ phenote/trunk/src/java/phenote/dataadapter/CharacterListManager.java 2007-10-03 19:15:27 UTC (rev 953) @@ -2,6 +2,7 @@ // I think this makes more sense in dataadapter than datamodel ? // actually should go in edit package maybe? +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -9,9 +10,9 @@ import javax.swing.JOptionPane; +import phenote.datamodel.CharacterI; import phenote.datamodel.CharacterList; import phenote.datamodel.CharacterListI; -import phenote.datamodel.CharacterI; import phenote.datamodel.OntologyManager; /** Contains current CharacterList. sends out CharacterListChanged events @@ -24,6 +25,7 @@ private CharacterListI characterList = new CharacterList(); private List<CharListChangeListener> listenerList = new ArrayList<CharListChangeListener>(6); + private File currentFile; // can hold source of current character list if loaded from a file // public CharacterListManager() {} @@ -80,5 +82,14 @@ characterList.clear(); // notify listeners??? } + + public File getCurrentDataFile() { + return this.currentFile; + } + + public void setCurrentDataFile(File aFile) { + this.currentFile = aFile; + } + } Modified: phenote/trunk/src/java/phenote/dataadapter/LoadSaveManager.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/LoadSaveManager.java 2007-10-03 17:34:22 UTC (rev 952) +++ phenote/trunk/src/java/phenote/dataadapter/LoadSaveManager.java 2007-10-03 19:15:27 UTC (rev 953) @@ -84,6 +84,7 @@ return; } else { + this.characterListManager.setCurrentDataFile(f); this.characterListManager.setCharacterList(this,charList); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-10-03 17:34:23
|
Revision: 952 http://obo.svn.sourceforge.net/obo/?rev=952&view=rev Author: nlw Date: 2007-10-03 10:34:22 -0700 (Wed, 03 Oct 2007) Log Message: ----------- Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/LoadingScreen.java Added Paths: ----------- phenote/trunk/images/elephant_header.jpg Added: phenote/trunk/images/elephant_header.jpg =================================================================== (Binary files differ) Property changes on: phenote/trunk/images/elephant_header.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: phenote/trunk/src/java/phenote/gui/LoadingScreen.java =================================================================== --- phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:17:18 UTC (rev 951) +++ phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 17:34:22 UTC (rev 952) @@ -64,11 +64,12 @@ panel.setBackground(Color.WHITE); getContentPane().add(panel, BorderLayout.CENTER); - ImageIcon imageIcon = new ImageIcon("/phenote/images/elephant_header.jpg"); + ImageIcon imageIcon = new ImageIcon("images/elephant_header.jpg"); JLabel logo = new JLabel(); // logo.createTitle(""); - logo.setIcon(SwingResourceManager.getIcon(LoadingScreen.class, "/phenote/images/elephant_header.jpg")); + logo.setIcon(imageIcon); + // logo.setIcon(SwingResourceManager.getIcon(LoadingScreen.class, "images/elephant_header.jpg")); startupProgressBar = new JProgressBar(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-10-03 08:17:14
|
Revision: 951 http://obo.svn.sourceforge.net/obo/?rev=951&view=rev Author: nlw Date: 2007-10-03 01:17:18 -0700 (Wed, 03 Oct 2007) Log Message: ----------- *the swt designer class Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/LoadingScreen.java Added Paths: ----------- phenote/trunk/src/java/com/ phenote/trunk/src/java/com/swtdesigner/ phenote/trunk/src/java/com/swtdesigner/SwingResourceManager.java Added: phenote/trunk/src/java/com/swtdesigner/SwingResourceManager.java =================================================================== --- phenote/trunk/src/java/com/swtdesigner/SwingResourceManager.java (rev 0) +++ phenote/trunk/src/java/com/swtdesigner/SwingResourceManager.java 2007-10-03 08:17:18 UTC (rev 951) @@ -0,0 +1,158 @@ +package com.swtdesigner; + +import java.awt.Image; +import java.awt.Toolkit; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Iterator; +import javax.swing.ImageIcon; + +/** + * Utility class for managing resources such as colors, fonts, images, etc. + * + * This class may be freely distributed as part of any application or plugin. + * <p> + * Copyright (c) 2003 - 2004, Instantiations, Inc. <br>All Rights Reserved + * + * @author scheglov_ke + */ +public class SwingResourceManager { + + /** + * Maps image names to images + */ + private static HashMap<String, Image> m_ClassImageMap = new HashMap<String, Image>(); + + /** + * Returns an image encoded by the specified input stream + * @param is InputStream The input stream encoding the image data + * @return Image The image encoded by the specified input stream + */ + private static Image getImage(InputStream is) { + try { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + byte buf[] = new byte[1024 * 4]; + while (true) { + int n = is.read(buf); + if (n == -1) + break; + baos.write(buf, 0, n); + } + baos.close(); + return Toolkit.getDefaultToolkit().createImage(baos.toByteArray()); + } catch (Throwable e) { + return null; + } + } + + /** + * Returns an image stored in the file at the specified path relative to the specified class + * @param clazz Class The class relative to which to find the image + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(Class clazz, String path) { + String key = clazz.getName() + '|' + path; + Image image = m_ClassImageMap.get(key); + if (image == null) { + if ((path.length() > 0) && (path.charAt(0) == '/')) { + String newPath = path.substring(1, path.length()); + image = getImage(new BufferedInputStream(clazz.getClassLoader().getResourceAsStream(newPath))); + } else { + image = getImage(clazz.getResourceAsStream(path)); + } + m_ClassImageMap.put(key, image); + } + return image; + } + + /** + * Returns an image stored in the file at the specified path + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(String path) { + return getImage("default", path); //$NON-NLS-1$ + } + + /** + * Returns an image stored in the file at the specified path + * @param section String The storage section in the cache + * @param path String The path to the image file + * @return Image The image stored in the file at the specified path + */ + public static Image getImage(String section, String path) { + String key = section + '|' + SwingResourceManager.class.getName() + '|' + path; + Image image = m_ClassImageMap.get(key); + if (image == null) { + try { + FileInputStream fis = new FileInputStream(path); + image = getImage(fis); + m_ClassImageMap.put(key, image); + fis.close(); + } catch (IOException e) { + return null; + } + } + return image; + } + + /** + * Clear cached images in specified section + * @param section the section do clear + */ + public static void clearImages(String section) { + for (Iterator I = m_ClassImageMap.keySet().iterator(); I.hasNext();) { + String key = (String) I.next(); + if (!key.startsWith(section + '|')) + continue; + Image image = m_ClassImageMap.get(key); + image.flush(); + I.remove(); + } + } + + /** + * Returns an icon stored in the file at the specified path relative to the specified class + * @param clazz Class The class relative to which to find the icon + * @param path String The path to the icon file + * @return Icon The icon stored in the file at the specified path + */ + public static ImageIcon getIcon(Class clazz, String path) { + return getIcon(getImage(clazz, path)); + } + + /** + * Returns an icon stored in the file at the specified path + * @param path String The path to the icon file + * @return Icon The icon stored in the file at the specified path + */ + public static ImageIcon getIcon(String path) { + return getIcon("default", path); //$NON-NLS-1$ + } + + /** + * Returns an icon stored in the file at the specified path + * @param section String The storage section in the cache + * @param path String The path to the icon file + * @return Icon The icon stored in the file at the specified path + */ + public static ImageIcon getIcon(String section, String path) { + return getIcon(getImage(section, path)); + } + + /** + * Returns an icon based on the specified image + * @param image Image The original image + * @return Icon The icon based on the image + */ + public static ImageIcon getIcon(Image image) { + if (image == null) + return null; + return new ImageIcon(image); + } +} \ No newline at end of file Property changes on: phenote/trunk/src/java/com/swtdesigner/SwingResourceManager.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: phenote/trunk/src/java/phenote/gui/LoadingScreen.java =================================================================== --- phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:14:23 UTC (rev 950) +++ phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:17:18 UTC (rev 951) @@ -25,7 +25,7 @@ import org.jdesktop.layout.GroupLayout; import org.jdesktop.layout.LayoutStyle; //import com.jgoodies.forms.factories.DefaultComponentFactory; -//import com.swtdesigner.SwingResourceManager; +import com.swtdesigner.SwingResourceManager; import phenote.error.ErrorEvent; import phenote.error.ErrorListener; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-10-03 08:14:19
|
Revision: 950 http://obo.svn.sourceforge.net/obo/?rev=950&view=rev Author: nlw Date: 2007-10-03 01:14:23 -0700 (Wed, 03 Oct 2007) Log Message: ----------- *geez, one more bad jar reference taken out Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/LoadingScreen.java Modified: phenote/trunk/src/java/phenote/gui/LoadingScreen.java =================================================================== --- phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:12:31 UTC (rev 949) +++ phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:14:23 UTC (rev 950) @@ -24,8 +24,8 @@ import org.jdesktop.layout.GroupLayout; import org.jdesktop.layout.LayoutStyle; -import com.jgoodies.forms.factories.DefaultComponentFactory; -import com.swtdesigner.SwingResourceManager; +//import com.jgoodies.forms.factories.DefaultComponentFactory; +//import com.swtdesigner.SwingResourceManager; import phenote.error.ErrorEvent; import phenote.error.ErrorListener; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-10-03 08:12:28
|
Revision: 949 http://obo.svn.sourceforge.net/obo/?rev=949&view=rev Author: nlw Date: 2007-10-03 01:12:31 -0700 (Wed, 03 Oct 2007) Log Message: ----------- *removed one bad error from ontology data adapter Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-03 08:03:53 UTC (rev 948) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-03 08:12:31 UTC (rev 949) @@ -596,7 +596,6 @@ if (fieldConfig.hasOntologies()) { for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { - phenote.loadingScreen.setMessageText("loading separate obo session with "+o.getName()); Ontology o = initOntology(oc); // LOAD OBO SESSION if (oc.isPostCompRel()) { // POST COMP REL ONTOLOGY cf.setPostCompAllowed(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-10-03 08:03:57
|
Revision: 948 http://obo.svn.sourceforge.net/obo/?rev=948&view=rev Author: nlw Date: 2007-10-03 01:03:53 -0700 (Wed, 03 Oct 2007) Log Message: ----------- *added in a new loading screen that has a better progress bar, and indicates what is going on behind the scenes for the user. its a start. not all the code is cleaned up yet. want to add better response/progressbar updates from oboedit to indicate percent done loading, etc. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/main/Phenote.java Added Paths: ----------- phenote/trunk/src/java/phenote/gui/LoadingScreen.java phenote/trunk/src/java/phenote/images/OK.GIF phenote/trunk/src/java/phenote/images/arrow.small.left.gif phenote/trunk/src/java/phenote/images/arrow.small.right.gif phenote/trunk/src/java/phenote/images/elephant_header.jpg phenote/trunk/src/java/phenote/images/star2.gif Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-02 19:49:03 UTC (rev 947) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-03 08:03:53 UTC (rev 948) @@ -21,6 +21,11 @@ import java.util.HashMap; import java.util.Map; +import java.beans.PropertyChangeEvent; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + + import org.apache.log4j.Logger; import org.geneontology.dataadapter.DataAdapterException; import org.geneontology.dataadapter.IOOperation; @@ -40,6 +45,7 @@ import phenote.error.ErrorManager; import phenote.gui.SynchOntologyDialog; import phenote.util.FileUtil; +import phenote.main.Phenote; /** is this really a data adapter? - OntologyLoader? this isnt a data adapter it doesnt load & commit character data - just loads ontologies. rename OntologyLoader @@ -53,9 +59,10 @@ private boolean initializingOntologies = false; private Map<String,Ontology> fileToOntologyCache = new HashMap<String,Ontology>(); private OBOMetaData adapterMetaData; - + private Phenote phenote = Phenote.getPhenote(); private static final Logger LOG = Logger.getLogger(OntologyDataAdapter.class); - + private int numFiles; + private int progressFactor=3; // does this need to be false for zfin private static final boolean DO_ONE_OBO_SESSION = true; @@ -126,8 +133,9 @@ for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { String file = findOboUrlString(oc); // throws oex if not found - if (!files.contains(file)) // dont load file twice + if (!files.contains(file)) { // dont load file twice files.add(file); + } } catch (OntologyException e) { String m = e.getMessage()+" Please check config & obo files"; @@ -136,6 +144,9 @@ } } // should we have singleOboSession instance var?? or confusing with multi? + numFiles = files.size(); + progressFactor = 1+(10/numFiles); //this is kind of a hack right now until we get threading + System.out.println("numfiles="+numFiles); OBOSession os = getOboSession(files); return os; } @@ -153,6 +164,7 @@ /** This actually creates both CharFields and Ontologies and maps namespaces from obo file adapter meta data */ private void mapNamespacesToOntologies(OBOSession oboSession) throws OntologyException { + int progress = phenote.loadingScreen.getStartupProgress(); for (FieldConfig fieldConfig : cfg().getEnbldFieldCfgs()) { CharField cf = fieldConfig.getCharField(); // creates char field (if not there) // ontology manager.addCF??? @@ -172,8 +184,13 @@ String urlString = oc.getLoadUrl().toString(); Collection<Namespace> spaces = adapterMetaData.getNamespaces(urlString); // loads ontology from spaces + //ah! but this is loading the ontologies multiple times i think! Ontology o = new Ontology(spaces,oc,oboSession); + progress+=progressFactor; + phenote.loadingScreen.setMessageText("loading: "+o.getName()); + phenote.loadingScreen.setProgress(progress); + // ADD TO CHAR FIELD if (oc.isPostCompRel()) { // POST COMP REL ONTOLOGY cf.setPostCompAllowed(true); @@ -205,6 +222,7 @@ private URL findOboUrl(OntologyConfig ontCfg) throws OntologyException { // first get local url (if there is one) to use to compare against repos url // get normal/cached/local ontology + int progress = phenote.loadingScreen.getStartupProgress(); String filename = ontCfg.getFile(); if (filename == null) throw new OntologyException(ontCfg.getName()+" has null file"); @@ -222,6 +240,9 @@ URL reposUrl = ontCfg.getReposUrl(); // throws MalfUrlEx //long mem = Runtime.getRuntime().totalMemory()/1000000; //startTimer(); LOG.debug(reposUrl+" checking with repos for newer ontol\n"); + phenote.loadingScreen.setMessageText("checking for updates: "+ontCfg.getName()); + progress+=progressFactor; + phenote.loadingScreen.setProgress(progress); // if out of synch copies repos to local(.phenote/obo-files) // url may be jar/obo-files or svn/obo-files but this function will put file // in cache ~/.phenote/obo-files @@ -247,8 +268,11 @@ called by findOboUrl which has already established that the reposUrl exists */ private URL synchWithRepositoryUrl(URL localUrl, URL reposUrl, String ontol, String filename) + throws OntologyException { + int progress = phenote.loadingScreen.getStartupProgress(); + boolean useRepos = false; if (localUrl == null) { useRepos = true; @@ -295,9 +319,18 @@ // download obo to local cache (takes time!) String file = localUrl!=null ? FileUtil.getNameOfFile(localUrl) : filename; //String file = FileUtil.getNameOfFile(localUrl); + phenote.loadingScreen.setMessageText("updating ontology file: "+ontol); + progress+=progressFactor; + phenote.loadingScreen.setProgress(progress); + + try { localUrl = new File(FileUtil.getDotPhenoteOboDir(),file).toURL(); LOG.info("Downloading new ontology from repository "+reposUrl+" to "+localUrl); + phenote.loadingScreen.setMessageText("downloading from repository: "+ontol); + progress+=progressFactor; + phenote.loadingScreen.setProgress(progress); + copyReposToLocal(reposUrl,localUrl); } catch (MalformedURLException e) { throw new OntologyException(e); } @@ -406,6 +439,7 @@ cfg.setReadPaths(fileList); cfg.setBasicSave(false); //i think i need this for dangling references cfg.setAllowDangling(true); //setting this to true for now! should be configrable + phenote.loadingScreen.setMessageText("loading ontologies into memory"); try { // throws data adapter exception OBOSession os = (OBOSession)fa.doOperation(IOOperation.READ,cfg,null); adapterMetaData = fa.getMetaData(); // check for null? @@ -492,7 +526,7 @@ /** If repository is configured loads obo from repos if local out of date */ private void loadOboSessionCheckRepos(Ontology o,OntologyConfig oc) throws OntologyException { - + int progress = phenote.loadingScreen.getStartupProgress(); // // first get normal/cached/local ontology // String filename = oc.getFile(); // // throws OntologyEx if file not found -- need to catch - should still try url @@ -521,6 +555,9 @@ long mem = Runtime.getRuntime().totalMemory()/1000000; LOG.debug(url+" checking with repos... loading obo session mem "+mem+"\n"); + progress+=progressFactor; + phenote.loadingScreen.setMessageText("checking for updates: "+o.getName()); + phenote.loadingScreen.setProgress(progress); startTimer(); loadOboSessionFromUrl(o,url,oc.getFile()); @@ -534,6 +571,7 @@ private void loadOboSessionFromUrl(Ontology o, URL url, String filename) throws OntologyException { //URL url = findFile(filename); // throws OntologyEx if file not found + phenote.loadingScreen.setMessageText("doing something with "+o.getName()); o.setOboSession(getOboSession(url)); // throws OntEx if error if (filename!=null) fileToOntologyCache.put(filename,o); // ?? @@ -558,6 +596,7 @@ if (fieldConfig.hasOntologies()) { for (OntologyConfig oc : fieldConfig.getOntologyConfigList()) { try { + phenote.loadingScreen.setMessageText("loading separate obo session with "+o.getName()); Ontology o = initOntology(oc); // LOAD OBO SESSION if (oc.isPostCompRel()) { // POST COMP REL ONTOLOGY cf.setPostCompAllowed(true); @@ -578,6 +617,19 @@ // i think this order needs to be same as config order ontologyManager.addField(cf); } + +// public OntologyPropertyListener() implements PropertyChangeListener { +// public void propertyChange(PropertyChangeEvent e) { +// String propertyName = e.getPropertyName(); +// if ("loading".equals(propertyName) { +// loadingScreen. +// } else if ("config".equals(propertyName) { +// } else { +// +// } +// } +// ... +// } } // private void loadRelationshipOntology() { hmmmmmm Added: phenote/trunk/src/java/phenote/gui/LoadingScreen.java =================================================================== --- phenote/trunk/src/java/phenote/gui/LoadingScreen.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/LoadingScreen.java 2007-10-03 08:03:53 UTC (rev 948) @@ -0,0 +1,222 @@ +package phenote.gui; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.lang.Object; + +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JTextPane; +import javax.swing.SwingConstants; +import javax.swing.SwingUtilities; +import java.awt.event.ActionListener; +//import javax.swing.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + + +import org.jdesktop.layout.GroupLayout; +import org.jdesktop.layout.LayoutStyle; +import com.jgoodies.forms.factories.DefaultComponentFactory; +import com.swtdesigner.SwingResourceManager; + +import phenote.error.ErrorEvent; +import phenote.error.ErrorListener; +import phenote.main.PhenoteVersion; + +public class LoadingScreen extends JFrame { + + /** + * Launch the application + * @param args + */ +// public static void main(String args[]) { +// try { +// LoadingScreen frame = new LoadingScreen(); +// frame.setVisible(true); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + +// JProgressBar ontologyProgressBar; + JProgressBar startupProgressBar; + JLabel message; + + /** + * Create the frame + */ + public LoadingScreen() { + super(); + setBackground(Color.WHITE); + getContentPane().setBackground(Color.WHITE); + setBounds(100, 100, 500, 375); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + final JPanel panel = new JPanel(); + panel.setBackground(Color.WHITE); + getContentPane().add(panel, BorderLayout.CENTER); + + ImageIcon imageIcon = new ImageIcon("/phenote/images/elephant_header.jpg"); + + JLabel logo = new JLabel(); +// logo.createTitle(""); + logo.setIcon(SwingResourceManager.getIcon(LoadingScreen.class, "/phenote/images/elephant_header.jpg")); + + + startupProgressBar = new JProgressBar(); + startupProgressBar.setString(""); + startupProgressBar.setStringPainted(true); + startupProgressBar.setMaximum(100); + startupProgressBar.setValue(0); + + message = new JLabel(); + message.setHorizontalAlignment(SwingConstants.CENTER); + message.setText("Initializing..."); + + JLabel versionLabel; + versionLabel = new JLabel(); + versionLabel.setHorizontalAlignment(SwingConstants.CENTER); + versionLabel.setText("version "+ PhenoteVersion.versionString()); + + + final GroupLayout groupLayout_1 = new GroupLayout((JComponent) panel); + groupLayout_1.setHorizontalGroup( + groupLayout_1.createParallelGroup(GroupLayout.LEADING) + .add(groupLayout_1.createSequentialGroup() + .add(87, 87, 87) + .add(logo) + .addContainerGap(87, Short.MAX_VALUE)) + .add(groupLayout_1.createSequentialGroup() + .add(96, 96, 96) + .add(versionLabel, GroupLayout.PREFERRED_SIZE, 309, GroupLayout.PREFERRED_SIZE) + .addContainerGap(95, Short.MAX_VALUE)) + .add(GroupLayout.TRAILING, groupLayout_1.createSequentialGroup() + .add(43, 43, 43) + .add(message, GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE) + .add(40, 40, 40)) + .add(groupLayout_1.createSequentialGroup() + .add(64, 64, 64) + .add(startupProgressBar, GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE) + .add(63, 63, 63)) + ); + groupLayout_1.setVerticalGroup( + groupLayout_1.createParallelGroup(GroupLayout.TRAILING) + .add(GroupLayout.LEADING, groupLayout_1.createSequentialGroup() + .add(24, 24, 24) + .add(logo) + .addPreferredGap(LayoutStyle.RELATED) + .add(versionLabel) + .addPreferredGap(LayoutStyle.RELATED, 83, Short.MAX_VALUE) + .add(startupProgressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addPreferredGap(LayoutStyle.RELATED) + .add(message)) + ); + panel.setLayout(groupLayout_1); + + final JPanel footerPanel = new JPanel(); + footerPanel.setBackground(Color.WHITE); + getContentPane().add(footerPanel, BorderLayout.SOUTH); + + JTextPane footerTextPane; + footerTextPane = new JTextPane(); + footerTextPane.setContentType("text/html"); + footerTextPane.setFont(new Font("Helvetica", Font.PLAIN, 9)); + footerTextPane.setAutoscrolls(false); + footerTextPane.setEditable(false); + footerTextPane.setText("<html><body><center><font size=2>Phenote is part of the <a href='http://www.bioontology.org'>" + + "National Center for Biomedical Ontology</a>, <br>" + + "a part of the <a href='http://www.bisti.nih.gov/ncbc/index.cfm'> National " + + "Centers for Biomedical Computing</a>, and is supported by the <a href='http://nihroadmap.nih.gov/'> NIH Roadmap</a>.<br> " + + "Developed at the Berkeley Bioinformatics and Ontologies Project (<a href='http://www.berkeleybop.org'>BBOP</a>)</font></center></body></html>"); + + final GroupLayout groupLayout = new GroupLayout((JComponent) footerPanel); + groupLayout.setHorizontalGroup( + groupLayout.createParallelGroup(GroupLayout.LEADING) + .add(groupLayout.createSequentialGroup() + .add(13, 13, 13) + .add(footerTextPane, GroupLayout.PREFERRED_SIZE, 475, GroupLayout.PREFERRED_SIZE) + .addContainerGap(12, Short.MAX_VALUE)) + ); + groupLayout.setVerticalGroup( + groupLayout.createParallelGroup(GroupLayout.TRAILING) + .add(groupLayout.createSequentialGroup() + .addContainerGap(70, Short.MAX_VALUE) + .add(footerTextPane, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + footerPanel.setLayout(groupLayout); + // + pack(); + } + + public void setMessageText(String m) { + message.setText(m); + pack(); + } + + public void setProgressMax(int maxProgress) + { +// ontologyProgressBar.setMaximum(maxProgress); + } + + public void setProgress(int progress) + { + final int theProgress = progress; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + startupProgressBar.setValue(theProgress); + } + }); + } + + public int getStartupProgress() { + return startupProgressBar.getValue(); + } + + public void setProgress(String message, int progress) + { + final int theProgress = progress; + final String theMessage = message; + setProgress(progress); + SwingUtilities.invokeLater(new Runnable() { + public void run() { +// ontologyProgressBar.setValue(theProgress); +// ontologyProgressBar.setString(theMessage); + } + }); + } + + public void setScreenVisible(boolean b) + { + final boolean boo = b; + SwingUtilities.invokeLater(new Runnable() { + public void run() { + setVisible(boo); + } + }); + } + + public void setMessage(String message) + { + if (message==null) + { + message = ""; +// ontologyProgressBar.setStringPainted(false); + } + else + { +// ontologyProgressBar.setStringPainted(true); + } +// ontologyProgressBar.setString(message); +// messagePanel.setText(message); + } + +} Property changes on: phenote/trunk/src/java/phenote/gui/LoadingScreen.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: phenote/trunk/src/java/phenote/images/OK.GIF =================================================================== (Binary files differ) Property changes on: phenote/trunk/src/java/phenote/images/OK.GIF ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/src/java/phenote/images/arrow.small.left.gif =================================================================== (Binary files differ) Property changes on: phenote/trunk/src/java/phenote/images/arrow.small.left.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/src/java/phenote/images/arrow.small.right.gif =================================================================== (Binary files differ) Property changes on: phenote/trunk/src/java/phenote/images/arrow.small.right.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/src/java/phenote/images/elephant_header.jpg =================================================================== (Binary files differ) Property changes on: phenote/trunk/src/java/phenote/images/elephant_header.jpg ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: phenote/trunk/src/java/phenote/images/star2.gif =================================================================== (Binary files differ) Property changes on: phenote/trunk/src/java/phenote/images/star2.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2007-10-02 19:49:03 UTC (rev 947) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2007-10-03 08:03:53 UTC (rev 948) @@ -29,6 +29,8 @@ import org.apache.log4j.Logger; import org.apache.log4j.xml.DOMConfigurator; +import com.sun.java.help.impl.SwingWorker; + import phenote.charactertemplate.CharacterTemplateController; import phenote.config.Config; import phenote.config.ConfigException; @@ -41,6 +43,7 @@ import phenote.error.ErrorManager; import phenote.gui.CharacterTableController; import phenote.gui.GridBagUtil; +import phenote.gui.LoadingScreen; import phenote.gui.MenuManager; import phenote.gui.SelectionHistory; import phenote.gui.SplashScreen; @@ -61,9 +64,11 @@ private CommandLine commandLine = CommandLine.inst(); private JFrame frame; public SplashScreen splashScreen; + public LoadingScreen loadingScreen; private String logoFile = "images/phenote_logo.jpg"; + // public static Keymap defaultKeymap; @@ -133,14 +138,25 @@ phenote.doCommandLine(args); // does config //new phenote.gui.ConfigGui(); // testing out + + /* set up the overall task of loading the software + there will be several events: + 1. loading configuration - display config name + 2. checking for ontology updates - per ontology display name + 3. updating ontologies (name) - downloading... display name + 4. loading into datamodel - display name - this is the bulk of the time + */ // put this is in a phenote.util.Log class? - get file from config - default? phenote.splashScreen.setProgress("Configuring...", 10); + phenote.loadingScreen.setMessageText("Loading configuration: "+Config.inst().getConfigName()); + phenote.loadingScreen.setProgress(5); // LOG4J if (!phenote.commandLine.isLogSpecified()) { try { DOMConfigurator.configure(Config.inst().getLogConfigUrl()); } catch (FileNotFoundException e) { phenote.splashScreen.setProgress("bad file:"+e.getMessage(),10); + phenote.loadingScreen.setMessageText("Bad config: "+e.getMessage()); LOG.error(e.getMessage()); } } @@ -148,10 +164,19 @@ LOG.debug("debug test2 of log4j"); phenote.splashScreen.setProgress("Initializing Ontologies...", 20); + phenote.loadingScreen.setMessageText("Initializing Ontologies"); + phenote.loadingScreen.setProgress(10); +// phenote.loadingScreen.setProgress(20); +// boolean done = false; + phenote.initOntologies(); phenote.splashScreen.setProgress("Ontologies Initialized", 70); + phenote.loadingScreen.setMessageText("Ontologies Initialized"); +// phenote.loadingScreen.setProgress(70); phenote.loadFromCommandLine(); // aft ontols, reads from cmd line if specified phenote.splashScreen.setProgress("Phenote Loaded", 100); + phenote.loadingScreen.setMessageText("Phenote Loaded"); + phenote.loadingScreen.setProgress(100); if (phenote.commandLine.writeIsSpecified()) { phenote.writeFromCommandLine(); // it hangs after writing - not sure why @@ -162,6 +187,7 @@ { phenote.initGui(); phenote.splashScreenDestruct(); +// phenote.loadingScreenDestruct(); } if (Config.inst().dataInputServletIsEnabled()) @@ -252,15 +278,19 @@ // ImageIcon myImage = new ImageIcon(logoFile); splashScreen = new SplashScreen(myImage,enable); + loadingScreen = new LoadingScreen(); + if (!enable) return; - splashScreen.setLocationRelativeTo(null); - splashScreen.setProgressMax(100); - splashScreen.setScreenVisible(true); - splashScreen.setProgress("Phenote version "+PhenoteVersion.versionString(), 0); +// splashScreen.setLocationRelativeTo(null); +// splashScreen.setProgressMax(100); +// splashScreen.setScreenVisible(true); + loadingScreen.setScreenVisible(true); +// splashScreen.setProgress("Phenote version "+PhenoteVersion.versionString(), 0); } private void splashScreenDestruct() { splashScreen.setScreenVisible(false); + loadingScreen.setScreenVisible(false); } private void doCommandLine(String[] args) { @@ -280,7 +310,16 @@ } } +// private void ontologyProgressChangeListener extends PropertyChangeListener { +// public void propertyChange(PropertyChangeEvent evt) { +// if (!done) { +// int progress = task.getProgress(); +// String m = "some ontology"; +// loadingScreen.setProgress(m, progress); +// } + + public Frame getFrame() { return frame; } private void makeMainWindow() { @@ -428,6 +467,8 @@ //public CharacterTablePanel getCharacterTablePanel() { return characterTablePanel; } public CharacterTableController getCharacterTableController() { return this.tableController; } + + } // /** args is most likely null if not called from command line */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-10-02 19:49:06
|
Revision: 947 http://obo.svn.sourceforge.net/obo/?rev=947&view=rev Author: mgibson Date: 2007-10-02 12:49:03 -0700 (Tue, 02 Oct 2007) Log Message: ----------- datamodel now parsing date for date fields - was taking in as string before Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java phenote/trunk/src/java/phenote/datamodel/AbstractCharacter.java phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldException.java phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java phenote/trunk/src/java/phenote/datamodel/CharacterI.java Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimFieldParser.java 2007-10-02 19:49:03 UTC (rev 947) @@ -73,10 +73,10 @@ if (cfv.isDangler()) // throw error if not term? cfv.setName(items[columnIndex+1]); } - // no longer thrown really - dangler created instead! - catch (TermNotFoundException e) { - LOG.error("Error: Term not found ("+value+") "+e.getMessage()+ - " (and no dangler created)"); + // no longer thrown for term not found - dangler created instead! + // this is thrown for faulty dates + catch (CharFieldException e) { + LOG.error(e.getMessage()); } } } Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-02 19:49:03 UTC (rev 947) @@ -14,7 +14,7 @@ import phenote.datamodel.CharacterI; import phenote.datamodel.CharacterIFactory; import phenote.datamodel.OntologyManager; -import phenote.datamodel.TermNotFoundException; +import phenote.datamodel.CharFieldException; /** I stole this from phenosyntaxchar, but modifying for tab delimited. will * initially hard code in the tab-delimiter, but eventually it should be generic to @@ -200,7 +200,7 @@ } - /** if term then value is ID and termName is name of term, if free text then + /** READ, if term then value is ID and termName is name of term, if free text then value is free text and termName is null */ private void addDelValToChar(int fieldNum, String value, String termName) { // it doesn't really matter if there's a blank column in this mode @@ -223,15 +223,15 @@ // set String -> for obo class automatically find term // if term not found makes a dangler //this assumes that you are loading data the same order you saved it - CharFieldValue v = character.setValue(cf,value); // throws TermNotFoundEx + CharFieldValue v = character.setValue(cf,value); // throws CFEx for bad date if (v.isDangler()) v.setName(termName); // ??? return; // if no ex thrown were done } - // no longer thrown really - dangler created instead! - catch (TermNotFoundException e) { - System.out.println("Error1: term not found ("+value+") "+e.getMessage()); - log().error("Error2: Term not found ("+value+") "+e.getMessage()); + // thrown for bad date, not for not found - dangler created instead! + catch (CharFieldException e) { + System.out.println(e.getMessage()); // ? + log().error(e.getMessage()); } } Modified: phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/dataadapter/phenosyntax/PhenoSyntaxChar.java 2007-10-02 19:49:03 UTC (rev 947) @@ -13,7 +13,7 @@ import phenote.datamodel.CharField; import phenote.datamodel.CharFieldValue; import phenote.datamodel.OntologyManager; -import phenote.datamodel.TermNotFoundException; +import phenote.datamodel.CharFieldException; import phenote.config.Config; import phenote.config.ConfigException; @@ -179,7 +179,7 @@ character.setValue(cf,value); // throws TermNotFoundEx return; // if no ex thrown were done } - catch (TermNotFoundException e) {} // do nothing - try next char field + catch (CharFieldException e) {} // do nothing - try next char field } } catch (ConfigException e) { log().error(e.getMessage()); } // field not found @@ -213,36 +213,3 @@ return log; } } -// try { -// if (tag.equals("PUB")) -// character.setPub(value); -// else if (tag.equals("GT")) -// character.setGenotype(value); -// else if (tag.equals("GC")) -// character.setGeneticContext(om.getOboClassWithExcep(value)); // throws ex -// else if (tag.equals("E")) -// 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? -// System.out.println("pheno syntax tag "+tag+" not recognized (value "+value+")"); -// } -// catch (OntologyManager.TermNotFoundException e) { -// log().error("Term not found for tag "+tag+" value "+value+" in loaded " -// +"ontologies - check syntax with ontology files."); -// return; -// } -// if (character.hasValue("Pub")) // hasPub -// sb.append("PUB=").append(character.getValueString("Pub")); //Pub()); -// // Genotype - not strictly part of pheno syntax but lets face it we need it -// // i would say its an omission from syntax -// //sb.append(" GT=").append(character.getGenotype()); -// if (character.hasValue("Genotype")) -// sb.append(" GT=").append(character.getValueString("Genotype")); -// if (character.hasValue("Genetic Context")) -// sb.append(" GC=").append(makeValue(character.getTerm("Genetic Context"))); - -// if (!character.hasValue("Entity")) -// throw new BadCharException("Error: character has no entity, ignoring"); -// //sb.append(" E=").append(makeValue(character.getEntity())); -// sb.append(" E=").append(makeValue(character.getTerm("Entity"))); Modified: phenote/trunk/src/java/phenote/datamodel/AbstractCharacter.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/AbstractCharacter.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/datamodel/AbstractCharacter.java 2007-10-02 19:49:03 UTC (rev 947) @@ -2,6 +2,8 @@ import java.util.List; +import org.apache.log4j.Logger; + import org.geneontology.oboedit.datamodel.OBOClass; public abstract class AbstractCharacter implements CharacterI { @@ -15,9 +17,10 @@ /** if term field, string should be id, obo class will be searched for, if class not found then dangler is created. if free text field just uses string of - course. the dangler makes termNotFoundEx irrelevant - take out? or will there - be a no dangler mode? probably not right? */ - public CharFieldValue setValue(CharField cf, String s) throws TermNotFoundException { + course. the dangler makes termNotFound Ex irrelevant - take out? or will there + be a no dangler mode? probably not right? + CharFieldEx thrown if improper date for date field */ + public CharFieldValue setValue(CharField cf, String s) throws CharFieldException { CharFieldValue cfv = cf.makeValue(this, s); setValue(cf, cfv); return cfv; @@ -171,14 +174,16 @@ } - public void setGenotype(String gt) { - try { - setValue(getGenotypeField(), gt); - } catch (CharFieldException x) { - throw new RuntimeException(x); - } catch (TermNotFoundException e) { - } // doesnt happen for free text field - } + // still used by phenoxml - phase out + public void setGenotype(String gt) { + try { + setValue(getGenotypeField(), gt); + } catch (CharFieldException x) { + //throw new RuntimeException(x); // runtime?? + log().error("Failed to set genotype "+x); + } + } + public String getGenotype() { try { return getValueString(getGenotypeField()); @@ -224,4 +229,9 @@ } } + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-02 19:49:03 UTC (rev 947) @@ -1,5 +1,6 @@ package phenote.datamodel; +import java.text.ParseException; import java.util.ArrayList; import java.util.List; @@ -134,6 +135,8 @@ return type == Type.TERM; } + public boolean isDate() { return type == Type.DATE; } + public boolean isID() { return type == Type.ID; } public boolean isReadOnly() { @@ -194,26 +197,21 @@ public Ontology getPostCompRelOntol() { return postCompRelOntol; } /** if free text returns string charfieldValue, for ontology field valueString is - id and searches ontologies for id, throws ontologyException if not found - this needs to deal with post comp!!!! */ + id and searches ontologies for id, throws CharFieldException if invalid date for + date field (used to for term not found but now creates dangler instead) + this deals with postcomp too */ public CharFieldValue makeValue(CharacterI c, String valueString) - throws TermNotFoundException { + throws CharFieldException { - // FREE TEXT FIELD - if (!hasOntologies()) // -> !isTerm() or isFreeText() - return new CharFieldValue(valueString,c,this); + // empty value + if (valueString == null || valueString.trim().equals("")) + return CharFieldValue.emptyValue(c,this); // TERM - else { - - // null term - if (valueString.trim().equals("")) - return CharFieldValue.emptyValue(c,this); - + if (isTerm()) { OBOClass oboClass=null; - // CHECK FOR POST COMP - could probably move this to char field but right now just - // trying to get this working before i split town... + // POST COMP - move this to char field value? if (OntologyManager.inst().isPostComp(valueString)) { try { // just gets first ontology for now - fix this! @@ -221,10 +219,9 @@ oboClass = OntologyManager.inst().getPostComp(os,valueString); } catch (TermNotFoundException e) {} - } - // TERM not post comp + // TERM regular, not post comp else { for (Ontology ont : ontologyList) { try { oboClass = ont.getTerm(valueString); } @@ -232,7 +229,7 @@ } } - // if cant find it make a dangler! + // DANGLER if cant find it make a dangler! if (oboClass == null && danglerMode()) { oboClass = new DanglingClassImpl(valueString); String e = valueString+" not found in loaded obo files. Creating a 'dangler'"; @@ -241,10 +238,29 @@ if (oboClass != null) return new CharFieldValue(oboClass,c,this); - else - throw new TermNotFoundException(valueString+" not found in ontologies for " - +this); + // if danglers are permanent this should be tossed as makes irrelevant + else { + TermNotFoundException e = + new TermNotFoundException(valueString+" not found in ontologies for "+this); + throw new CharFieldException(e); + } } + + // DATE + else if (isDate()) { + try { return CharFieldValue.makeDate(valueString,c,this); } + catch (ParseException e) { + throw new CharFieldException(e); + } + + } + + // FREE TEXT FIELD + //if (!hasOntologies()) // -> !isTerm() or isFreeText() + else + return new CharFieldValue(valueString,c,this); + + } // i think we eventually will want this always to be so Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldException.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldException.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldException.java 2007-10-02 19:49:03 UTC (rev 947) @@ -2,4 +2,5 @@ public class CharFieldException extends Exception { CharFieldException(String m) { super(m); } + CharFieldException(Exception e) { super(e); } } Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-02 19:49:03 UTC (rev 947) @@ -1,6 +1,7 @@ package phenote.datamodel; import java.text.DateFormat; +import java.text.ParseException; import java.util.Date; import org.geneontology.oboedit.datamodel.OBOClass; @@ -21,7 +22,7 @@ private OBOClass oboClassValue=null; private String stringValue=null; private Date dateValue=null; - private boolean isOboClass=true; + //private boolean isOboClass=true; private CharFieldEnum charFieldEnum; private CharField charField; // private CharField??? @@ -31,36 +32,30 @@ // phase out public CharFieldValue(String s,CharacterI c, CharFieldEnum e) { stringValue = s; - isOboClass = false; character = c; charFieldEnum = e; } - // for generic field - CharField or String??? + // for string field public CharFieldValue(String value,CharacterI c,CharField cf) { - //System.out.println("CFV const "+value); this(c,cf); stringValue = value; - isOboClass = false; } // phase out public CharFieldValue(OBOClass o,CharacterI c,CharFieldEnum e) { oboClassValue = o; - isOboClass = true; character = c; charFieldEnum = e; } public CharFieldValue(OBOClass o,CharacterI c,CharField cf) { this(c,cf); oboClassValue = o; - isOboClass = true; } public CharFieldValue(Date d, CharacterI c, CharField cf) { this(c,cf); dateValue = d; - isOboClass = false; } private CharFieldValue(CharacterI c,CharField cf) { @@ -68,10 +63,17 @@ charField = cf; } + /** dateString is a date, if not valid date throws ParseEx */ + static CharFieldValue makeDate(String dateString, CharacterI c, CharField cf) + throws ParseException { + CharFieldValue cfv = new CharFieldValue(c,cf); + cfv.dateValue = DateFormat.getDateInstance().parse(dateString); + return cfv; + } + CharFieldValue cloneCharFieldValue() { if (!charField.getCopyEnabled()) { CharFieldValue nullCloneValue = new CharFieldValue(character, charField); - nullCloneValue.isOboClass = isOboClass; return nullCloneValue; } // return null; // null?? new CharFieldValue(character @@ -86,17 +88,20 @@ // } static CharFieldValue emptyValue(CharacterI c,CharField cf) { - if (cf.hasOntologies()) - return new CharFieldValue((OBOClass)null,c,cf); - else - return new CharFieldValue((String)null,c,cf); // ""? + // everything is null, type from char field + return new CharFieldValue(c,cf); +// if (cf.isTerm()) +// return new CharFieldValue((OBOClass)null,c,cf); +// else if (cf.isDate()) +// else +// return new CharFieldValue((String)null,c,cf); // ""? } void setCharacter(CharacterI c) { character = c; } public CharacterI getCharacter() { return character; } boolean isEmpty() { - if (isOboClass) + if (isTerm()) return oboClassValue == null; else if (isDate()) return dateValue == null; @@ -130,9 +135,9 @@ stringValue = name; } - public boolean isTerm() { return isOboClass; } + public boolean isTerm() { return getCharField().isTerm(); } - public boolean isDate() { return dateValue != null; } + public boolean isDate() { return getCharField().isDate(); } public Date getDate() { return dateValue; } public OBOClass getOboClass() { return getTerm(); } // --> getTerm more general Modified: phenote/trunk/src/java/phenote/datamodel/CharacterI.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2007-10-01 22:00:24 UTC (rev 946) +++ phenote/trunk/src/java/phenote/datamodel/CharacterI.java 2007-10-02 19:49:03 UTC (rev 947) @@ -27,7 +27,7 @@ if cf is a term will look for OBOClass with ID in valueString, if ID not found will create dangler which actually makes TermNotFoundEx irrelevant take out? or do we want a non-dangler mode?? */ - public CharFieldValue setValue(CharField cf, String valueString) throws TermNotFoundException; + public CharFieldValue setValue(CharField cf, String valueString) throws CharFieldException; public CharField getCharFieldForName(String fieldName) throws CharFieldException; public CharFieldValue getValue(CharField cf); public String getValueString(CharField cf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-10-01 22:00:31
|
Revision: 946 http://obo.svn.sourceforge.net/obo/?rev=946&view=rev Author: mgibson Date: 2007-10-01 15:00:24 -0700 (Mon, 01 Oct 2007) Log Message: ----------- Date Created now reading and writing from tab delim automatically created with new annotations Modified Paths: -------------- phenote/trunk/src/java/phenote/config/Config.java phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/edit/AddTransaction.java Modified: phenote/trunk/src/java/phenote/config/Config.java =================================================================== --- phenote/trunk/src/java/phenote/config/Config.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/config/Config.java 2007-10-01 22:00:24 UTC (rev 946) @@ -874,14 +874,14 @@ // return fields; // } - public String getLabelForCharField(CharField cf) throws ConfigException { - for (FieldConfig fc : getEnbldFieldCfgs()) { - if (fc.hasCharField(cf)) - return fc.getLabel(); - } - // failed to find field config for char field - shouldnt happen - throw new ConfigException("Label for "+cf+" not found"); - } +// public String getLabelForCharField(CharField cf) throws ConfigException { +// for (FieldConfig fc : getEnbldFieldCfgs()) { +// if (fc.hasCharField(cf)) +// return fc.getLabel(); +// } +// // failed to find field config for char field - shouldnt happen +// throw new ConfigException("Label for "+cf+" not found"); +// } public String getSyntaxAbbrevForCharField(CharField cf) throws ConfigException { for (FieldConfig fc : getEnbldFieldCfgs()) { Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-01 22:00:24 UTC (rev 946) @@ -94,35 +94,29 @@ } + // Character -> String, for writeback of course private String makeDelimitedString() throws BadCharException { if (character == null) { // shouldnt happen log().error("Error: no Character to make delimited string with"); return ""; //?? } StringBuffer sb = new StringBuffer(); -//***************** - try { - - // ontology manager should have char fields in order of config which should be - // syntax order - hope this isnt too presumptious - for (CharField cf : OntologyManager.inst().getCharFieldList()) { - if (character.hasValue(cf)) { - Config.inst().getLabelForCharField(cf); - // sb.append(Config.inst().getLabelForCharField(cf)); - sb.append(makeValue(character.getValue(cf))); - } - else if (isTerm(cf)) sb.append(delimiter); - //need to make sure to add extra delimiter for ontology fields - sb.append(delimiter); - } - + //try { + // ontology manager should have char fields in order of config which should be + // syntax order - hope this isnt too presumptious + for (CharField cf : OntologyManager.inst().getCharFieldList()) { + if (character.hasValue(cf)) { + sb.append(makeValue(character.getValue(cf))); } - catch (ConfigException e) { - throw new BadCharException(e.getMessage()); - } + // if empty term then do 2 delimiters since it takes up 2 spots + else if (isTerm(cf)) sb.append(delimiter); + //need to make sure to add extra delimiter for ontology fields + sb.append(delimiter); + } - - return sb.toString(); +// }catch(ConfigException e){throw new BadCharException(e.getMessage());} + + return sb.toString(); } /** If a char field has ontologies it is not free text */ @@ -142,7 +136,7 @@ private String makeValue(CharFieldValue v) { if (v.isTerm()) return makeTermValue(v.getOboClass()); - return v.getName(); + return v.getValueAsString(); } private String makeTermValue(OBOClass term) { Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-01 22:00:24 UTC (rev 946) @@ -41,6 +41,9 @@ /** used for relationship */ public CharField(CharFieldEnum c) { charFieldEnum = c; + name = c.getName(); + tag = c.getTag(); // name if not set + type = c.getType(); // may be null } /** a generic field with no char field enum - get hip Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2007-10-01 22:00:24 UTC (rev 946) @@ -1,5 +1,8 @@ package phenote.datamodel; +// type is from xmlbean Field +import phenote.config.xml.FieldDocument.Field.Type; + // labels? methods? subclasses? // is this taking enums too far? or a good use of them? /** so this class has evolved - this was actually doing the setting of field values at one @@ -18,16 +21,35 @@ PUB("Pub"), GENOTYPE("Genotype"), ALLELE("Allele"), GENETIC_CONTEXT("Genetic Context"), ENTITY("Entity"), QUALITY("Quality"), + DATE_CREATED("Date Created","date_created",Type.DATE), /** Its questionable if relationship belongs here ??? */ RELATIONSHIP("Relationship"); // CHAR FIELD ENUM vars & methods (make its own class!) private final String name; - private CharFieldEnum(String name) { this.name = name; } + private final String tag; + private final Type.Enum type; + private CharFieldEnum(String name) { + this(name,null,null); + } + private CharFieldEnum(String name,String tag,Type.Enum type) { + this.name = name; + this.tag = tag; + this.type = type; + } public String toString() { return getName(); } public String getName() { return name; } - public boolean equals(String s) { return name.equalsIgnoreCase(s); } - public boolean equals(CharField cf) { return name.equals(cf.getName()); } + public String getTag() { + return tag!= null ? tag : name; + } + public Type.Enum getType() { return type; } + public boolean equals(String s) { + if (s == null) return false; + return name.equalsIgnoreCase(s) || s.equalsIgnoreCase(tag); + } + public boolean equals(CharField cf) { + return equals(cf.getName()) || equals(cf.getTag()); + } // no longer used? //public abstract void setValue(CharacterI c, CharFieldValue v); Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-01 22:00:24 UTC (rev 946) @@ -1,5 +1,6 @@ package phenote.datamodel; +import java.text.DateFormat; import java.util.Date; import org.geneontology.oboedit.datamodel.OBOClass; @@ -97,6 +98,8 @@ boolean isEmpty() { if (isOboClass) return oboClassValue == null; + else if (isDate()) + return dateValue == null; else return ((stringValue == null) || (stringValue.equals(""))); } @@ -108,6 +111,11 @@ } public String getValueAsString() { + if (isEmpty()) return ""; // null? + if (isTerm()) + return oboClassValue.getName(); + if (isDate()) + return DateFormat.getDateInstance().format(dateValue); if (!isTerm()) return stringValue; if (oboClassValue != null) // obo class may not be set yet Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-10-01 22:00:24 UTC (rev 946) @@ -41,11 +41,11 @@ private OntologyManager() { // always have user & date field by default // should be at end in case displayed?? - CharField dateCreated = - new CharField("Date Created","date_created",Type.DATE); - addField(dateCreated); +// CharField dateCreated = +// new CharField("Date Created","date_created",Type.DATE); +// addField(dateCreated); } - + public static OntologyManager inst() { if (singleton == null) singleton = new OntologyManager(); @@ -86,6 +86,7 @@ } public CharField getCharFieldForName(String fieldName) throws CharFieldException { + if (fieldName == null) throw new CharFieldException("Char field string is null"); for (CharField cf : getCharFieldList()) { //if (cf.getName().equalsIgnoreCase(fieldName)) if (cf.isField(fieldName)) // checks name and datatag @@ -94,7 +95,24 @@ throw new CharFieldException("No field for "+fieldName); } + // ? + private CharField getCharFieldForEnum(CharFieldEnum en) throws CharFieldException { + try { return getCharFieldForName(en.getName()); } + catch (CharFieldException e) { return getCharFieldForName(en.getTag()); } + } + /** If date_created doesnt exist then create it - its a fundamental */ + public CharField getDateCreatedField() { + try { return getCharFieldForEnum(CharFieldEnum.DATE_CREATED); } + catch (CharFieldException e) { + // if !config.doCreateDate throw CFex?? + CharField dateCreated = new CharField(CharFieldEnum.DATE_CREATED); + addField(dateCreated); + return dateCreated; + } + } + + /** This is where the ontologies are in a generic fashion. A char field has one or more ontologies (entity char field often has more than ontology)*/ public List<CharField> getCharFieldList() { return charFieldList; } Modified: phenote/trunk/src/java/phenote/edit/AddTransaction.java =================================================================== --- phenote/trunk/src/java/phenote/edit/AddTransaction.java 2007-10-01 18:26:20 UTC (rev 945) +++ phenote/trunk/src/java/phenote/edit/AddTransaction.java 2007-10-01 22:00:24 UTC (rev 946) @@ -37,11 +37,11 @@ public void editModel() { getCharList().add(addChar); - // automatically put in date_created??? - try { - CharField dateField = OntologyManager.inst().getCharFieldForName("date_created"); - CharFieldValue v = new CharFieldValue(getDate(),addChar,dateField); - } catch (CharFieldException e) { System.out.println("no date_created field"); } //? + // automatically put in date_created??? //try { + CharField dateField = OntologyManager.inst().getDateCreatedField(); + CharFieldValue v = new CharFieldValue(getDate(),addChar,dateField); + addChar.setValue(dateField,v); + //} catch (CharFieldException e) { System.out.println("no date_created field"); } //? isUndone = false; // index = getCharList().indexOf(addChar); ?? } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-10-01 18:26:17
|
Revision: 945 http://obo.svn.sourceforge.net/obo/?rev=945&view=rev Author: mgibson Date: 2007-10-01 11:26:20 -0700 (Mon, 01 Oct 2007) Log Message: ----------- Did a bunch of work on obo mapping. its more or less working still a bug or 2 PhenotypeMapping is the class to use for phenotypes doesnt yet deal with E2 (just a property) duplication bug with objects need to be able to config relations and objects & subjects if no relation configged or in java mapping then creates a PHENOTE_MAPPING_REL:fieldName otherwise it would drop data or crash & burn need to get obo annotation adapter grooving also added a DataeCreated field - dont have to config it - automatic did while waiting for obo edit bug fixes - not all there yet - close Modified Paths: -------------- phenote/trunk/conf/phenote-config.rnc phenote/trunk/conf/phenote-config.xsd phenote/trunk/jars/oboedit.jar phenote/trunk/jars/phenoteconfigbeans.jar phenote/trunk/src/java/phenote/config/Config.java phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedFileAdapter.java phenote/trunk/src/java/phenote/datamodel/AnnotationCharacter.java phenote/trunk/src/java/phenote/datamodel/AnnotationMappingDriver.java phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java phenote/trunk/src/java/phenote/datamodel/Character.java phenote/trunk/src/java/phenote/datamodel/OboUtil.java phenote/trunk/src/java/phenote/datamodel/Ontology.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/edit/AddTransaction.java phenote/trunk/src/java/phenote/gui/field/PostCompGui.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java Added Paths: ----------- phenote/trunk/src/java/phenote/datamodel/PhenotypeMapping.java Modified: phenote/trunk/conf/phenote-config.rnc =================================================================== --- phenote/trunk/conf/phenote-config.rnc 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/conf/phenote-config.rnc 2007-10-01 18:26:20 UTC (rev 945) @@ -86,6 +86,11 @@ field = element field { + ## what relation to use in mapping field to obo annotation + attribute obo-relation { xsd:string }, + ## unclear if enable is needed, if false then field not used, but if user + ## changed mind could easily bring reenable field, also for merges can + ## just unenable fields getting wiped out - i like that attribute enable { xsd:boolean }, attribute name { xsd:string }, attribute colwidth { xsd:int }, @@ -98,7 +103,8 @@ ## added term is assumed, otherewise free_text is the default ## ID requires a : and no whitespace ## free_text is just for backward compatibility - phase out - attribute type { "FREE_TEXT" | "TERM" | "INT" | "ID" | "READ_ONLY" | "HIDDEN" | "free_text" }, + attribute type { "FREE_TEXT" | "TERM" | "INT" | "ID" | "READ_ONLY" | "DATE" + | "HIDDEN" | "free_text" }, ## should this be another type? will there be anything readonly aside from strings? ##attribute read-only { xsd:boolean }, ## file is for single ontology - rename ontology_file? Modified: phenote/trunk/conf/phenote-config.xsd =================================================================== --- phenote/trunk/conf/phenote-config.xsd 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/conf/phenote-config.xsd 2007-10-01 18:26:20 UTC (rev 945) @@ -102,6 +102,11 @@ <xs:element minOccurs="0" ref="x:postcomp"/> <xs:element minOccurs="0" maxOccurs="unbounded" ref="x:ontology"/> </xs:sequence> + <xs:attribute name="obo-relation" use="required" type="xs:string"> + <xs:annotation> + <xs:documentation>what relation to use in mapping field to obo annotation</xs:documentation> + </xs:annotation> + </xs:attribute> <xs:attribute name="enable" use="required" type="xs:boolean"/> <xs:attribute name="name" use="required" type="xs:string"/> <xs:attribute name="colwidth" use="required" type="xs:int"/> @@ -124,6 +129,7 @@ <xs:enumeration value="INT"/> <xs:enumeration value="ID"/> <xs:enumeration value="READ_ONLY"/> + <xs:enumeration value="DATE"/> <xs:enumeration value="HIDDEN"/> <xs:enumeration value="free_text"/> </xs:restriction> Modified: phenote/trunk/jars/oboedit.jar =================================================================== (Binary files differ) 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 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/config/Config.java 2007-10-01 18:26:20 UTC (rev 945) @@ -875,13 +875,13 @@ // } public String getLabelForCharField(CharField cf) throws ConfigException { - for (FieldConfig fc : getEnbldFieldCfgs()) { - if (fc.hasCharField(cf)) - return fc.getLabel(); - } - // failed to find field config for char field - shouldnt happen - throw new ConfigException("Syn Abbrev for "+cf+" not found"); - } + for (FieldConfig fc : getEnbldFieldCfgs()) { + if (fc.hasCharField(cf)) + return fc.getLabel(); + } + // failed to find field config for char field - shouldnt happen + throw new ConfigException("Label for "+cf+" not found"); + } public String getSyntaxAbbrevForCharField(CharField cf) throws ConfigException { for (FieldConfig fc : getEnbldFieldCfgs()) { Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2007-10-01 18:26:20 UTC (rev 945) @@ -103,6 +103,7 @@ try { OBOSession os = loadAllOboFilesIntoOneOboSession(); initCharFields(); + ontologyManager.setOboSession(os); // map namespaces to ontologies? 2 methods? mapNamespacesToOntologies(os); // load ontologies from namespaces Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-10-01 18:26:20 UTC (rev 945) @@ -45,10 +45,10 @@ return delimitedString; } String getDelimitedHeaderString() throws BadCharException { - if (delimitedHeaderString == null) { + if (delimitedHeaderString == null) { delimitedHeaderString = makeDelimitedHeaderString(); - } - return delimitedHeaderString; + } + return delimitedHeaderString; } /** the idea for the tab-delimited output writer is to @@ -61,38 +61,42 @@ * hard return * should i include the config file on the first line?...maybe in the future * */ - private String makeDelimitedHeaderString() throws BadCharException { - if (character == null) { // shouldnt happen - System.out.println("Error: could not make tab-delimited header"); - return ""; //?? - } - StringBuffer sb = new StringBuffer(); - try { + private String makeDelimitedHeaderString() { //throws BadCharException { + if (character == null) { // shouldnt happen + System.out.println("Error: could not make tab-delimited header"); + return ""; //?? + } + StringBuffer sb = new StringBuffer(); + //try { // ontology manager should have char fields in order of config which should be // syntax order - hope this isnt too presumptious - for (CharField cf : OntologyManager.inst().getCharFieldList()) { - //if its a free text field - only one col necessary. - //if its an ontology field - need two cols (one for ID, the other for text) - sb.append(Config.inst().getLabelForCharField(cf)); - //for now, i'll call on the syntax abbrev, but i'll want to use the acutal name - // if (!isFreeText(cf)) { // } // now have third type isInt, so can't just negate 2007 07 09 - if (isTerm(cf)) { - sb.append(" ID").append(delimiter); - sb.append(Config.inst().getLabelForCharField(cf)).append(" Name"); + for (CharField cf : OntologyManager.inst().getCharFieldList()) { + //if its a free text field - only one col necessary. + //if its an ontology field - need two cols (one for ID, the other for text) + // the label from config & char field should be the same, so dont need to get + // from config - was there some reason for this??? + //String label = Config.inst().getLabelForCharField(cf); + String label = cf.getName(); + sb.append(label); + //for now, i'll call on the syntax abbrev, but i'll want to use the acutal name + // if (!isFreeText(cf)) { // } // now have third type isInt, so can't just negate 2007 07 09 + if (isTerm(cf)) { + sb.append(" ID").append(delimiter); + sb.append(label).append(" Name"); } - sb.append(delimiter); - } - } - catch (ConfigException e) { - throw new BadCharException(e.getMessage()); + sb.append(delimiter); } +// } +// catch (ConfigException e) { +// throw new BadCharException(e.getMessage()); +// } return sb.toString(); - + } private String makeDelimitedString() throws BadCharException { if (character == null) { // shouldnt happen - System.out.println("Error: no Character to make delimited string with"); + log().error("Error: no Character to make delimited string with"); return ""; //?? } StringBuffer sb = new StringBuffer(); Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedFileAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedFileAdapter.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedFileAdapter.java 2007-10-01 18:26:20 UTC (rev 945) @@ -64,6 +64,8 @@ boolean isHeader = false; while (!isHeader) { String headerLine=lnr.readLine(); //reading header line + if (headerLine == null) // EndOfFile no header! + throw new DelimitedEx("No valid header found"); try { delChar.setHeader(headerLine); isHeader = true; // no ex thrown - success @@ -73,8 +75,15 @@ } } //fields = headerToCharFields(headerLine); - } catch (IOException e) { + } catch (DelimitedEx x) { + LOG.error("Tab-delimited read failure "+x); + // failed to get header(?) - shouldnt go on i think + // return null??? throw ex?? return empty charList? + return charList; + } + catch (IOException e) { LOG.error("Tab-delimited read failure "+e); + return charList; } for (String line=lnr.readLine(); line != null; line = lnr.readLine()) { try { Modified: phenote/trunk/src/java/phenote/datamodel/AnnotationCharacter.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/AnnotationCharacter.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/AnnotationCharacter.java 2007-10-01 18:26:20 UTC (rev 945) @@ -1,139 +1,227 @@ package phenote.datamodel; +import org.apache.log4j.Logger; + +import org.geneontology.util.ObjectUtil; import org.geneontology.oboedit.annotation.datamodel.Annotation; import org.geneontology.oboedit.annotation.datamodel.impl.AnnotationImpl; import org.geneontology.oboedit.datamodel.LinkedObject; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.impl.DanglingClassImpl; import org.geneontology.oboedit.util.TermUtil; public class AnnotationCharacter extends AbstractCharacter { + private static final Logger LOG = Logger.getLogger(AnnotationCharacter.class); + protected static int idgen = 0; - protected Annotation annotation; - protected AnnotationMappingDriver driver; + protected Annotation annotation; + protected AnnotationMappingDriver driver; + private CharFieldValue objectGenus; + private CharFieldValue objectDifferentia; - /* - * Extend this method to provide more field mappings. This should be all you - * need to do for simple mappings - */ - protected OBOProperty getPropertyForField(CharField cf) { - return driver.getPropertyForField(cf); - } + public AnnotationCharacter(AnnotationMappingDriver driver) { + this("__temp__:" + idgen++, driver); + annotation.setIsAnonymous(true); + } - protected CharFieldValue getCharFieldValue(OBOClass oboClass, - CharacterI character, CharField field) { - return driver.getCharFieldValue(oboClass, character, field); - } + public AnnotationCharacter(String id, AnnotationMappingDriver driver) { + this(new AnnotationImpl(id), driver); + } + + public AnnotationCharacter(Annotation annotation, AnnotationMappingDriver driver) { + this.annotation = annotation; + this.driver = driver; + } - protected CharFieldValue getCharFieldValue(String s, CharacterI character, - CharField field) { - return driver.getCharFieldValue(s, character, field); - } + /* + * Extend this method to provide more field mappings. This should be all you + * need to do for simple mappings + */ + protected OBOProperty getPropertyForField(CharField cf) { + return driver.getPropertyForField(cf); + } - protected void setPropertyValue(Annotation annotation, - OBOProperty property, OBOClass value) { - driver.setPropertyValue(annotation, property, value); - } - protected void setPropertyValue(Annotation annotation, - OBOProperty property, String value) { - driver.setPropertyValue(annotation, property, value); - } + protected void setPropertyValue(Annotation annotation, + OBOProperty property, OBOClass value) { + driver.setPropertyValue(annotation, property, value); + } + + protected void setPropertyValue(Annotation annotation, + OBOProperty property, String value) { + driver.setPropertyValue(annotation, property, value); + } - protected OBOProperty getDefaultRelationship() { - return driver.getDefaultRelationship(); - } + protected OBOProperty getDefaultRelationship() { + return driver.getDefaultRelationship(); + } - protected boolean isSubjectField(CharField cf) { - return driver.isSubjectField(cf); - } + protected boolean isSubjectField(CharField cf) { + return driver.isSubjectField(cf); + } + + protected boolean isObjectField(CharField cf) { + return driver.isObjectField(cf); + } - protected boolean isObjectField(CharField cf) { - return driver.isObjectField(cf); - } + private boolean isObjectGenusField(CharField cf) { + return driver.isObjectGenusField(cf); + } - protected void resetRelationshipField() { - if (!annotation.getRelationship().equals(getDefaultRelationship())) { - if (driver.getAuditHistoryMode()) { - driver.addHistoryItem(annotation - .getRelationshipChangeItem(getDefaultRelationship())); - } - if (driver.getChangeObjectsMode()) - annotation.setRelationship(getDefaultRelationship()); - } - } + private boolean isObjectDifferentiaField(CharField cf) { + return driver.isObjectDifferentiaField(cf); + } - public void setValue(CharField cf, CharFieldValue cfv) { - if (isSubjectField(cf) && cfv.isTerm()) { - if (driver.getAuditHistoryMode()) { - driver.addHistoryItem(annotation.getSubjectChangeItem(cfv - .getOboClass())); - } - if (driver.getChangeObjectsMode()) - annotation.setSubject(cfv.getOboClass()); - resetRelationshipField(); - } else if (isObjectField(cf) && cfv.isTerm()) { - if (driver.getAuditHistoryMode()) { - driver.addHistoryItem(annotation.getObjectChangeItem(cfv - .getOboClass())); - } - if (driver.getChangeObjectsMode()) - annotation.setObject(cfv.getOboClass()); - resetRelationshipField(); - } else { - OBOProperty prop = getPropertyForField(cf); - if (prop != null) { - if (cfv.isTerm()) { - setPropertyValue(annotation, prop, cfv.getOboClass()); - } else { - setPropertyValue(annotation, prop, cfv.getName()); - } - } - } - } + protected void resetRelationshipField() { + if (!ObjectUtil.equals(annotation.getRelationship(),getDefaultRelationship())) { + if (driver.getAuditHistoryMode()) { + driver.addHistoryItem(annotation + .getRelationshipChangeItem(getDefaultRelationship())); + } + if (driver.getChangeObjectsMode()) + annotation.setRelationship(getDefaultRelationship()); + } + } + - public AnnotationCharacter(AnnotationMappingDriver driver) { - this("__temp__:" + idgen++, driver); - annotation.setIsAnonymous(true); - } + public void setValue(CharField cf, CharFieldValue cfv) { + // SUBJECT - if not a term(eg genotype), make a dangler?? + // Annotation only takes LinkedObjects not strings for subjects + if (isSubjectField(cf)) { //&& cfv.isTerm()) { + OBOClass term = cfv.toTerm(); // if not term, makes dangler + if (driver.getAuditHistoryMode()) + driver.addHistoryItem(annotation.getSubjectChangeItem(term)); + if (driver.getChangeObjectsMode()) + annotation.setSubject(term); + resetRelationshipField(); + } + // OBJECT GENUS -- should allow non terms to become danglers like above + else if (isObjectGenusField(cf)) { // && cfv.isTerm()) { + objectGenus = cfv; + setObject(); +// if (driver.getAuditHistoryMode()) { +// driver.addHistoryItem(annotation.getObjectChangeItem(cfv +// .getOboClass())); +// } +// if (driver.getChangeObjectsMode()) +// annotation.setObject(cfv.getOboClass()); +// resetRelationshipField(); + } + // OBJECT DIFFERENTIA + else if (isObjectDifferentiaField(cf)) { + objectDifferentia = cfv; + setObject(); + } + // PROPERTIES (not subject or object) + else { + LOG.debug("setting charfield "+cf+" to val +"+cfv); + OBOProperty prop = getPropertyForField(cf); + if (prop != null) { + if (cfv.isTerm()) { + setPropertyValue(annotation, prop, cfv.getOboClass()); + } else { + setPropertyValue(annotation, prop, cfv.getName()); + } + } + } + } + + /** If have genus then set object, if just diff then do nothing - wait for genus */ + private void setObject() { + // NO GENUS - return, wait for diff + if (!hasObjectGenus()) return; // cant do object without genus - public AnnotationCharacter(String id, AnnotationMappingDriver driver) { - this(new AnnotationImpl(id), driver); - } + // NO DIFF just set genus then + if (!hasObjectDiff()) { + setAnnotObject(objectGenus.toTerm()); + } - public AnnotationCharacter(Annotation annotation, AnnotationMappingDriver driver) { - this.annotation = annotation; - this.driver = driver; + // GENUS & DIFF - make post comp + else { + OBOProperty rel = driver.getPropertyForField(objectDifferentia.getCharField()); + OBOClass pc = + OboUtil.makePostCompTerm(objectGenus.toTerm(),rel,objectDifferentia.toTerm()); + setAnnotObject(pc); + } + } + + private boolean hasObjectGenus() { return objectGenus!=null; } + private boolean hasObjectDiff() { return objectDifferentia!=null; } + + + private void setAnnotObject(OBOClass term) { + if (driver.getAuditHistoryMode()) + driver.addHistoryItem(annotation.getObjectChangeItem(term)); + + if (driver.getChangeObjectsMode()) + annotation.setObject(term); + resetRelationshipField(); + } + + + + public CharFieldValue getValue(CharField cf) { + CharFieldValue cfv = null; + if (isSubjectField(cf)) { + LinkedObject subject = annotation.getSubject(); + if (subject instanceof OBOClass) { + cfv = new CharFieldValue((OBOClass) subject, this, cf); + } + } + else if (isObjectGenusField(cf)) { + cfv = objectGenus; +// LinkedObject link = annotation.getObject(); +// if (link != null && TermUtil.isClass(link)) { +// OBOClass postComp = TermUtil.getClass(link); +// OBOClass genus = OboUtil.getGenusTerm(postComp); // if no pc just term +// cfv = new CharFieldValue(genus,this,cf); +// } + } + else if (isObjectDifferentiaField(cf)) { + cfv = objectDifferentia; +// LinkedObject link = annotation.getObject(); +// if (link != null && TermUtil.isClass(link)) { +// OBOClass postComp = TermUtil.getClass(link); + +// OBOProperty rel = getPropertyForField(cf); + +// //OBOClass diff = OboUtil.getDifferentiaTerm(postComp); +// // assumes only one diff +// OBOClass diff = OboUtil.getDifferentiaTerm(postComp,rel); +// if (diff != null) +// cfv = new CharFieldValue(diff,this,cf); +// } + } + else { + OBOProperty prop = getPropertyForField(cf); + LOG.debug("AC.getVal got prop "+prop+" for field "+cf); + if (prop != null) { + Object o = TermUtil.getPropValue(annotation, prop); + LOG.debug("AC.getVal2 got propval "+o+" for field "+cf); + + if (o instanceof OBOClass) { + cfv = getCharFieldValue((OBOClass) o, this, cf); + } else if (o instanceof String) { + cfv = getCharFieldValue((String) o, this, cf); + } + } + } + if (cfv == null) + cfv = CharFieldValue.emptyValue(this, cf); + return cfv; + } + + protected CharFieldValue getCharFieldValue(OBOClass oboClass, + CharacterI character, CharField field) { + return driver.getCharFieldValue(oboClass, character, field); } - public CharFieldValue getValue(CharField cf) { - CharFieldValue cfv = null; - if (isSubjectField(cf)) { - LinkedObject subject = annotation.getSubject(); - if (subject instanceof OBOClass) { - cfv = new CharFieldValue((OBOClass) subject, this, cf); - } - } else if (isObjectField(cf)) { - LinkedObject object = annotation.getObject(); - if (object instanceof OBOClass) { - cfv = new CharFieldValue((OBOClass) object, this, cf); - } - } else { - OBOProperty prop = getPropertyForField(cf); - if (prop != null) { - Object o = TermUtil.getPropValue(annotation, prop); - if (o instanceof OBOClass) { - cfv = getCharFieldValue((OBOClass) o, this, cf); - } else if (o instanceof String) { - cfv = getCharFieldValue((String) o, this, cf); - } - } - } - if (cfv == null) - cfv = CharFieldValue.emptyValue(this, cf); - return cfv; + protected CharFieldValue getCharFieldValue(String s, CharacterI character, + CharField field) { + return driver.getCharFieldValue(s, character, field); } public CharacterI cloneCharacter() { Modified: phenote/trunk/src/java/phenote/datamodel/AnnotationMappingDriver.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/AnnotationMappingDriver.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/AnnotationMappingDriver.java 2007-10-01 18:26:20 UTC (rev 945) @@ -28,7 +28,10 @@ public boolean isSubjectField(CharField cf); - public boolean isObjectField(CharField cf); + // replace with isObjectGenusField? + public boolean isObjectField(CharField cf); + public boolean isObjectGenusField(CharField cf); + public boolean isObjectDifferentiaField(CharField cf); public boolean getAuditHistoryMode(); Modified: phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java 2007-10-01 18:26:20 UTC (rev 945) @@ -26,52 +26,67 @@ protected boolean changeObjectsMode = true; protected List<HistoryItem> historyItems; - /** - * We probably want to create a special static ontology that extends - * AnnotationOntology to contain these properties. This is here just to keep - * the example simple - */ - protected static final OBOProperty GENOTYPE_REL = new OBOPropertyImpl( - "oban:has_genotype", "has_genotype"); - protected static final OBOProperty HAS_QUALITY_REL = new OBOPropertyImpl( - "pato:has_quality", "has_quality"); + /** + * We probably want to create a special static ontology that extends + * AnnotationOntology to contain these properties. This is here just to keep + * the example simple + */ + protected static final OBOProperty GENOTYPE_REL = new OBOPropertyImpl( + "oban:has_genotype", "has_genotype"); + protected static final OBOProperty HAS_QUALITY_REL = new OBOPropertyImpl( + "pato:has_quality", "has_quality"); + + public OBOProperty getPropertyForField(CharField cf) { + // First check if configged/in char field + // if (cf.hasOboRelation()) return cf.getOboRelation(); + if (CharFieldEnum.PUB.equals(cf)) { + return AnnotationOntology.EVIDENCE_REL(); + } else if (CharFieldEnum.GENOTYPE.equals(cf)) { + return GENOTYPE_REL; + } + //return null; + // since not configged nor in java/mapper create one on fly - better + // than returning null which causes failure - should pring error + // message though(?) - info, error might be annoying + // LOG.info("No obo relationship found for "+cf); + return new OBOPropertyImpl("PHENOTE_MAPPING_REL:"+cf.getTag(),cf.getTag()); + } - public OBOProperty getPropertyForField(CharField cf) { - if (cf.equals(CharFieldEnum.PUB.getName())) { - return AnnotationOntology.EVIDENCE_REL(); - } else if (cf.equals(CharFieldEnum.GENOTYPE.getName())) { - return GENOTYPE_REL; - } - return null; - } + /** retrieves prop from obo session by id, if not there then creates one */ + protected OBOProperty getRelation(String id, String name) { + OBOProperty p = OntologyManager.inst().getRelation(id); + if (p != null) return p; + return new OBOPropertyImpl(id,name); + } + public List<HistoryItem> popHistoryList() { List<HistoryItem> out = historyItems; historyItems = new LinkedList<HistoryItem>(); return out; } - public CharFieldValue getCharFieldValue(OBOClass oboclass, - CharacterI character, CharField field) { - return new CharFieldValue(oboclass, character, field); - } - + public CharFieldValue getCharFieldValue(OBOClass oboclass, + CharacterI character, CharField field) { + return new CharFieldValue(oboclass, character, field); + } + public CharFieldValue getCharFieldValue(String s, CharacterI character, CharField field) { return new CharFieldValue(s, character, field); } - public void setPropertyValue(Annotation annotation, OBOProperty property, - OBOClass value) { - clearProperty(annotation, property); - if (changeObjectsMode) - annotation.addPropertyValue(property, value); - if (auditHistoryMode) { - historyItems.add(new AddPropertyValueHistoryItem( - annotation.getID(), property.getID(), value.getType() - .getID(), value.getID())); - } - } + public void setPropertyValue(Annotation annotation, OBOProperty property, + OBOClass value) { + clearProperty(annotation, property); + if (changeObjectsMode) + annotation.addPropertyValue(property, value); + if (auditHistoryMode) { + historyItems.add(new AddPropertyValueHistoryItem( + annotation.getID(), property.getID(), value.getType() + .getID(), value.getID())); + } + } public void setPropertyValue(Annotation annotation, OBOProperty property, String value) { @@ -107,18 +122,26 @@ } } - public OBOProperty getDefaultRelationship() { - return HAS_QUALITY_REL; - } + public OBOProperty getDefaultRelationship() { + return HAS_QUALITY_REL; + } - public boolean isSubjectField(CharField cf) { - return CharFieldEnum.ENTITY.getName().equals(cf); - } + public boolean isSubjectField(CharField cf) { + return CharFieldEnum.ENTITY.equals(cf); + } - public boolean isObjectField(CharField cf) { - return CharFieldEnum.QUALITY.getName().equals(cf); - } + // phase out? for isObjectGenusField? + public boolean isObjectField(CharField cf) { + return isObjectGenusField(cf);//CharFieldEnum.QUALITY.getName().equals(cf); + } + public boolean isObjectGenusField(CharField cf) { + return CharFieldEnum.QUALITY.equals(cf); + } + public boolean isObjectDifferentiaField(CharField cf) { + return false; // basic - no object differentia + } + public boolean getAuditHistoryMode() { return auditHistoryMode; } Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-10-01 18:26:20 UTC (rev 945) @@ -83,6 +83,14 @@ return name; } + /** Tag is what comes from datatag in config, used for referencing field + (like from smart atlas servlet), and as dangling prefix for obo + mapping, if datatag not set in config, returns name */ + public String getTag() { + if (tag == null) return getName(); + return tag; + } + /** returns true if field has has tag or name of input tag */ public boolean isField(String tag) { if (tag.equalsIgnoreCase(this.tag)) return true; Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2007-10-01 18:26:20 UTC (rev 945) @@ -26,6 +26,9 @@ private CharFieldEnum(String name) { this.name = name; } public String toString() { return getName(); } public String getName() { return name; } + public boolean equals(String s) { return name.equalsIgnoreCase(s); } + public boolean equals(CharField cf) { return name.equals(cf.getName()); } + // no longer used? //public abstract void setValue(CharacterI c, CharFieldValue v); //public abstract CharFieldValue getValue(CharacterI c); @@ -33,7 +36,7 @@ // unclear if we need this??? need it in generic field config public static CharFieldEnum getCharFieldEnum(String fieldString) throws Exception { for ( CharFieldEnum cfe : CharFieldEnum.values()) { - if (cfe.name.equalsIgnoreCase(fieldString)) + if (cfe.equals(fieldString)) return cfe; } //System.out.println("ERROR: No Char Field found for string "+fieldString); Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2007-10-01 18:26:20 UTC (rev 945) @@ -1,6 +1,9 @@ package phenote.datamodel; +import java.util.Date; + import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.impl.DanglingClassImpl; import org.geneontology.oboedit.util.TermUtil; @@ -16,6 +19,7 @@ private OBOClass oboClassValue=null; private String stringValue=null; + private Date dateValue=null; private boolean isOboClass=true; private CharFieldEnum charFieldEnum; private CharField charField; @@ -52,6 +56,12 @@ isOboClass = true; } + public CharFieldValue(Date d, CharacterI c, CharField cf) { + this(c,cf); + dateValue = d; + isOboClass = false; + } + private CharFieldValue(CharacterI c,CharField cf) { character = c; charField = cf; @@ -92,7 +102,12 @@ } // maybe this should be called getString??? why getName??? + // --> getValueAsString - much better name - phase out public String getName() { + return getValueAsString(); + } + + public String getValueAsString() { if (!isTerm()) return stringValue; if (oboClassValue != null) // obo class may not be set yet @@ -109,6 +124,9 @@ public boolean isTerm() { return isOboClass; } + public boolean isDate() { return dateValue != null; } + public Date getDate() { return dateValue; } + public OBOClass getOboClass() { return getTerm(); } // --> getTerm more general public OBOClass getTerm() { return oboClassValue; } @@ -125,9 +143,21 @@ return TermUtil.isDangling(getTerm()); } - public String toString() { return getName(); } + /** if cfv is a term just returns it, otherwise makes a dangling term out of + its value, string or date or whatnot */ + public OBOClass toTerm() { + if (isTerm()) return getTerm(); + else { + OBOClass term = + new DanglingClassImpl(getCharField().getTag()+":"+getValueAsString()); + term.setName(getName()); + return term; + } + } + public String toString() { return getValueAsString(); } + // if (charFieldEnum == null) // System.out.println("ERROR no datamodel associated with configuration, cant set"+ // " value"); Modified: phenote/trunk/src/java/phenote/datamodel/Character.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Character.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/Character.java 2007-10-01 18:26:20 UTC (rev 945) @@ -6,30 +6,24 @@ 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 - Should the Character datamodel be a generic hash of CharField-CharFieldValues? - That can be free text or from ontologies? - This is the straightontabular implementation of CharacterI */ +/** The Character datamodel is a generic hash of CharField-CharFieldValues + CharFieldValues are free text or from ontologies + This is the straightontabular implementation of CharacterI + In the table view a character represents a row */ public class Character extends AbstractCharacter implements CharacterI { private HashMap<CharField,CharFieldValue> charFieldToValue = new HashMap<CharField,CharFieldValue>(); - /** chould only be constrcuted from factory */ - Character() {} + /** should only be constrcuted from factory */ + Character() { + // automatically add date was constructed + } - // obo edit annotation that gets modified in setValues + // obo edit annotation that gets modified in setValues - this alternative was passed + // for just having a whole separate AnnotationCharacter // private OBOEditAnntotation - get & set methods - /** Throws CharFieldEx if fieldString not valid field, TermNotFoundEx if valueString - not found in ontologies associated with field - returns the constructed CharFieldValue */ -// public CharFieldValue setValue(String fieldString, String valueString) -// throws CharFieldException,TermNotFoundException { -// CharField cf = getCharFieldForName(fieldString); -// return setValue(cf,valueString); -// } /** for generic fields its just a map from char field to char field value */ public void setValue(CharField cf, CharFieldValue cfv) { @@ -39,23 +33,7 @@ // setOboEditModel(oboEditAnnotation,cf,cfv); } - // --> AbstractCharacter -// private void setValue(CharFieldValue cfv) { -// setValue(cfv.getCharField(),cfv); -// } - // --> AbstractCharacter -// public CharFieldValue setValue(CharField cf, String s) -// throws TermNotFoundException { -// // finds term or makes dangler or uses string for free text -// CharFieldValue cfv = cf.makeValue(this,s); -// setValue(cf,cfv); -// return cfv; -// } -// private void setValue(CharField cf, OBOClass term) { -// setValue(new CharFieldValue(term,this,cf)); -// } - /** generic getter */ public CharFieldValue getValue(CharField cf) { CharFieldValue cfv = charFieldToValue.get(cf); @@ -64,8 +42,6 @@ if (cfv == null) { cfv = CharFieldValue.emptyValue(this,cf); // set in hash? } -// if (cfv == null && cf.hasCharFieldEnum()) // phase out - i think this is phased out -// cfv = cf.getCharFieldEnum().getValue(this); return cfv; } @@ -87,11 +63,6 @@ return getTerm(cf); } -// private OBOClass getTerm(CharField cf) { -// if (!hasValue(cf)) return null; // ?? exception? -// return getValue(cf).getOboClass(); -// } - // should this be isNull? public boolean hasValue(CharField cf) { // empty string is a valid value for non-required field - or should there @@ -118,92 +89,7 @@ return OntologyManager.inst().getCharFieldList(); } - // conveneince methods... -// public String getPub() { -// try { return getValueString(getPubField()); } -// catch (CharFieldException e) { return null; } // ?? ""? -// } -// public boolean hasPub() { return getPub()!=null && !getPub().equals(""); } -// private CharField getPubField() throws CharFieldException { -// return getCharFieldForName(CharFieldEnum.PUB.getName()); -// } -// public String getGenotype() { -// try { return getValueString(getGenotypeField()); } -// catch (CharFieldException e) { return null; } // ?? -// } -// private CharField getGenotypeField() throws CharFieldException { -// return getCharFieldForName(CharFieldEnum.GENOTYPE.getName()); -// } -// /** cant decide to kill this or not - part of me thinks entity is fundamental to -// phenote so why not make it handy */ -// public OBOClass getEntity() { -// try { return getValue(getEntityField()).getTerm(); } -// catch (CharFieldException e) { return null; } // ?? -// } -// private CharField getEntityField() throws CharFieldException { -// return getCharFieldForName(CharFieldEnum.ENTITY.getName()); -// //catch (CharFieldException e) { return null; } // ?? ex? -// } -// public OBOClass getQuality() { -// //return quality; -// try { return getValue(getQualField()).getTerm(); } -// catch (CharFieldException e) { return null; } // ?? -// } -// private CharField getQualField() throws CharFieldException { -// return getCharFieldForName(CharFieldEnum.QUALITY.getName()); -// } -// public boolean hasGeneticContext() { -// return getGeneticContext()!=null && !getGeneticContext().equals(""); -// } -// public OBOClass getGeneticContext() { -// try { return getTerm(getGenConField()); } -// catch (CharFieldException e) { return null; } // ?? -// } -// private CharField getGenConField() throws CharFieldException { -// return getCharFieldForName(CharFieldEnum.GENETIC_CONTEXT.getName()); -// } - -// public void setPub(String p ) { -// try { setValue(new CharFieldValue(p,this,getPubField())); } -// catch (CharFieldException x) { log().error("no Pub field -> config!"); } -// } -// public void setGenotype(String gt) { -// try { setValue(getGenotypeField(),gt); } -// catch (CharFieldException x) { log().error(x); } -// catch (TermNotFoundException e) {} // doesnt happen for free text field -// } -// public void setEntity(OBOClass e) { -// try { setValue(new CharFieldValue(e,this,getEntityField())); } -// catch (CharFieldException x) { log().error("no Entity field -> config!"); } -// } -// public void setQuality(OBOClass q) { -// try {setValue(new CharFieldValue(q,this,getQualField())); } -// catch (CharFieldException e) { log().error("no Quality field -> config!"); } -// } -// public void setGeneticContext(OBOClass gc) { -// try { setValue(getGenConField(),gc); } -// catch (CharFieldException e) { log().error("no Genetic Context field -> config!"); } -// } - -// // this is just used for testing at this point -// public boolean equals(CharacterI ch) { -// //return eq(getGenotype(),ch.getGenotype()) && eq(getEntity(),ch.getEntity()) -// // && eq(quality,ch.getQuality()) && eq(geneticContext,ch.getGeneticContext()); -// for (CharField cf : getAllCharFields()) { -// if (!eq(getValue(cf),ch.getValue(cf))) -// return false; -// } -// return true; -// } - -// /** check if both are null in addition to .equals() */ -// private boolean eq(CharFieldValue c1,CharFieldValue c2) { -// if (c1==null && c2==null) return true; -// if (c2 == null) return false; -// return c1.equals(c2); -// } - public CharacterI cloneCharacter() { //try { // do OBOClasses clone? do we need to clone them? dont think so - immutable @@ -222,11 +108,6 @@ // used by character table panel public boolean hasNoContent() { -// if (hasPub()) return false; -// if (genotype!=null && !genotype.equals("")) return false; -// if (getEntity() != null) return false; -// if (getQuality() != null) return false; -// return geneticContext == null; for (CharField cf : getAllCharFields()) { if (hasValue(cf)) return false; } @@ -234,8 +115,6 @@ } public String toString() { - //return "Pub "+pub+" genotype "+genotype+" gen ctxt "+geneticContext+" entity "+ - // entity+" qual "+quality; StringBuffer sb = new StringBuffer(); for (CharField cf : getAllCharFields()) { sb.append(cf.getName()).append(" ").append(charFieldToValue.get(cf)).append(" "); @@ -249,3 +128,28 @@ return log; } } + /** Throws CharFieldEx if fieldString not valid field, TermNotFoundEx if valueString + not found in ontologies associated with field + returns the constructed CharFieldValue */ +// public CharFieldValue setValue(String fieldString, String valueString) +// throws CharFieldException,TermNotFoundException { +// CharField cf = getCharFieldForName(fieldString); +// return setValue(cf,valueString); +// } +// // this is just used for testing at this point +// public boolean equals(CharacterI ch) { +// //return eq(getGenotype(),ch.getGenotype()) && eq(getEntity(),ch.getEntity()) +// // && eq(quality,ch.getQuality()) && eq(geneticContext,ch.getGeneticContext()); +// for (CharField cf : getAllCharFields()) { +// if (!eq(getValue(cf),ch.getValue(cf))) +// return false; +// } +// return true; +// } + +// /** check if both are null in addition to .equals() */ +// private boolean eq(CharFieldValue c1,CharFieldValue c2) { +// if (c1==null && c2==null) return true; +// if (c2 == null) return false; +// return c1.equals(c2); +// } Modified: phenote/trunk/src/java/phenote/datamodel/OboUtil.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OboUtil.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/OboUtil.java 2007-10-01 18:26:20 UTC (rev 945) @@ -1,11 +1,14 @@ package phenote.datamodel; +import org.geneontology.oboedit.datamodel.Link; +import org.geneontology.oboedit.datamodel.LinkedObject; 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; +import org.geneontology.oboedit.util.TermUtil; /** changing this from static to non-static so can build post comp object from @@ -35,12 +38,21 @@ // return postCompTerm; // } + public static OBOClass makePostCompTerm(OBOClass genus, OBOProperty rel, + OBOClass diff) { + OboUtil u = initPostCompTerm(genus); + u.addRelDiff(rel,diff); + return u.getPostCompTerm(); + } + + public static OboUtil initPostCompTerm(OBOClass genus) { OboUtil ou = new OboUtil(); ou.addGenus(genus); return ou; } + private void addGenus(OBOClass genus) { id = genus.getID(); name = genus.getName(); @@ -76,4 +88,61 @@ return "^"+r+"("+d+")"; } + /** for non post comp returns term itself */ + public static OBOClass getGenusTerm(OBOClass term) { + if (isPostCompTerm(term)) { + for (Object o : term.getParents()) { + OBORestriction r = (OBORestriction)o; + if (r.completes() && r.getType().equals(OBOProperty.IS_A)) + return (OBOClass)r.getParent(); // check downcast? + } + // error msg? + } + return term; + } + + public static boolean isPostCompTerm(OBOClass term) { + for (Link l : term.getParents()) { + if (isLinkToDiff(l)) + return true; + } + return false; + } + + public static boolean isLinkToDiff(Link l) { + if (!isOboRestriction(l)) return false; + return isLinkToDiff(getOboRestriction(l)); + } + + public static boolean isLinkToDiff(OBORestriction r) { + // i guess there is a case where isa is completes - but why? + return r.completes() && !r.getType().equals(OBOProperty.IS_A); + } + + public static boolean isOboRestriction(Link l) { + return l instanceof OBORestriction; + } + + public static OBORestriction getOboRestriction(Link l) { + if (!isOboRestriction(l)) return null; + return (OBORestriction)l; + } + + /** Assumes theres only one term with diffRel, returns the 1st one it finds + null if none found - ex? */ + public static OBOClass getDifferentiaTerm(OBOClass postComp, + OBOProperty diffRel) { + if (!isPostCompTerm(postComp)) return null; // ex? + // loop thru parents looking for diffRel + for (Link l : postComp.getParents()) { + OBOProperty rel = l.getType(); + if (rel.equals(diffRel)) { + LinkedObject lo = l.getParent(); + if (TermUtil.isClass(lo)) + return TermUtil.getClass(lo); + } + } + return null; // diff not found - OboEx? + } + } Modified: phenote/trunk/src/java/phenote/datamodel/Ontology.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/Ontology.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/Ontology.java 2007-10-01 18:26:20 UTC (rev 945) @@ -153,11 +153,6 @@ } //if (term == null) -// if (danglerMode()) { no not here - multi ontol field needs to loop thru ontols -// // shoot error? or let handler do that? -// return new DanglingClassImpl(id); // name will have to be added by dataadap? -// } - throw new TermNotFoundException(id +" id not found in ontology "+name); //return oc; } Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-10-01 18:26:20 UTC (rev 945) @@ -5,12 +5,15 @@ import org.apache.log4j.Logger; import org.geneontology.oboedit.datamodel.OBOClass; +import org.geneontology.oboedit.datamodel.OBOProperty; import org.geneontology.oboedit.datamodel.OBOSession; import org.geneontology.oboedit.postcomp.ParseException; import org.geneontology.oboedit.postcomp.PostcompUtil; import org.geneontology.oboedit.postcomp.TokenMgrError; +import org.geneontology.oboedit.util.TermUtil; import phenote.config.Config; +import phenote.config.xml.FieldDocument.Field.Type; //import phenote.datamodel.CharFieldEnum; //import phenote.datamodel.OboUtil; @@ -28,12 +31,20 @@ /** CharFields generically hold zero or more ontologies - are charFields that dont have ontologies in this list?? yes */ private List<CharField> charFieldList = new ArrayList<CharField>(); + /** OBOSession holds all ontologies */ + private OBOSession oboSession; public final static String DEFAULT_GROUP = "default"; /** Singleton */ - private OntologyManager() {} + private OntologyManager() { + // always have user & date field by default + // should be at end in case displayed?? + CharField dateCreated = + new CharField("Date Created","date_created",Type.DATE); + addField(dateCreated); + } public static OntologyManager inst() { if (singleton == null) @@ -46,6 +57,18 @@ charFieldList.add(cf); } + public void setOboSession(OBOSession s) { oboSession = s; } + public OBOSession getOboSession() { return oboSession; } + + /** returns relation of id from obo session, null if dont have */ + public OBOProperty getRelation(String id) { + for (OBOProperty p : TermUtil.getRelationshipTypes(oboSession)) { + if (p.getID().equals(id)) + return p; + } + return null; + } + /** get char field for int. 0 based. based on order in config file CharacterTableModel relies on this order */ public CharField getCharField(int i) throws OntologyException { Added: phenote/trunk/src/java/phenote/datamodel/PhenotypeMapping.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/PhenotypeMapping.java (rev 0) +++ phenote/trunk/src/java/phenote/datamodel/PhenotypeMapping.java 2007-10-01 18:26:20 UTC (rev 945) @@ -0,0 +1,42 @@ +package phenote.datamodel; + + +import org.geneontology.oboedit.datamodel.OBOProperty; +import org.geneontology.oboedit.datamodel.impl.OBOPropertyImpl; + + +public class PhenotypeMapping extends BasicAnnotationMappingDriver { + + /** inheres_in is not in RO which is surprising - but its in RO proposed */ + private final OBOProperty INHERES_IN_REL = + getRelation("OBO_REL:inheres_in","inheres_in"); + private final OBOProperty INFLUENCES_REL = getRelation("OBOL:influences","influences"); + + + public OBOProperty getPropertyForField(CharField cf) { + if (CharFieldEnum.ENTITY.equals(cf)) + return INHERES_IN_REL; + return super.getPropertyForField(cf); // pub, genotype + } + + /** this is the relationship between subject & object should be renamed + subjectObjectRelationship */ + public OBOProperty getDefaultRelationship() { + return INFLUENCES_REL; // genotype influences phenotype + } + + // there should probably be some check that the genotype field exists in + // present configuration - in fact the config should specify a subject field + public boolean isSubjectField(CharField cf) { + return CharFieldEnum.GENOTYPE.equals(cf); + } + + public boolean isObjectGenusField(CharField cf) { + return CharFieldEnum.QUALITY.equals(cf); + } + + public boolean isObjectDifferentiaField(CharField cf) { + return CharFieldEnum.ENTITY.equals(cf); + } + +} Modified: phenote/trunk/src/java/phenote/edit/AddTransaction.java =================================================================== --- phenote/trunk/src/java/phenote/edit/AddTransaction.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/edit/AddTransaction.java 2007-10-01 18:26:20 UTC (rev 945) @@ -1,16 +1,20 @@ package phenote.edit; import java.util.ArrayList; +import java.util.Date; import java.util.List; import org.geneontology.oboedit.datamodel.OBOClass; import phenote.dataadapter.CharacterListManager; import phenote.datamodel.CharField; +import phenote.datamodel.CharFieldException; +import phenote.datamodel.CharFieldValue; import phenote.datamodel.CharacterI; import phenote.datamodel.CharacterListI; +import phenote.datamodel.OntologyManager; -/** For adding a character (not a char subpart - thats an update) */ +/** For adding a character (not a char field/subpart - thats an update) */ public class AddTransaction implements TransactionI { @@ -33,10 +37,18 @@ public void editModel() { getCharList().add(addChar); + // automatically put in date_created??? + try { + CharField dateField = OntologyManager.inst().getCharFieldForName("date_created"); + CharFieldValue v = new CharFieldValue(getDate(),addChar,dateField); + } catch (CharFieldException e) { System.out.println("no date_created field"); } //? isUndone = false; // index = getCharList().indexOf(addChar); ?? } + // get current date + private Date getDate() { return new Date(); } + // public int getIndex() { return index; } ??? public void undo() { Modified: phenote/trunk/src/java/phenote/gui/field/PostCompGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/PostCompGui.java 2007-10-01 17:05:05 UTC (rev 944) +++ phenote/trunk/src/java/phenote/gui/field/PostCompGui.java 2007-10-01 18:26:20 UTC (rev 945) @@ -18,6 +18,7 @@ import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; +import org.geneontology.oboedit.datamodel.Link; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; import org.geneontology.oboedit.datamodel.OBORestriction; @@ -88,17 +89,9 @@ //genusField.setListSelectionModel(this.selectionModel); compFieldPanel.addCharFieldGuiToPanel(genusField); - // REL-DIFFS + // REL-DIFF - put in 1 differentia addRelDiffGui(); - // HARDWIRE 2ND REL&DIFF FOR NOW eventually put in refine button to add more diffs - //addRelDiffGui(); - - // WHAT THE HELL HARDWIRE A 3RD - //addRelDiffGui(); - - - setGuiFromSelectedModel(); // override FieldPanel preferred size which will set window size @@ -162,14 +155,14 @@ OBOClass currentTerm = getModelTerm(); if (currentTerm == null) return; - //genusField.setText(getGenusString(currentTerm)); - genusField.setOboClass(getGenusTerm(currentTerm)); + OBOClass genus = OboUtil.getGenusTerm(currentTerm); + genusField.setOboClass(genus); // should this happen automatically from setOboClass or is that a burden/inefficiency - genusField.setOntologyChooserFromTerm(getGenusTerm(currentTerm)); + genusField.setOntologyChooserFromTerm(genus); //if (modelHasDiff(currentTerm)) // should query if temp or real post comp?? try { - List<RelDiffModel>diffs = getRelDiffs(currentTerm); + List<RelDiffModel>diffs = getRelDiffs(currentTerm); // CompEx if none for (int i=0; i<diffs.size(); i++) { // check that have enough guis for diffs @@ -177,18 +170,9 @@ relDiffGuis.get(i).setRelDiffModel(diffs.get(i)); } } - catch (CompEx e) { log().debug("get rel diffs failed "+e); } + //just got no diffs no need for msg log().debug("get rel diffs failed "+e); } + catch (CompEx e) {} - -// for (RelDiffGui rd : relDiffGuis) { -// try { rd.relField.setRel(getRel(currentTerm)); } catch (Exception e){} -// try { -// rd.diffField.setOboClass(getDiffTerm(currentTerm)); -// rd.diffField.setOntologyChooserFromTerm(getDiffTerm(currentTerm)); -// } -// catch (Exception e) {} // throws if no diff term -// } - } /** If model has changed (main window fiddling - hmmm) set gui */ @@ -220,28 +204,28 @@ } // util fn? - private boolean isPostCompTerm(OBOClass term) { - for (Object o : term.getParents()) { - if ( ((OBORestriction)o).completes() ) - return true; - } - return false; - } +// 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().equals(OBOProperty.IS_A)) - return (OBOClass)r.getParent(); // check downcast? - } - // error msg? - } - return term; - } +// private OBOClass getGenusTerm(OBOClass term) { +// if (isPostCompTerm(term)) { +// for (Object o : term.getParents()) { +// OBORestriction r = (OBORestriction)o; +// if (r.completes() && r.getType().equals(OBOProperty.IS_A)) +// return (OBOClass)r.getParent(); // check downcast? +// } +// // error msg? +// } +// return term; +// } private class CompEx extends Exception { private CompEx() {} @@ -249,14 +233,13 @@ } private List<RelDiffModel> getRelDiffs(OBOClass term) throws CompEx { - if (!isPostCompTerm(term)) throw new CompEx(); + if (!OboUtil.isPostCompTerm(term)) throw new CompEx(); List<RelDiffModel>diffs = new ArrayList<RelDiffModel>(4); - for (Object o : term.getParents()) { - OBORestriction r = (OBORestriction)o; + for (Link l : term.getParents()) { + OBORestriction r = (OBORestriction)l; if (isLinkToDiff(r)) { diffs.add(new RelDiffModel(r)); } - //return r; } if (diffs.isEmpty()) throw new CompEx(); // none found return diffs; @@ -266,32 +249,32 @@ return r.completes() && !r.getType().equals(OBOProperty.IS_A); } - /** 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 CompEx { - OBORestriction link = getDiffLink(term); // throws Ex - return (OBOClass)link.getParent(); // check downcast? - } +// /** 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 CompEx { +// 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 CompEx { - return getDiffLink(term).getType(); // throws ex - } +// /** If term is post comp return obo property relationship for differentia +// otherwise thorws exception */ +// private OBOProperty getRel(OBOClass term) throws CompEx { +// return getDiffLink(term).getType(); // throws ex +// } - /** return the oboRestriction link between term and its differentia - exception if there is none. - This assumes that there is only one diff - no longer true! - should make specific ex*/ - private OBORestriction getDiffLink(OBOClass term) throws CompEx { - if (!isPostCompTerm(term)) throw new CompEx(); - for (Object o : term.getParents()) { - OBORestriction r = (OBORestriction)o; - if (r.completes() && r.getType() != OBOProperty.IS_A) - return r; - } - throw new CompEx(); // none found - } +// /** return the oboRestriction link between term and its differentia +// exception if there is none. +// This assumes that there is only one diff - no longer true! +// should make specific ex*/ +// private OBORestriction getDiffLink(OBOClass term) throws CompEx { +// if (!OboUtil.isPostCompTerm(term)) throw new CompEx(); +// for (Object o : term.getParents()) { +// OBORestriction r = (OBORestriction)o; +// if (r.completes() && r.getType() != OBOPrope... [truncated message content] |
From: <ba...@us...> - 2007-10-01 17:05:02
|
Revision: 944 http://obo.svn.sourceforge.net/obo/?rev=944&view=rev Author: balhoff Date: 2007-10-01 10:05:05 -0700 (Mon, 01 Oct 2007) Log Message: ----------- Just a minor fix on checking values from preferences. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java Modified: phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java 2007-10-01 16:54:26 UTC (rev 943) +++ phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java 2007-10-01 17:05:05 UTC (rev 944) @@ -104,8 +104,8 @@ for (TableColumn column : this.getColumns()) { final int newIndex = this.getOrderPrefs().getInt(this.getColumnName(column), 0); final int currentIndex = this.getIndexOfColumn(column); - final int maxIndex = this.table.getColumnCount() - 1; - if ((newIndex < maxIndex) && (currentIndex < maxIndex)) { + final int columnCount = this.table.getColumnCount(); + if ((newIndex < columnCount) && (currentIndex < columnCount)) { this.table.getColumnModel().moveColumn(currentIndex, newIndex); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-10-01 16:54:22
|
Revision: 943 http://obo.svn.sourceforge.net/obo/?rev=943&view=rev Author: balhoff Date: 2007-10-01 09:54:26 -0700 (Mon, 01 Oct 2007) Log Message: ----------- New table column width and ordering persistence class. Modified Paths: -------------- phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java phenote/trunk/src/java/phenote/gui/CharacterTableController.java Added Paths: ----------- phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java Modified: phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java =================================================================== --- phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java 2007-09-28 14:32:53 UTC (rev 942) +++ phenote/trunk/src/java/phenote/charactertemplate/CharacterTemplateController.java 2007-10-01 16:54:26 UTC (rev 943) @@ -36,6 +36,7 @@ import phenote.edit.CharChangeListener; import phenote.edit.EditManager; import phenote.gui.MenuManager; +import phenote.gui.TableColumnPrefsSaver; import phenote.gui.TermInfo; import phenote.gui.field.FieldPanel; import phenote.gui.selection.SelectionManager; @@ -286,6 +287,7 @@ this.selectionModel = new EventSelectionModel<CharacterI>(this.filteredCharacters); this.characterTemplateTable.setSelectionModel(this.selectionModel); this.characterTemplateTable.putClientProperty("Quaqua.Table.style", "striped"); + new TableColumnPrefsSaver(this.characterTemplateTable, this.getTableAutoSaveName()); this.filterField.putClientProperty("Quaqua.TextField.style", "search"); FieldPanel fieldPanel = new FieldPanel(true, false, this.representedGroup, this.selectionManager, this.editManager, this.selectionModel); this.charFieldPanelContainer.add(fieldPanel); @@ -337,6 +339,10 @@ return null; } + private String getTableAutoSaveName() { + return Config.inst().getConfigName() + this.representedGroup + "CharacterTemplateTable"; + } + private List<CharacterI> getCurrentCharacters() { return (this.filteredCharacters == null) ? this.sortedCharacters : this.filteredCharacters; } Modified: phenote/trunk/src/java/phenote/gui/CharacterTableController.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-28 14:32:53 UTC (rev 942) +++ phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-10-01 16:54:26 UTC (rev 943) @@ -4,8 +4,6 @@ import java.awt.Rectangle; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; import java.util.Comparator; import java.util.List; @@ -17,7 +15,6 @@ import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.TableColumn; import org.apache.log4j.Logger; import org.swixml.SwingEngine; @@ -43,10 +40,6 @@ public class CharacterTableController { - private static int DEFAULT_COLWIDTH=150; //default column width for table - private static int INIT_TABLE_WIDTH=1400; - private static int DEFAULT_VIEW_WIDTH=500; - private int tableWidth=INIT_TABLE_WIDTH; private static final String SAVE_STRING = "Save Data"; private String representedGroup = "default"; private SortedList<CharacterI> sortedCharacters; @@ -137,36 +130,12 @@ this.graphButton.getParent().remove(this.graphButton); } this.filterField.putClientProperty("Quaqua.TextField.style", "search"); - this.setColumnWidths(); - if (tableWidth>DEFAULT_VIEW_WIDTH) this.characterTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); this.characterTable.addMouseListener(new PopupListener(new TableRightClickMenu(this.characterTable))); this.characterTablePanel.validate(); this.selectionModel.addListSelectionListener(new SelectionListener()); + new TableColumnPrefsSaver(this.characterTable, this.getTableAutoSaveName()); } - private void setColumnWidths() { - //this method sets the column widths according to those in the configuration - //will determine the total table width according to dimensions in config - final int columnCount = this.tableFormat.getColumnCount(); - int totalWidth = 0; - for (int i = 0; i < columnCount; i++) { - TableColumn column = this.characterTable.getColumnModel().getColumn(i); - int width = this.getWidthOfColumn(i); - if (width==0) //-1 is no display - {width=DEFAULT_COLWIDTH;} - column.setPreferredWidth(width); - column.addPropertyChangeListener(new ColwidthChangeListener()); - this.characterTable.getTableHeader().setResizingColumn(column); - column.setWidth(width); - totalWidth+=width; - } - tableWidth=totalWidth; - } - - private int getWidthOfColumn(int columnIndex) { - return Config.inst().getFieldColwidth(columnIndex); - } - private void addInitialBlankCharacter() { SwingUtilities.invokeLater(new Runnable() { public void run() { @@ -226,6 +195,10 @@ else return CharacterTableController.SAVE_STRING; } + private String getTableAutoSaveName() { + return Config.inst().getConfigName() + this.representedGroup + "CharacterTable"; + } + private static Logger log() { return Logger.getLogger(CharacterTableController.class); } @@ -271,25 +244,6 @@ } } - private static class ColwidthChangeListener implements PropertyChangeListener { - public void propertyChange(PropertyChangeEvent e) - { - //listens for changes to the column widths, makes changes to config, - //and flags that there's been changes (so that they'll be saved) - if (e.getPropertyName().equals("width")) { - TableColumn col = (TableColumn)e.getSource(); - int colIndex = col.getModelIndex(); - Integer newWidth = (Integer)e.getNewValue(); - int w = newWidth.intValue(); - if (w!=(Config.inst().getFieldColwidth(colIndex))) { - //only flag modified if changed from original settings - Config.inst().setFieldColwidth(colIndex, w); - Config.inst().setConfigModified(true); - } - } - } - } - private class PopupListener extends MouseAdapter { JPopupMenu popup; int col; int row; Added: phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/TableColumnPrefsSaver.java 2007-10-01 16:54:26 UTC (rev 943) @@ -0,0 +1,164 @@ +package phenote.gui; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.prefs.BackingStoreException; +import java.util.prefs.Preferences; + +import javax.swing.JTable; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.event.TableColumnModelListener; +import javax.swing.table.TableColumn; + +import org.apache.log4j.Logger; + +/** + * Persists user changes to column widths and order for a table using java.util.prefs. Column + * titles should be unique within the table. If the column content (count or titles) is changed + * between uses of a table, columns will be reset to the default order until the user moves them + * again. + */ +public class TableColumnPrefsSaver implements PropertyChangeListener, TableColumnModelListener { + + private int defaultColumnWidth; + private JTable table; + private String autoSaveName; + + /** + * Constructs a TableColumnPrefsSaver for the given table using a default column width of 150. + * Column widths and order are persisted to the preferences datastore. The autoSaveName should + * be sufficiently unique to avoid conflicts with saved states for other tables. + */ + public TableColumnPrefsSaver(JTable aTable, String autoSaveName) { + this(aTable, autoSaveName, 150); + } + + /** + * Constructs a TableColumnPrefsSaver for the given table. Column widths and order are persisted + * to the preferences datastore. The autoSaveName should be sufficiently unique to avoid conflicts + * with saved states for other tables. If no column width values are already saved for this table, the + * defaultColumnWidth will be used. + */ + public TableColumnPrefsSaver(JTable aTable, String autoSaveName, int defaultColumnWidth) { + this.table = aTable; + this.autoSaveName = autoSaveName; + this.defaultColumnWidth = defaultColumnWidth; + this.table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + this.sizeColumns(); + for (TableColumn column : this.getColumns()) { + column.addPropertyChangeListener(this); + } + this.orderColumns(); + this.table.getColumnModel().addColumnModelListener(this); + } + + public void propertyChange(PropertyChangeEvent e) { + if (e.getPropertyName().equals("width")) { + this.saveColumnWidth((TableColumn)(e.getSource())); + } + } + + public void columnAdded(TableColumnModelEvent e) { + this.saveColumnOrdering(); + } + + public void columnMarginChanged(ChangeEvent e) {} + + public void columnMoved(TableColumnModelEvent e) { + this.saveColumnOrdering(); + } + + public void columnRemoved(TableColumnModelEvent e) { + this.saveColumnOrdering(); + } + + public void columnSelectionChanged(ListSelectionEvent e) {} + + private void sizeColumns() { + for (TableColumn column : this.getColumns()) { + final int width = this.getWidthPrefs().getInt(this.getColumnName(column), this.defaultColumnWidth); + column.setPreferredWidth(width); + } + } + + private void saveColumnWidth(TableColumn column) { + this.getWidthPrefs().putInt(column.getHeaderValue().toString(), column.getWidth()); + } + + private void orderColumns() { + final List<String> prefNames; + try { + prefNames = Arrays.asList(this.getOrderPrefs().keys()); + } catch (BackingStoreException e) { + log().error("Failed to read table column order from prefs", e); + return; + } + final List<String> columnNames = this.getAllColumnNames(); + if (prefNames.containsAll(columnNames) && columnNames.containsAll(prefNames)) { + for (TableColumn column : this.getColumns()) { + final int newIndex = this.getOrderPrefs().getInt(this.getColumnName(column), 0); + final int currentIndex = this.getIndexOfColumn(column); + final int maxIndex = this.table.getColumnCount() - 1; + if ((newIndex < maxIndex) && (currentIndex < maxIndex)) { + this.table.getColumnModel().moveColumn(currentIndex, newIndex); + } + } + } + this.saveColumnOrdering(); + } + + private void saveColumnOrdering() { + try { + this.getOrderPrefs().clear(); + } catch (BackingStoreException e) { + log().error("Unable to store table column ordering", e); + return; + } + for (int i = 0; i < this.table.getColumnModel().getColumnCount(); i++) { + this.getOrderPrefs().putInt(this.table.getColumnName(i), i); + } + } + + private String getColumnName(TableColumn column) { + return column.getHeaderValue().toString(); + } + + private List<String> getAllColumnNames() { + List<String> names = new ArrayList<String>(); + for (TableColumn column : this.getColumns()) { + names.add(this.getColumnName(column)); + } + return names; + } + + private List<TableColumn> getColumns() { + return Collections.list(this.table.getColumnModel().getColumns()); + } + + private int getIndexOfColumn(TableColumn column) { + return this.getColumns().indexOf(column); + } + + private Preferences getPrefsRoot() { + return Preferences.userNodeForPackage(this.getClass()).node(this.autoSaveName); + } + + private Preferences getWidthPrefs() { + return this.getPrefsRoot().node("width"); + } + + private Preferences getOrderPrefs() { + return this.getPrefsRoot().node("order"); + } + + private static Logger log() { + return Logger.getLogger(TableColumnPrefsSaver.class); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-28 14:32:50
|
Revision: 942 http://obo.svn.sourceforge.net/obo/?rev=942&view=rev Author: balhoff Date: 2007-09-28 07:32:53 -0700 (Fri, 28 Sep 2007) Log Message: ----------- Removed some debugging statements. Modified Paths: -------------- 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/FreeTextField.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-27 17:41:43 UTC (rev 941) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-28 14:32:53 UTC (rev 942) @@ -30,7 +30,6 @@ import phenote.datamodel.CharField; import phenote.datamodel.CharFieldValue; -import phenote.datamodel.CharacterI; import phenote.gui.SearchParams; import phenote.gui.SearchParamsI; /** has a jcombobox that does auto completion - i had to do some tricks(hacks) to get it Modified: phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2007-09-27 17:41:43 UTC (rev 941) +++ phenote/trunk/src/java/phenote/gui/field/CharFieldGui.java 2007-09-28 14:32:53 UTC (rev 942) @@ -183,14 +183,12 @@ protected abstract void setCharFieldValue(CharFieldValue value); protected void focusLost() { - log().debug("Focus lost on " + this.getCharField().getName()); if (this.shouldResetGuiForMultipleValues()) { this.setGuiForMultipleValues(); } } protected void focusGained() { - log().debug("Focus gained on " + this.getCharField().getName()); if (this.isInMultipleValueState()) { this.setGuiForMultipleValues(); this.setHasChangedMultipleValues(false); Modified: phenote/trunk/src/java/phenote/gui/field/FreeTextField.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/FreeTextField.java 2007-09-27 17:41:43 UTC (rev 941) +++ phenote/trunk/src/java/phenote/gui/field/FreeTextField.java 2007-09-28 14:32:53 UTC (rev 942) @@ -160,7 +160,6 @@ /** update model using currently selected chars */ protected void updateModel() { - log().debug("Update model"); List<CharacterI> chars = getSelectedChars(); updateModel(chars); } Modified: phenote/trunk/src/java/phenote/gui/field/TermCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-09-27 17:41:43 UTC (rev 941) +++ phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-09-28 14:32:53 UTC (rev 942) @@ -180,10 +180,6 @@ */ private OBOClass getSelectedOboClass() throws OboException { Object obj = getSelectedObject(); // throws oboex - log().debug("The selected list object is: " + obj + " with class " + obj.getClass()); - if (obj instanceof String) { - log().debug("String"); - } //return oboClassDowncast(obj); // throws oboex CompletionTerm t = completionTermDowncast(obj); return t.getOboClass(); @@ -204,7 +200,6 @@ * edits one or more selected chars */ protected void updateModel() { - log().debug("Update model"); try { this.setCurrentValidItem(); } @@ -248,7 +243,6 @@ // allow user to nullify field protected void setModelToNull() { - log().debug("Nulling model"); setModel(null); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-27 17:41:42
|
Revision: 941 http://obo.svn.sourceforge.net/obo/?rev=941&view=rev Author: balhoff Date: 2007-09-27 10:41:43 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Moved filter field to button area. Changed label to "Filter". Modified Paths: -------------- phenote/trunk/conf/character_table_panel.xml phenote/trunk/conf/character_template.xml Modified: phenote/trunk/conf/character_table_panel.xml =================================================================== --- phenote/trunk/conf/character_table_panel.xml 2007-09-27 02:01:02 UTC (rev 940) +++ phenote/trunk/conf/character_table_panel.xml 2007-09-27 17:41:43 UTC (rev 941) @@ -1,21 +1,12 @@ <?xml version="1.0" encoding="UTF-8" ?> <panel id="characterTablePanel" constraints="BorderLayout.CENTER" layout="GridBagLayout"> - <panel layout="GridBagLayout"> - <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="0" fill="GridBagConstraints.HORIZONTAL"/> - <label text="Search:" horizontalAlignment="SwingConstants.RIGHT"> - <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="0" anchor="GridBagConstraints.EAST"/> - </label> - <textfield id="filterField" columns="25"> - <gridbagconstraints gridx="1" gridy="0" weightx="0" weighty="0" anchor="GridBagConstraints.EAST" insets="0,0,0,5"/> - </textfield> - </panel> <scrollpane horizontalScrollBarPolicy="JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS"> - <gridbagconstraints gridx="0" gridy="1" weightx="1" weighty="1" fill="GridBagConstraints.BOTH" insets="5,5,0,5"/> + <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="1" fill="GridBagConstraints.BOTH" insets="5,5,0,5"/> <table id="characterTable"/> </scrollpane> <panel id="buttonPanel"> - <gridbagconstraints gridx="0" gridy="2" weightx="1" insets="10,10,10,10" fill="GridBagConstraints.HORIZONTAL"/> + <gridbagconstraints gridx="0" gridy="1" weightx="1" insets="10,10,10,10" fill="GridBagConstraints.HORIZONTAL"/> <button id="addButton" text="New" action="addNewCharacter" toolTipText="Add new row"/> <button id="duplicateButton" text="Duplicate" action="duplicateSelectedCharacters" toolTipText="Duplicate selected rows"/> <button id="deleteButton" text="Delete" action="deleteSelectedCharacters" toolTipText="Delete selected rows"/> @@ -25,5 +16,13 @@ <button id="commitButton" text="Save Data" action="commitCharacters" toolTipText="Save Data"/> <panel size="20,1" preferredSize="20,1"/> <button id="graphButton" text="Graph" action="showGraph" toolTipText="Show Graph View"/> + <panel layout="GridBagLayout"> + <label text="Filter:" horizontalAlignment="SwingConstants.RIGHT"> + <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="0" anchor="GridBagConstraints.EAST"/> + </label> + <textfield id="filterField" columns="25"> + <gridbagconstraints gridx="1" gridy="0" weightx="0" weighty="0" anchor="GridBagConstraints.EAST" insets="0,0,0,5"/> + </textfield> + </panel> </panel> </panel> Modified: phenote/trunk/conf/character_template.xml =================================================================== --- phenote/trunk/conf/character_template.xml 2007-09-27 02:01:02 UTC (rev 940) +++ phenote/trunk/conf/character_template.xml 2007-09-27 17:41:43 UTC (rev 941) @@ -9,7 +9,7 @@ <panel constraints="BorderLayout.CENTER" layout="GridBagLayout"> <panel layout="GridBagLayout"> <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="0" fill="GridBagConstraints.HORIZONTAL"/> - <label text="Search:" horizontalAlignment="SwingConstants.RIGHT"> + <label text="Filter:" horizontalAlignment="SwingConstants.RIGHT"> <gridbagconstraints gridx="0" gridy="0" weightx="1" weighty="0" anchor="GridBagConstraints.EAST"/> </label> <textfield id="filterField" columns="25"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-27 02:01:01
|
Revision: 940 http://obo.svn.sourceforge.net/obo/?rev=940&view=rev Author: balhoff Date: 2007-09-26 19:01:02 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Update buttons enabled state based on selection. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/CharacterTableController.java Modified: phenote/trunk/src/java/phenote/gui/CharacterTableController.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-26 19:33:35 UTC (rev 939) +++ phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-27 02:01:02 UTC (rev 940) @@ -15,6 +15,8 @@ import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.TableColumn; import org.apache.log4j.Logger; @@ -55,6 +57,8 @@ private JPanel characterTablePanel; // initialized by swix private JTable characterTable; // initialized by swix private JTextField filterField; // initialized by swix + private JButton duplicateButton; // initialized by swix + private JButton deleteButton; // initialized by swix private JButton commitButton; // initialized by swix private JButton graphButton; // initialized by swix @@ -137,6 +141,7 @@ if (tableWidth>DEFAULT_VIEW_WIDTH) this.characterTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); this.characterTable.addMouseListener(new PopupListener(new TableRightClickMenu(this.characterTable))); this.characterTablePanel.validate(); + this.selectionModel.addListSelectionListener(new SelectionListener()); } private void setColumnWidths() { @@ -183,6 +188,12 @@ } } + private void updateButtonStates() { + final boolean hasSelection = !this.selectionModel.isSelectionEmpty(); + this.duplicateButton.setEnabled(hasSelection); + this.deleteButton.setEnabled(hasSelection); + } + private void clearFilter() { this.filterField.setText(""); } @@ -238,9 +249,14 @@ CharacterTableController.this.selectionModel.setSelectionInterval(0, 0); } } - } + private class SelectionListener implements ListSelectionListener { + public void valueChanged(ListSelectionEvent e) { + CharacterTableController.this.updateButtonStates(); + } + } + private static class EverythingEqualComparator<T> implements Comparator<T> { public int compare(T o1, T o2) { return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-26 19:33:32
|
Revision: 939 http://obo.svn.sourceforge.net/obo/?rev=939&view=rev Author: balhoff Date: 2007-09-26 12:33:35 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Character table now selects first row when new dataset is loaded. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/CharacterTableController.java Modified: phenote/trunk/src/java/phenote/gui/CharacterTableController.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-26 19:18:30 UTC (rev 938) +++ phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-26 19:33:35 UTC (rev 939) @@ -21,6 +21,8 @@ import org.swixml.SwingEngine; import phenote.config.Config; +import phenote.dataadapter.CharListChangeEvent; +import phenote.dataadapter.CharListChangeListener; import phenote.dataadapter.CharacterListManager; import phenote.dataadapter.LoadSaveManager; import phenote.datamodel.CharField; @@ -65,6 +67,7 @@ this.selectionModel = new EventSelectionModel<CharacterI>(this.filteredCharacters); this.tableFormat = new CharacterTableFormat(this.representedGroup); this.getEditManager().addCharChangeListener(new CharacterChangeListener()); + CharacterListManager.getCharListMan(this.representedGroup).addCharListChangeListener(new CharacterListChangeListener()); this.initializeInterface(); this.addInitialBlankCharacter(); } @@ -168,7 +171,7 @@ } private void setSelectionWithCharacters(List<CharacterI> characters) { - this.filterField.setText(""); + this.clearFilter(); this.selectionModel.clearSelection(); for (CharacterI character : characters) { final int index = this.filteredCharacters.indexOf(character); @@ -179,6 +182,10 @@ } } } + + private void clearFilter() { + this.filterField.setText(""); + } private void updateCharacterForGlazedLists(CharacterI character) { final int index = this.getCharacterListManager().getCharacterList().getList().indexOf(character); @@ -224,6 +231,16 @@ } } + private class CharacterListChangeListener implements CharListChangeListener { + public void newCharList(CharListChangeEvent e) { + CharacterTableController.this.clearFilter(); + if (!CharacterTableController.this.filteredCharacters.isEmpty()) { + CharacterTableController.this.selectionModel.setSelectionInterval(0, 0); + } + } + + } + private static class EverythingEqualComparator<T> implements Comparator<T> { public int compare(T o1, T o2) { return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-09-26 19:18:33
|
Revision: 938 http://obo.svn.sourceforge.net/obo/?rev=938&view=rev Author: mgibson Date: 2007-09-26 12:18:30 -0700 (Wed, 26 Sep 2007) Log Message: ----------- fixed bug where null terms were being made into danglers Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java phenote/trunk/src/java/phenote/datamodel/CharField.java Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-09-26 17:59:18 UTC (rev 937) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-09-26 19:18:30 UTC (rev 938) @@ -188,36 +188,6 @@ } } - /** Parse syntax line into character - throw DelimitedEx if blank line/no - columns found - just splitting at tab. */ - void parseLineOld_DELETE(String line) throws DelimitedEx { // cf list? - character = CharacterIFactory.makeChar(); -// System.out.println("input line="+line); - String[] items = splitLine(line); - - // doesnt split always return at least 1 item even for empty line??? - boolean found = (items.length>0); //m.find(); -// System.out.println("numcols="+items.length); - if (!found) - throw new DelimitedEx(line); // skips whitespace lines ?? - int colCount = 0; - int fieldCount = 0; - while (found) { - String value = items[colCount]; - // this aint right - this hardwires column # to field, should use column name! - CharField c = Config.inst().getEnbldCharField(fieldCount); -//System.out.println("col="+colCount+"; fieldCount="+fieldCount+"; val="+value+"; charfieldname ="+c.getName()); - String termName = null; - if (c.isTerm()) { - colCount++; //skip over the Name, only keep ID - termName = items[colCount]; - } - addDelValToChar(fieldCount,value,termName); // termName null if not term - colCount++; - fieldCount++; - found = (colCount<items.length); // if parsing last tag found will be false - at end - } - } class SyntaxParseException extends Exception { private String syntaxLine; @@ -275,3 +245,34 @@ return log; } } + +// /** Parse syntax line into character - throw DelimitedEx if blank line/no +// columns found - just splitting at tab. */ +// void parseLineOld_DELETE(String line) throws DelimitedEx { // cf list? +// character = CharacterIFactory.makeChar(); +// // System.out.println("input line="+line); +// String[] items = splitLine(line); + +// // doesnt split always return at least 1 item even for empty line??? +// boolean found = (items.length>0); //m.find(); +// // System.out.println("numcols="+items.length); +// if (!found) +// throw new DelimitedEx(line); // skips whitespace lines ?? +// int colCount = 0; +// int fieldCount = 0; +// while (found) { +// String value = items[colCount]; +// // this aint right - this hardwires column # to field, should use column name! +// CharField c = Config.inst().getEnbldCharField(fieldCount); +// //System.out.println("col="+colCount+"; fieldCount="+fieldCount+"; val="+value+"; charfieldname ="+c.getName()); +// String termName = null; +// if (c.isTerm()) { +// colCount++; //skip over the Name, only keep ID +// termName = items[colCount]; +// } +// addDelValToChar(fieldCount,value,termName); // termName null if not term +// colCount++; +// fieldCount++; +// found = (colCount<items.length); // if parsing last tag found will be false - at end +// } +// } Modified: phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java 2007-09-26 17:59:18 UTC (rev 937) +++ phenote/trunk/src/java/phenote/datamodel/BasicAnnotationMappingDriver.java 2007-09-26 19:18:30 UTC (rev 938) @@ -17,6 +17,9 @@ import org.geneontology.oboedit.history.DeletePropertyValueHistoryItem; import org.geneontology.oboedit.history.HistoryItem; +/** Maps ENTITY to subject and QUALITY to object + but is this proper? shouldnt genotype be subject? */ + public class BasicAnnotationMappingDriver implements AnnotationMappingDriver { protected boolean auditHistoryMode = false; Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-09-26 17:59:18 UTC (rev 937) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-09-26 19:18:30 UTC (rev 938) @@ -195,6 +195,10 @@ // TERM else { + // null term + if (valueString.trim().equals("")) + return CharFieldValue.emptyValue(c,this); + OBOClass oboClass=null; // CHECK FOR POST COMP - could probably move this to char field but right now just This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-26 17:59:21
|
Revision: 937 http://obo.svn.sourceforge.net/obo/?rev=937&view=rev Author: balhoff Date: 2007-09-26 10:59:18 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Fixed - delimited file adapter could not read files with some empty cells. Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java Modified: phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-09-26 17:20:44 UTC (rev 936) +++ phenote/trunk/src/java/phenote/dataadapter/delimited/DelimitedChar.java 2007-09-26 17:59:18 UTC (rev 937) @@ -2,21 +2,19 @@ import java.util.ArrayList; 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 phenote.datamodel.Character; +import phenote.config.Config; +import phenote.config.ConfigException; +import phenote.datamodel.CharField; +import phenote.datamodel.CharFieldValue; import phenote.datamodel.CharacterI; import phenote.datamodel.CharacterIFactory; -import phenote.datamodel.CharField; -import phenote.datamodel.CharFieldValue; import phenote.datamodel.OntologyManager; import phenote.datamodel.TermNotFoundException; -import phenote.config.Config; -import phenote.config.ConfigException; /** I stole this from phenosyntaxchar, but modifying for tab delimited. will * initially hard code in the tab-delimiter, but eventually it should be generic to @@ -174,8 +172,10 @@ private String[] splitLine(String line) { //parse based on tab...will be delimiter in future - Pattern p = Pattern.compile("\t"); - return p.split(line); + final String delimiter = "\t"; + final Pattern p = Pattern.compile(delimiter); + final String trimmedLine = (line.endsWith(delimiter)) ? (line.substring(0, line.length() -1)) : line; + return p.split(trimmedLine, -1); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-09-26 17:20:40
|
Revision: 936 http://obo.svn.sourceforge.net/obo/?rev=936&view=rev Author: mgibson Date: 2007-09-26 10:20:44 -0700 (Wed, 26 Sep 2007) Log Message: ----------- took out commented out code Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-26 17:19:52 UTC (rev 935) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-26 17:20:44 UTC (rev 936) @@ -309,28 +309,7 @@ else log().error("Combo Popup not a component, cant repaint"); } -// private void compRepaint() { -// AccessibleContext ac = jComboBox.getAccessibleContext(); -// for (int i=0; i<ac.getAccessibleChildrenCount(); i++) { -// Accessible a = ac.getAccessibleChild(i); -// log().debug("Accessible child "+a); -// if (a instanceof Component) ((Component)a).repaint(); -// } -// } -// private void compRepaintCont(java.awt.Container parent) { -// System.out.println(parent+" repainting jcombo kids... "+parent.getComponentCount()); -// log().debug("repainting jcombo kids... "+parent.getComponentCount()); -// for (Component c : parent.getComponents()) { -// log().debug("repainting jcombo child "+c); -// log().debug("instance of ComboPopup "+(c instanceof ComboPopup)); -// c.repaint(); -// if (c instanceof java.awt.Container) compRepaintCont((java.awt.Container)c); -// } - -// } - - private long time=0; private long time() { long newTime = System.currentTimeMillis(); @@ -368,13 +347,6 @@ protected JList getUIJList() { if (!hasComboPopup()) return null; return getComboPopup().getList(); -// Accessible popup = jComboBox.getAccessibleContext().getAccessibleChild(0); -// if (!(popup instanceof ComboPopup)) { -// this.log().error("Can't retrieve popup from combobox; can't do mouse overs - found instead " + popup.getClass()); -// return null; -// } else { -// return ((ComboPopup)popup).getList(); -// } } private boolean hasComboPopup() { return getComboPopup() != null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-09-26 17:19:58
|
Revision: 935 http://obo.svn.sourceforge.net/obo/?rev=935&view=rev Author: mgibson Date: 2007-09-26 10:19:52 -0700 (Wed, 26 Sep 2007) Log Message: ----------- fixed threading gui bug where combo list for completion was sometimes coming up empty - it wasnt sufficient to call repaint on the JComboBox which seems odd to me - i needed to get a hold of the ComboPopup - which is a plaf thing - and repaint that - and ComboPopup is not a child component of JComboBox oddly enough so used jims trick of getting it through the Accessible - its wierd that thats the only way it seems to get at that - JComboBox is a funny puppy the threaded completion optimization was the cause of this bug the min-completion-chars optimization is now farily irrelevant (except to supress pre loading ontols set to 1) Modified Paths: -------------- phenote/trunk/conf/birn.cfg phenote/trunk/conf/demo.cfg phenote/trunk/conf/ncbo.cfg phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java Modified: phenote/trunk/conf/birn.cfg =================================================================== --- phenote/trunk/conf/birn.cfg 2007-09-26 16:27:21 UTC (rev 934) +++ phenote/trunk/conf/birn.cfg 2007-09-26 17:19:52 UTC (rev 935) @@ -21,7 +21,7 @@ <ns:field name="Organism" enable="true" datatag="GT" desc="This is like the genotype; its probably a mouse strain or some other identifying factor" colwidth="67"/> <ns:field name="Phenotypic Character" enable="true" desc="This is a free-text field for phenotype characters for now, not exactly sure what this captures; it might be just a grouping or it might be conclusions, or something else entirely" colwidth="96"/> - <ns:field name="Entity" datatag="E" min-completion-chars="3" enable="true" colwidth="150"> + <ns:field name="Entity" datatag="E" min-completion-chars="2" enable="true" colwidth="150"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> <ns:ontology name="BIRNLex" file="BIRNLex.obo"/> @@ -39,7 +39,7 @@ <ns:ontology file="http://www.berkeleybop.org/ontologies/obo-all/quality/quality.obo" name="Quality"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="3" enable="true" colwidth="114"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="2" enable="true" colwidth="114"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> <ns:ontology name="BIRNLex" file="BIRNLex.obo"/> Modified: phenote/trunk/conf/demo.cfg =================================================================== --- phenote/trunk/conf/demo.cfg 2007-09-26 16:27:21 UTC (rev 934) +++ phenote/trunk/conf/demo.cfg 2007-09-26 17:19:52 UTC (rev 935) @@ -38,7 +38,7 @@ <ns:field name="Genetic Context" datatag="GC" enable="true"> <ns:ontology name="Genetic Context" file="context.obo"/> </ns:field> - <ns:field name="Entity" datatag="E" min-completion-chars="3" enable="true"> + <ns:field name="Entity" datatag="E" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" repos-subdir="OBO_REL" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="GO" file="ftp://ftp.geneontology.org/pub/go/ontology/gene_ontology_edit.obo"/> @@ -50,7 +50,7 @@ <ns:ontology name="PATO" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/quality.obo"/> <ns:ontology name="MP" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/mammalian_phenotype.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="3" enable="true"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="GO" file="ftp://ftp.geneontology.org/pub/go/ontology/gene_ontology_edit.obo" /> Modified: phenote/trunk/conf/ncbo.cfg =================================================================== --- phenote/trunk/conf/ncbo.cfg 2007-09-26 16:27:21 UTC (rev 934) +++ phenote/trunk/conf/ncbo.cfg 2007-09-26 17:19:52 UTC (rev 935) @@ -40,7 +40,7 @@ <ns:ontology name="Genetic Context" file="context.obo"/> </ns:field> - <ns:field name="Entity" datatag="E" min-completion-chars="2" enable="true"> + <ns:field name="Entity" datatag="E" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="EHDAA" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/anatomy/gross_anatomy/animal_gross_anatomy/human/human-dev-anat-abstract.obo"/> @@ -56,7 +56,7 @@ <ns:ontology name="MP" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/mammalian_phenotype.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="2" enable="true" desc="To be used when using relational qualities"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="1" enable="true" desc="To be used when using relational qualities"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="EHDAA" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/anatomy/gross_anatomy/animal_gross_anatomy/human/human-dev-anat-abstract.obo"/> Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-26 16:27:21 UTC (rev 934) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-26 17:19:52 UTC (rev 935) @@ -10,6 +10,7 @@ import java.util.List; import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; import javax.swing.ComboBoxModel; import javax.swing.InputMap; import javax.swing.JComboBox; @@ -289,10 +290,47 @@ changingCompletionList = false; if (showPopup) //only show popup on key events actually only do com jComboBox.showPopup(); + //jComboBox.revalidate(); + //jComboBox.repaint(); + //getUIJList().repaint(); + //compRepaint(jComboBox); + //compRepaint(); + comboPopupRepaint(); } } + private void comboPopupRepaint() { + if (!hasComboPopup()) { + log().error("no combo popup to repaint"); + return; + } + ComboPopup p = getComboPopup(); + if (p instanceof Component) ((Component)p).repaint(); + else log().error("Combo Popup not a component, cant repaint"); + } +// private void compRepaint() { +// AccessibleContext ac = jComboBox.getAccessibleContext(); +// for (int i=0; i<ac.getAccessibleChildrenCount(); i++) { +// Accessible a = ac.getAccessibleChild(i); +// log().debug("Accessible child "+a); +// if (a instanceof Component) ((Component)a).repaint(); +// } +// } + +// private void compRepaintCont(java.awt.Container parent) { +// System.out.println(parent+" repainting jcombo kids... "+parent.getComponentCount()); +// log().debug("repainting jcombo kids... "+parent.getComponentCount()); +// for (Component c : parent.getComponents()) { +// log().debug("repainting jcombo child "+c); +// log().debug("instance of ComboPopup "+(c instanceof ComboPopup)); +// c.repaint(); +// if (c instanceof java.awt.Container) compRepaintCont((java.awt.Container)c); +// } + +// } + + private long time=0; private long time() { long newTime = System.currentTimeMillis(); @@ -328,15 +366,35 @@ } protected JList getUIJList() { - Accessible popup = jComboBox.getAccessibleContext().getAccessibleChild(0); - if (!(popup instanceof ComboPopup)) { - this.log().error("Can't retrieve popup from combobox; can't do mouse overs - found instead " + popup.getClass()); - return null; - } else { - return ((ComboPopup)popup).getList(); + if (!hasComboPopup()) return null; + return getComboPopup().getList(); +// Accessible popup = jComboBox.getAccessibleContext().getAccessibleChild(0); +// if (!(popup instanceof ComboPopup)) { +// this.log().error("Can't retrieve popup from combobox; can't do mouse overs - found instead " + popup.getClass()); +// return null; +// } else { +// return ((ComboPopup)popup).getList(); +// } + } + + private boolean hasComboPopup() { return getComboPopup() != null; } + + /** compbo popup is plaf, and not a child component - only way i see to get + it is via Accessible - wierd */ + private ComboPopup getComboPopup() { + //Accessible popup = jComboBox.getAccessibleContext().getAccessibleChild(0); + AccessibleContext ac = jComboBox.getAccessibleContext(); + for (int i=0; i<ac.getAccessibleChildrenCount(); i++) { + Accessible a = ac.getAccessibleChild(i); + if (a instanceof ComboPopup) + return (ComboPopup)a; } + // no ComboPopup found... exception? + log().error("Can't retrieve popup from combobox; can't do mouse overs"); + return null; // ex? } + // for TestPhenote public void doMouseOver(int itemNumber) { //System.out.println("AutoComboBox.doMouseOver not implemented yet"); @@ -461,124 +519,3 @@ } -// GARBAGE - /** @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,CharField cf) { -// protected AbstractAutoCompList(SearchParamsI sp,boolean editModel,CharField cf, -// String label) { -// super(cf,label); -// init(); -// } - /** Override - configureEditor is called when user selects item and sets text - field to item selected, unfortunately this happens after the listening - code in this class that sets to term name (not syn name), and then the syn - name gets set - so this is to catch & repress the subsequent syn name - setting - hope that makes sense heres the jdocs from JComboBox for this method: - Initializes the editor with the specified item. It seems to be ok as far - as i can tell to supress this method entirely - if this ends up being - problematic then this should be coulpled with a flag set in setCurrentValidItem - or a related method to supress the syn coming after term set - this doesnt seem to be supressing anymore so i guess its ok */ -// public void configureEditor(ComboBoxEditor anEditor,Object anItem) { -// //log().debug("configure editor called"+anItem); -// //new Throwable().printStackTrace(); -// // it appears to be ok to supress this entirely -// super.configureEditor(anEditor,anItem); // ??? supress -// } - -// // 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 = getSelectedOboClass(); } -// // 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; } -// } - // hmmmmmm - layout issues... actually the fix was to set the minimum size - // issue was with big terms screwing up layout -// public void layoutComboBox(java.awt.Container parent, MetalComboBoxLayoutManager manager ) { -// javax.swing.Icon icon = ((javax.swing.plaf.metal.MetalComboBoxButton)arrowButton).getComboIcon(); -// java.awt.Insets buttonInsets = arrowButton.getInsets(); -// java.awt.Insets insets = comboBox.getInsets(); -// int buttonWidth = icon.getIconWidth() + buttonInsets.left + buttonInsets.right; -// log().debug(" comb width "+comboBox.getWidth()+" inset right "+insets.right+" but width "+ buttonWidth+" in left "+insets.left+" l2r "+ comboBox.getComponentOrientation().isLeftToRight()+rectangleForCurrentValue()+editor.getBounds()); -// super.layoutComboBox(parent,manager); -// } - /** 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 - this actually needs to go in subclass of JCombo if we go there - this class - no longer sublcasses JCombo - for now commenting out */ -// 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> getTermsOld(String in) { -// // or CompletionList.getCompletionList(getOntology()) ?? -// //CompletionList cl = CompletionList.getCompletionList(); -// //return cl.getCompletionTermList(getOntology(),in,searchParams); -// return ontology.getSearchTerms(in,searchParams); // vector of OBOClass's -// } - //setModel(defaultComboBoxModel); - //defaultComboBoxModel = new DefaultComboBoxModel(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..... - // 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 - // 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; - //log().debug("inputchanged "+inputChanged()); - // this seems like a good idea but leads to a bug - if user types a letter - // then hits "New" then comes back and types same letter then this stops comp - // also i dont think this actually stops any funny behavior - //if (!inputChanged()) // if input is actually same no need to recomp - //return; - //keyTyped = false; - /** 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 - also we are no longer subclass of JCombo so this doesnt - even get called - if we do need this then we need to subclass JCombo */ -// public void setSelectedItem(Object item) { -// doCompletion = false; -// jComboBox.setSelectedItem(item); -// doCompletion = true; -// } - //boolean fiddle = KeyboardState.shouldProcess(e); - //System.out.println("ATF.settext ["+text+"] curr term rel name "+getCurrentTermRelName()); - //if (charField!=null) - //log().debug(charField.getName()+" AutoTextField.setText ["+text+"]"+getCurrentTermRelName()); - //new Throwable().printStackTrace(); - //getTextField().addKeyListener(new AutoKeyListener()); - //return (String)getSelectedItem(); - //if (charField!=null)log().debug(charField.getName()+" setting text ["+text+"]"); - //new Throwable().printStackTrace(); - //this.keyTyped = doCompletion; // key has to be typed for completion - // {charField.getCharFieldEnum().getValue(chr).getOboClass() } Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-26 16:27:21 UTC (rev 934) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-26 17:19:52 UTC (rev 935) @@ -7,6 +7,7 @@ import java.util.List; import java.util.Set; //import java.util.Vector; +import org.apache.log4j.Logger; import org.geneontology.util.AbstractTaskDelegate; import org.geneontology.util.TaskDelegate; @@ -102,6 +103,7 @@ } public void execute() { + try { List<CompletionTerm> searchTerms = new ArrayList<CompletionTerm>(); // if no input should phenote give no terms? or all terms? @@ -138,8 +140,9 @@ searchTerms.addAll(obsoletes); } } - + } + } catch (CancelEx x) { return; } // task has been cancelled @@ -150,6 +153,10 @@ results = searchTerms; if (!isCancelled()) searchListener.newResults(results); // send off results + + } catch (RuntimeException x) { + log().error("got runtime exception in completion "+x); + } } // end of execute method @@ -288,128 +295,11 @@ return sortedTerms; } } + + private Logger log; + private Logger log() { + if (log == null) log = Logger.getLogger(getClass()); + return log; + } } - // now done in Ontology.filterList() so dont have to check every time -// /** 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:"); // take these out of ontology? -// } - // finally got rid of default vector model for AbstractAutoCompList! -// /** 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/TermCompList requires */ -// public Vector<CompletionTerm> getStringMatchTerms(String input) { -// Vector<CompletionTerm> searchTerms = new Vector<CompletionTerm>(); -// if (input == null || input.equals("")) -// return searchTerms; - -// // gets term set for currently selected ontology -// //Set ontologyTermList = getCurrentOntologyTermSet(); -// List<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete -// searchTerms = getSearchTerms(input,ontologyTermList); - -// // if obsoletes set then add them in addition to regulars -// if (searchParams.searchObsoletes()) { -// ontologyTermList = ontology.getSortedObsoleteTerms(); -// Vector obsoletes = getSearchTerms(input,ontologyTermList); -// searchTerms.addAll(obsoletes); -// } -// return searchTerms; -// } - -// /** helper fn for getSearchTerms(String,SearhParamsI) */ -// private Vector<CompletionTerm> getSearchTerms(String input, -// List<OBOClass> ontologyTermList) { -// SearchTermList searchTermList = new SearchTermList(); -// if (ontologyTermList == null) -// return searchTermList.getVector(); - -// //boolean ignoreCase = true; // param? //if (ignoreCase) -// //input = input.toLowerCase(); // done in CompletionTerm - -// // i think iterators are more efficient than get(i) ?? -// Iterator<OBOClass> iter = ontologyTermList.iterator(); -// while (iter.hasNext()) { - -// OBOClass oboClass = iter.next(); - -// CompletionTerm ct = new CompletionTerm(oboClass); -// if (ct.matches(input,searchParams)) { -// searchTermList.addTerm(ct); -// } - -// } -// return searchTermList.getVector(); -// } - -// 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) -> Ont -// searchTermList.addContainsTerm(oboClass); -// return true; -// } -// return false; -// } -// String originalTerm = oboClass.getName();//toString(); -// boolean termAdded = false; -// if (searchParams.searchTerms()) { -// // adds originalTerm to searchTerms if match (1st if exact) -// termAdded = compareAndAddTerm(input,originalTerm,oboClass,searchTermList); -// 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,searchTermList); -// //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,searchTermList); -// if (termAdded) continue; // not really necesary as its last } -// 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; } -// CompletionTerm t = new CompletionTerm(oboClass); -// if (first) startsWithTerms.add(0,t); -// else startsWithTerms.add(t); -// //uniqueCheck.put(oboClass,null); // dont need value -// } -// /** Add term thats not startsWith but contains */ -// private void addContainsTerm(OBOClass oboClass) { -// containTerms.add(new CompletionTerm(oboClass)); -// } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-26 16:27:18
|
Revision: 934 http://obo.svn.sourceforge.net/obo/?rev=934&view=rev Author: balhoff Date: 2007-09-26 09:27:21 -0700 (Wed, 26 Sep 2007) Log Message: ----------- Changes to support use of native lib for Quaqua in webstart. Also, added properties to jnlp so that application will know version and build information at runtime. Modified Paths: -------------- phenote/trunk/build.xml phenote/trunk/doc/phenote-website/phenote.jnlp Modified: phenote/trunk/build.xml =================================================================== --- phenote/trunk/build.xml 2007-09-25 13:22:33 UTC (rev 933) +++ phenote/trunk/build.xml 2007-09-26 16:27:21 UTC (rev 934) @@ -28,6 +28,7 @@ <property name="lib" value="jars"/> <property name="jarfile" value="jars/phenote.jar"/> + <property name="nativelibs-jarname" value="phenote-nativelibs.jar"/> <property name="obo" value="obo-files"/> <property name="conf" value="conf"/> <property name="images" value="images"/> @@ -463,6 +464,9 @@ <copy todir="phenote-webstart/${phenote.version}/jars"> <fileset file="${lib}/*.jar"/> </copy> + <jar destfile="phenote-webstart/${phenote.version}/jars/${nativelibs-jarname}"> + <fileset file="${lib}/*.jnilib"/> + </jar> </target> <target name="sign-webstart-jars"> Modified: phenote/trunk/doc/phenote-website/phenote.jnlp =================================================================== --- phenote/trunk/doc/phenote-website/phenote.jnlp 2007-09-25 13:22:33 UTC (rev 933) +++ phenote/trunk/doc/phenote-website/phenote.jnlp 2007-09-26 16:27:21 UTC (rev 934) @@ -44,6 +44,9 @@ <jar href="jars/jdom.jar" /> <jar href="jars/quaqua.jar" /> <jar href="jars/jebl-0.4.jar" /> + <nativelib href="jars/phenote-nativelibs.jar"/> + <property name="phenote.version" value="@@phenote.version@@"/> + <property name="phenote.build" value="@@phenote.build@@"/> </resources> <!-- no cmd line param will ask user for config at initialization --> <application-desc main-class="phenote.main.Phenote"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-09-25 13:22:29
|
Revision: 933 http://obo.svn.sourceforge.net/obo/?rev=933&view=rev Author: mgibson Date: 2007-09-25 06:22:33 -0700 (Tue, 25 Sep 2007) Log Message: ----------- comp list searcher now checks every 50 terms whether its been cancelled - both for new searches and refinement of old searches (letter added) Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-24 21:39:19 UTC (rev 932) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-25 13:22:33 UTC (rev 933) @@ -9,6 +9,7 @@ //import java.util.Vector; import org.geneontology.util.AbstractTaskDelegate; +import org.geneontology.util.TaskDelegate; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; @@ -113,53 +114,68 @@ // optimization - if user has only typed one more letter (common case) // use previous search list - if (input.startsWith(previousInput) - && input.length() == previousInput.length() + 1) { - searchTerms = searchPreviousList(input,previousCompList); - } - - else { - // gets term set for currently selected ontology(s) - //Set ontologyTermList = getCurrentOntologyTermSet(); - // THIS IS WRONG! or is it? - for (Ontology ontology : ontologyList) { - Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete - List<CompletionTerm> l = getSearchTermList(input,ontologyTermList); - searchTerms.addAll(l); - - // if obsoletes set then add them in addition to regulars - if (searchParams.searchObsoletes()) { - ontologyTermList = ontology.getSortedObsoleteTerms(); - List<CompletionTerm> obsoletes = getSearchTermList(input,ontologyTermList); - searchTerms.addAll(obsoletes); - } + try { + if (input.startsWith(previousInput) + && input.length() == previousInput.length() + 1) { + searchTerms = searchPreviousList(input,previousCompList,this); } - } + + else { + // gets term set for currently selected ontology(s) + //Set ontologyTermList = getCurrentOntologyTermSet(); + // THIS IS WRONG! or is it? + for (Ontology ontology : ontologyList) { + Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete + List<CompletionTerm> l = + getSearchTermList(input,ontologyTermList,this); + searchTerms.addAll(l); + + // if obsoletes set then add them in addition to regulars + if (searchParams.searchObsoletes()) { + ontologyTermList = ontology.getSortedObsoleteTerms(); + List<CompletionTerm> obsoletes = + getSearchTermList(input,ontologyTermList,this); + searchTerms.addAll(obsoletes); + } + } + } + } + catch (CancelEx x) { return; } // task has been cancelled + previousInput = input; previousCompList = searchTerms; //return searchTerms; //setResults(searchTerms); results = searchTerms; - searchListener.newResults(results); // send off results - - } - } + if (!isCancelled()) + searchListener.newResults(results); // send off results + + } // end of execute method + } // end CompTask inner class + private boolean isBlank(String s) { return s == null || s.equals(""); } - /** helper fn for getSearchTerms(String,SearhParamsI) */ + + private class CancelEx extends Exception {} + + /** helper fn for CompTaskDelegate */ private List<CompletionTerm> getSearchTermList(String input, - Collection<OBOClass> ontologyTermList) { + Collection<OBOClass> ontologyTermList, + TaskDelegate task) throws CancelEx { SearchTermList searchTermList = new SearchTermList(); if (ontologyTermList == null) return searchTermList.getList(); + int i =0; for (OBOClass oboClass : ontologyTermList) { + //for (int i=0; i<ontologyTermList.size(); i++) { + if (i++ % 50 == 0 && task.isCancelled()) throw new CancelEx(); CompletionTerm ct = new CompletionTerm(oboClass); // if input is blank then add all terms (list all terms on empty input) // matches records the kind of hit in CompTerm @@ -172,10 +188,16 @@ } private List<CompletionTerm> searchPreviousList(String input, - List<CompletionTerm> prevList) { + List<CompletionTerm> prevList, + TaskDelegate task) + throws CancelEx { + // alternatively could just remove terms from prev list??? SearchTermList newList = new SearchTermList(); - for (CompletionTerm ct : prevList) { + //for (CompletionTerm ct : prevList) { + for (int i=0; i<prevList.size(); i++) { + if (i % 50 == 0 && task.isCancelled()) throw new CancelEx(); + CompletionTerm ct = prevList.get(i); ct.resetMatchState(); // reusing ct has stale match state from previous search if (ct.matches(input,searchParams)) newList.addTerm(ct); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <nl...@us...> - 2007-09-24 21:39:15
|
Revision: 932 http://obo.svn.sourceforge.net/obo/?rev=932&view=rev Author: nlw Date: 2007-09-24 14:39:19 -0700 (Mon, 24 Sep 2007) Log Message: ----------- *fixed frame closing bug in request-term... it was exiting the application when closing the window. now it hides and disposes the frame. program should keep running just fine. Modified Paths: -------------- phenote/trunk/src/java/phenote/gui/TermRequestGUI.java Modified: phenote/trunk/src/java/phenote/gui/TermRequestGUI.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermRequestGUI.java 2007-09-24 17:56:15 UTC (rev 931) +++ phenote/trunk/src/java/phenote/gui/TermRequestGUI.java 2007-09-24 21:39:19 UTC (rev 932) @@ -62,7 +62,7 @@ super(); setTitle("Term Request"); setBounds(100, 100, 500, 375); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); final JPanel panel = new JPanel(); getContentPane().add(panel, BorderLayout.CENTER); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mg...@us...> - 2007-09-24 17:56:14
|
Revision: 931 http://obo.svn.sourceforge.net/obo/?rev=931&view=rev Author: mgibson Date: 2007-09-24 10:56:15 -0700 (Mon, 24 Sep 2007) Log Message: ----------- optimization for auto complete now uses threading via obo edits TaskDelegates to cancel autocomps that have been superseded with new typed letters its not even cancelling ongoing searches yet and the improvement is awesome - this blows away the min chars optimization which sort of becomes irrelevant (and its buggy anyways) except min chars 1 is a way of disabling preloading ontolgies into fields - which is good for post comp window which can take a long time to come up otherwise Modified Paths: -------------- phenote/trunk/conf/birn.cfg phenote/trunk/conf/birn2.cfg phenote/trunk/conf/flybase.cfg phenote/trunk/conf/ncbo.cfg phenote/trunk/conf/smart-atlas.cfg phenote/trunk/jars/org.geneontology.jar phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java phenote/trunk/src/java/phenote/gui/field/RelationCompList.java phenote/trunk/src/java/phenote/gui/field/TermCompList.java phenote/trunk/src/java/phenote/servlet/PhenoteController.java Added Paths: ----------- phenote/trunk/src/java/phenote/gui/field/SearchListener.java Modified: phenote/trunk/conf/birn.cfg =================================================================== --- phenote/trunk/conf/birn.cfg 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/conf/birn.cfg 2007-09-24 17:56:15 UTC (rev 931) @@ -21,7 +21,7 @@ <ns:field name="Organism" enable="true" datatag="GT" desc="This is like the genotype; its probably a mouse strain or some other identifying factor" colwidth="67"/> <ns:field name="Phenotypic Character" enable="true" desc="This is a free-text field for phenotype characters for now, not exactly sure what this captures; it might be just a grouping or it might be conclusions, or something else entirely" colwidth="96"/> - <ns:field name="Entity" datatag="E" min-completion-chars="4" enable="true" colwidth="150"> + <ns:field name="Entity" datatag="E" min-completion-chars="3" enable="true" colwidth="150"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> <ns:ontology name="BIRNLex" file="BIRNLex.obo"/> @@ -39,7 +39,7 @@ <ns:ontology file="http://www.berkeleybop.org/ontologies/obo-all/quality/quality.obo" name="Quality"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="4" enable="true" colwidth="114"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="3" enable="true" colwidth="114"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> <ns:ontology name="BIRNLex" file="BIRNLex.obo"/> Modified: phenote/trunk/conf/birn2.cfg =================================================================== --- phenote/trunk/conf/birn2.cfg 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/conf/birn2.cfg 2007-09-24 17:56:15 UTC (rev 931) @@ -23,7 +23,7 @@ <ns:field name="Organism" enable="true" datatag="GT" desc="This is like the genotype; its probably a mouse strain or some other identifying factor"/> <ns:field name="Phenotypic Character" enable="true" desc="This is a free-text field for phenotype characters for now, not exactly sure what this captures; it might be just a grouping or it might be conclusions, or something else entirely"/> - <ns:field name="Entity" min-completion-chars="4" datatag="E" enable="true"> + <ns:field name="Entity" min-completion-chars="1" datatag="E" enable="true"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> @@ -43,7 +43,7 @@ <ns:ontology file="http://www.berkeleybop.org/ontologies/obo-all/quality/quality.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="4" enable="true"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> Modified: phenote/trunk/conf/flybase.cfg =================================================================== --- phenote/trunk/conf/flybase.cfg 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/conf/flybase.cfg 2007-09-24 17:56:15 UTC (rev 931) @@ -37,7 +37,7 @@ <ns:ontology file="context.obo"/> </ns:field> - <ns:field name="Entity" datatag="E" min-completion-chars="3"> + <ns:field name="Entity" datatag="E" min-completion-chars="1"> <!-- postcomp relationship-ontology="relationship.obo" repos-subdir="OBO_REL"/ --> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> Modified: phenote/trunk/conf/ncbo.cfg =================================================================== --- phenote/trunk/conf/ncbo.cfg 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/conf/ncbo.cfg 2007-09-24 17:56:15 UTC (rev 931) @@ -40,7 +40,7 @@ <ns:ontology name="Genetic Context" file="context.obo"/> </ns:field> - <ns:field name="Entity" datatag="E" min-completion-chars="3" enable="true"> + <ns:field name="Entity" datatag="E" min-completion-chars="2" enable="true"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="EHDAA" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/anatomy/gross_anatomy/animal_gross_anatomy/human/human-dev-anat-abstract.obo"/> @@ -56,7 +56,7 @@ <ns:ontology name="MP" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/phenotype/mammalian_phenotype.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="3" enable="true" desc="To be used when using relational qualities"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="2" enable="true" desc="To be used when using relational qualities"> <ns:ontology name="Relationship" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo" is-postcomp-rel="true"/> <ns:ontology name="FMA" file="http://obo.svn.sourceforge.net/viewvc/*checkout*/obo/fma-conversion/trunk/fma_obo.obo"/> <ns:ontology name="EHDAA" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/anatomy/gross_anatomy/animal_gross_anatomy/human/human-dev-anat-abstract.obo"/> Modified: phenote/trunk/conf/smart-atlas.cfg =================================================================== --- phenote/trunk/conf/smart-atlas.cfg 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/conf/smart-atlas.cfg 2007-09-24 17:56:15 UTC (rev 931) @@ -30,7 +30,7 @@ <ns:field name="Slice Type" datatag="slicetype" enable="true" desc="coronal or sagittal, read only?"/> <ns:field name="Slice Number" datatag="slicenumber" enable="true" desc="images have many slices(?)"/> - <ns:field name="Entity" datatag="E" min-completion-chars="4" enable="true"> + <ns:field name="Entity" datatag="E" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> @@ -52,7 +52,7 @@ <ns:ontology file="http://www.berkeleybop.org/ontologies/obo-all/quality/quality.obo"/> </ns:field> - <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="4" enable="true"> + <ns:field name="Add'l Entity" datatag="E2" min-completion-chars="1" enable="true"> <ns:ontology name="Relationship" is-postcomp-rel="true" file="http://obo.cvs.sourceforge.net/*checkout*/obo/obo/ontology/OBO_REL/ro.obo"/> <ns:ontology name="SAO" file="SAO.obo"/> Modified: phenote/trunk/jars/org.geneontology.jar =================================================================== (Binary files differ) Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-09-24 17:56:15 UTC (rev 931) @@ -261,18 +261,38 @@ // returns a list of CompletionTerms (checks if relations) // if input is empty will return whole list (if configged) //log().debug("got new completion request for input "+input+" time "+time()); - List<CompletionTerm> l = getSearchItems(input); + listSearchListener.showPopup = showPopup; + /*List<CompletionTerm> l =*/ getSearchItems(input,listSearchListener); //log().debug("got search items for input "+input+" milsec: "+time()); - changingCompletionList = true; - // could just do comboBoxModel.setList(l); ??? - compComboBoxModel = new CompComboBoxModel(l); - jComboBox.setModel(compComboBoxModel); - changingCompletionList = false; - if (showPopup) - jComboBox.showPopup();//only show popup on key events actually only do comp w key +// changingCompletionList = true; +// // could just do comboBoxModel.setList(l); ??? +// compComboBoxModel = new CompComboBoxModel(l); +// jComboBox.setModel(compComboBoxModel); +// changingCompletionList = false; +// if (showPopup) +// jComboBox.showPopup();//only show popup on key events actually only //log().debug("put comp list in gui for input "+input+" milsec: "+time()); } + private ListSearchListener listSearchListener = new ListSearchListener(); + + /** This is where the CompListSearcher results get returned + from thread */ + private class ListSearchListener implements SearchListener { + private boolean showPopup = true; + // could have CompletionItem superclass for rel & term?? + public void newResults(List results) { + changingCompletionList = true; + // could just do comboBoxModel.setList(l); ??? + compComboBoxModel = new CompComboBoxModel(results); + jComboBox.setModel(compComboBoxModel); + changingCompletionList = false; + if (showPopup) //only show popup on key events actually only do com + jComboBox.showPopup(); + } + } + + private long time=0; private long time() { long newTime = System.currentTimeMillis(); @@ -291,7 +311,8 @@ this.inTestMode = inTestMode; } - protected abstract List<CompletionTerm> getSearchItems(String input); + // no longer returns List<CompletionTerm>, a thread sends list to listener + protected abstract void getSearchItems(String input,SearchListener l); // if (isRelationshipList()) return termSearcher.getStringMatchRelations(input); // else return termSearcher.getStringMatchTerms(input);} Modified: phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/src/java/phenote/gui/field/CompListSearcher.java 2007-09-24 17:56:15 UTC (rev 931) @@ -8,6 +8,7 @@ import java.util.Set; //import java.util.Vector; +import org.geneontology.util.AbstractTaskDelegate; import org.geneontology.oboedit.datamodel.OBOClass; import org.geneontology.oboedit.datamodel.OBOProperty; @@ -59,6 +60,7 @@ ontologyList = l; // (List<Ontology>)l.clone(); cant clone interfaces } + /** relations are short ontologies - dont need threaded optimization */ public List<CompletionRelation> getStringMatchRelations(String input) { List<CompletionRelation> matches = new ArrayList<CompletionRelation>(); // most likely only 1 relation ontology, but no harm being general @@ -71,47 +73,80 @@ return matches; } + private CompTaskDelegate compTaskDelegate = null; + /** Returns a List of CompletionTerms from ontology that contain input string constrained by compParams. compParams specifies syns,terms,defs,& obs should input be just part of search params? called by servlet & standalone now */ - public List<CompletionTerm> getStringMatchTermList(String input) { - List<CompletionTerm> searchTerms = new ArrayList<CompletionTerm>(); - - boolean nothingForNothing = false; // get from FieldConfig!! - if (nothingForNothing && isBlank(input)) { - return searchTerms; // empty - } + public /*List<CompletionTerm>*/ void getStringMatchTermList(String input, + SearchListener lis) { + + //new org.jdesktop.swingworker.SwingWorker(); + // kill old task! + if (compTaskDelegate!=null) compTaskDelegate.cancel(); + compTaskDelegate = new CompTaskDelegate(input,lis); + org.geneontology.swing.BackgroundUtil.scheduleTask(compTaskDelegate); - // optimization - if user has only typed one more letter (common case) - // use previous search list - if (input.startsWith(previousInput) - && input.length() == previousInput.length() + 1) { - searchTerms = searchPreviousList(input,previousCompList); + } + + private class CompTaskDelegate + extends AbstractTaskDelegate<List<CompletionTerm>> { + + private String input; + private SearchListener searchListener; + + private CompTaskDelegate(String input,SearchListener l) { + this.input = input; + this.searchListener = l; } - else { - // gets term set for currently selected ontology(s) - //Set ontologyTermList = getCurrentOntologyTermSet(); - // THIS IS WRONG! or is it? - for (Ontology ontology : ontologyList) { - Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete - List<CompletionTerm> l = getSearchTermList(input,ontologyTermList); - searchTerms.addAll(l); - - // if obsoletes set then add them in addition to regulars - if (searchParams.searchObsoletes()) { - ontologyTermList = ontology.getSortedObsoleteTerms(); - List<CompletionTerm> obsoletes = getSearchTermList(input,ontologyTermList); - searchTerms.addAll(obsoletes); + public void execute() { + List<CompletionTerm> searchTerms = new ArrayList<CompletionTerm>(); + + // if no input should phenote give no terms? or all terms? + boolean nothingForNothing = false; // get from FieldConfig!! + if (nothingForNothing && isBlank(input)) { + results = searchTerms; // empty + searchListener.newResults(results); + return; + } + + // optimization - if user has only typed one more letter (common case) + // use previous search list + if (input.startsWith(previousInput) + && input.length() == previousInput.length() + 1) { + searchTerms = searchPreviousList(input,previousCompList); + } + + else { + // gets term set for currently selected ontology(s) + //Set ontologyTermList = getCurrentOntologyTermSet(); + // THIS IS WRONG! or is it? + for (Ontology ontology : ontologyList) { + Collection<OBOClass> ontologyTermList = ontology.getSortedTerms(); // non obsolete + List<CompletionTerm> l = getSearchTermList(input,ontologyTermList); + searchTerms.addAll(l); + + // if obsoletes set then add them in addition to regulars + if (searchParams.searchObsoletes()) { + ontologyTermList = ontology.getSortedObsoleteTerms(); + List<CompletionTerm> obsoletes = getSearchTermList(input,ontologyTermList); + searchTerms.addAll(obsoletes); + } } } + + previousInput = input; + previousCompList = searchTerms; + //return searchTerms; + //setResults(searchTerms); + results = searchTerms; + searchListener.newResults(results); // send off results + } - - previousInput = input; - previousCompList = searchTerms; - return searchTerms; } + private boolean isBlank(String s) { return s == null || s.equals(""); } Modified: phenote/trunk/src/java/phenote/gui/field/RelationCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/src/java/phenote/gui/field/RelationCompList.java 2007-09-24 17:56:15 UTC (rev 931) @@ -117,8 +117,10 @@ // protected Vector getSearchItems(String input) { // return getCompListSearcher().getStringMatchRelations(input); // } - protected List getSearchItems(String input) { - return getCompListSearcher().getStringMatchRelations(input); + protected void getSearchItems(String input, SearchListener l) { + // for now not threading and just sending results to listener - + // relations are short lists - dont need threaded optimization + l.newResults(getCompListSearcher().getStringMatchRelations(input)); } Added: phenote/trunk/src/java/phenote/gui/field/SearchListener.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/SearchListener.java (rev 0) +++ phenote/trunk/src/java/phenote/gui/field/SearchListener.java 2007-09-24 17:56:15 UTC (rev 931) @@ -0,0 +1,9 @@ +package phenote.gui.field; + +import java.util.List; + +public interface SearchListener { + // should there be an event - not needed at this pt - maybe later + // could add a CompItem super class of term & rel? + public void newResults(List results); +} Modified: phenote/trunk/src/java/phenote/gui/field/TermCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/src/java/phenote/gui/field/TermCompList.java 2007-09-24 17:56:15 UTC (rev 931) @@ -115,8 +115,9 @@ } } - protected List<CompletionTerm> getSearchItems(String input) { - return getCompListSearcher().getStringMatchTermList(input); + /** now threaded so cant return - set AbAutoCompList when done */ + protected void getSearchItems(String input,SearchListener l) { + /*return*/ getCompListSearcher().getStringMatchTermList(input,l); } /** Modified: phenote/trunk/src/java/phenote/servlet/PhenoteController.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2007-09-24 17:25:47 UTC (rev 930) +++ phenote/trunk/src/java/phenote/servlet/PhenoteController.java 2007-09-24 17:56:15 UTC (rev 931) @@ -13,6 +13,7 @@ import phenote.gui.SearchParams; import phenote.gui.field.CompListSearcher; import phenote.gui.field.CompletionTerm; +import phenote.gui.field.SearchListener; import phenote.util.HtmlUtil; import javax.servlet.http.HttpServletRequest; @@ -45,8 +46,9 @@ LOG.info("param entityInput: " + userInput); LOG.info("Field entity: " + field); - form.setCompletionTermList(getCompletionList(userInput, ontologyName, field)); - LOG.debug(form.getAjaxReturnList()); + //form.setCompletionTermList( // this is now done by ContSearchListener + getCompletionList(userInput, ontologyName, field, form); + LOG.debug(form.getAjaxReturnList()); // ?? should this go in CSL? } else if (form.isTermInfoRequest()) { String termId = form.getTermId(); LOG.debug("doGet term info param: " + termId + " ont " + ontologyName); @@ -65,18 +67,36 @@ return new ModelAndView("term_completion", "formBean", form); } - private List<CompletionTerm> getCompletionList(String userInput, String ontologyName, String field) { - List<CompletionTerm> termList = null; + private void getCompletionList(String userInput, String ontologyName, String field, + PhenoteBean form) { + //List<CompletionTerm> termList = null; + SearchListener searchListener = new ContSearchListener(ontologyName,field,form); try { - termList = getCompListSearcher(ontologyName).getStringMatchTermList(userInput); + //termList = its now threaded - term list returned to SearchListener + getCompListSearcher(ontologyName).getStringMatchTermList(userInput,searchListener); } catch (OntologyException e) { // Todo: Add this error as an error completion list LOG.error(e.getMessage(), e); } - includeAdditionalAttributes(termList, ontologyName, field); - return termList; + //includeAdditionalAttributes(termList, ontologyName, field); + //return termList; } + private class ContSearchListener implements SearchListener { + private String ontologyName; + private String field; + private PhenoteBean form; + private ContSearchListener(String ontologyName, String field, PhenoteBean form) { + this.ontologyName = ontologyName; + this.field = field; + this.form = form; + } + public void newResults(List termList) { + includeAdditionalAttributes(termList, ontologyName, field); + form.setCompletionTermList(termList); + } + } + private void includeAdditionalAttributes(List<CompletionTerm> termList, String ontologyName, String field) { if (termList == null) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ba...@us...> - 2007-09-24 17:26:03
|
Revision: 930 http://obo.svn.sourceforge.net/obo/?rev=930&view=rev Author: balhoff Date: 2007-09-24 10:25:47 -0700 (Mon, 24 Sep 2007) Log Message: ----------- Fix for threading bug with adding initial character to table. Modified Paths: -------------- phenote/trunk/src/java/phenote/datamodel/CharacterList.java phenote/trunk/src/java/phenote/gui/CharacterTableController.java Modified: phenote/trunk/src/java/phenote/datamodel/CharacterList.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharacterList.java 2007-09-24 06:20:35 UTC (rev 929) +++ phenote/trunk/src/java/phenote/datamodel/CharacterList.java 2007-09-24 17:25:47 UTC (rev 930) @@ -2,7 +2,6 @@ import ca.odell.glazedlists.BasicEventList; import ca.odell.glazedlists.EventList; -import ca.odell.glazedlists.GlazedLists; /** i made this as a transferable when i didnt get the whole transferable thing and now i dont whether to scrap it or not. all it is at the moment is a @@ -10,8 +9,7 @@ functionality - i guess ill keep it for now */ public class CharacterList implements CharacterListI { - // the thread safe version is required due to problems selecting the first character when the character table is first created - private EventList<CharacterI> characterList = GlazedLists.threadSafeList(new BasicEventList<CharacterI>()); + private EventList<CharacterI> characterList = new BasicEventList<CharacterI>(); public CharacterI get(int i) { // should this check if i is out of range - throw ex, or print error msg?? Modified: phenote/trunk/src/java/phenote/gui/CharacterTableController.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-24 06:20:35 UTC (rev 929) +++ phenote/trunk/src/java/phenote/gui/CharacterTableController.java 2007-09-24 17:25:47 UTC (rev 930) @@ -14,6 +14,7 @@ import javax.swing.JPopupMenu; import javax.swing.JTable; import javax.swing.JTextField; +import javax.swing.SwingUtilities; import javax.swing.table.TableColumn; import org.apache.log4j.Logger; @@ -67,7 +68,7 @@ this.initializeInterface(); this.addInitialBlankCharacter(); } - + public JPanel getCharacterTablePanel() { return this.characterTablePanel; } @@ -159,7 +160,11 @@ } private void addInitialBlankCharacter() { - this.getEditManager().addInitialCharacter(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + CharacterTableController.this.getEditManager().addInitialCharacter(); + } + }); } private void setSelectionWithCharacters(List<CharacterI> characters) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |