@Override public void add(DrawingView view) { views.add(view); view.addNotify(this); view.getComponent().addFocusListener(focusHandler); if (tool != null) { view.addMouseListener(tool); view.addMouseMotionListener(tool); view.addKeyListener(tool); } updateActiveView(); }
@Override public void setTool(Tool newValue) { Tool oldValue = tool; if (newValue == tool) { return; } if (tool != null) { for (DrawingView v : views) { v.removeMouseListener(tool); v.removeMouseMotionListener(tool); v.removeKeyListener(tool); } tool.deactivate(this); tool.removeToolListener(toolHandler); } tool = newValue; if (tool != null) { tool.activate(this); for (DrawingView v : views) { v.addMouseListener(tool); v.addMouseMotionListener(tool); v.addKeyListener(tool); } tool.addToolListener(toolHandler); } firePropertyChange(TOOL_PROPERTY, oldValue, newValue); }