@Override public void remove(DrawingView view) { view.getComponent().removeFocusListener(focusHandler); views.remove(view); if (tool != null) { view.removeMouseListener(tool); view.removeMouseMotionListener(tool); view.removeKeyListener(tool); } view.removeNotify(this); if (activeView == view) { view = (views.size() > 0) ? views.iterator().next() : null; } 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); }