1 17 18 package org.objectweb.jac.aspects.gui.swing; 19 20 import java.awt.Component ; 21 import java.util.List ; 22 import java.util.Vector ; 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 ; 27 28 public class SwingEditorContainer extends SwingContainerView 29 implements EditorContainer 30 { 31 Vector editors = new Vector (); 32 boolean showButtons; 33 36 public SwingEditorContainer(boolean showButtons) { 37 super(Constants.VERTICAL); 38 } 39 40 public void addEditor(Object editor) { 41 editors.add(editor); 42 } 43 public void removeEditor(Object editor) { 44 editors.remove(editor); 45 } 46 public List getEditors() { 47 return (List)editors.clone(); 48 } 49 public boolean hasEnabledEditor() { 50 Iterator it = editors.iterator(); 51 while (it.hasNext()) { 52 Object 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 component = (Component )editors.get(0); 72 loggerFocus.debug("passing focus to "+component); 73 component.requestFocus(); 74 } 75 } 76 } 77 | Popular Tags |