Author: lgiessmann Date: Fri Jul 8 02:00:38 2011 New Revision: 581
Log: gdl-frontend: Widgets: fixed a bug in GdlList when applying list styles
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 branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.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 Fri Jul 8 00:02:50 2011 (r580) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Fri Jul 8 02:00:38 2011 (r581) @@ -99,23 +99,10 @@ this.mainPanel.add(this.containerPanel); } + this.subElements.add(widget); this.containerPanel.add(widget); } - - // this method should be invoked if a new sub-element is added to this instance - protected void addToContainerPanel(Element elem){ - if(this.containerPanel == null){ - this.containerPanel = new VerticalPanel(); - this.mainPanel.add(this.containerPanel); - } - - Element panel = this.containerPanel.getElement(); - Node lastItem = panel.getLastChild(); - if(lastItem == null) panel.insertFirst(lastItem); - else panel.insertAfter(elem, lastItem); - } -
// 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 00:02:50 2011 (r580) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TestClass.java Fri Jul 8 02:00:38 2011 (r581) @@ -3,6 +3,7 @@ import us.isidor.gdl.anaToMia.TmEngine.jtmsBasedEngine.JtmsTmEngine; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; +import us.isidor.gdl.anaToMia.Widgets.container.GdlList; import us.isidor.gdl.anaToMia.Widgets.isidorus.LoadSchemaCallback; import us.isidor.gdl.anaToMia.Widgets.text.GdlListBox; import us.isidor.gdl.anaToMia.Widgets.text.GdlText; @@ -115,7 +116,7 @@ fsHover.addTheme(gdlHover); - GdlListBox tmp = new GdlListBox(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 00:02:50 2011 (r580) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlList.java Fri Jul 8 02:00:38 2011 (r581) @@ -17,11 +17,10 @@ import us.isidor.gdl.anaToMia.Widgets.values.ListStylePositionValue; import us.isidor.gdl.anaToMia.Widgets.values.ListStyleTypeValue;
+ public class GdlList extends GdlVisibleObject{ - - // some constructors - protected GdlList() throws InvalidGdlSchemaException{ + protected GdlList() throws InvalidGdlSchemaException, ExecutionException { super(); this.initList(this.getOrdered()); } @@ -34,9 +33,11 @@ // sets the list Element to either ol or ul depending on the gdl:ordered property - public void initList(boolean ordered) throws InvalidGdlSchemaException { + public void initList(boolean ordered) throws InvalidGdlSchemaException, ExecutionException { // this object is able to own only one sub-element - super.subElements.add(new ListWidget(this.getOrdered())); + ListWidget list = new ListWidget(this.getOrdered()); + super.addToContainerPanel(list); + this.setGdlStyle(list); } @@ -74,7 +75,7 @@ } else if(this.getOrdered()){ return ListStyleTypeValue.DECIMAL; } else { - return ListStyleTypeValue.CIRCLE; + return ListStyleTypeValue.DISC; } }
@@ -104,14 +105,14 @@ // sets the css property list-style-type - public void setListStyleType(Widget widget, ListStyleTypeValue value) throws InvalidGdlSchemaException, ExecutionException { - this.setCssProperty(widget, null, "list-style-type", value.getCssValue()); + public void setListStyleType(ListWidget widget, ListStyleTypeValue value) throws InvalidGdlSchemaException, ExecutionException { + widget.getListElement().setAttribute("style", widget.getListElement().getAttribute("style") + " list-style-type: " + value.getCssValue() + ";"); } // sets the css property list-style-position - public void setListStylePositionValue(Widget widget, ListStylePositionValue value) throws InvalidGdlSchemaException, ExecutionException { - this.setCssProperty(widget, null, "list-style-position", value.getCssValue()); + public void setListStylePositionValue(ListWidget widget, ListStylePositionValue value) throws InvalidGdlSchemaException, ExecutionException { + widget.getListElement().setAttribute("style", widget.getListElement().getAttribute("style") + " list-style-position: " + value.getCssValue() + ";"); } @@ -132,13 +133,13 @@ public void setGdlStyle(Widget widget) throws InvalidGdlSchemaException, ExecutionException { super.setGdlStyle(widget);
- this.setListStylePositionValue(widget, this.getListStylePosition()); - this.setListStyleType(widget, this.getListStyleType()); + this.setListStylePositionValue((ListWidget)widget, this.getListStylePosition()); + this.setListStyleType((ListWidget)widget, this.getListStyleType()); } // inserts the passed item on the given index - public void append(GdlVisibleObject item, int position){ + public void insert(GdlVisibleObject item, int position){ if(this.subElements != null && this.subElements.size() != 0){ ((ListWidget)this.subElements.get(0)).insertWidget(item, position); } @@ -154,14 +155,18 @@ private ArrayList<Pair<ListItem, Integer>> itemsAndIndexes = new ArrayList<Pair<ListItem, Integer>>(); public ListWidget(){ + initWidget(this.basePanel); this.listElement = DOM.createElement("ul"); this.basePanel.getElement().insertFirst(this.listElement); } + public ListWidget(boolean ordered){ + initWidget(this.basePanel); if(ordered) this.listElement = DOM.createElement("ol"); else this.listElement = DOM.createElement("ul"); this.basePanel.getElement().insertFirst(this.listElement); + this.listElement.insertFirst(DOM.createElement("li")); } @@ -201,6 +206,11 @@ } + // returns the acutal DOM element + public Element getListElement(){ + return this.listElement; + } + // returns all ListItems public ArrayList<ListItem> getItems(){ ArrayList<ListItem> items = new ArrayList<GdlList.ListItem>();
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java Fri Jul 8 00:02:50 2011 (r580) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java Fri Jul 8 02:00:38 2011 (r581) @@ -65,7 +65,6 @@ elem.addMouseOutHandler(hsHandler); elem.addFocusHandler(fsHandler); elem.addBlurHandler(fsHandler); - this.subElements.add(elem); super.addToContainerPanel(elem); return elem; }
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 Fri Jul 8 00:02:50 2011 (r580) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Fri Jul 8 02:00:38 2011 (r581) @@ -67,7 +67,6 @@ elem.addMouseOutHandler(hsHandler); elem.addFocusHandler(fsHandler); elem.addBlurHandler(fsHandler); - this.subElements.add(elem); super.addToContainerPanel(elem); return elem; }