KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > swing > SwingEditorContainer


1 /*
2   Copyright (C) 2001-2002 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */

17
18 package org.objectweb.jac.aspects.gui.swing;
19
20 import java.awt.Component JavaDoc;
21 import java.util.List JavaDoc;
22 import java.util.Vector JavaDoc;
23 import org.objectweb.jac.aspects.gui.Constants;
24 import org.objectweb.jac.aspects.gui.EditorContainer;
25 import org.objectweb.jac.aspects.gui.FieldEditor;
26 import java.util.Iterator JavaDoc;
27
28 public class SwingEditorContainer extends SwingContainerView
29     implements EditorContainer
30 {
31     Vector JavaDoc editors = new Vector JavaDoc();
32     boolean showButtons;
33     /**
34      * @param showButtons unused parameter
35      */

36     public SwingEditorContainer(boolean showButtons) {
37         super(Constants.VERTICAL);
38     }
39
40     public void addEditor(Object JavaDoc editor) {
41         editors.add(editor);
42     }
43     public void removeEditor(Object JavaDoc editor) {
44         editors.remove(editor);
45     }
46     public List getEditors() {
47         return (List)editors.clone();
48     }
49     public boolean hasEnabledEditor() {
50         Iterator JavaDoc it = editors.iterator();
51         while (it.hasNext()) {
52             Object JavaDoc view = it.next();
53             if (view instanceof FieldEditor &&
54                 ((FieldEditor)view).isEnabled()) {
55                 return true;
56             }
57         }
58         return false;
59     }
60
61     public void setShowButtons(boolean showButtons) {
62         this.showButtons = showButtons;
63     }
64     public boolean showButtons() {
65         return showButtons;
66     }
67
68     public void requestFocus() {
69         loggerFocus.debug("requestFocus on "+this);
70         if (!editors.isEmpty()) {
71             Component JavaDoc component = (Component JavaDoc)editors.get(0);
72             loggerFocus.debug("passing focus to "+component);
73             component.requestFocus();
74         }
75     }
76 }
77
Popular Tags