Author: lgiessmann Date: Fri Jul 8 04:01:43 2011 New Revision: 583
Log: gdl-frontend: Widgets: fixed the registration of event-handlers for GdlList => fixed the style-handlers for hover, active 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/base/TestClass.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.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 Fri Jul 8 02:13:38 2011 (r582) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 8 04:01:43 2011 (r583) @@ -21,7 +21,6 @@ import us.isidor.gdl.anaToMia.Widgets.values.CursorValue; import us.isidor.gdl.anaToMia.Widgets.values.NumUnitValue; import com.google.gwt.core.client.JsArray; -import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Style.Float; import com.google.gwt.dom.client.Style.VerticalAlign; @@ -55,7 +54,6 @@ import com.google.gwt.user.client.ui.Panel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; -import com.google.gwt.dom.client.Node;
public abstract class GdlVisibleObject extends Composite implements GdlDescriptor, HasClickHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasFocusHandlers, HasMouseDownHandlers, HasMouseUpHandlers, HasBlurHandlers{
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 8 02:13:38 2011 (r582) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 8 04:01:43 2011 (r583) @@ -83,6 +83,8 @@ Topic gdlTextDecoration = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlTextDecoration)); Topic gdlDisplay = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlDisplay)); Topic gdlContentOrientation = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlContentOrientation)); + Topic gdlListStyleType = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlListStyleType)); + tmpRepresentative.createOccurrence(gdlId, "ID_1", null); tmpRepresentative.createOccurrence(gdlBackgroundColor, "red", null); @@ -106,6 +108,7 @@ tmpRepresentative.createOccurrence(gdlTextDecoration, "underline", null); tmpRepresentative.createOccurrence(gdlDisplay, "inline", null); tmpRepresentative.createOccurrence(gdlContentOrientation, "vertical", null); + tmpRepresentative.createOccurrence(gdlListStyleType, "square", null); Occurrence bgcHover = tmpRepresentative.createOccurrence(gdlBackgroundColor, "green", null); bgcHover.addTheme(gdlHover); Occurrence bgcActive = tmpRepresentative.createOccurrence(gdlBackgroundColor, "purple", null); @@ -116,7 +119,7 @@ fsHover.addTheme(gdlHover); - GdlList tmp = new GdlList(tmpRepresentative){}; + GdlList tmp = new GdlList(tmpRepresentative); this.mainPanel.add(tmp); }catch(Exception e){ e.printStackTrace();
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Fri Jul 8 02:13:38 2011 (r582) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Fri Jul 8 04:01:43 2011 (r583) @@ -7,17 +7,38 @@ import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.Widget; import com.google.gwt.dom.client.Node; +import com.google.gwt.event.dom.client.BlurEvent; +import com.google.gwt.event.dom.client.BlurHandler; +import com.google.gwt.event.dom.client.FocusEvent; +import com.google.gwt.event.dom.client.FocusHandler; +import com.google.gwt.event.dom.client.HasBlurHandlers; +import com.google.gwt.event.dom.client.HasFocusHandlers; +import com.google.gwt.event.dom.client.HasMouseDownHandlers; +import com.google.gwt.event.dom.client.HasMouseOutHandlers; +import com.google.gwt.event.dom.client.HasMouseOverHandlers; +import com.google.gwt.event.dom.client.HasMouseUpHandlers; +import com.google.gwt.event.dom.client.MouseDownEvent; +import com.google.gwt.event.dom.client.MouseDownHandler; +import com.google.gwt.event.dom.client.MouseOutEvent; +import com.google.gwt.event.dom.client.MouseOutHandler; +import com.google.gwt.event.dom.client.MouseOverEvent; +import com.google.gwt.event.dom.client.MouseOverHandler; +import com.google.gwt.event.dom.client.MouseUpEvent; +import com.google.gwt.event.dom.client.MouseUpHandler; +import com.google.gwt.event.shared.HandlerRegistration; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis; import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject; +import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; +import us.isidor.gdl.anaToMia.Widgets.environment.FocusStyleHandler; +import us.isidor.gdl.anaToMia.Widgets.environment.HoverStyleHandler; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; import us.isidor.gdl.anaToMia.Widgets.environment.Pair; import us.isidor.gdl.anaToMia.Widgets.values.ListStylePositionValue; import us.isidor.gdl.anaToMia.Widgets.values.ListStyleTypeValue;
-// TODO: check style attributes + css pseudo classes
public class GdlList extends GdlVisibleObject{ // some constructors @@ -37,6 +58,18 @@ public void initList(boolean ordered) throws InvalidGdlSchemaException, ExecutionException { // this object is able to own only one sub-element ListWidget list = new ListWidget(this.getOrdered()); + ActiveStyleHandler asHandler = new ActiveStyleHandler(this); + FocusStyleHandler fsHandler = new FocusStyleHandler(this); + HoverStyleHandler hsHandler = new HoverStyleHandler(this); + int idSuffix = 0; + if(this.subElements != null) idSuffix = this.subElements.size(); + list.setId(this.getId() + "__GDL_" + idSuffix); + list.addMouseDownHandler(asHandler); + list.addMouseUpHandler(asHandler); + list.addMouseOverHandler(hsHandler); + list.addMouseOutHandler(hsHandler); + list.addFocusHandler(fsHandler); + list.addBlurHandler(fsHandler); super.addToContainerPanel(list); this.setGdlStyle(list); } @@ -134,8 +167,11 @@ public void setGdlStyle(Widget widget) throws InvalidGdlSchemaException, ExecutionException { super.setGdlStyle(widget);
- this.setListStylePositionValue((ListWidget)widget, this.getListStylePosition()); - this.setListStyleType((ListWidget)widget, this.getListStyleType()); + // this may be only called if the ListWidget is the passed argument + if(widget.getClass().equals(ListWidget.class)){ + this.setListStylePositionValue((ListWidget)widget, this.getListStylePosition()); + this.setListStyleType((ListWidget)widget, this.getListStyleType()); + } } @@ -148,7 +184,7 @@ // Wraps a ul an ol element as a widget based on a SimplePanel - protected class ListWidget extends Composite { + protected class ListWidget extends Composite implements HasMouseDownHandlers, HasMouseUpHandlers, HasFocusHandlers, HasBlurHandlers, HasMouseOutHandlers, HasMouseOverHandlers{ private SimplePanel basePanel = new SimplePanel(); private Element listElement = null; // note: index is not the actual index of the item in the array list, @@ -235,6 +271,47 @@ return -1; } + + + public void setId(String id){ + DOM.setElementAttribute(this.basePanel.getElement(), "id", id); + } + + + @Override + public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) { + return this.basePanel.addDomHandler(handler, MouseOverEvent.getType()); + } + + + @Override + public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) { + return this.basePanel.addDomHandler(handler, MouseOutEvent.getType()); + } + + + @Override + public HandlerRegistration addBlurHandler(BlurHandler handler) { + return this.basePanel.addDomHandler(handler, BlurEvent.getType()); + } + + + @Override + public HandlerRegistration addFocusHandler(FocusHandler handler) { + return this.basePanel.addDomHandler(handler, FocusEvent.getType()); + } + + + @Override + public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) { + return this.basePanel.addDomHandler(handler, MouseUpEvent.getType()); + } + + + @Override + public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { + return this.basePanel.addDomHandler(handler, MouseDownEvent.getType()); + } } @@ -297,8 +374,5 @@ } } } - - - } }