1 23 24 package org.objectweb.fractal.gui.graph.model; 25 26 import org.objectweb.fractal.api.control.BindingController; 27 28 import org.objectweb.fractal.gui.model.Interface; 29 30 import java.util.Map ; 31 import java.util.HashMap ; 32 import java.util.Iterator ; 33 34 37 38 public class BasicTools implements Tools, BindingController { 39 40 44 45 public final static String TOOLS_LISTENERS_BINDING = "tools-listeners"; 46 47 50 51 private Map toolsListeners; 52 53 56 57 private int tool; 58 59 62 63 private Interface bindItf; 64 65 68 69 public BasicTools () { 70 toolsListeners = new HashMap (); 71 } 72 73 77 public String [] listFc () { 78 return (String [])toolsListeners.keySet().toArray( 79 new String [toolsListeners.size()]); 80 } 81 82 public Object lookupFc (final String clientItfName) { 83 if (clientItfName.startsWith(TOOLS_LISTENERS_BINDING)) { 84 return toolsListeners.get(clientItfName); 85 } 86 return null; 87 } 88 89 public void bindFc ( 90 final String clientItfName, 91 final Object serverItf) 92 { 93 if (clientItfName.startsWith(TOOLS_LISTENERS_BINDING)) { 94 toolsListeners.put(clientItfName, serverItf); 95 } 96 } 97 98 public void unbindFc (final String clientItfName) { 99 if (clientItfName.startsWith(TOOLS_LISTENERS_BINDING)) { 100 toolsListeners.remove(clientItfName); 101 } 102 } 103 104 108 public int getTool () { 109 return tool; 110 } 111 112 public void setTool (final int tool) { 113 if (tool != this.tool) { 114 this.tool = tool; 115 Iterator i = toolsListeners.values().iterator(); 116 while (i.hasNext()) { 117 ((ToolsListener)i.next()).toolChanged(); 118 } 119 } 120 } 121 122 public Interface getBindInterface () { 123 return bindItf; 124 } 125 126 public void setBindInterface (final Interface i) { 127 this.bindItf = i; 128 } 129 } 130 | Popular Tags |