15a16,17 > import CH.ifa.draw.util.CollectionsFactory; > 16a19,19 > import java.util.List; 39a43,49 > /** > * A tool can have a drawing view on which it operates > * independingly of the currently active drawing view. > * For example, if a tool can be used > */ > private DrawingView myDrawingView; > 62,62c72,72 < * Activates the tool for the given view. This method is called --- > * Activates the tool for use on the given view. This method is called 65,65c75,75 < * Since tools will be disabled unless they are useable, there will always --- > * Since tools will be disabled unless it is useable, there will always 66a77,78 > * Tool should never be activated if the view is null. > * Ideally, the dditor should take care of that. 66,66c76,76 < * be an active view when this method is called. based on isUsable() --- > * be an active view when this is called. based on isUsable() 68a81,83 > if (getActiveView() != null) { > getActiveView().clearSelection(); > getActiveView().checkDamage(); 69,71d80 < if (view() != null) { < view().clearSelection(); < view().checkDamage(); 80a93,93 > * An inactive tool should never be deactivated 83a97,97 > if (getActiveView() != null) { 84,84d96 < if (view() != null) { 85,85c98,98 < view().setCursor(Cursor.getDefaultCursor()); --- > getActiveView().setCursor(Cursor.getDefaultCursor()); 122a136,136 > setView((DrawingView)e.getSource()); 134a149,152 > // setView(null);//This must be fixed!!! the view should not be held onto after mouse up?? > //unlike super.mousedown which is usually called immediately after a sub classes mouse down > //method starts, super.mouseup should probably be called last before the method ends? > //it must if its going to set the view to null. getting messy. 155a174,177 > public Drawing getActiveDrawing() { > return getActiveView().drawing(); > } > 162a185,188 > protected void setEditor(DrawingEditor newDrawingEditor) { > myDrawingEditor = newDrawingEditor; > } > 166a193,200 > return myDrawingView; > } > > protected void setView(DrawingView newDrawingView) { > myDrawingView = newDrawingView; > } > > public DrawingView getActiveView() { 259,259c293,293 < setUsable((view() != null) && view().isInteractive()); --- > setUsable((getActiveView() != null) && getActiveView().isInteractive()); 264,264c298,298 < private Vector myRegisteredListeners; --- > private List myRegisteredListeners; 267a302,302 > myRegisteredListeners = CollectionsFactory.current().createList(); 268,268d301 < myRegisteredListeners = new Vector(); 272a307,309 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolUsable(new EventObject(myObservedTool)); 273,275d306 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolUsable(new EventObject(myObservedTool)); 279a314,316 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolUnusable(new EventObject(myObservedTool)); 280,282d313 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolUnusable(new EventObject(myObservedTool)); 286a321,323 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolActivated(new EventObject(myObservedTool)); 287,289d320 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolActivated(new EventObject(myObservedTool)); 293a328,330 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolDeactivated(new EventObject(myObservedTool)); 294,296d327 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolDeactivated(new EventObject(myObservedTool)); 300a335,337 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolEnabled(new EventObject(myObservedTool)); 301,303d334 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolEnabled(new EventObject(myObservedTool)); 307a342,344 > Iterator iter = myRegisteredListeners.iterator(); > while (iter.hasNext()) { > ((ToolListener)iter.next()).toolDisabled(new EventObject(myObservedTool)); 308,310d341 < Enumeration le = myRegisteredListeners.elements(); < while (le.hasMoreElements()) { < ((ToolListener)le.nextElement()).toolDisabled(new EventObject(myObservedTool));