1 3 package org.objectweb.fractal.swing; 4 5 import org.objectweb.fractal.api.control.BindingController; 6 7 import java.util.Map ; 8 import java.util.TreeMap ; 9 import java.util.Iterator ; 10 11 import javax.swing.JMenu ; 12 13 public class JMenuBarImpl 14 extends javax.swing.JMenuBar 15 implements JMenuBarItf, JMenuBarAttributes, BindingController 16 { 17 18 private final static String MENUS_BINDING = "menus"; 20 private final Map menus = new TreeMap (); 21 22 public JMenuBarImpl () { 23 super(); 24 } 25 26 public String [] listFc () { 27 return (String [])menus.keySet().toArray(new String [menus.size()]); 29 } 30 31 public Object lookupFc (String clientItfName) { 32 if (clientItfName.startsWith(MENUS_BINDING)) { 34 return menus.get(clientItfName); 35 } 36 return null; 37 } 38 39 public void bindFc (String clientItfName, Object serverItf) { 40 if (clientItfName.startsWith(MENUS_BINDING)) { 42 menus.put(clientItfName, serverItf); 43 Iterator i = menus.values().iterator(); 44 while (i.hasNext()) { 45 super.remove((JMenu )i.next()); 46 } 47 i = menus.values().iterator(); 48 while (i.hasNext()) { 49 super.add((JMenu )i.next()); 50 } 51 } 52 } 53 54 public void unbindFc (String clientItfName) { 55 if (clientItfName.startsWith(MENUS_BINDING)) { 57 Object serverItf = menus.remove(clientItfName); 58 super.remove((JMenu )serverItf); 59 } 60 } 61 62 } 63 | Popular Tags |