Author: lgiessmann Date: Wed Jul 27 08:02:34 2011 New Revision: 678
Log: gdl-frontend: Widgets: implementd a remove function, so a sub-element of each GdlWidget can be removed, additionally the gdl:Action-Buttons placed with gdl:button-position are reset
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/complexData/GdlDatePicker.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.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/GdlReference.java 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/GdlTitle.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 Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Wed Jul 27 08:02:34 2011 (r678) @@ -105,6 +105,21 @@ } + // removes the passed widget, it's parent, and returns the parent + protected ButtonableObject removeFromContainer(Widget widget) throws InvalidGdlSchemaException, ExecutionException { + for (Widget elem : this.subElements) { + if(((ButtonableObject)elem).getMainObject().equals(widget)){ + elem.removeFromParent(); + this.subElements.remove(elem); + return (ButtonableObject)elem; + } + } + this.setNthButtons(); + + return null; + } + + // sets all buttons in the sub-elements that are specified by a // gdl:button-position association protected void setNthButtons() throws InvalidGdlSchemaException, ExecutionException {
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/complexData/GdlDatePicker.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/complexData/GdlDatePicker.java Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/complexData/GdlDatePicker.java Wed Jul 27 08:02:34 2011 (r678) @@ -25,6 +25,7 @@ import com.google.gwt.user.datepicker.client.DatePicker; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; +import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.IGdlHasValue; import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; @@ -74,6 +75,9 @@ } + public ButtonableObject removeDatePicker(DateWidget elem) throws InvalidGdlSchemaException, ExecutionException{ + return this.removeFromContainer(elem); + }
@Override
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/container/GdlUnit.java Wed Jul 27 08:02:34 2011 (r678) @@ -28,6 +28,7 @@ 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.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.GdlPosition; import us.isidor.gdl.anaToMia.Widgets.base.GdlPsis; import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject; @@ -91,6 +92,11 @@ } + public ButtonableObject removeUnit(UnitWidget elem) throws InvalidGdlSchemaException, ExecutionException{ + return this.removeFromContainer(elem); + } + + // returns a String instance that represents the literal value of this elements name. public String getUnitName() throws InvalidGdlSchemaException { Occurrence nameOcc = getNoneOrOneUnscopedOccurrence(GdlPsis.OccurrenceType.gdlUnitName);
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 Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java Wed Jul 27 08:02:34 2011 (r678) @@ -56,7 +56,7 @@ // removes the passed element and all its handlers from the outer element - protected void removeListbox(ListBox elem) throws InvalidGdlSchemaException, ExecutionException{ + protected void removeListBox(ListBox elem) throws InvalidGdlSchemaException, ExecutionException{ for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) { if(item.getFirst().equals(elem)){ this.eventHandlers.remove(item); @@ -64,15 +64,7 @@ } } - ButtonableObject toRemove = null; - for (Widget widget: this.subElements){ - if(((ButtonableObject)widget).getMainObject().equals(widget)){ - toRemove = (ButtonableObject)widget; - } - } - - this.subElements.remove(toRemove); - elem.removeFromParent(); + this.removeFromContainer(elem); }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlReference.java Wed Jul 27 08:02:34 2011 (r678) @@ -41,15 +41,15 @@ public GdlReference(Topic tmRepresentative) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative); // TODO: create a Reference element for each TM-elem - Reference ref = this.createReference(); // TODO: remove + ReferenceWidget ref = this.createReference(); // TODO: remove ref.setText("Reference"); // TODO: remove ref.setHref("http://www.google.de"); // TODO: remove this.setNthButtons(); } - private Reference createReference() throws InvalidGdlSchemaException, ExecutionException { - Reference reference = new Reference(); + private ReferenceWidget createReference() throws InvalidGdlSchemaException, ExecutionException { + ReferenceWidget reference = new ReferenceWidget(); DOM.setElementAttribute(reference.getElement(), "id", this.getId() + "__GDL_" + this.subElements.size()); super.addToContainerPanel(reference); ActiveStyleHandler asHandler = new ActiveStyleHandler(this); @@ -67,6 +67,12 @@ } + // removes the passed element + public void removeReference(ReferenceWidget elem) throws InvalidGdlSchemaException, ExecutionException { + this.removeFromContainer(elem); + } + + // returns a ColorValue instance that represents the text color of this element. // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // or null. @@ -148,7 +154,7 @@ public ArrayList<String> getStringValue() { ArrayList<String> result = new ArrayList<String>(); for (Widget widget : this.subElements) { - result.add(((Reference)((ButtonableObject)widget).getMainObject()).getText()); + result.add(((ReferenceWidget)((ButtonableObject)widget).getMainObject()).getText()); } return result; } @@ -172,7 +178,7 @@ protected class ReferenceClickHandler implements ClickHandler { @Override public void onClick(ClickEvent event) { - Reference ref = (Reference)event.getSource(); + ReferenceWidget ref = (ReferenceWidget)event.getSource(); Window.open(ref.getHref(), "new_window", ""); /* TODO: implement @@ -192,96 +198,16 @@ } - /* - protected class Reference extends Composite implements HasFocusHandlers, HasBlurHandlers, HasMouseDownHandlers, HasMouseUpHandlers, HasMouseOutHandlers, HasMouseOverHandlers { - Hyperlink link = new Hyperlink(); - - - public Reference(){ - initWidget(link); - } - - - public Reference(String text){ - this(); - this.link.setText(text); - } - - - public Reference(String text, String href){ - this(text); - this.link.setTargetHistoryToken(href); - } - - - public String getText(){ - return this.link.getText(); - } - - - public void setText(String text){ - this.link.setText(text); - } - - - public String getHref(){ - return this.link.getTargetHistoryToken(); - } - - - public void setHref(String text){ - this.link.setTargetHistoryToken(text); - } - - - @Override - public HandlerRegistration addBlurHandler(BlurHandler handler) { - return this.addDomHandler(handler, BlurEvent.getType()); - } - - - @Override - public HandlerRegistration addFocusHandler(FocusHandler handler) { - return this.addDomHandler(handler, FocusEvent.getType()); - } - - - @Override - public HandlerRegistration addMouseOverHandler(MouseOverHandler handler) { - return this.addDomHandler(handler, MouseOverEvent.getType()); - } - - - @Override - public HandlerRegistration addMouseOutHandler(MouseOutHandler handler) { - return this.addDomHandler(handler, MouseOutEvent.getType()); - } - - - @Override - public HandlerRegistration addMouseUpHandler(MouseUpHandler handler) { - return this.addDomHandler(handler, MouseUpEvent.getType()); - } - - - @Override - public HandlerRegistration addMouseDownHandler(MouseDownHandler handler) { - return this.addDomHandler(handler, MouseDownEvent.getType()); - } - } - */ - - // this class wraps a Label that is used as - protected class Reference extends Label implements HasFocusHandlers, HasBlurHandlers { + protected class ReferenceWidget extends Label implements HasFocusHandlers, HasBlurHandlers { private String href = ""; - public Reference(){ + public ReferenceWidget(){ super(); } - public Reference(String text, String href) { + public ReferenceWidget(String text, String href) { super(text); if(href != null) this.href = href; }
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 Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlText.java Wed Jul 27 08:02:34 2011 (r678) @@ -73,7 +73,7 @@ // removes the passed element and all its handlers from the outer element - protected void removeTextArea(TextArea elem) throws InvalidGdlSchemaException, ExecutionException{ + public void removeTextArea(TextArea elem) throws InvalidGdlSchemaException, ExecutionException{ for (Pair<Widget, ArrayList<EventHandler>> item : this.eventHandlers) { if(item.getFirst().equals(elem)){ this.eventHandlers.remove(item); @@ -81,16 +81,7 @@ } } - ButtonableObject toRemove = null; - for (Widget elemIter : this.subElements){ - if(((ButtonableObject)elemIter).getMainObject().equals(elem)){ - toRemove = (ButtonableObject)elemIter; - break; - } - } - - this.subElements.remove(toRemove); - toRemove.removeFromParent(); + this.removeFromContainer(elem); }
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java Wed Jul 27 05:56:40 2011 (r677) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlTitle.java Wed Jul 27 08:02:34 2011 (r678) @@ -87,6 +87,13 @@ return title; } + + // removes the passed element and all its handlers from the outer element + public void removeTitle(TitleWidget elem) throws InvalidGdlSchemaException, ExecutionException { + this.removeFromContainer(elem); + } + + // 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