001 /* 002 Copyright (C) 2001-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 java.awt.Component; 021 import java.util.List; 022 import java.util.Vector; 023 import org.objectweb.jac.aspects.gui.Constants; 024 import org.objectweb.jac.aspects.gui.EditorContainer; 025 import org.objectweb.jac.aspects.gui.FieldEditor; 026 import java.util.Iterator; 027 028 public class SwingEditorContainer extends SwingContainerView 029 implements EditorContainer 030 { 031 Vector editors = new Vector(); 032 boolean showButtons; 033 /** 034 * @param showButtons unused parameter 035 */ 036 public SwingEditorContainer(boolean showButtons) { 037 super(Constants.VERTICAL); 038 } 039 040 public void addEditor(Object editor) { 041 editors.add(editor); 042 } 043 public void removeEditor(Object editor) { 044 editors.remove(editor); 045 } 046 public List getEditors() { 047 return (List)editors.clone(); 048 } 049 public boolean hasEnabledEditor() { 050 Iterator it = editors.iterator(); 051 while (it.hasNext()) { 052 Object view = it.next(); 053 if (view instanceof FieldEditor && 054 ((FieldEditor)view).isEnabled()) { 055 return true; 056 } 057 } 058 return false; 059 } 060 061 public void setShowButtons(boolean showButtons) { 062 this.showButtons = showButtons; 063 } 064 public boolean showButtons() { 065 return showButtons; 066 } 067 068 public void requestFocus() { 069 loggerFocus.debug("requestFocus on "+this); 070 if (!editors.isEmpty()) { 071 Component component = (Component)editors.get(0); 072 loggerFocus.debug("passing focus to "+component); 073 component.requestFocus(); 074 } 075 } 076 }