From: <mg...@us...> - 2007-03-23 20:02:14
|
Revision: 415 http://svn.sourceforge.net/obo/?rev=415&view=rev Author: mgibson Date: 2007-03-23 13:02:12 -0700 (Fri, 23 Mar 2007) Log Message: ----------- if there are more than 12 fields phenote now makes a tabbed panel currently hardwired to 12 - should make configurable my charfieldgui rework laid groundwork for this as field panel now controls layout of fields not vice versa which was quirky also reworked layout of whole main panel - more flexible now - using more of gridbaglayout and setPrefferedSize over setMinimumSize setMinSize really needs to be used sparingly need config to say dont put field in table - as table gets way too jammed worms got a lot of fields Modified Paths: -------------- phenote/trunk/src/java/phenote/datamodel/CharField.java phenote/trunk/src/java/phenote/datamodel/OntologyManager.java phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java phenote/trunk/src/java/phenote/gui/GridBagUtil.java phenote/trunk/src/java/phenote/gui/SelectionHistory.java phenote/trunk/src/java/phenote/gui/TermInfo.java phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java phenote/trunk/src/java/phenote/gui/field/FieldPanel.java phenote/trunk/src/java/phenote/gui/field/FreeTextField.java phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java phenote/trunk/src/java/phenote/main/Phenote.java Modified: phenote/trunk/src/java/phenote/datamodel/CharField.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/datamodel/CharField.java 2007-03-23 20:02:12 UTC (rev 415) @@ -19,6 +19,7 @@ private String name; private boolean postCompAllowed=false; private Ontology postCompRelOntol; + // index? orderNumber? for order in gui/datamodel? public CharField(CharFieldEnum c) { charFieldEnum = c; Modified: phenote/trunk/src/java/phenote/datamodel/OntologyManager.java =================================================================== --- phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/datamodel/OntologyManager.java 2007-03-23 20:02:12 UTC (rev 415) @@ -56,6 +56,7 @@ /** 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; } + public int getNumberOfFields() { return charFieldList.size(); } public List<Ontology> getAllOntologies() { List<Ontology> ontologies = new ArrayList<Ontology>(); @@ -177,20 +178,3 @@ // return null; // this shouldnt happen - err msg? // } -// /** util fn! */ -// private OBOClass makePostCompTerm(OBOClass genus, String relation, OBOClass diff) { -// String nm = pcString(genus.getName(),diff.getName()); -// String id = pcString(genus.getID(),diff.getID()); -// OBOClass postComp = new OBOClassImpl(nm,id); -// OBOProperty ISA = OBOProperty.IS_A; -// OBORestrictionImpl gRel = new OBORestrictionImpl(postComp,ISA,genusTerm); -// return postComp; -// } -// private void addOntologyList(List<Ontology> l) { -// allOntologyList.addAll(l); -// } - -// private void addOntology(Ontology o) { -// allOntologyList.add(o); -// } - Modified: phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/CharacterTablePanel.java 2007-03-23 20:02:12 UTC (rev 415) @@ -72,8 +72,9 @@ //setBorder(new javax.swing.border.LineBorder(java.awt.Color.RED)); debug //setLayout(new GridLayout(2,1)); // row,col setLayout(new GridBagLayout()); - setPreferredSize(new Dimension(1800,800)); - setMinimumSize(new Dimension(1400,630)); // 630 + //setPreferredSize(new Dimension(1800,800)); + setPreferredSize(new Dimension(1400,500)); + //setMinimumSize(new Dimension(1400,630)); // 630 characterTableModel = new CharacterTableModel(); charJTable = new JTable(characterTableModel); Modified: phenote/trunk/src/java/phenote/gui/GridBagUtil.java =================================================================== --- phenote/trunk/src/java/phenote/gui/GridBagUtil.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/GridBagUtil.java 2007-03-23 20:02:12 UTC (rev 415) @@ -60,4 +60,8 @@ } + public static void padLeft(GridBagConstraints g,int pad) { + g.insets.left = pad; + } + } Modified: phenote/trunk/src/java/phenote/gui/SelectionHistory.java =================================================================== --- phenote/trunk/src/java/phenote/gui/SelectionHistory.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/SelectionHistory.java 2007-03-23 20:02:12 UTC (rev 415) @@ -69,7 +69,7 @@ public JComponent getComponent() { JPanel termHistoryPanel = new JPanel(new BorderLayout(0,0)); // hgap,vgap termHistoryPanel.setPreferredSize(new Dimension(200,100)); - termHistoryPanel.setMinimumSize(new Dimension(100,100)); + //termHistoryPanel.setMinimumSize(new Dimension(100,100)); if (DO_HTML) { JEditorPane editorPane = new JEditorPane(); editorPane.setContentType("text/html"); // sets up HTMLEditorKit Modified: phenote/trunk/src/java/phenote/gui/TermInfo.java =================================================================== --- phenote/trunk/src/java/phenote/gui/TermInfo.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/TermInfo.java 2007-03-23 20:02:12 UTC (rev 415) @@ -59,7 +59,7 @@ public JComponent getComponent() { JPanel termInfoPanel = new JPanel(new BorderLayout(0,0)); // hgap,vgap termInfoPanel.setPreferredSize(new Dimension(400,100)); - termInfoPanel.setMinimumSize(new Dimension(380,100)); + //termInfoPanel.setMinimumSize(new Dimension(380,100)); //termInfoPanel.setMaximumSize(new Dimension(380,400)); if (DO_HTML) { JEditorPane editorPane = new JEditorPane(); Modified: phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/field/AbstractAutoCompList.java 2007-03-23 20:02:12 UTC (rev 415) @@ -90,10 +90,10 @@ //charFieldGui = cfg; //setCharField(cf); jComboBox.setPreferredSize(CharFieldGui.inputSize); //new Dimension(390,20)); - jComboBox.setMaximumSize(CharFieldGui.inputSize); //new Dimension(390,20)); + //jComboBox.setMaximumSize(CharFieldGui.inputSize); //new Dimension(390,20)); // this is super critical - fixes bug where layout goes to hell if string are long // in completion - dont ask me why???? - jComboBox.setMinimumSize(CharFieldGui.inputSize); + //jComboBox.setMinimumSize(CharFieldGui.inputSize); AutoTextFieldEditor autoTextFieldEditor = new AutoTextFieldEditor(); jComboBox.setEditor(autoTextFieldEditor); // dont know why by setting fonts this seem to get worse not better in terms of Modified: phenote/trunk/src/java/phenote/gui/field/FieldPanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/FieldPanel.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/field/FieldPanel.java 2007-03-23 20:02:12 UTC (rev 415) @@ -7,12 +7,14 @@ import java.util.ArrayList; import java.util.List; +import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JTabbedPane; import phenote.datamodel.CharField; import phenote.datamodel.CharFieldEnum; @@ -32,47 +34,74 @@ private SearchParamPanel searchParamPanel; // searchParamManager? private OntologyManager ontologyManager = OntologyManager.inst(); private JPanel fieldPanel; + //private JComponent fieldPanel; private SearchParamsI searchParams; + private JTabbedPane jTabbedPane; + /** eventually configurable (with default 12) - for now hardwire at 12 */ + private static int fieldsPerTab = 12; + public FieldPanel() { this(true,true); } // false for post comp panel public FieldPanel(boolean doAllFields,boolean addSearchPanel) { - initGui(addSearchPanel); + initGui(); if (doAllFields) initCharFieldGuis(); + if (addSearchPanel) + initSearchPanel(); } - private void initGui(boolean addSearchPanel) { + private void initGui() { // should figure y from # of fields really!!! yes!!! // width of ontology labels effects x - this.setMinimumSize(new Dimension(700,490));//690,490)); + this.setPreferredSize(new Dimension(650,350));//690,490)); + //this.setMinimumSize(new Dimension(700,490));//690,490)); //this.setPreferredSize(new Dimension(2000,750)); // irrelevant in box layout //this.setMaximumSize(new Dimension(2000,750)); BoxLayout bl = new BoxLayout(this,BoxLayout.X_AXIS); // grid bag? this.setLayout(bl); - fieldPanel = new JPanel(new GridBagLayout()); - // panel inside of panel - i think is a leftover no reason now - add(fieldPanel); + + } + + private void initSearchPanel() { // search param panel - maybe search panel should be added to main frame? - if (addSearchPanel) - add(getSearchParamPanel().getPanel()); + add(Box.createRigidArea(new Dimension(2,0))); + add(getSearchParamPanel().getPanel()); } private void initCharFieldGuis() { + fieldPanel = new JPanel(new GridBagLayout()); + if (isTabbed()) { + jTabbedPane = new JTabbedPane(); + add(jTabbedPane); + } + else { // no tabs + add(fieldPanel); + } + + int fieldNum = 0; + int tab = 1; for (CharField charField : ontologyManager.getCharFieldList()) { + if (isTabbed() && fieldNum % fieldsPerTab == 0) { + fieldPanel = new JPanel(new GridBagLayout()); + jTabbedPane.addTab("Tab "+tab++,fieldPanel); + } + ++fieldNum; //CharFieldGui gui = new CharFieldGui(charField,this); // adds to panel CharFieldGui gui = CharFieldGui.makeCharFieldGui(charField,getSearchParams()); addCharFieldGuiToPanel(gui); charFieldGuiList.add(gui); } - // search param panel - maybe search panel should be added to main frame? - //add(getSearchParamPanel().getPanel()); --> initGui } + private boolean isTabbed() { + return ontologyManager.getNumberOfFields() > fieldsPerTab; + } + void addCharFieldGuiToPanel(CharFieldGui fieldGui) { addLabel(fieldGui.getLabel(),fieldGui.hasOntologyChooser()); if (fieldGui.hasOntologyChooser()) Modified: phenote/trunk/src/java/phenote/gui/field/FreeTextField.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/FreeTextField.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/field/FreeTextField.java 2007-03-23 20:02:12 UTC (rev 415) @@ -37,6 +37,7 @@ //charFieldGui = cfg; textField = new JTextField(35); textField.setMinimumSize(CharFieldGui.inputSize); + //textField.setPreferredSize(CharFieldGui.inputSize); textField.setEditable(true); textField.getDocument().addDocumentListener(new TextFieldDocumentListener()); textField.addFocusListener(new FreeFocusListener()); Modified: phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java =================================================================== --- phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/gui/field/SearchParamPanel.java 2007-03-23 20:02:12 UTC (rev 415) @@ -23,7 +23,8 @@ JPanel getPanel() { JPanel panel = new JPanel(); - panel.setMinimumSize(new Dimension(305,150)); + //panel.setMinimumSize(new Dimension(305,150)); + panel.setPreferredSize(new Dimension(60,50)); // panel.setPreferredSize(new Dimension(250,250)); ?? BoxLayout boxLayout = new BoxLayout(panel,BoxLayout.Y_AXIS); panel.setLayout(boxLayout); Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2007-03-23 14:21:24 UTC (rev 414) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2007-03-23 20:02:12 UTC (rev 415) @@ -33,7 +33,6 @@ public class Phenote { - //private static final String VERSION = "0.8.2 dev"; private static final Logger LOG = Logger.getLogger(Phenote.class); private static boolean standalone = false; // default for servlet @@ -57,7 +56,6 @@ System.out.println("Failed to set to Java/Metal look & feel"); } phenote = getPhenote(); - //phenote.initConfig(args); phenote.doCommandLine(args); // does config // put this is in a phenote.util.Log class? - get file from config - default? try { DOMConfigurator.configure(Config.inst().getLogConfigUrl()); } @@ -73,12 +71,6 @@ /** private constructor -> singleton */ private Phenote() {} -// /** args is most likely null if not called from command line */ -// public void initConfig(String[] args) { -// // gets config file from command line & loads - if no config file -// // loads default. should actually put that logic here. -// doCommandLine(args); // load config file -// } public void initOntologies() { //OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? @@ -135,7 +127,7 @@ frame = new JFrame("Phenote "+PhenoteVersion.versionString()); frame.getContentPane().add(makeMainPanel()); MenuManager.createMenuManager(frame); - frame.setPreferredSize(new Dimension(1200,700)); //1100,700)); + frame.setPreferredSize(new Dimension(1220,800)); //1100,700)); if (standalone) // if stand alone exit java on window close frame.addWindowListener(new WindowExit()); frame.pack(); @@ -156,18 +148,24 @@ private JPanel makeMainPanel() { JPanel mainPanel = new JPanel(new GridBagLayout()); // ?? - JPanel upperPanel = new JPanel(); - BoxLayout bl = new BoxLayout(upperPanel,BoxLayout.X_AXIS); - upperPanel.setLayout(bl); + JPanel upperPanel = new JPanel(new GridBagLayout()); + //BoxLayout bl=new BoxLayout(upperPanel,BoxLayout.X_AXIS);upperPanel.setLayout(bl); + GridBagConstraints ugbc = GridBagUtil.makeFillingConstraint(0,0); + ugbc.weightx = 1; + fieldPanel = new FieldPanel(); // field panel contains search params - upperPanel.add(fieldPanel); + upperPanel.add(fieldPanel,ugbc); termInfo = new TermInfo(); - upperPanel.add(termInfo.getComponent()); + ugbc.gridx++; + ugbc.weightx = 5; + upperPanel.add(termInfo.getComponent(),ugbc); selectionHistory = new SelectionHistory(); - upperPanel.add(selectionHistory.getComponent()); + ugbc.gridx++; + ugbc.weightx = 3; + upperPanel.add(selectionHistory.getComponent(),ugbc); //++gbc.gridx; // ?? //gbc.anchor = GridBagConstraints.NORTHWEST; // ?? //mainPanel.add(termInfo.getComponent(),gbc); @@ -179,13 +177,13 @@ // int anchor = GridBagConstraints.WEST; // GridBagConstraints gbc = GridBagUtil.makeConstraint(0,0,1,1,weightY,4,4,fill,anchor); GridBagConstraints gbc = GridBagUtil.makeFillingConstraint(0,0); - gbc.weighty = 10; + gbc.weighty = 1; mainPanel.add(upperPanel,gbc); characterTablePanel = new CharacterTablePanel(); //termAndTablePanel.add(characterTablePanel); ++gbc.gridy; // ? - gbc.weighty = 17; + gbc.weighty = 10; mainPanel.add(characterTablePanel,gbc); return mainPanel; @@ -201,4 +199,10 @@ public CharacterTablePanel getCharacterTablePanel() { return characterTablePanel; } } +// /** args is most likely null if not called from command line */ +// public void initConfig(String[] args) { +// // gets config file from command line & loads - if no config file +// // loads default. should actually put that logic here. +// doCommandLine(args); // load config file +// } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |