Author: lgiessmann Date: Fri Jul 1 14:03:30 2011 New Revision: 552
Log: gdl-frontend: Widgets: fixed a bug in the constructor AutoNumValue(String)
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/values/AutoNumUnitValue.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 1 13:42:48 2011 (r551) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 1 14:03:30 2011 (r552) @@ -39,10 +39,12 @@ this.tmRepresentative = tmRepresentative; this.tm = this.tmRepresentative.getTopicMap(); - // TODO: apply GDL style + this.setId(this.getId()); + this.setGdlStyle(); } + // returns the topic that represents this element public Topic getTmRepresentative(){ return this.tmRepresentative; } @@ -50,7 +52,9 @@ // a helper method that returns all occurrences of the type bound to the passed PSI private JsArray<Occurrence> getOccurrences(String occurrenceType){ - return tmRepresentative.getOccurrences(tm.getTopicBySubjectIdentifier(tm.createLocator(occurrenceType))); + Topic occType = tm.getTopicBySubjectIdentifier(tm.createLocator(occurrenceType)); + if(occType == null) return null; + else return tmRepresentative.getOccurrences(occType); } @@ -65,7 +69,7 @@ } if(unscopedOccs.size() > 1){ - throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one unscoped occurrence of the type " + occurrenceType + "but is bound " + unscopedOccs.size() + " times to it"); + throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to none or one unscoped occurrence of the type " + occurrenceType + ", but is bound " + unscopedOccs.size() + " times to it"); } else if(unscopedOccs.size() == 1){ return unscopedOccs.get(0); } else { @@ -107,7 +111,7 @@ public String getId() throws InvalidGdlSchemaException { JsArray<Occurrence> idOccs = getOccurrences(GdlPsis.OccurrenceType.gdlId); if(idOccs.length() != 1){ - throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to exactly one occurrence of the type " + GdlPsis.OccurrenceType.gdlId + "but is bound " + idOccs.length() + " times to it"); + throw new InvalidGdlSchemaException("The topic " + GdlPsis.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to exactly one occurrence of the type " + GdlPsis.OccurrenceType.gdlId + ", but is bound " + idOccs.length() + " times to it"); } else { return idOccs.get(0).getValue(); } @@ -1499,7 +1503,11 @@ - public void setGdlStyle(){ + public void setGdlStyle() throws InvalidGdlSchemaException { // TODO: implement + + this.setWidth(this.getWidth(null)); + this.setHeight(this.getHeight(null)); + this.setBackgroundColor(this.getBackgroundColor(null)); } }
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 1 13:42:48 2011 (r551) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 1 14:03:30 2011 (r552) @@ -11,13 +11,12 @@ import com.google.gwt.dom.client.Style.Display; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; -import com.google.gwt.event.dom.client.MouseOutEvent; 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.HorizontalPanel; import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; +
public class TestClass implements EntryPoint{ HorizontalPanel mainPanel = new HorizontalPanel(); @@ -59,20 +58,26 @@ try{ Topic tmpRepresentative = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator("http://test.org/test-top")); Topic gdlBackgroundColor = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlBackgroundColor)); + Topic gdlId = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlId)); + Topic gdlWidth = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlWidth)); + Topic gdlHeight = gdlPanel.getSchemaTm().createTopicBySubjectIdentifier(gdlPanel.getSchemaTm().createLocator(GdlPsis.OccurrenceType.gdlHeight)); tmpRepresentative.createOccurrence(gdlBackgroundColor, "red", null); + tmpRepresentative.createOccurrence(gdlId, "ID_1", null); + tmpRepresentative.createOccurrence(gdlWidth, "300px", null); + tmpRepresentative.createOccurrence(gdlHeight, "300px", null); + GdlVisibleObject tmp = new GdlVisibleObject(tmpRepresentative){};
- tmp.setPixelSize(300, 300); // TODO: remove - DOM.setStyleAttribute(tmp.getElement(), "backgroundColor", "lime"); // TODO: remove this.mainPanel.add(tmp); }catch(Exception e){ + e.printStackTrace(); Window.alert(">> e >> " + e.getClass() + " >> " + e.getMessage()); } }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AutoNumUnitValue.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AutoNumUnitValue.java Fri Jul 1 13:42:48 2011 (r551) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/values/AutoNumUnitValue.java Fri Jul 1 14:03:30 2011 (r552) @@ -14,14 +14,14 @@ if(upperString.equals("AUTO")){ super.unit = null; // if unit is null, the default value is auto super.value = 0f; - }else if(value.endsWith("PX")){ - this.value = makeFloat(value, 2); + }else if(upperString.endsWith("PX")){ + this.value = makeFloat(upperString, 2); this.unit = CssUnit.PIXEL; - }else if (value.endsWith("PT")){ - this.value = makeFloat(value, 2); + }else if (upperString.endsWith("PT")){ + this.value = makeFloat(upperString, 2); this.unit = CssUnit.POINT; - } else if(value.endsWith("%")){ - this.value = makeFloat(value, 1); + } else if(upperString.endsWith("%")){ + this.value = makeFloat(upperString, 1); this.unit = CssUnit.PERCENTAGE; } else { throw new InvalidGdlSchemaException("auto numeric values supported by the GDL containing a unit definition must be of the form <numeric-value>(pt|px|%)|auto, but found: " + value);