From: <mg...@us...> - 2006-08-28 20:26:10
|
Revision: 102 Author: mgibson Date: 2006-08-28 13:25:57 -0700 (Mon, 28 Aug 2006) ViewCVS: http://svn.sourceforge.net/obo/?rev=102&view=rev Log Message: ----------- refactor - made CharFieldEnum its own class - bout time improved layout of ontology chooser - snuggles in with label Modified Paths: -------------- phenote/trunk/src/java/phenote/config/Config.java phenote/trunk/src/java/phenote/config/FieldConfig.java phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/edit/UpdateTransaction.java phenote/trunk/src/java/phenote/gui/AutoComboBox.java phenote/trunk/src/java/phenote/gui/CharFieldGui.java phenote/trunk/src/java/phenote/gui/CharacterTableModel.java phenote/trunk/src/java/phenote/gui/TermInfo.java phenote/trunk/src/java/phenote/gui/TermPanel.java phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java Added Paths: ----------- phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java Modified: phenote/trunk/src/java/phenote/config/Config.java =================================================================== --- phenote/trunk/src/java/phenote/config/Config.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/config/Config.java 2006-08-28 20:25:57 UTC (rev 102) @@ -25,7 +25,7 @@ import phenote.config.xml.FieldDocument.Field; import phenote.config.xml.OntologyDocument.Ontology; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.dataadapter.DataAdapterI; import phenote.dataadapter.fly.FlybaseDataAdapter; import phenote.dataadapter.phenosyntax.PhenoSyntaxFileAdapter; Modified: phenote/trunk/src/java/phenote/config/FieldConfig.java =================================================================== --- phenote/trunk/src/java/phenote/config/FieldConfig.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/config/FieldConfig.java 2006-08-28 20:25:57 UTC (rev 102) @@ -3,7 +3,7 @@ import java.util.ArrayList; import java.util.List; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; public class FieldConfig { Modified: phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/dataadapter/OntologyDataAdapter.java 2006-08-28 20:25:57 UTC (rev 102) @@ -16,7 +16,7 @@ import org.geneontology.oboedit.dataadapter.OBOFileAdapter; import phenote.datamodel.CharField; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.Ontology; import phenote.datamodel.OntologyManager; import phenote.config.Config; Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2006-08-28 20:25:57 UTC (rev 102) @@ -13,70 +13,70 @@ // is this taking enums too far? or a good use of them? // would it be nice to have a class that wrapped String and OBOClass? // and all possible field values? or would that be annoying? - public enum CharFieldEnum { - PUB("Pub") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setPub(v.getName()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getPub(),c,this); - } - }, - LUMP("Genotype") { // genotype? default? - public void setValue(CharacterI c, CharFieldValue v) { - c.setGenotype(v.getName()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getGenotype(),c,this); - } - }, - GENETIC_CONTEXT("Genetic Context") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setGeneticContext(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getGeneticContext(),c,this); - } - }, - ENTITY("Entity") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setEntity(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getEntity(),c,this); - } - }, - QUALITY("Quality") { - public void setValue(CharacterI c, CharFieldValue v) { - c.setQuality(v.getOboClass()); - } - public CharFieldValue getValue(CharacterI c) { - return new CharFieldValue(c.getQuality(),c,this); - } - }; +// public enum CharFieldEnum { - private final String name; - private CharFieldEnum(String name) { this.name = name; } - public String toString() { return name; } - public abstract void setValue(CharacterI c, CharFieldValue v); - public abstract CharFieldValue getValue(CharacterI c); +// PUB("Pub") { +// public void setValue(CharacterI c, CharFieldValue v) { +// c.setPub(v.getName()); +// } +// public CharFieldValue getValue(CharacterI c) { +// return new CharFieldValue(c.getPub(),c,this); +// } +// }, +// LUMP("Genotype") { // genotype? default? +// public void setValue(CharacterI c, CharFieldValue v) { +// c.setGenotype(v.getName()); +// } +// public CharFieldValue getValue(CharacterI c) { +// return new CharFieldValue(c.getGenotype(),c,this); +// } +// }, +// GENETIC_CONTEXT("Genetic Context") { +// public void setValue(CharacterI c, CharFieldValue v) { +// c.setGeneticContext(v.getOboClass()); +// } +// public CharFieldValue getValue(CharacterI c) { +// return new CharFieldValue(c.getGeneticContext(),c,this); +// } +// }, +// ENTITY("Entity") { +// public void setValue(CharacterI c, CharFieldValue v) { +// c.setEntity(v.getOboClass()); +// } +// public CharFieldValue getValue(CharacterI c) { +// return new CharFieldValue(c.getEntity(),c,this); +// } +// }, +// QUALITY("Quality") { +// public void setValue(CharacterI c, CharFieldValue v) { +// c.setQuality(v.getOboClass()); +// } +// public CharFieldValue getValue(CharacterI c) { +// return new CharFieldValue(c.getQuality(),c,this); +// } +// }; - // is this getting silly? abstract? --> char field value i think - //public void setOboClass(CharacterI c, OBOClass o) {} - //public OBOClass getOBOClass(CharacterI c) { return null; } - // unclear if we need this??? need it in generic field config - public static CharFieldEnum getCharFieldEnum(String fieldString) { - for ( CharFieldEnum cfe : CharFieldEnum.values()) { - if (cfe.name.equalsIgnoreCase(fieldString)) - return cfe; - } - System.out.println("ERROR: No Char Field found for string "+fieldString); - return null; - } - }; +// // CHAR FIELD ENUM vars & methods (make its own class!) +// private final String name; +// private CharFieldEnum(String name) { this.name = name; } +// public String toString() { return name; } +// public abstract void setValue(CharacterI c, CharFieldValue v); +// public abstract CharFieldValue getValue(CharacterI c); - +// // unclear if we need this??? need it in generic field config +// public static CharFieldEnum getCharFieldEnum(String fieldString) { +// for ( CharFieldEnum cfe : CharFieldEnum.values()) { +// if (cfe.name.equalsIgnoreCase(fieldString)) +// return cfe; +// } +// System.out.println("ERROR: No Char Field found for string "+fieldString); +// return null; +// } + +// }; + + // CHAR FIELD VARS private List<Ontology> ontologyList = new ArrayList<Ontology>(3); private CharFieldEnum charFieldEnum; // or subclass private String name; @@ -116,6 +116,9 @@ public boolean hasOneOntology() { return hasOntologies() && getOntologySize() == 1; } + public boolean hasMoreThanOneOntology() { + return hasOntologies() && !hasOneOntology(); + } public Ontology getOntology() { if (!hasOntologies()) return null; @@ -142,6 +145,9 @@ } } + // is this getting silly? abstract? --> char field value i think + //public void setOboClass(CharacterI c, OBOClass o) {} + //public OBOClass getOBOClass(CharacterI c) { return null; } // public CharField(CharFieldEnum c, Ontology o) { // charFieldEnum = c; // ontologyList.add(o); Added: phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java (rev 0) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldEnum.java 2006-08-28 20:25:57 UTC (rev 102) @@ -0,0 +1,68 @@ +package phenote.datamodel; + + // separate class? labels? methods? subclasses? + // is this taking enums too far? or a good use of them? + // would it be nice to have a class that wrapped String and OBOClass? + // and all possible field values? or would that be annoying? + public enum CharFieldEnum { + + PUB("Pub") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setPub(v.getName()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getPub(),c,this); + } + }, + LUMP("Genotype") { // genotype? default? + public void setValue(CharacterI c, CharFieldValue v) { + c.setGenotype(v.getName()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getGenotype(),c,this); + } + }, + GENETIC_CONTEXT("Genetic Context") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setGeneticContext(v.getOboClass()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getGeneticContext(),c,this); + } + }, + ENTITY("Entity") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setEntity(v.getOboClass()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getEntity(),c,this); + } + }, + QUALITY("Quality") { + public void setValue(CharacterI c, CharFieldValue v) { + c.setQuality(v.getOboClass()); + } + public CharFieldValue getValue(CharacterI c) { + return new CharFieldValue(c.getQuality(),c,this); + } + }; + + + // CHAR FIELD ENUM vars & methods (make its own class!) + private final String name; + private CharFieldEnum(String name) { this.name = name; } + public String toString() { return name; } + public abstract void setValue(CharacterI c, CharFieldValue v); + public abstract CharFieldValue getValue(CharacterI c); + + // unclear if we need this??? need it in generic field config + public static CharFieldEnum getCharFieldEnum(String fieldString) { + for ( CharFieldEnum cfe : CharFieldEnum.values()) { + if (cfe.name.equalsIgnoreCase(fieldString)) + return cfe; + } + System.out.println("ERROR: No Char Field found for string "+fieldString); + return null; + } + + }; Modified: phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/datamodel/CharFieldValue.java 2006-08-28 20:25:57 UTC (rev 102) @@ -2,7 +2,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; -import phenote.datamodel.CharField.CharFieldEnum; +//import phenote.datamodel.CharField.CharFieldEnum; /** At the moment char field values can be Strings (genotype) and OBOClasses, and possibly more coming (Genotype?). This class attempts to hide the details of the actual Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2006-08-28 20:25:57 UTC (rev 102) @@ -6,7 +6,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; /** Manages all of the ontology. Eventually will get config info (xml? OntologyConfig?) and set itself up from that. Should there be an ontology package - whats funny Modified: phenote/trunk/src/java/phenote/edit/UpdateTransaction.java =================================================================== --- phenote/trunk/src/java/phenote/edit/UpdateTransaction.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/edit/UpdateTransaction.java 2006-08-28 20:25:57 UTC (rev 102) @@ -2,7 +2,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharFieldValue; import phenote.datamodel.CharacterI; Modified: phenote/trunk/src/java/phenote/gui/AutoComboBox.java =================================================================== --- phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/gui/AutoComboBox.java 2006-08-28 20:25:57 UTC (rev 102) @@ -23,7 +23,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.CharField; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharacterI; import phenote.datamodel.Ontology; import phenote.datamodel.SearchParamsI; Modified: phenote/trunk/src/java/phenote/gui/CharFieldGui.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/gui/CharFieldGui.java 2006-08-28 20:25:57 UTC (rev 102) @@ -10,7 +10,7 @@ import javax.swing.event.DocumentEvent; import phenote.datamodel.CharField; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharacterI; import phenote.datamodel.Ontology; import phenote.datamodel.OntologyManager; @@ -93,9 +93,9 @@ isCombo = true; String name = charField.getFirstOntology().getName(); - JLabel label = termPanel.addLabel(name,parent); + JLabel label = termPanel.addLabel(name,parent,charField.hasMoreThanOneOntology()); // if has more than one ontology(entity) than add ontology choose list - if (!charField.hasOneOntology()) { + if (charField.hasMoreThanOneOntology()) { label.setText(charField.getName()); initOntologyChooser(charField,parent); } Modified: phenote/trunk/src/java/phenote/gui/CharacterTableModel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTableModel.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/gui/CharacterTableModel.java 2006-08-28 20:25:57 UTC (rev 102) @@ -8,7 +8,7 @@ import phenote.datamodel.Character; import phenote.datamodel.CharacterI; import phenote.datamodel.CharacterListI; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.dataadapter.CharacterListManager; import phenote.config.Config; Modified: phenote/trunk/src/java/phenote/gui/TermInfo.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/gui/TermInfo.java 2006-08-28 20:25:57 UTC (rev 102) @@ -29,7 +29,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.CharacterI; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.OntologyManager; import phenote.edit.EditManager; import phenote.edit.UpdateTransaction; @@ -55,8 +55,8 @@ JComponent getComponent() { JPanel termInfoPanel = new JPanel(new BorderLayout(0,0)); // hgap,vgap - termInfoPanel.setPreferredSize(new Dimension(500,700)); - termInfoPanel.setMinimumSize(new Dimension(300,500)); + termInfoPanel.setPreferredSize(new Dimension(600,700)); + termInfoPanel.setMinimumSize(new Dimension(350,500)); if (DO_HTML) { JEditorPane editorPane = new JEditorPane(); editorPane.setContentType("text/html"); // sets up HTMLEditorKit @@ -75,7 +75,8 @@ scrollPane.setPreferredSize(new Dimension(400,300)); scrollPane.setMaximumSize(new Dimension(400,300)); // border - make JPanel for it (there is a disclaimer about non JPanel) - scrollPane.setBorder(BorderFactory.createTitledBorder("Term Info")); + //scrollPane.setBorder(BorderFactory.createTitledBorder("Term Info")); + termInfoPanel.setBorder(BorderFactory.createTitledBorder("Term Info")); termInfoPanel.add(scrollPane,BorderLayout.CENTER); JButton useTermButton = new JButton("Use Term"); Modified: phenote/trunk/src/java/phenote/gui/TermPanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermPanel.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/gui/TermPanel.java 2006-08-28 20:25:57 UTC (rev 102) @@ -17,7 +17,7 @@ import javax.swing.JPanel; import phenote.datamodel.CharField; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.CharacterI; import phenote.datamodel.Ontology; import phenote.datamodel.OntologyManager; @@ -75,8 +75,12 @@ } JLabel addLabel(String labelString,Container parent) { + return addLabel(labelString,parent,false); // false - no ont chooser + } + + JLabel addLabel(String labelString,Container parent,boolean hasOntChooser) { JLabel label = new JLabel(labelString); - GridBagConstraints gbc = makeLabelConstraint(); + GridBagConstraints gbc = makeLabelConstraint(hasOntChooser); parent.add(label,gbc); return label; } @@ -92,23 +96,25 @@ private int gridbagRow = 0; boolean ontologyChooserPresent = false; - private GridBagConstraints makeLabelConstraint() { - ontologyChooserPresent = false; // cheesy + private GridBagConstraints makeLabelConstraint(boolean hasOntChooser) { + ontologyChooserPresent = hasOntChooser; // ?? // x,y,horizPad,vertPad // make width 2 unless theres a chooser, then 1 - return GridBagUtil.makeConstraint(0,gridbagRow,1,3); + int width = hasOntChooser ? 1 : 2; + return GridBagUtil.makeWidthConstraint(0,gridbagRow,1,3,width); } + private GridBagConstraints makeOntologyChooserConstraint() { + ontologyChooserPresent = true; // cheesy - dont need? + return GridBagUtil.makeConstraint(1,gridbagRow,1,3); // width 1 + } + private GridBagConstraints makeFieldConstraint() { - int x = ontologyChooserPresent ? 2 : 1; - int width = ontologyChooserPresent ? 1 : 2; // ??? + int x = 2;//ontologyChooserPresent ? 2 : 1; + int width = 1;//ontologyChooserPresent ? 1 : 2; // ??? return GridBagUtil.makeWidthConstraint(x,gridbagRow++,1,3,width); } - private GridBagConstraints makeOntologyChooserConstraint() { - ontologyChooserPresent = true; // cheesy - return GridBagUtil.makeConstraint(1,gridbagRow,1,3); - } // for test and term info to listen - move to test code? Modified: phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java =================================================================== --- phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-08-28 19:20:10 UTC (rev 101) +++ phenote/trunk/src/java/phenote/servlet/PhenoteServlet.java 2006-08-28 20:25:57 UTC (rev 102) @@ -12,7 +12,7 @@ import org.geneontology.oboedit.datamodel.OBOClass; import phenote.datamodel.CharField; -import phenote.datamodel.CharField.CharFieldEnum; +import phenote.datamodel.CharFieldEnum; import phenote.datamodel.Ontology; import phenote.datamodel.OntologyManager; import phenote.datamodel.SearchParamsI; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |