001    /*
002      Copyright (C) 2002 Laurent Martelli <laurent@aopsys.com>
003      
004      This program is free software; you can redistribute it and/or modify
005      it under the terms of the GNU Lesser General Public License as
006      published by the Free Software Foundation; either version 2 of the
007      License, or (at your option) any later version.
008    
009      This program is distributed in the hope that it will be useful,
010      but WITHOUT ANY WARRANTY; without even the implied warranty of
011      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012      GNU Lesser General Public License for more details.
013    
014      You should have received a copy of the GNU Lesser General Public License
015      along with this program; if not, write to the Free Software
016      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
017    
018    package org.objectweb.jac.aspects.gui.swing;
019    
020    import org.objectweb.jac.aspects.gui.Constants;
021    import org.objectweb.jac.aspects.gui.FieldEditor;
022    import org.objectweb.jac.aspects.gui.GuiAC;
023    import org.objectweb.jac.aspects.gui.TabsView;
024    import org.objectweb.jac.aspects.gui.View;
025    import org.objectweb.jac.core.rtti.FieldItem;
026    import java.util.Iterator;
027    import java.util.List;
028    import java.util.Vector;
029    
030    public class ObjectView extends SwingContainerView 
031    {
032       Vector editors = new Vector();
033       boolean showButtons = true;
034    
035       public ObjectView() {
036          super(Constants.VERTICAL);      
037       }
038    
039       public void addEditor(FieldEditor editor) {
040          editors.add(editor);
041       }
042       
043       public List getEditors() {
044          return editors;
045       }
046    
047       public void setShowButtons(boolean value) {
048          this.showButtons = value;
049       }
050    
051       public void setFocus(FieldItem field, Object option) {
052          String[] categories = GuiAC.getCategories(field);
053          if (categories!=null && categories.length>0) {
054             Iterator it = getViews().iterator();
055             while(it.hasNext()) {
056                View view = (View)it.next();
057                if (view instanceof TabsView) {
058                   ((TabsView)view).select(categories[0]);
059                }
060             }
061          }
062       }
063    
064    }