Author: lgiessmann Date: Thu Aug 25 15:05:01 2011 New Revision: 789
Log: gdl-frontend: Widgets: implemented addSubItem for GdlListBox => explicitly set Literal-Values, literal-values and tm-values of the constraint bound to the element's value-group are set; currently explecitely set TM-Values are not handled
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/text/GdlListBox.java branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/TextGrid_ServiceRegistry_required_TMCL_and_GDL_Schema_with_test_data.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 Thu Aug 25 14:25:06 2011 (r788) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Aug 25 15:05:01 2011 (r789) @@ -7,6 +7,7 @@ * GdlButton * GdlComplexData * GdlListBox +* implement the ahndling of default-values * Implement TopicMaps data consumption * Implement TopicMaps data generation * Implement HiddenValue
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 Thu Aug 25 14:25:06 2011 (r788) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Thu Aug 25 15:05:01 2011 (r789) @@ -2115,6 +2115,13 @@ }
+ // returns the display-by schema that is defined for the passed + // TM-Value that is bound to this element + public Topic getDisplayByOfTmValue(Topic tmValue) throws InvalidGdlSchemaException{ + return TmHelper.getDisplayByTopicOf(tmValue); + } + + // returns the preferred scope that is bound to the value-group of // this element - or an empty ArrayList public ArrayList<Topic> getPreferredScopeOfValueGroup() throws InvalidGdlSchemaException { @@ -2127,6 +2134,13 @@ } }
+ + // returns the preferred scope that is bound to the passed TM-Value topic + // this element - or an empty ArrayList + public ArrayList<Topic> getPreferredScopeOfTmValue(Topic tmValue) throws InvalidGdlSchemaException{ + return TmHelper.getPrefferedScopesForTopicOf(tmValue); + } +
// returns the string that represents the topic topicToRepresent corresponding // to the passed displayBy and prefferedScopes arguments
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 Thu Aug 25 14:25:06 2011 (r788) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/text/GdlListBox.java Thu Aug 25 15:05:01 2011 (r789) @@ -1,16 +1,15 @@ package us.isidor.gdl.anaToMia.Widgets.text;
import java.util.ArrayList; - import com.google.gwt.event.shared.EventHandler; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.Widget; - import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.Widgets.base.PSIs; +import us.isidor.gdl.anaToMia.Widgets.base.TmHelper; import us.isidor.gdl.anaToMia.Widgets.environment.ActiveStyleHandler; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.FocusStyleHandler; @@ -27,15 +26,59 @@ public GdlListBox(Topic tmRepresentative, Construct receivedData) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative, receivedData); - // TODO: create a ListBox element for each TM-elem - this.createNewListBox().addItem("List-Box"); + + if(receivedData != null && this.getConstraint() != null) this.setReceivedData(); + else this.setDefaultValue(); + this.setNthButtons(); } @Override public void addSubItem(String value) throws InvalidGdlSchemaException, ExecutionException { - // TODO: implement + ArrayList<String> options = new ArrayList<String>(); + + // get the explicitly set TM-Values and Literal-Values. + // if no values were set explecitly, get the values for the constraint + ArrayList<String> exLiteralValues = this.getLiterals(); + ArrayList<Topic> exTmValues = this.getTmValues(); + if(exLiteralValues.size() != 0 && exTmValues.size() != 0){ + throw new InvalidGdlSchemaException("found literal values and tm values for the value group " + TmHelper.getAnyIdOfTopic(this.getValueGroup()) + ", but mixin literal and tm-values for a value group is not allowed!"); + } else if(exLiteralValues.size() != 0){ + options = exLiteralValues; + } else if(exTmValues.size() != 0){ + // TODO: get all Topics that are represented by a TM-Value + // TODO: get its string-representation + // TODO: add it to the options ArrayList + } else { + ArrayList<Topic> tmValues = this.getTmValuesForConstraint(); + if(tmValues.size() != 0){ + for (Topic topic : tmValues) options.add(this.getTopicRepresentation(topic, this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup())); + } else { + throw new InvalidGdlSchemaException("found no value to display for the value-group" + TmHelper.getAnyIdOfTopic(this.getValueGroup())); + } + } + + ListBox lb = this.createNewListBox(); + for(String item : options) lb.addItem(item); + + int i = 0; + for( ; i != lb.getItemCount(); ++i){ + if(lb.getItemText(i).equals(value)){ + lb.setSelectedIndex(i); + break; + } + } + + if(i == lb.getItemCount()){ + lb.addItem(value); + for(i = 0 ; i != lb.getItemCount(); ++i){ + if(lb.getItemText(i).equals(value)){ + lb.setSelectedIndex(i); + break; + } + } + } } @@ -91,25 +134,6 @@ } - // returns the gdl:one-per-group property - if no value is set the default value is returned - public boolean getOnePerGroup() throws InvalidGdlSchemaException { - Occurrence onePerGroupOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlOnePerGroup); - - if(onePerGroupOcc != null){ - String boolStr = onePerGroupOcc.getValue().toUpperCase(); - if(boolStr.equals("TRUE")){ - return true; - } else if(boolStr.equals("FALSE")) { - return false; - } else { - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlOnePerGroup + " must be set to one of "true" or "false", but is "" + onePerGroupOcc.getValue() + """); - } - } else { - return false; - } - } - - // returns an int instance of a gdl:size occurrence. // If no gdl:size occurrence is set, the default value is returned public int getSize() throws InvalidGdlSchemaException { @@ -142,12 +166,7 @@ // directly when calling the ListBox constructor } - - public void setOnePerGroup(Widget widget, boolean value){ - // TODO: implement => http://code.google.com/p/gwt-traction/source/browse/src/com/tractionsoftware... - } - - + // sets the css properties, by calling the super class's method and the local // method, which sets some specific properties for the GdlText instance @Override @@ -155,6 +174,5 @@ super.setGdlStyle(widget);
this.setSize(widget, this.getSize()); - this.setOnePerGroup(widget, this.getOnePerGroup()); } } \ No newline at end of file
Modified: branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/TextGrid_ServiceRegistry_required_TMCL_and_GDL_Schema_with_test_data.jtm ============================================================================== --- branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/TextGrid_ServiceRegistry_required_TMCL_and_GDL_Schema_with_test_data.jtm Thu Aug 25 14:25:06 2011 (r788) +++ branches/gdl-frontend/src/anaToMia/GDL_Widgets/war/gdl_widgets/TextGrid_ServiceRegistry_required_TMCL_and_GDL_Schema_with_test_data.jtm Thu Aug 25 15:05:01 2011 (r789) @@ -1280,7 +1280,7 @@ ], "subject_locators":null, "item_identifiers":null, - "instance_of":["si:[pref_2:Text]" + "instance_of":["si:[pref_2:List-Box]" ], "names":null, "occurrences":[{