[isidorus-cvs] r575 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base text

lgiessmann at common-lisp.net lgiessmann at common-lisp.net
Thu Jul 7 13:50:27 UTC 2011


Author: lgiessmann
Date: Thu Jul  7 06:50:26 2011
New Revision: 575

Log:
gdl-frontend: Widgets: foxed a bug in the style-handlers, which are responsible for setting the css properties of active, hover and focus

Modified:
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
   branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Thu Jul  7 05:58:31 2011	(r574)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java	Thu Jul  7 06:50:26 2011	(r575)
@@ -65,7 +65,7 @@
 	protected ArrayList<Pair<String, String>> focusCssNamesAndStyles = new ArrayList<Pair<String,String>>();
 	protected ArrayList<Pair<String, String>> hoverCssNamesAndStyles = new ArrayList<Pair<String,String>>();
 	protected ArrayList<Widget> subElements = new ArrayList<Widget>();
-	protected ArrayList<Pair<TextArea, ArrayList<EventHandler>>> eventHandlers = new ArrayList<Pair<TextArea, ArrayList<EventHandler>>>();
+	protected ArrayList<Pair<Widget, ArrayList<EventHandler>>> eventHandlers = new ArrayList<Pair<Widget, ArrayList<EventHandler>>>();
 	
 
 	// some constructors
@@ -1573,39 +1573,36 @@
 	
 	
 	// adds the passed handler to the list eventHandlers
-	private void addEventHandler(TextArea elem, EventHandler handler){
+	private void addEventHandler(Widget elem, EventHandler handler){
 		if(handler == null || elem == null) return;
 		
-		for (Pair<TextArea, ArrayList<EventHandler>> item : this.eventHandlers) {
+		for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) {
 			if(item.getFirst().equals(elem)){
-				item.getSecond().add(handler);
-				return;
+				if(!item.getSecond().contains(handler)){
+					item.getSecond().add(handler);
+					return;
+				}
 			}
 		}
 		ArrayList<EventHandler> newHandlerList = new ArrayList<EventHandler>();
 		newHandlerList.add(handler);
-		this.eventHandlers.add(new Pair<TextArea, ArrayList<EventHandler>>(elem, newHandlerList));
+		this.eventHandlers.add(new Pair<Widget, ArrayList<EventHandler>>(elem, newHandlerList));
 	}
 	
 	
 	// remove the passed handler of the list eventHandlers
-	private void removeEventHandler(TextArea elem, EventHandler handler){
-		for (Pair<TextArea, ArrayList<EventHandler>> item : this.eventHandlers) {
+	private void removeEventHandler(Widget elem, EventHandler handler){
+		for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) {
 			if(item.getFirst().equals(elem)){
-				for (EventHandler handlerItem : item.getSecond()) {
-					if(handlerItem.equals(handler)){
-						item.getSecond().remove(handlerItem);
-						return;
-					}
-				}
+				item.getSecond().remove(handler);
 			}
 		}
 	}
 	
 	
 	// returns the last handler bound to the passed element.
-	private EventHandler getLastHandler(TextArea elem){
-		for (Pair<TextArea, ArrayList<EventHandler>> item : this.eventHandlers) {
+	private EventHandler getLastHandler(Widget elem){
+		for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) {
 			if(item.getFirst().equals(elem)){
 				int idx = item.getSecond().size() - 1;
 				if(idx >= 0){
@@ -1617,6 +1614,7 @@
 		return null;
 	}
 	
+	
 	// applies the styles bound to hover and the passed element
 	private void onHoverStart(Widget widget){
 		for (Pair<String, String> elem : this.hoverCssNamesAndStyles) {
@@ -1643,7 +1641,7 @@
 	
 	// some handler for applying the css style bound to the pseudo classes hover, active and focus 
 	public void onHoverStart(MouseOverEvent event, HoverStyleHandler handler) {
-		TextArea source = (TextArea)event.getSource();
+		Widget source = (Widget)event.getSource();
 		this.addEventHandler(source, handler);
 		for (Pair<String, String> elem : this.hoverCssNamesAndStyles) {
 			DOM.setStyleAttribute(source.getElement(), elem.getFirst(), elem.getSecond());
@@ -1672,7 +1670,7 @@
 
 	// shall be called to apply the styles of the focus class
 	public void onFocusStart(FocusEvent event, FocusStyleHandler handler) {
-		TextArea source = (TextArea)event.getSource();
+		Widget source = (Widget)event.getSource();
 		this.addEventHandler(source, handler);
 		for (Pair<String, String> elem : this.focusCssNamesAndStyles) {
 			DOM.setStyleAttribute(source.getElement(), elem.getFirst(), elem.getSecond());
@@ -1683,7 +1681,7 @@
 	// shall be called when the blur event was fired 
 	public void onFocusEnd(BlurEvent event, FocusStyleHandler handler) {
 		try{
-			TextArea source = (TextArea)event.getSource();
+			Widget source = (Widget)event.getSource();
 			this.removeEventHandler(source, handler);
 			EventHandler lastHandler = this.getLastHandler(source);
 			if(lastHandler == null){
@@ -1700,7 +1698,7 @@
 	
 	// shall be called to apply the styles of the sctive class
 	public void onActiveStart(MouseDownEvent event, ActiveStyleHandler handler) {
-		TextArea source = (TextArea)event.getSource();
+		Widget source = (Widget)event.getSource();
 		this.addEventHandler(source, handler);
 		for (Pair<String, String> elem : this.activeCssNamesAndStyles) {
 			DOM.setStyleAttribute(source.getElement(), elem.getFirst(), elem.getSecond());
@@ -1711,7 +1709,7 @@
 	// shall be called to apply the styles of the focus class
 	public void onActiveEnd(MouseUpEvent event, ActiveStyleHandler handler) {
 		try{
-			TextArea source = (TextArea)event.getSource();
+			Widget source = (Widget)event.getSource();
 			this.removeEventHandler(source, handler);
 			EventHandler lastHandler = this.getLastHandler(source);
 			if(lastHandler == null){

Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java	Thu Jul  7 05:58:31 2011	(r574)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java	Thu Jul  7 06:50:26 2011	(r575)
@@ -70,7 +70,7 @@
 	
 	// removes the passed element and all its handlers from the outer element
 	protected void removeTextArea(TextArea elem) throws InvalidGdlSchemaException, ExecutionException{
-		for (Pair<TextArea, ArrayList<EventHandler>> item : this.eventHandlers) {
+		for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) {
 			if(item.getFirst().equals(elem)){
 				this.eventHandlers.remove(item);
 				break;




More information about the Isidorus-cvs mailing list