Author: lgiessmann
Date: Fri Jul 8 06:22:52 2011
New Revision: 584
Log:
gdl-frontend: Widgets: implemented the setters of all GDL properties of GdlTextObject in the class GdlTitle
Added:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java
Modified:
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
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
branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTextObject.java
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Fri Jul 8 04:01:43 2011 (r583)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPsis.java Fri Jul 8 06:22:52 2011 (r584)
@@ -158,6 +158,7 @@
public final static String gdlRows = gdl + "rows";
public final static String gdlCols = gdl + "cols";
public final static String gdlResize = gdl + "resize";
+ public final static String gdlTitleOrder = gdl + "title-order";
public final static String gdlUnitName = gdl + "unit-name";
public final static String gdlUnitBorderWidth = gdl + "unit-border-width";
public final static String gdlUnitBorderTopWidth = gdl + "unit-border-top-width";
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 04:01:43 2011 (r583)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 8 06:22:52 2011 (r584)
@@ -21,6 +21,7 @@
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;
@@ -101,6 +102,18 @@
this.containerPanel.add(widget);
}
+
+ public static void replaceStyleProperty(Element elem, String styleName, String styleValue){
+ String oldStyle = elem.getAttribute("style");
+ if(oldStyle.matches("(^| |;)" + styleName + " *:")){
+ elem.setAttribute("style", oldStyle.replaceAll(styleName + ":.+;", styleName + ": " + styleValue + ";"));
+ } else {
+ elem.setAttribute("style", oldStyle + " " + styleName + ": " + styleValue + ";");
+ }
+
+ }
+
+
// a helper method that returns all occurrences of the type bound to the passed PSI
protected JsArray<Occurrence> getOccurrences(String occurrenceType){
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 04:01:43 2011 (r583)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 8 06:22:52 2011 (r584)
@@ -7,6 +7,7 @@
import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback;
import us.isidor.gdl.anaToMia.Widgets.text.GdlListBox;
import us.isidor.gdl.anaToMia.Widgets.text.GdlText;
+import us.isidor.gdl.anaToMia.Widgets.text.GdlTitle;
import us.isidor.gdl.anaToMia.Widgets.values.CursorValue;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
@@ -84,6 +85,7 @@
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));
+ Topic gdlDirection = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlDirection));
tmpRepresentative.createOccurrence(gdlId, "ID_1", null);
@@ -109,6 +111,7 @@
tmpRepresentative.createOccurrence(gdlDisplay, "inline", null);
tmpRepresentative.createOccurrence(gdlContentOrientation, "vertical", null);
tmpRepresentative.createOccurrence(gdlListStyleType, "square", null);
+ tmpRepresentative.createOccurrence(gdlDirection, "rtl", null);
Occurrence bgcHover = tmpRepresentative.createOccurrence(gdlBackgroundColor, "green", null);
bgcHover.addTheme(gdlHover);
Occurrence bgcActive = tmpRepresentative.createOccurrence(gdlBackgroundColor, "purple", null);
@@ -119,7 +122,7 @@
fsHover.addTheme(gdlHover);
- GdlList tmp = new GdlList(tmpRepresentative);
+ GdlTitle tmp = new GdlTitle(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 04:01:43 2011 (r583)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Fri Jul 8 06:22:52 2011 (r584)
@@ -3,8 +3,8 @@
import java.util.ArrayList;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Composite;
-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;
@@ -44,18 +44,18 @@
// some constructors
protected GdlList() throws InvalidGdlSchemaException, ExecutionException {
super();
- this.initList(this.getOrdered());
+ this.createList();
}
public GdlList(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
super(tmRepresentative);
- this.initList(this.getOrdered());
+ this.createList();
}
// sets the list Element to either ol or ul depending on the gdl:ordered property
- public void initList(boolean ordered) throws InvalidGdlSchemaException, ExecutionException {
+ public void createList() throws InvalidGdlSchemaException, ExecutionException {
// this object is able to own only one sub-element
ListWidget list = new ListWidget(this.getOrdered());
ActiveStyleHandler asHandler = new ActiveStyleHandler(this);
@@ -140,13 +140,13 @@
// sets the css property list-style-type
public void setListStyleType(ListWidget widget, ListStyleTypeValue value) throws InvalidGdlSchemaException, ExecutionException {
- widget.getListElement().setAttribute("style", widget.getListElement().getAttribute("style") + " list-style-type: " + value.getCssValue() + ";");
+ if(value != null) super.replaceStyleProperty(widget.getListElement(), "list-style-type", value.getCssValue());
}
// sets the css property list-style-position
public void setListStylePositionValue(ListWidget widget, ListStylePositionValue value) throws InvalidGdlSchemaException, ExecutionException {
- widget.getListElement().setAttribute("style", widget.getListElement().getAttribute("style") + " list-style-position: " + value.getCssValue() + ";");
+ if(value != null) super.replaceStyleProperty(widget.getListElement(), "list-style-position", value.getCssValue());
}
@@ -185,7 +185,7 @@
// Wraps a ul an ol element as a widget based on a SimplePanel
protected class ListWidget extends Composite implements HasMouseDownHandlers, HasMouseUpHandlers, HasFocusHandlers, HasBlurHandlers, HasMouseOutHandlers, HasMouseOverHandlers{
- private SimplePanel basePanel = new SimplePanel();
+ private AbsolutePanel basePanel = new AbsolutePanel();
private Element listElement = null;
// note: index is not the actual index of the item in the array list,
// it is the user's passed index when inserting this element
@@ -203,11 +203,6 @@
if(ordered) this.listElement = DOM.createElement("ol");
else this.listElement = DOM.createElement("ul");
this.basePanel.getElement().insertFirst(this.listElement);
-
- // TODO: remove
- Element li = DOM.createElement("li");
- li.setInnerHTML("Hallo !!!");
- this.listElement.insertFirst(li);
}
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTextObject.java
==============================================================================
--- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTextObject.java Fri Jul 8 04:01:43 2011 (r583)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTextObject.java Fri Jul 8 06:22:52 2011 (r584)
@@ -61,9 +61,9 @@
public TextAlignValue getTextAlign(String styleClass) throws InvalidGdlSchemaException {
Occurrence textAlignOcc = null;
if(styleClass != null){
- textAlignOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlDirection, styleClass);
+ textAlignOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlTextAlign, styleClass);
} else {
- textAlignOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlDirection);
+ textAlignOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlTextAlign);
}
if(textAlignOcc == null && styleClass != null){
@@ -86,9 +86,9 @@
public NormalNumUnitValue getLineHeight(String styleClass) throws InvalidGdlSchemaException {
Occurrence lineHeightOcc = null;
if(styleClass != null){
- lineHeightOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlDirection, styleClass);
+ lineHeightOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlLineHeight, styleClass);
} else {
- lineHeightOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlDirection);
+ lineHeightOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlLineHeight);
}
if(lineHeightOcc == null && styleClass != null){
Added: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java Fri Jul 8 06:22:52 2011 (r584)
@@ -0,0 +1,399 @@
+package us.isidor.gdl.anaToMia.Widgets.text;
+
+import java.util.ArrayList;
+
+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.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.ColorValue;
+import us.isidor.gdl.anaToMia.Widgets.values.CssValue;
+import us.isidor.gdl.anaToMia.Widgets.values.DirectionValue;
+import us.isidor.gdl.anaToMia.Widgets.values.FontWeightValue;
+import us.isidor.gdl.anaToMia.Widgets.values.NormalNumUnitValue;
+import us.isidor.gdl.anaToMia.Widgets.values.PositiveNumUnitValue;
+import us.isidor.gdl.anaToMia.Widgets.values.TextAlignValue;
+import us.isidor.gdl.anaToMia.Widgets.values.TextDecorationValue;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Style.FontStyle;
+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 com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Widget;
+
+
+public class GdlTitle extends GdlTextObject {
+ protected ArrayList<Pair<String, String>> titleActiveCssNamesAndStyles = new ArrayList<Pair<String,String>>();
+ protected ArrayList<Pair<String, String>> titleFocusCssNamesAndStyles = new ArrayList<Pair<String,String>>();
+ protected ArrayList<Pair<String, String>> titleHoverCssNamesAndStyles = new ArrayList<Pair<String,String>>();
+
+ protected GdlTitle() throws InvalidGdlSchemaException, ExecutionException {
+ super();
+ }
+
+
+ public GdlTitle(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{
+ super(tmRepresentative);
+ // TODO: create a Title element for each TM-elem
+ this.createTitle();
+ }
+
+
+ // returns a PositiveNumUnitValue instance that represents the text font-size of this element.
+ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned
+ // or null. The default values of gdl:Title differ to gdl:Text-Object
+ @Override
+ public PositiveNumUnitValue getFontSize(String styleClass) throws InvalidGdlSchemaException {
+ Occurrence sizeOcc = null;
+ if(styleClass != null){
+ sizeOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlFontSize, styleClass);
+ } else {
+ sizeOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlFontSize);
+ }
+
+ if(sizeOcc == null && styleClass != null){
+ return null;
+ } else if(sizeOcc == null) {
+ switch(this.getTitleOrder()){
+ case 1: return new PositiveNumUnitValue("24pt");
+ case 2: return new PositiveNumUnitValue("19pt");
+ case 3: return new PositiveNumUnitValue("16pt");
+ default: return new PositiveNumUnitValue("14pt");
+ }
+ } else {
+ return new PositiveNumUnitValue(sizeOcc.getValue());
+ }
+ }
+
+
+ // returns the property of a gdl:title-order occurrence, otherwise the default value if no occurrence is set
+ public int getTitleOrder() throws InvalidGdlSchemaException{
+ Occurrence orderOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlTitleOrder);
+
+ if(orderOcc != null){
+ try{
+ int titleOrder = Integer.valueOf(orderOcc.getValue());
+ return titleOrder;
+ }catch(NumberFormatException e){
+ throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlTitleOrder + " must be set to one of \"1\", \"2\", \"3\" or \"4\", but is \"" + orderOcc.getValue() + "\"");
+ }
+ } else {
+ return 1;
+ }
+ }
+
+
+ @Deprecated
+ public void setTitleOrder(Widget widget, int value){
+ // this method is not implemented, since the title-order is set in initTitle
+ // It exists only for consistency reasons
+ }
+
+
+
+
+
+ // adds a stly property and value as a pair to the corresponding array list
+ private void addStyleToStore(String styleClass, String property, String value){
+ if(styleClass == null) return;
+ else if(styleClass.equals(GdlPsis.Scope.gdlActive)) this.titleActiveCssNamesAndStyles.add(new Pair<String, String>(property, value));
+ else if(styleClass.equals(GdlPsis.Scope.gdlFocus)) this.titleFocusCssNamesAndStyles.add(new Pair<String, String>(property, value));
+ else if(styleClass.equals(GdlPsis.Scope.gdlHover)) this.titleHoverCssNamesAndStyles.add(new Pair<String, String>(property, value));
+ }
+
+
+
+ // sets the direction style property of this element by using the GWT DOM class
+ @Override
+ public void setDirection(Widget widget, DirectionValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "direction", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "direction", value.getCssValue());
+ }
+ }
+
+
+ // sets the text-align style property of this element by using the GWT DOM class
+ @Override
+ public void setTextAlign(Widget widget, TextAlignValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "text-align", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "text-align", value.getCssValue());
+ }
+ }
+
+
+ // sets the line-height style property of this element by using the GWT DOM class
+ @Override
+ public void setLineHeight(Widget widget, NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "line-height", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "line-height", value.getCssValue());
+ }
+ }
+
+
+ // sets the text-decoration style property of this element by using the GWT DOM class
+ @Override
+ public void setTextDecoration(Widget widget, TextDecorationValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "text-decoration", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "text-decoration", value.getCssValue());
+ }
+ }
+
+
+ // sets the color style property of this element by using the GWT DOM class
+ @Override
+ public void setColor(Widget widget, ColorValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "color", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "color", value.getCssValue());
+ }
+ }
+
+
+ // sets the font-family style property of this element by using the GWT DOM class
+ @Override
+ public void setFontFamily(Widget widget, String value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "font-family", value);
+ }
+ this.addStyleToStore(styleClass, "font-family", value);
+ }
+ }
+
+
+ // sets the font-style style property of this element by using the GWT DOM class
+ @Override
+ public void setFontStyle(Widget widget, FontStyle value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "font-style", value.getCssName());
+ }
+ this.addStyleToStore(styleClass, "font-style", value.getCssName());
+ }
+ }
+
+
+ // sets the font-size style property of this element by using the GWT DOM class
+ @Override
+ public void setFontSize(Widget widget, PositiveNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "font-size", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "font-size", value.getCssValue());
+ }
+ }
+
+
+ // sets the font-weight style property of this element by using the GWT DOM class
+ @Override
+ public void setFontWeight(Widget widget, FontWeightValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "font-weight", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "font-weight", value.getCssValue());
+ }
+ }
+
+
+ // sets the letter-spacing style property of this element by using the GWT DOM class
+ @Override
+ public void setLetterSpacing(Widget widget, NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "letter-spacing", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "letter-spacing", value.getCssValue());
+ }
+ }
+
+ // sets the word-spacing style property of this element by using the GWT DOM class
+ @Override
+ public void setWordSpacing(Widget widget, NormalNumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException {
+ if(value != null && widget.getClass().equals(TitleWidget.class)) {
+ if(styleClass == null){
+ super.replaceStyleProperty(((TitleWidget)widget).getTitleElement(), "word-spacing", value.getCssValue());
+ }
+ this.addStyleToStore(styleClass, "word-spacing", value.getCssValue());
+ }
+ }
+
+
+
+ // TODO: override 2x onActiveStart => handle style classes
+
+ // TODO: override 2x onHoverStart => handle style classes
+
+ // TODO: override 2x onFocusStart => handle style classes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ // sets the list Element to either ol or ul depending on the gdl:ordered property
+ public void createTitle() throws InvalidGdlSchemaException, ExecutionException {
+ // this object is able to own only one sub-element
+ TitleWidget title = new TitleWidget(this.getTitleOrder());
+ title.setText("TITLE!!!");
+ 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();
+ title.setId(this.getId() + "__GDL_" + idSuffix);
+ title.addMouseDownHandler(asHandler);
+ title.addMouseUpHandler(asHandler);
+ title.addMouseOverHandler(hsHandler);
+ title.addMouseOutHandler(hsHandler);
+ title.addFocusHandler(fsHandler);
+ title.addBlurHandler(fsHandler);
+ super.addToContainerPanel(title);
+ this.setGdlStyle(title);
+ }
+
+
+ // this class represents the acutal content of this widget, i.e.
+ // it wraps a h1, h2, h3 or h4 element
+ protected class TitleWidget extends Composite implements HasMouseDownHandlers, HasMouseUpHandlers, HasMouseOverHandlers, HasMouseOutHandlers, HasBlurHandlers, HasFocusHandlers{
+ private AbsolutePanel basePanel = new AbsolutePanel();
+ private Element titleElement = null;
+
+
+ // some constructurs
+ public TitleWidget()throws ExecutionException{
+ initWidget(this.basePanel);
+ this.initTitleElement(1);
+ }
+
+
+
+ public Element getTitleElement(){
+ return this.titleElement;
+ }
+
+
+ public TitleWidget(int titleOrder) throws ExecutionException{
+ if(titleOrder <= 0 || titleOrder > 4) throw new ExecutionException("The title order of a GDL Title element must be 1, 2, 3 or 4");
+ initWidget(this.basePanel);
+ this.initTitleElement(titleOrder);
+ }
+
+
+ // creates and returns the actual title element
+ private void initTitleElement(int titleOrder) throws ExecutionException {
+ switch(titleOrder){
+ case 1: this.titleElement = DOM.createElement("h1");
+ break;
+ case 2: this.titleElement = DOM.createElement("h2");
+ break;
+ case 3: this.titleElement = DOM.createElement("h3");
+ break;
+ case 4: this.titleElement = DOM.createElement("h4");
+ break;
+ default: throw new ExecutionException("The title order of a GDL Title element must be 1, 2, 3 or 4");
+ }
+ this.basePanel.getElement().insertFirst(this.titleElement);
+ }
+
+
+ // inserts the passed string as content to the heading
+ public void setText(String text){
+ if(text == null) return;
+ this.titleElement.setInnerText(text);
+ }
+
+
+ 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());
+ }
+ }
+}