[isidorus-cvs] r669 - in branches/gdl-frontend/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets src/us/isidor/gdl/anaToMia/Widgets/base src/us/isidor/gdl/anaToMia/Widgets/button war/gdl_widgets

Author: lgiessmann Date: Tue Jul 26 04:19:31 2011 New Revision: 669 Log: gdl-frontend: Widgets: implemented GdlActionButton Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt 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/button/GdlActionButton.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Fri Jul 22 10:44:58 2011 (r668) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Tue Jul 26 04:19:31 2011 (r669) @@ -1,5 +1,4 @@ * Implement GdlButton(s) -* Implement GdlButton(s) positioning * Implement TopicMaps data consumption * Implement TopicMaps data generation * ImplementGdlVisibleObject => (de)registerButtonCallback 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 22 10:44:58 2011 (r668) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Tue Jul 26 04:19:31 2011 (r669) @@ -1323,8 +1323,7 @@ if(value != null) this.setCssProperty(widget, styleClass, "borderTopLeftRadius", value.getCssValue()); } - - + // sets the padding style property of this element by using the GWT DOM class public void setPadding(Widget widget, NumUnitValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException { if(value != null) this.setCssProperty(widget, styleClass, "padding", value.getCssValue()); @@ -1421,8 +1420,7 @@ throw new InvalidGdlSchemaException("GDL defines only the style classes " + values + ", but found " + styleClass); } } - - + // sets a given css property and css value of this element's sub element protected void setCssProperty(Widget elem, String styleClass, String cssProperty, String cssValue)throws InvalidGdlSchemaException, ExecutionException{ Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java Fri Jul 22 10:44:58 2011 (r668) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlActionButton.java Tue Jul 26 04:19:31 2011 (r669) @@ -1,12 +1,25 @@ package us.isidor.gdl.anaToMia.Widgets.button; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Button; +import com.google.gwt.user.client.ui.Widget; + +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.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; +import us.isidor.gdl.anaToMia.Widgets.value.AbsoluteNumValue; +import us.isidor.gdl.anaToMia.Widgets.value.BorderStyleValue; +import us.isidor.gdl.anaToMia.Widgets.value.ColorValue; +import us.isidor.gdl.anaToMia.Widgets.value.ContentOrientationValue; +import us.isidor.gdl.anaToMia.Widgets.value.CursorValue; +import us.isidor.gdl.anaToMia.Widgets.value.NumUnitValue; +import us.isidor.gdl.anaToMia.Widgets.value.TextAlignValue; public class GdlActionButton extends GdlButton { - // TODO: implement - + protected GdlActionButton(){ super(); } @@ -14,5 +27,217 @@ public GdlActionButton(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative); + // TODO: set all tm values + this.createButton().setText("Action-Button"); // TODO: remove set text + } + + + // creates a new button if no one exist, otherwise returns the existing button + protected Button createButton() throws InvalidGdlSchemaException, ExecutionException{ + if(this.subElements.size() != 0) return (Button)this.subElements.get(0); + Button btn = new Button(); + this.setGdlStyle(btn); + this.subElements.add(btn); + this.mainPanel.add(btn); + this.setId(this.getId()); + return btn; + } + + + // sets the id property of this element by using the GWT DOM class + @Override + public void setId(String id){ + if(id != null && this.subElements.size() != 0){ + DOM.setElementProperty(this.subElements.get(0).getElement(), "id", id); + } + } + + + // content orientation has no effect on buttons + @Override + @Deprecated + public void setContentOrientation(ContentOrientationValue value) throws InvalidGdlSchemaException, ExecutionException { + return; + } + + + // returns a TextAlingvalue instance that represents the text-align of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. The default value for gdl:Action-Button is Center + @Override + public TextAlignValue getTextAlign(String styleClass) throws InvalidGdlSchemaException { + Occurrence textAlignOcc = null; + if(styleClass != null){ + textAlignOcc = super.getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlTextAlign, styleClass); + } else { + textAlignOcc = super.getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlTextAlign); + } + + if(textAlignOcc == null && styleClass != null){ + return null; + } else if(textAlignOcc == null) { + return TextAlignValue.CENTER; + } else { + try{ + return TextAlignValue.valueOf(textAlignOcc.getValue().toUpperCase()); + }catch(IllegalArgumentException e){ + throw new InvalidGdlSchemaException("The occurrence " + GdlPsis.OccurrenceType.gdlTextAlign + " must be set to one of \"left\", \"right\", \"center\" or \"justify\", but is \"" + textAlignOcc.getValue() + "\""); + } + } + } + + + // returns a AbsoluteNumValue instance that represents the width of this element's border. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + public AbsoluteNumValue getBorderWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderWidth, styleClass); + } else { + widthOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderWidth); + } + + if(widthOcc == null && styleClass != null){ + return null; + } else if(widthOcc == null) { + return new AbsoluteNumValue("1px"); + } else { + return new AbsoluteNumValue(widthOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the padding of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + @Override + public NumUnitValue getPadding(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlPadding, styleClass); + } else { + paddingOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlPadding); + } + + if(paddingOcc == null && styleClass != null){ + return null; + } else if(paddingOcc == null) { + return new NumUnitValue("5px"); + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns a ColorValue instance that represents the color of this element's border. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + @Override + public ColorValue getBorderColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor, styleClass); + } else { + colorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderColor); + } + + if(colorOcc == null && styleClass != null){ + return null; + } else if(colorOcc == null) { + return new ColorValue("#bbbbbb"); + } else { + return new ColorValue(colorOcc.getValue()); + } + } + + + + // returns a ColorValue instance that represents the style of this element's border. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + public BorderStyleValue getBorderStyle(String styleClass) throws InvalidGdlSchemaException { + Occurrence styleOcc = null; + if(styleClass != null){ + styleOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderStyle, styleClass); + } else { + styleOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderStyle); + } + + if(styleOcc == null && styleClass != null){ + return null; + } else if(styleOcc == null) { + return BorderStyleValue.SOLID; + } else { + try{ + return BorderStyleValue.valueOf(styleOcc.getValue().toUpperCase()); + }catch(IllegalArgumentException e){ + String values = "none, hidden, dotted, dashed, solid, double, groove, ridge, inset, outset"; + throw new InvalidGdlSchemaException("border-style must be set to one of " + values + ", but is " + styleOcc.getValue()); + } + } + } + + + // returns a CursorValue instance that represents the cursor of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + public CursorValue getCursor(String styleClass) throws InvalidGdlSchemaException { + Occurrence cursorOcc = null; + if(styleClass != null){ + cursorOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlCursor, styleClass); + } else { + cursorOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlCursor); + } + + if(cursorOcc == null && styleClass != null){ + return null; + } else if(cursorOcc == null) { + return CursorValue.POINTER; + } else { + try{ + return CursorValue.valueOf(cursorOcc.getValue().toUpperCase().replace("-", "_")); + }catch(IllegalArgumentException e){ + String values = "auto, default, crosshair, pointer, move, n-resize, ne-resize," + + "nw-resize, e-resize, se-resize, s-resize, sw-resize, w-resize," + + "text, wait, help, or progress"; + throw new InvalidGdlSchemaException("cursor must be set to one of " + values + ", but is " + cursorOcc.getValue()); + } + } + } + + + + // returns a NumUnitValue instance that represents the radius of this element's border. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + public NumUnitValue getBorderRadius(String styleClass) throws InvalidGdlSchemaException { + Occurrence radiusOcc = null; + if(styleClass != null){ + radiusOcc = getNoneOrOneScopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRadius, styleClass); + } else { + radiusOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlBorderRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null) { + return new NumUnitValue("5px"); + } else { + return new NumUnitValue(radiusOcc.getValue()); + } + } + + + // Returns the actual button element + public Button getButton(){ + if(this.subElements.size() == 0) return null; + else return (Button)this.subElements.get(0); } } Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Fri Jul 22 10:44:58 2011 (r668) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/test.gdl.jtm Tue Jul 26 04:19:31 2011 (r669) @@ -50,6 +50,7 @@ {"subject_identifiers":["[doc:default-creator-topic-view-1]"], "instance_of":["si:[gdl:Default-Creator-Topic-View]"], "names":[{"value": "Def. Creator View 1", "type":"si:[gdl:view-name]"}], "occurrences":[{"type":"si:[gdl:id]", "value":"default_creator_topic_view_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:background-color]", "value":"#ccc"}, {"type":"si:[gdl:width]", "value":"500px"}, {"type":"si:[gdl:height]", "value":"600px"}]}, {"subject_identifiers":["[gdl:View]"]}, {"subject_identifiers":["[gdl:Button]"]}, + {"subject_identifiers":["[gdl:Action-Button]"]}, {"subject_identifiers":["[gdl:Input-Button]"]}, {"subject_identifiers":["[gdl:Radio-Button]"]}, {"subject_identifiers":["[gdl:Check-Box]"]}, @@ -60,6 +61,7 @@ {"subject_identifiers":["[gdl:List]"]}, {"subject_identifiers":["[doc:unit-1-radio-button]"], "instance_of":["si:[gdl:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_radio_button_id"},{"type":"si:[gdl:content-orientation]", "value":"horizontal"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin-left]", "value":"15pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]}, {"subject_identifiers":["[doc:unit-1-check-box]"], "instance_of":["si:[gdl:Check-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"unit_1_check_box_id"},{"type":"si:[gdl:content-orientation]", "value":"vertical"}, {"type":"si:[gdl:background-color]", "value": "lime"}, {"type":"si:[gdl:margin]", "value":"30pt"}, {"type":"si:[gdl:font-size]", "value":"8pt"}]}, + {"subject_identifiers":["[doc:unit-1-action-button]"], "instance_of":["si:[gdl:Action-Button]"], "occurrences":[{"type":"si:[gdl:id]","value":"unit_1_action_button"}]}, {"subject_identifiers":["[doc:list-item-1]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"list_item_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:padding-bottom]", "value":"5px"}, {"type":"si:[gdl:margin-bottom]", "value":"5px"}]}, {"subject_identifiers":["[doc:list-item-3]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"list_item_3_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:padding-bottom]", "value":"5px"}]}, {"subject_identifiers":["[doc:list-item-2]"], "instance_of":["si:[gdl:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"list_item_2_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:padding]", "value":"5px"}, {"type":"si:[gdl:margin-top]", "value":"5px"}]}, @@ -72,6 +74,7 @@ {"subject_identifiers":["[doc:pos-of-unit-1-reference]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:pos-of-unit-1-radio-button]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:pos-of-unit-1-check-box]"], "instance_of":["si:[gdl:Position]"]}, + {"subject_identifiers":["[doc:pos-of-unit-1-action-button]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:pos-of-unit-1-space]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:pos-of-unit-1-text]"], "instance_of":["si:[gdl:Position]"]}, {"subject_identifiers":["[doc:reference-1]"], "instance_of":["si:[gdl:Reference]"], "occurrences":[{"type":"si:[gdl:id]", "value":"reference_1_id", "datatype":"[xsd:ID]"}, {"type":"si:[gdl:margin-left]", "value":"200px"}, {"type":"si:[gdl:background-color]", "value":"yellow"}]}, @@ -149,6 +152,7 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Input-Button]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Input-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Radio-Button]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Input-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Check-Box]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdl:Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdl:Action-Button]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-1]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-creator-topic-view-2]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:test-schema]"},{"type":"si:[gdl:containee]", "player":"si:[doc:default-editor-topic-view]"}]}, @@ -186,9 +190,11 @@ {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-text]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-radio-button]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-check-box]"}]}, + {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[doc:unit-1]"},{"type":"si:[gdl:containee]", "player":"si:[doc:unit-1-action-button]"}]}, {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-reference]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-reference]"}]}, {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-space]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-reference]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-space]"}]}, {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-reference]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-space]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-text]"}]}, {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-radio-button]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-text]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-radio-button]"}]}, - {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-check-box]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-radio-button]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-check-box]"}]} + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-check-box]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-radio-button]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-check-box]"}]}, + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[doc:pos-of-unit-1-action-button]"},{"type":"si:[gdl:ancestor]", "player":"si:[doc:unit-1-check-box]"}, {"type":"si:[gdl:descendant]", "player":"si:[doc:unit-1-action-button]"}]} ]} \ No newline at end of file
participants (1)
-
lgiessmann@common-lisp.net