From lgiessmann at common-lisp.net Thu Nov 17 09:54:39 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Thu, 17 Nov 2011 01:54:39 -0800 Subject: [isidorus-cvs] r1033 - in trunk/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets war/gdl_widgets Message-ID: Author: lgiessmann Date: Thu Nov 17 01:54:38 2011 New Revision: 1033 Log: added the GDL ontology defined with the TMCL vocabulary in the CTM syntax Added: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/GDL_Ontology.tmcl.ctm Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Oct 27 02:18:29 2011 (r1032) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Nov 17 01:54:38 2011 (r1033) @@ -23,4 +23,5 @@ * finalise GdlDefaultCreatorTopicView * finalise GdlDefaultEditorTopicView * finalise GdlAssociationView.getContent() +* inmplement GdlPanel.OnErrorHandler * Fix css-pseudo-class-handlers \ No newline at end of file Added: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/GDL_Ontology.tmcl.ctm ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/GDL_Ontology.tmcl.ctm Thu Nov 17 01:54:38 2011 (r1033) @@ -0,0 +1,606 @@ +%include http://www.isotopicmaps.org/tmcl/templates.ctm +%prefix tmcl http://psi.topicmaps.org/tmcl/ +%prefix gdl http://isidor.us/gdl/ +%prefix gdlt http://isidor.us/gdl/types/ + + +# Association types +contains gdl:contains isa tmcl:association-type; + has-role(containee, 1, 1); + has-role(container, 1, 1); + has-role(nth-element, 0, 1). + +position gdl:position isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(ancestor, 1, 1); + has-role(descendant, 1, 1). + +button-position gdl:button-position isa tmcl:association-type; + has-role(action-button, 1, 1); + has-role(nth-element, 1, 1); + role-combination(nth-element, Nth-Element, action-button, Action-Button). + +view-binding gdl:view-binding isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(value-group, 1, 1); + role-combination(value-group, Value-Group, descriptor, Text); + role-combination(value-group, Value-Group, descriptor, List-Box); + role-combination(value-group, Value-Group, descriptor, Complex-Data); + role-combination(value-group, Value-Group, descriptor, Input-Button). + role-combination(value-group, Value-Group, descriptor, Action-Button); + role-combination(value-group, Value-Group, descriptor, Reference); + role-combination(value-group, Value-Group, descriptor, Title); + role-combination(value-group, Value-Group, descriptor, Info). + +tm-binding gdl:tm-binding isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(tm-construct, 0, 1); + has-role(hidden-value, 0, 1); + role-combination(tm-construct, tmcl:topic-name-constraint, descriptor, Unit); + role-combination(tm-construct, tmcl:variant-name-constraint, descriptor, Unit); + role-combination(tm-construct, tmcl:topic-occurrence-constraint, descriptor, Unit); + role-combination(tm-construct, tmcl:topic-type, descriptor, TM-Value); + role-combination(value-group, Value-Group, tm-construct, Datatype); + role-combination(value-group, Value-Group, tm-construct, Type); + role-combination(value-group, Value-Group, tm-construct, Variant-Name-Scope); + role-combination(value-group, Value-Group, tm-construct, Variant-Name-Reifier); + role-combination(value-group, Value-Group, tm-construct, Variant-Name-Identifiers); + role-combination(value-group, Value-Group, tm-construct, Role-Player); + role-combination(hidden-value, Hidden-Value, tm-construct, Datatype); + role-combination(hidden-value, Hidden-Value, tm-construct, Type); + role-combination(hidden-value, Hidden-Value, tm-construct, Variant-Name-Scope); + role-combination(hidden-value, Hidden-Value, tm-construct, Variant-Name-Reifier); + role-combination(hidden-value, Hidden-Value, tm-construct, Variant-Name-Identifiers); + role-combination(hidden-value, Hidden-Value, tm-construct, Role-Player) + role-combination(descriptor, Role-Player, tm-construct, tmcl:item-identifier-constraint); + role-combination(descriptor, Role-Player, tm-construct, tmcl:reifier-constraint); + role-combination(descriptor, Role-Player, tm-construct, tmcl:topic-role-constraint); + role-combination(descriptor, Variant-Name-Identifiers, tm-construct, tmcl:variant-name-constraint); + role-combination(descriptor, Datatype, tm-construct, tmcl:topic-occurrence-constraint); + role-combination(descriptor, Datatype, tm-construct, tmcl:variant-name-constraint); + role-combination(descriptor, Type, tm-construct, tmcl:topic-name-constraint); + role-combination(descriptor, Type, tm-construct, tmcl:association-role-constraint); + role-combination(descriptor, Type, tm-construct, tmcl:topic-role-constraint); + role-combination(descriptor, Type, tm-construct, tmcl:topic-occurrence-constraint); + role-combination(descriptor, Variant-Name-Scope, tm-construct, tmcl:variant-name-constraint); + role-combination(descriptor, Variant-Name-Reifier, tm-construct, tmcl:variant-name-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:subject-identifier-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:subject-locator-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:item-identifier-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:topic-name-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:reifier-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:variant-name-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:topic-occurrence-constraint); + role-combination(value-group, Value-Group, tm-construct, tmcl:scope-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:subject-identifier-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:subject-locator-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:item-identifier-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:topic-name-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:reifier-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:variant-name-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:topic-occurrence-constraint); + role-combination(hidden-value, Value-Group, tm-construct, tmcl:scope-constraint). + +topic-view-binding gdl:topic-view-binding isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(tm-value, 1, 1); + role-combination(tm-value, TM-Value, descriptor, Topic-View). + + +display-by gdl:display-by isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(tm-construct, 1, 1); + role-combination(descriptor, TM-Value, tm-construct, tmcl:topic-name-constraint); + role-combination(descriptor, TM-Value, tm-construct, tmcl:item-identifier-constraint); + role-combination(descriptor, TM-Value, tm-construct, tmcl:subject-locator-constraint); + role-combination(descriptor, TM-Value, tm-construct, tmcl:subject-identifier-constraint); + role-combination(descriptor, Value-Group, tm-construct, tmcl:topic-name-constraint); + role-combination(descriptor, Value-Group, tm-construct, tmcl:item-identifier-constraint); + role-combination(descriptor, Value-Group, tm-construct, tmcl:subject-locator-constraint); + role-combination(descriptor, Value-Group, tm-construct, tmcl:subject-identifier-constraint). + + +association-view-binding gdl:association-view-binding isa tmcl:association-type; + has-role(descriptor, 1, 1); + has-role(tm-construct, 1, 1); + role-combination(descriptor, Association-View, tm-construct, tmcl:topic-role-constraint); + role-combination(descriptor, Association-View, tm-construct, tmcl:association-role-constraint). + +preferred-scope gdl:preferred-scope isa tmcl:association-type; + has-role(tm-construct, 1, 1); + has-role(descriptor, 1, 1); + role-combination(tm-construct, tmcl:topic-type, descriptor, Value-Group); + role-combination(tm-construct, tmcl:topic-type, descriptor, TM-Value). + +value-binding gdl:value-binding isa tmcl:association-type; + has-role(hidden-value, 1, 1); + has-role(value, 1, 1); + role-combination(value, Default-Value, hidden-value, Hidden-Value); + role-combination(value, Value, value-group, Value-Group). + + +# Role types +container gdl:container isa tmcl:role-type. +containee gdl:containee isa tmcl:role-type. +descriptor gdl:descriptor isa tmcl:role-type. +ancestor gdl:ancestor isa tmcl:role-type. +descendant gdl:descendant isa tmcl:role-type. +button-position gdl:action-button isa tmcl:role-type. +nth-element gdl:nth-element isa tmcl:role-type. +value-group gdl:value-group isa tmcl:role-type. +tm-construct gdl:tm-construct isa tmcl:role-type. +tm-value gdl:tm-value isa tmcl:role-type. + + +# The schema itself +schema-name gdl:schema-name isa tmcl:name-type. + +Schema gdlt:Schema isa tmcl:topic-type; + has-name(schema-name, 1, 1); + plays-role(container, contains, 0, *). + + +# The abstract base topic type of all GDL topics +Descriptor gdlt:Descriptor isa tmcl:topic-type; + is-abstract(). + + +# The abstract base topic type of all visible elements modeled by GDL topics +display gdl:display isa tmcl:occurrence-type. +id gdl:id isa tmcl:occurrence-type. +margin gdl:margin isa tmcl:occurrence-type. +margin-left gdl:margin-left isa tmcl:occurrence-type. +margin-top gdl:margin-top isa tmcl:occurrence-type. +margin-right gdl:margin-right isa tmcl:occurrence-type. +margin-bottom gdl:margin-bottom isa tmcl:occurrence-type. +border-color gdl:border-color isa tmcl:occurrence-type. +border-left-color gdl:border-left-color isa tmcl:occurrence-type. +border-top-color gdl:border-top-color isa tmcl:occurrence-type. +border-right-color gdl:border-right-color isa tmcl:occurrence-type. +border-bottom-color gdl:border-bottom-color isa tmcl:occurrence-type. +border-style gdl:border-style isa tmcl:occurrence-type. +border-left-style gdl:border-left-style isa tmcl:occurrence-type. +border-top-style gdl:border-top-style isa tmcl:occurrence-type. +border-right-style gdl:border-right-style isa tmcl:occurrence-type. +border-bottom-style gdl:border-bottom-style isa tmcl:occurrence-type. +border-width gdl:border-width isa tmcl:occurrence-type. +border-left-width gdl:border-left-width isa tmcl:occurrence-type. +border-top-width gdl:border-top-width isa tmcl:occurrence-type. +border-right-width gdl:border-right-width isa tmcl:occurrence-type. +border-bottom-width gdl:border-bottom-width isa tmcl:occurrence-type. +border-radius gdl:border-radius isa tmcl:occurrence-type. +border-bottom-left-radius gdl:border-bottom-left-radius isa tmcl:occurrence-type. +border-top-left-radius gdl:border-top-left-radius isa tmcl:occurrence-type. +border-top-right-radius gdl:border-top-right-radius isa tmcl:occurrence-type. +border-bottom-right-radius gdl:border-bottom-right-radius isa tmcl:occurrence-type. +padding gdl:padding isa tmcl:occurrence-type. +padding-left gdl:padding-left isa tmcl:occurrence-type. +padding-top gdl:padding-top isa tmcl:occurrence-type. +padding-right gdl:padding-right isa tmcl:occurrence-type. +padding-bottom gdl:padding-bottom isa tmcl:occurrence-type. +cursor gdl:cursor isa tmcl:occurrence-type. +z-index gdl:z-index isa tmcl:occurrence-type. +width gdl:width isa tmcl:occurrence-type. +min-width gdl:min-width isa tmcl:occurrence-type. +max-width gdl:max-width isa tmcl:occurrence-type. +height gdl:height isa tmcl:occurrence-type. +min-height gdl:min-height isa tmcl:occurrence-type. +max-height gdl:max-height isa tmcl:occurrence-type. +float gdl:float isa tmcl:occurrence-type. +clear gdl:clear isa tmcl:occurrence-type. +content-orientation gdl:content-orientation isa tmcl:occurrence-type. +background-color gdl:background-color isa tmcl:occurrence-type. +vertical-align gdl:vertical-align isa tmcl:occurrence-type. + +VisibleObject gdlt:VisibleObject ako Descriptor; + isa tmcl:topic-type; + is-abstract(); + has-occurrence(id, 1, 1); + has-occurrence(display, 0, 1); + has-occurrence(margin, 0, 1); + has-occurrence(margin-left, 0, 1); + has-occurrence(margin-top, 0, 1); + has-occurrence(margin-right, 0, 1); + has-occurrence(margin-bottom, 0, 1); + has-occurrence(border-color, 0, 1); + has-occurrence(border-left-color, 0, 1); + has-occurrence(border-top-color, 0, 1); + has-occurrence(border-right-color, 0, 1); + has-occurrence(border-bottom-color, 0, 1); + has-occurrence(border-style, 0, 1); + has-occurrence(border-left-style, 0, 1); + has-occurrence(border-top-style, 0, 1); + has-occurrence(border-right-style, 0, 1); + has-occurrence(border-bottom-style, 0, 1); + has-occurrence(border-width, 0, 1); + has-occurrence(border-left-width, 0, 1); + has-occurrence(border-top-width, 0, 1); + has-occurrence(border-right-width, 0, 1); + has-occurrence(border-bottom-width, 0, 1); + has-occurrence(border-radius, 0, 1); + has-occurrence(border-bottom-left-radius, 0, 1); + has-occurrence(border-top-left-radius, 0, 1); + has-occurrence(border-top-right-radius, 0, 1); + has-occurrence(border-bottom-right-radius, 0, 1); + has-occurrence(padding, 0, 1); + has-occurrence(padding-left, 0, 1); + has-occurrence(padding-top, 0, 1); + has-occurrence(padding-right, 0, 1); + has-occurrence(padding-bottom, 0, 1); + has-occurrence(cursor, 0, 1); + has-occurrence(z-index, 0, 1); + has-occurrence(width, 0, 1); + has-occurrence(min-width, 0, 1); + has-occurrence(max-width, 0, 1); + has-occurrence(height, 0, 1); + has-occurrence(min-height, 0, 1); + has-occurrence(max-height, 0, 1); + has-occurrence(float, 0, 1); + has-occurrence(clear, 0, 1); + has-occurrence(content-orientation, 0, 1); + has-occurrence(background-color, 0, 1); + has-occurrence(vertical-align, 0, 1); + plays-role(containee, contains, 1, *); + plays-role(descendant, position, 0, 1); + plays-role(ancestor, position, 0, 1); + plays-role(container, contains, 0, *). + + +# The abstract base topic type of all textual elements modeled by GDL topics +direction gdl::direction isa tmcl:occurrence-type. +text-align gdl:text-align isa tmcl:occurrence-type. +line-height gdl:line-height isa tmcl:occurrence-type. +text-decoration gdl:text-decoration isa tmcl:occurrence-type. +color gdl:color isa tmcl:occurrence-type. +font-family gdl:font-family isa tmcl:occurrence-type. +font-style gdl:font-style isa tmcl:occurrence-type. +font-size gdl:font-size isa tmcl:occurrence-type. +font-weight gdl:font-weight isa tmcl:occurrence-type. +letter-spacing gdl:letter-spacing isa tmcl:occurrence-type. +word-spacing gdl:word-spacing isa tmcl:occurrence-type. + +TextObject gdlt:TextObject ako VisibleObject; + isa tmcl:topic-type; + is-abstract(); + has-occurrence(direction, 0, 1); + has-occurrence(text-align, 0, 1); + has-occurrence(line-height, 0, 1); + has-occurrence(text-decoration, 0, 1); + has-occurrence(color, 0, 1); + has-occurrence(font-family, 0, 1); + has-occurrence(font-style, 0, 1); + has-occurrence(font-size, 0, 1); + has-occurrence(font-weight, 0, 1); + has-occurrence(letter-spacing, 0, 1); + has-occurrence(word-spacing, 0, 1). + + +# The entire complex-data concept +Complex-Data gdlt:Complex-Data ako VisibleObject; + isa tmcl:topic-type; + is-abstract(); + plays-role(descriptor, view-binding, 1, 1). + +Image gdlt:Image ako Complex-Data; + isa tmcl:topic-type. + +Video gdl:Video ako Complex-Data; + isa tmcl:topic-type. + +Audio gdlt:Audio ako Complex-Data; + isa tmcl:topic-type. + +Time-Picker gdlt:Time-Picker ako Complex-Data; + isa tmcl:topic-type. + +Date-Picker gdlt:Date-Picker ako Complex-Data; + isa tmcl:topic-type. + +Date-Time-Picker gdlt:Date-Time-Picker ako Complex-Data; + isa tmcl:topic-type. + + +# The abstract base topic type of all buttons modeled by GDL topics +Button gdlt:Button ako TextObject; + isa tmcl:topic-type; + is-abstract(). + + +# The input-button concept +Input-Button gdlt:Input-Button ako Button; + isa tmcl:topic-type; + is-abstract(); + plays-role(descriptor, view-binding, 1, 1). + +Radio-Button gdlt:Radio-Button ako Input-Button; + isa tmcl:topic-type. + +Check-Box gdlt:Check-Box ako Input-Button; + isa tmcl:topic-type. + + +# The entire action-button concept +Action-Button gdlt:Action-Button ako Button; + isa tmcl:topic-type; + plays-role(action-button, button-position, 0, 1); + plays-role(containee, contains, 0, 1); + plays-role(descriptor, view-binding, 0, 1). + +Validate-Button gdlt:Validate-Button ako Action-Button; + isa tmcl:topic-type. + +Commit-Button gdlt:Commit-Button ako Action-Button; + isa tmcl:topic-type. + +Delete-Button gdlt:Delete-Button ako Action-Button; + isa tmcl:topic-type. + + +# The entire schema concept +view-name gdl:view-name isa tmcl:name-type. + +View gdlt:View ako Visible-Object; + isa tmcl:topic-type; + is-abstract(); + has-name(view-name, 1, 1); + plays-role(containee, contains, 1, 1); + plays-role(container, contains, 0, *). + +Topic-View gdlt:Topic-View ako View; + isa tmcl:topic-type; + is-abstract(); + plays-role(descriptor, topic-view-binding, 1, 1). + +Default-Topic-View gdlt:Default-Topic-View ako Topic-View; + isa tmcl:topic-type; + is-abstract(). + +Default-Creator-Topic-View gdlt:Default-Creator-Topic-View ako Default-Topic-View; + isa tmcl:topic-type. + +Default-Editor-Topic-View gdlt::Default-Editor-Topic-View ako Default-Topic-View; + isa tmcl:topic-type. + +Special-Topic-View gdlt:Special-Topic-View ako Topic-View; + isa tmcl:topic-type; + is-abstract(). + +Special-Creator-Topic-View gdlt:Special-Creator-Topic-View ako Special-Topic-View; + isa tmcl:topic-type. + +Special-Editor-Topic-View gdlt:Special-Editor-Topic-View ako Special-Editor-Topic-View; + isa tmcl:topic-type; + +Association-View gdlt:Association-View ako View; + isa tmcl:topic-type; + is-abstract(); + plays-role(descriptor, association-view-binding, 2, 2). + +Creator-Association-view gdlt:Creator-Association-View ako Association-View; + isa tmcl:topic-type. + +Editor-Association-view gdlt:Editor-Association-View ako Association-View; + isa tmcl:topic-type; + +# The entire value concept +Value gdlt:Value ako Descriptor; + isa tmcl:topic-type; + is-abstract(); + plays-role(value, value-binding, 0, 1). + +fixed gdl:fixed isa tmcl:occurrence-type. + +Default-Value gdlt:Default-Value ako Value; + isa tmcl:topic-type; + is-abstract(); + has-occurrence(fixed, 0, 1); + plays-role(value, value-binding, 0, 1). + +literal-value gdl:literal-value isa tmcl:occurrence-type. + +Literal-Value gdlt:Literal-Value ako Value; + isa tmcl:topic-type; + has-occurrence(literal-value, 1, 1). + +Default-Literal-Value gdlt:Default-Literal-Value ako Default-Value; + ako Literal-Value; + isa tmcl:topic-type. + +TM-Value gdlt:TM-Value ako Value; + isa tmcl:topic-type; + is-abstract(); + plays-role(tm-value, topic-view-binding, 0, *); + plays-role(descriptor, display-by, 0, 1); + plays-role(descriptor, tm-binding, 1, 1); + plays-role(descriptor, preferred-scope, 0, 1). + +TM-Type-Value gdlt:TM-Type-Value ako TM-Value; + isa tmcl:topic-type. + +TM-Single-Type-Value gdlt:Single-Type-Value ako TM-Value; + isa tmcl:topic-type. + +TM-Multiple-Type-Value gdlt::TM-Multiple-Type-Value ako TM-Value; + isa tmcl:topic-type. + +TM-Instance-Value gdlt:TM-Instance-Value ako TM-Value; + isa tmcl:topic-type. + +Default-TM-Value gdlt:Default-TM-Value ako Default-Value; + ako TM-Value; + isa tmcl:topic-type; + is-abstract(). + +Default-TM-Value-Type gdlt:Default-TM-Value-Type ako Default-Value; + isa tmcl:topic-type. + +Default-TM-Single-Type-Value gdlt:Default-TM-Single-Type-Value ako Default-Value; + isa tmcl:topic-type. + +Default-TM-Multiple-Type-Value gdlt:Default-TM-Multiple-Type-Value ako Default-Value; + isa tmcl:topic-type. + +Default-TM-Instance-Value gdlt:Default-TM-Instance-Value ako Default-Value; + isa tmcl:topic-type. + +Value-Group gdlt:Value-Group ako Descriptor; + isa tmcl:topic-type; + plays-role(value-group, view-binding, 1, 1); + plays-role(descriptor, preferred-scope, 0, 1); + plays-role(value-group, value-binding, 0, *); + plays-role(value-group, tm-binding, 0, 1); + plays-role(descriptor, display-by, 0, 1). + +Hidden-Value gdlt:Hidden-Value ako Descriptor; + isa tmcl:topic-type; + plays-role(containee, contains, 1, 1); + plays-role(hidden-value, value-binding, 1, 1); + plays-role(hidden-value, tm-binding, 1, 1). + + +# Additional ?constraint-like? topics defined by the GDL +Datatype gdlt:Datatype ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 0, 1). + +Type gdlt:Type ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 0, 1). + +Variant-Name-Scope gdlt:Variant-Name-Scope ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 1, 1). + +Variant-Name-Reifier gdlt:Variant-Name-Reifier ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 1, 1). + +Variant-Name-Identifiers gdlt:Variant-Name-Identifiers ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 1, 1). + +Role-Player gdlt:Role-Player ako Descriptor; + isa tmcl:topic-type; + plays-role(tm-construct, tm-binding, 1, 1); + plays-role(descriptor, tm-binding, 1, 2). + + +# The style-class concept along with the defined style-classes +Style-Class gdlt:Style-Class isa tmcl:topic-type. + +hover isa gdlt:Style-Class. + +focus isa gdlt:Style-Class. + +active isa gdlt:Style-Class. + + +# The positioning and referencing (nth-element) concept +position-style gdl:position-style isa tmcl:occurrence-type. +top gdl:top isa tmcl:occurrence-type. +right gdl:right isa tmcl:occurrence-type. +bottom gdl:bottom isa tmcl:occurrence-type. +left gdl:left isa tmcl:occurrence-type. + +Position gdlt:Position isa tmcl:topic-type; + isa tmcl:topic-type; + has-occurrence(position-style, 0, 1); + has-occurrence(top, 0, 1); + has-occurrence(right, 0, 1); + has-occurrence(bottom, 0, 1); + has-occurrence(left, 0, 1); + plays-role(descriptor, position, 1, 1). + +nth-value gdl:nth-value isa tmcl:occurrence-type. + +Nth-Element gdlt:Nth-Element isa Descriptor; + isa tmcl:topic-type; + has-occurrence(nth-value, 1, 1); + plays-role(nth-element, contains, 1, 1); + plays-role(nth-element, button-position, 1, 1). + + +# All topics that are not abstract and are direct sub-classes of Visible-Object +Space gdlt:Space ako Visible-Object; + isa tmcl:topic-type. + +ordered gdl:ordered isa tmcl:occurrence-type. +style-type gdl::style-type isa tmcl:occurrence-type. +list-style-position gdl:list-style-position isa tmcl:occurrence-type. + +List gdlt:List ako Visible-Object; + isa tmcl:topic-type; + has-occurrence(ordered, 0, 1); + has-occurrence(style-type, 0, 1); + has-occurrence(list-style-position, 0, 1); + plays-role(container, contains, 0, *). + + +# All topics that are not abstract and are direct sub-classes of Text-Object +multiple gdl:multiple isa tmcl:occurrence-type. +Size gdl:size isa tmcl:occurrence-type. + +List-Box gdlt:List-Box ako Text-Object; + isa tmcl:topic-type; + has-occurrence(multiple, 0, 1); + has-occurrence(size, 0, 1); + plays-role(descriptor, view-binding, 1, 1). + +unit-name gdl:unit-name isa tmcl:occurrence-type. + +Unit gdlt:Unit ako Text-Object; + isa tmcl:topic-type; + has-occurrence(unit-name, 0, 1); + plays-role(container, contains, 0, *); + plays-role(descriptor, tm-binding, 0, 1). + +Text gdlt:Text ako Text-Object; + isa tmcl:topic-type; + has-occurrence(text-type, 0, 1); + has-occurrence(readonly, 0, 1); + has-occurrence(rows, 0, 1); + has-occurrence(cols, 0, 1); + has-occurrence(resize, 0, 1); + plays-role(descriptor, view-binding, 1, 1). + +Info gdlt:Info ako Text-Object; + isa tmcl:topic-type; + plays-role(descriptor, view-binding, 1, 1); + plays-role(containee, constains, 1, 1). + +Reference gdlt:Reference ako Text-Object; + isa tmcl:topic-type; + plays-role(descriptor, view-binding, 1, 1). + +title-order gdl:title-order isa tmcl:occurrence-type. + +Title gdlt:Title ako Text-Object; + isa tmcl:topic-type; + has-occurrence(title-order, 0, 1) ; + plays-role(descriptor, view-binding, 1, 1). + + +# All extensions for the TMCL constraints that enable the adoption to the GDL +tmcl:topic-name-constraint plays-role(tm-construct, tm-binding, 0, *); + plays-role(tm-construct, display-by, 0, 1). +tmcl:variant-name-constraint plays-role(tm-construct, tm-binding, 0, *); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:topic-occurrence-constraint plays-role(tm-construct, tm-binding, 0, *). +tmcl:topic-role-constraint plays-role(tm-construct, association-view-binding, 0, *); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:association-role-constraint plays-role(tm-construct, association-view-binding, 0, *); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:topic-type plays-role(tm-construct, tm-binding, 0, *); + plays-role(tm-construct, preferred-scope, 0, *). +tmcl:subject-idenitifier-constraint plays-role(tm-construct, display-by, 0, 1); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:subject-locator-constraint plays-role(tm-construct, display-by, 0, 1); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:item-idenitifier-constraint plays-role(tm-construct, display-by, 0, 1); + plays-role(tm-construct, tm-binding, 0, *). +tmcl:reifier-constraint plays-role(tm-construct, tm-binding, 0, *). From lgiessmann at common-lisp.net Tue Nov 22 14:56:18 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Tue, 22 Nov 2011 06:56:18 -0800 Subject: [isidorus-cvs] r1034 - in trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: . base view Message-ID: Author: lgiessmann Date: Tue Nov 22 06:56:14 2011 New Revision: 1034 Log: gdl-frontend: Widgets: refactoring of GdlVisibleObject => implemented the class GdlVisbleObjectCssService for getting the css properties defined via the GDL Added: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectCssService.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Thu Nov 17 01:54:38 2011 (r1033) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Tue Nov 22 06:56:14 2011 (r1034) @@ -1,7 +1,10 @@ +* test GdlCechkBox +* test GdlRadioButton + * implement export of Fragments, e.g. exportJTM11Fragment(ArrayList topics, ArrayList associaitions), e.i. the passed topics and associations must be exported with all characteristics and associations, and all referenced topics must be exported as stubs -* finalise GdltopicView.getContent() +* finalise GdlTopicView.getContent() * finalise GdlPanel.doValidate() * finalise GdlCheckBox * finalise GdlCommitButton Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Thu Nov 17 01:54:38 2011 (r1033) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Tue Nov 22 06:56:14 2011 (r1034) @@ -80,6 +80,7 @@ protected Panel containerPanel = null; protected Topic tmRepresentative = null; protected TopicMap tm = null; + protected GdlVisibleObjectCssService cssService = null; protected ArrayList> activeCssNamesAndStyles = new ArrayList>(); protected ArrayList> focusCssNamesAndStyles = new ArrayList>(); protected ArrayList> hoverCssNamesAndStyles = new ArrayList>(); @@ -132,6 +133,8 @@ if(!(receivedData instanceof Topic) && !(receivedData instanceof Association) && !(receivedData instanceof Name) && !(receivedData instanceof Variant) && !(receivedData instanceof Occurrence) && !(receivedData instanceof Role) && receivedData != null) throw new ExecutionException("receivedData must be either a Topic, Association, Topic-Name, Name-Variant, Topic-Occurrence or Association-Role, but is: " + receivedData.getClass()); this.receivedData = receivedData; + this.cssService = new GdlVisibleObjectCssService(this); + this.setId(this.getId()); this.setGdlStyle(); } @@ -223,67 +226,27 @@ } - // a helper method that returns all occurrences of the type bound to the passed PSI - @SuppressWarnings("unchecked") - protected JsArray getOccurrences(String occurrenceType){ - Topic occType = tm.getTopicBySubjectIdentifier(tm.createLocator(occurrenceType)); - if(occType == null) return (JsArray)JsArray.createArray(); - else return tmRepresentative.getOccurrences(occType); - } - // a helper method that returns one occurrence of the type bound to the passed PSI. // If more than one occurrence is available an InvalidGdlSchemaException is thrown. // If nor occurrence is available the return value is null protected Occurrence getNoneOrOneUnscopedOccurrence(String occurrenceType) throws InvalidGdlSchemaException{ - JsArray occs = getOccurrences(occurrenceType); - ArrayList unscopedOccs = new ArrayList(); - for(int i = 0; i != occs.length(); ++i){ - if(occs.get(i).getScope().length() == 0) unscopedOccs.add(occs.get(i)); - } - - if(unscopedOccs.size() > 1){ - throw new InvalidGdlSchemaException("The topic " + TmHelper.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 { - return null; - } + return TmHelper.getNoneOrOneUnscopedOccurrence(this.tmRepresentative, occurrenceType); } // a helper method that returns one occurrence of the type bound to the passed PSI and scoped // by the theme bound to the passed PSI. If no such occurrence exist, the default value is null protected Occurrence getNoneOrOneScopedOccurrence(String occurrenceType, String theme) throws InvalidGdlSchemaException{ - Topic themeTopic = tm.getTopicBySubjectIdentifier(tm.createLocator(theme)); - if(themeTopic == null){ - return null; - } else { - JsArray occurrences = getOccurrences(occurrenceType); - ArrayList matchedOccurrences = new ArrayList(); - for(int i = 0; i != occurrences.length(); ++i){ - for(int j = 0; j != occurrences.get(i).getScope().length(); ++j){ - if(occurrences.get(i).getScope().get(j).equals(themeTopic)){ - matchedOccurrences.add(occurrences.get(i)); - break; - } - } - } - - if(matchedOccurrences.size() > 1){ - throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + "must be bound to none or one occurrence of the type " + occurrenceType + " and the scope " + theme + " but is bound " + matchedOccurrences.size() + " times to it"); - } else if(matchedOccurrences.size() == 1){ - return matchedOccurrences.get(0); - } else { - return null; - } - } + return TmHelper.getNoneOrOneScopedOccurrence(this.tmRepresentative, occurrenceType, theme); } // returns the string value of a gdl:id occurrence public String getId() throws InvalidGdlSchemaException { - JsArray idOccs = getOccurrences(PSIs.GDL.OccurrenceType.gdlId); + TopicMap tm = this.tmRepresentative.getTopicMap(); + Topic idOccType = TmHelper.getTopicByPsi(PSIs.GDL.OccurrenceType.gdlId, tm); + JsArray idOccs = this.tmRepresentative.getOccurrences(idOccType); if(idOccs.length() != 1){ throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to exactly one occurrence of the type " + PSIs.GDL.OccurrenceType.gdlId + ", but is bound " + idOccs.length() + " times to it"); } else { @@ -295,92 +258,35 @@ // returns a Display instance of a gdl:display occurrence. // If no gdl:display occurrence is set, the default value is returned public Display getDisplay() throws InvalidGdlSchemaException { - Occurrence displayOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlDisplay); - - if(displayOcc != null){ - String value = displayOcc.getValue().toLowerCase(); - if(value.equals("none")){ - return Display.NONE; - } else if (value.equals("inline")){ - return Display.INLINE; - } else if (value.equals("inline-block")){ - return Display.INLINE_BLOCK; - } else if(value.equals("block")){ - return Display.BLOCK; - } else { - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlDisplay + " must be set to one of \"none\", \"inline\", \"inline-block\" or \"block\", but is \"" + displayOcc.getValue() + "\""); - } - } else { - return Display.INLINE_BLOCK; - } + return this.cssService.getDisplay(); } // returns an AutoNumValue instance of a gdl:z-index occurrence. // If no gdl:z-index occurrence is set, the default value is returned public AutoNumValue getZindex() throws InvalidGdlSchemaException { - Occurrence zOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlZindex); - if(zOcc != null){ - return new AutoNumValue(zOcc.getValue()); - } else { - return new AutoNumValue(); - } + return this.cssService.getZindex(); } // returns a Float instance of a gdl:float occurrence or the default value for // this property if no gdl:float occurrence is available public Float getFloat() throws InvalidGdlSchemaException { - Occurrence floatOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlFloat); - - if(floatOcc != null){ - String value = floatOcc.getValue().toLowerCase(); - if(value.equals("none")){ - return Float.NONE; - } else if (value.equals("left")){ - return Float.LEFT; - } else if (value.equals("right")){ - return Float.RIGHT; - } else { - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlFloat + " must be set to one of \"none\", \"left\" or \"right\", but is \"" + floatOcc.getValue() + "\""); - } - } else { - return Float.NONE; - } + return this.cssService.getFloat(); } // returns a ClearValue instance of a gdl:clear occurrence or the default value for // this property if no gdl:clear occurrence is available public ClearValue getClear() throws InvalidGdlSchemaException { - Occurrence clearOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlClear); - - if(clearOcc != null){ - try{ - return ClearValue.valueOf(clearOcc.getValue().toUpperCase()); - }catch(IllegalArgumentException e){ - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlClear + " must be set to one of \"none\", \"left\", \"right\" or \"both\", but is \"" + clearOcc.getValue() + "\""); - } - } else { - return ClearValue.NONE; - } + return this.cssService.getClear(); } // returns a ContentOrientationValue instance of a gdl:content-orientation occurrence or the default value for // this property if no gdl:content-orientation occurrence is available public ContentOrientationValue getContentOrientation() throws InvalidGdlSchemaException { - Occurrence orientationOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlContentOrientation); - - if(orientationOcc != null){ - try{ - return ContentOrientationValue.valueOf(orientationOcc.getValue().toUpperCase()); - }catch(IllegalArgumentException e){ - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlContentOrientation + " must be set to one of \"horizontal\" or \"vertical\", but is \"" + orientationOcc.getValue() + "\""); - } - } else { - return ContentOrientationValue.VERTICAL; - } + return this.cssService.getContentOrientation(); } @@ -389,39 +295,7 @@ // is available. The styleClass attribute is used as scope for expressing // a css pseudo-class, if styleClass is null the occurrence must be unscoped public VerticalAlign getVerticalAlign(String styleClass) throws InvalidGdlSchemaException { - Occurrence vaOcc = null; - if(styleClass != null){ - vaOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlVerticalAlign, styleClass); - } else { - vaOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlVerticalAlign); - } - - if(vaOcc == null && styleClass != null){ - return null; - } else if(vaOcc == null) { - return VerticalAlign.BASELINE; - }else { - String value = vaOcc.getValue().toLowerCase(); - if(value.equals("baseline")){ - return VerticalAlign.BASELINE; - } else if(value.equals("sub")){ - return VerticalAlign.SUB; - } else if(value.equals("super")) { - return VerticalAlign.SUPER; - } else if(value.equals("top")) { - return VerticalAlign.TOP; - }else if(value.equals("text-top")) { - return VerticalAlign.TEXT_TOP; - }else if(value.equals("middle")) { - return VerticalAlign.MIDDLE; - }else if(value.equals("bottom")) { - return VerticalAlign.BOTTOM; - }else if(value.equals("text-bottom")) { - return VerticalAlign.TEXT_BOTTOM; - } else { - throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlVerticalAlign + " must be set to one of \"baseline\", \"sub\", \"super\", \"top\", \"text-top\", \"middle\", \"bottom\" or \"text-bottom\", but is \"" + vaOcc.getValue() + "\""); - } - } + return this.cssService.getVerticalAlign(styleClass); } @@ -430,20 +304,7 @@ // or null. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public NumUnitValue getMargin(String styleClass) throws InvalidGdlSchemaException { - Occurrence marginOcc = null; - if(styleClass != null){ - marginOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMargin, styleClass); - } else { - marginOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMargin); - } - - if(marginOcc == null && styleClass != null){ - return null; - } else if(marginOcc == null) { - return new NumUnitValue(); - } else { - return new NumUnitValue(marginOcc.getValue()); - } + return this.cssService.getMargin(styleClass); } @@ -451,18 +312,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // or null. public NumUnitValue getMarginTop(String styleClass) throws InvalidGdlSchemaException { - Occurrence marginOcc = null; - if(styleClass != null){ - marginOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginTop, styleClass); - } else { - marginOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginTop); - } - - if(marginOcc == null){ - return null; - } else { - return new NumUnitValue(marginOcc.getValue()); - } + return this.cssService.getMarginTop(styleClass); } @@ -470,18 +320,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // or null. public NumUnitValue getMarginRight(String styleClass) throws InvalidGdlSchemaException { - Occurrence marginOcc = null; - if(styleClass != null){ - marginOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginRight, styleClass); - } else { - marginOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginRight); - } - - if(marginOcc == null){ - return null; - } else { - return new NumUnitValue(marginOcc.getValue()); - } + return this.cssService.getMarginRight(styleClass); } @@ -489,18 +328,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // or null. public NumUnitValue getMarginBottom(String styleClass) throws InvalidGdlSchemaException { - Occurrence marginOcc = null; - if(styleClass != null){ - marginOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginBottom, styleClass); - } else { - marginOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginBottom); - } - - if(marginOcc == null){ - return null; - } else { - return new NumUnitValue(marginOcc.getValue()); - } + return this.cssService.getMarginBottom(styleClass); } @@ -508,18 +336,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // or null. public NumUnitValue getMarginLeft(String styleClass) throws InvalidGdlSchemaException { - Occurrence marginOcc = null; - if(styleClass != null){ - marginOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginLeft, styleClass); - } else { - marginOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMarginLeft); - } - - if(marginOcc == null){ - return null; - } else { - return new NumUnitValue(marginOcc.getValue()); - } + return this.cssService.getMarginLeft(styleClass); } @@ -528,20 +345,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public ColorValue getBorderColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderColor); - } - - if(colorOcc == null && styleClass != null){ - return null; - } else if(colorOcc == null) { - return new ColorValue(); - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBorderColor(styleClass); } @@ -549,18 +353,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public ColorValue getBorderTopColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopColor); - } - - if(colorOcc == null ){ - return null; - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBorderTopColor(styleClass); } @@ -568,18 +361,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public ColorValue getBorderRightColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightColor); - } - - if(colorOcc == null ){ - return null; - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBorderRightColor(styleClass); } @@ -587,18 +369,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public ColorValue getBorderBottomColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomColor); - } - - if(colorOcc == null ){ - return null; - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBorderBottomColor(styleClass); } @@ -606,18 +377,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public ColorValue getBorderLeftColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftColor); - } - - if(colorOcc == null ){ - return null; - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBorderLeftColor(styleClass); } @@ -626,25 +386,7 @@ // 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(PSIs.GDL.OccurrenceType.gdlBorderStyle, styleClass); - } else { - styleOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderStyle); - } - - if(styleOcc == null && styleClass != null){ - return null; - } else if(styleOcc == null) { - return BorderStyleValue.NONE; - } 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()); - } - } + return this.cssService.getBorderStyle(styleClass); } @@ -652,23 +394,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public BorderStyleValue getBorderTopStyle(String styleClass) throws InvalidGdlSchemaException { - Occurrence styleOcc = null; - if(styleClass != null){ - styleOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopStyle, styleClass); - } else { - styleOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopStyle); - } - - if(styleOcc == null){ - return null; - } 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-top-style must be set to one of " + values + ", but is " + styleOcc.getValue()); - } - } + return this.cssService.getBorderTopStyle(styleClass); } @@ -676,23 +402,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public BorderStyleValue getBorderRightStyle(String styleClass) throws InvalidGdlSchemaException { - Occurrence styleOcc = null; - if(styleClass != null){ - styleOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightStyle, styleClass); - } else { - styleOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightStyle); - } - - if(styleOcc == null){ - return null; - } 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-right-style must be set to one of " + values + ", but is " + styleOcc.getValue()); - } - } + return this.cssService.getBorderRightStyle(styleClass); } @@ -700,23 +410,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public BorderStyleValue getBorderBottomStyle(String styleClass) throws InvalidGdlSchemaException { - Occurrence styleOcc = null; - if(styleClass != null){ - styleOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomStyle, styleClass); - } else { - styleOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomStyle); - } - - if(styleOcc == null){ - return null; - } 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-bottom-style must be set to one of " + values + ", but is " + styleOcc.getValue()); - } - } + return this.cssService.getBorderBottomStyle(styleClass); } @@ -724,23 +418,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public BorderStyleValue getBorderLeftStyle(String styleClass) throws InvalidGdlSchemaException { - Occurrence styleOcc = null; - if(styleClass != null){ - styleOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftStyle, styleClass); - } else { - styleOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftStyle); - } - - if(styleOcc == null){ - return null; - } 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-left-style must be set to one of " + values + ", but is " + styleOcc.getValue()); - } - } + return this.cssService.getBorderLeftStyle(styleClass); } @@ -749,20 +427,7 @@ // 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(PSIs.GDL.OccurrenceType.gdlBorderWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderWidth); - } - - if(widthOcc == null && styleClass != null){ - return null; - } else if(widthOcc == null) { - return new AbsoluteNumValue(); - } else { - return new AbsoluteNumValue(widthOcc.getValue()); - } + return this.cssService.getBorderWidth(styleClass); } @@ -770,18 +435,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public AbsoluteNumValue getBorderTopWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopWidth); - } - - if(widthOcc == null){ - return null; - } else { - return new AbsoluteNumValue(widthOcc.getValue()); - } + return this.cssService.getBorderTopWidth(styleClass); } @@ -789,18 +443,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public AbsoluteNumValue getBorderRightWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRightWidth); - } - - if(widthOcc == null){ - return null; - } else { - return new AbsoluteNumValue(widthOcc.getValue()); - } + return this.cssService.getBorderRightWidth(styleClass); } @@ -808,18 +451,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public AbsoluteNumValue getBorderBottomWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomWidth); - } - - if(widthOcc == null){ - return null; - } else { - return new AbsoluteNumValue(widthOcc.getValue()); - } + return this.cssService.getBorderBottomWidth(styleClass); } @@ -827,18 +459,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public AbsoluteNumValue getBorderLeftWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderLeftWidth); - } - - if(widthOcc == null){ - return null; - } else { - return new AbsoluteNumValue(widthOcc.getValue()); - } + return this.cssService.getBorderLeftWidth(styleClass); } @@ -847,20 +468,7 @@ // 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(PSIs.GDL.OccurrenceType.gdlBorderRadius, styleClass); - } else { - radiusOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderRadius); - } - - if(radiusOcc == null && styleClass != null){ - return null; - } else if(radiusOcc == null) { - return new NumUnitValue(); - } else { - return new NumUnitValue(radiusOcc.getValue()); - } + return this.cssService.getBorderRadius(styleClass); } @@ -868,20 +476,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getBorderTopLeftRadius(String styleClass) throws InvalidGdlSchemaException { - Occurrence radiusOcc = null; - if(styleClass != null){ - radiusOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopLeftRadius, styleClass); - } else { - radiusOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopLeftRadius); - } - - if(radiusOcc == null && styleClass != null){ - return null; - } else if(radiusOcc == null){ - return null; - } else { - return new NumUnitValue(radiusOcc.getValue()); - } + return this.cssService.getBorderTopLeftRadius(styleClass); } @@ -889,20 +484,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getBorderTopRightRadius(String styleClass) throws InvalidGdlSchemaException { - Occurrence radiusOcc = null; - if(styleClass != null){ - radiusOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopRightRadius, styleClass); - } else { - radiusOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderTopRightRadius); - } - - if(radiusOcc == null && styleClass != null){ - return null; - } else if(radiusOcc == null){ - return null; - } else { - return new NumUnitValue(radiusOcc.getValue()); - } + return this.cssService.getBorderTopRightRadius(styleClass); } @@ -910,20 +492,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getBorderBottomLeftRadius(String styleClass) throws InvalidGdlSchemaException { - Occurrence radiusOcc = null; - if(styleClass != null){ - radiusOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomLeftRadius, styleClass); - } else { - radiusOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomLeftRadius); - } - - if(radiusOcc == null && styleClass != null){ - return null; - } else if(radiusOcc == null){ - return null; - } else { - return new NumUnitValue(radiusOcc.getValue()); - } + return this.cssService.getBorderBottomLeftRadius(styleClass); } @@ -931,20 +500,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getBorderBottomRightRadius(String styleClass) throws InvalidGdlSchemaException { - Occurrence radiusOcc = null; - if(styleClass != null){ - radiusOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomRightRadius, styleClass); - } else { - radiusOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBorderBottomRightRadius); - } - - if(radiusOcc == null && styleClass != null){ - return null; - } else if(radiusOcc == null){ - return null; - } else { - return new NumUnitValue(radiusOcc.getValue()); - } + return this.cssService.getBorderBottomRightRadius(styleClass); } @@ -953,20 +509,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public NumUnitValue getPadding(String styleClass) throws InvalidGdlSchemaException { - Occurrence paddingOcc = null; - if(styleClass != null){ - paddingOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlPadding, styleClass); - } else { - paddingOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlPadding); - } - - if(paddingOcc == null && styleClass != null){ - return null; - } else if(paddingOcc == null) { - return new NumUnitValue(); - } else { - return new NumUnitValue(paddingOcc.getValue()); - } + return this.cssService.getPadding(styleClass); } @@ -974,18 +517,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getPaddingTop(String styleClass) throws InvalidGdlSchemaException { - Occurrence paddingOcc = null; - if(styleClass != null){ - paddingOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingTop, styleClass); - } else { - paddingOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingTop); - } - - if(paddingOcc == null){ - return null; - } else { - return new NumUnitValue(paddingOcc.getValue()); - } + return this.cssService.getPaddingTop(styleClass); } @@ -993,18 +525,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getPaddingRight(String styleClass) throws InvalidGdlSchemaException { - Occurrence paddingOcc = null; - if(styleClass != null){ - paddingOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingRight, styleClass); - } else { - paddingOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingRight); - } - - if(paddingOcc == null){ - return null; - } else { - return new NumUnitValue(paddingOcc.getValue()); - } + return this.cssService.getPaddingRight(styleClass); } @@ -1012,18 +533,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getPaddingBottom(String styleClass) throws InvalidGdlSchemaException { - Occurrence paddingOcc = null; - if(styleClass != null){ - paddingOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingBottom, styleClass); - } else { - paddingOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingBottom); - } - - if(paddingOcc == null){ - return null; - } else { - return new NumUnitValue(paddingOcc.getValue()); - } + return this.cssService.getPaddingBottom(styleClass); } @@ -1031,18 +541,7 @@ // If a styleClass is set, only the corresponding value of the scoped occurrence is returned // null, null otherwise. public NumUnitValue getPaddingLeft(String styleClass) throws InvalidGdlSchemaException { - Occurrence paddingOcc = null; - if(styleClass != null){ - paddingOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingLeft, styleClass); - } else { - paddingOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlPaddingLeft); - } - - if(paddingOcc == null){ - return null; - } else { - return new NumUnitValue(paddingOcc.getValue()); - } + return this.cssService.getPaddingLeft(styleClass); } @@ -1051,20 +550,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlWidth); - } - - if(widthOcc == null && styleClass != null){ - return null; - } else if(widthOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(widthOcc.getValue()); - } + return this.cssService.getWidth(styleClass); } @@ -1073,20 +559,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getMinWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMinWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMinWidth); - } - - if(widthOcc == null && styleClass != null){ - return null; - } else if(widthOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(widthOcc.getValue()); - } + return this.cssService.getMinWidth(styleClass); } @@ -1095,20 +568,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getMaxWidth(String styleClass) throws InvalidGdlSchemaException { - Occurrence widthOcc = null; - if(styleClass != null){ - widthOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMaxWidth, styleClass); - } else { - widthOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMaxWidth); - } - - if(widthOcc == null && styleClass != null){ - return null; - } else if(widthOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(widthOcc.getValue()); - } + return this.cssService.getMaxWidth(styleClass); } @@ -1117,20 +577,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getHeight(String styleClass) throws InvalidGdlSchemaException { - Occurrence heightOcc = null; - if(styleClass != null){ - heightOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlHeight, styleClass); - } else { - heightOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlHeight); - } - - if(heightOcc == null && styleClass != null){ - return null; - } else if(heightOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(heightOcc.getValue()); - } + return this.cssService.getHeight(styleClass); } @@ -1139,20 +586,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getMinHeight(String styleClass) throws InvalidGdlSchemaException { - Occurrence heightOcc = null; - if(styleClass != null){ - heightOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMinHeight, styleClass); - } else { - heightOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMinHeight); - } - - if(heightOcc == null && styleClass != null){ - return null; - } else if(heightOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(heightOcc.getValue()); - } + return this.cssService.getMinHeight(styleClass); } @@ -1161,20 +595,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public AutoNumUnitValue getMaxHeight(String styleClass) throws InvalidGdlSchemaException { - Occurrence heightOcc = null; - if(styleClass != null){ - heightOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlMaxHeight, styleClass); - } else { - heightOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlMaxHeight); - } - - if(heightOcc == null && styleClass != null){ - return null; - } else if(heightOcc == null) { - return new AutoNumUnitValue(); - } else { - return new AutoNumUnitValue(heightOcc.getValue()); - } + return this.cssService.getMaxHeight(styleClass); } @@ -1183,27 +604,7 @@ // 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(PSIs.GDL.OccurrenceType.gdlCursor, styleClass); - } else { - cursorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlCursor); - } - - if(cursorOcc == null && styleClass != null){ - return null; - } else if(cursorOcc == null) { - return CursorValue.AUTO; - } 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()); - } - } + return this.cssService.getCursor(styleClass); } @@ -1212,20 +613,7 @@ // null, null otherwise. If the styleClass is null and no occurrence was found, the default value for this // property is returned. public ColorValue getBackgroundColor(String styleClass) throws InvalidGdlSchemaException { - Occurrence colorOcc = null; - if(styleClass != null){ - colorOcc = getNoneOrOneScopedOccurrence(PSIs.GDL.OccurrenceType.gdlBackgroundColor, styleClass); - } else { - colorOcc = getNoneOrOneUnscopedOccurrence(PSIs.GDL.OccurrenceType.gdlBackgroundColor); - } - - if(colorOcc == null && styleClass != null){ - return null; - } else if(colorOcc == null) { - return new ColorValue("#ffffff"); - } else { - return new ColorValue(colorOcc.getValue()); - } + return this.cssService.getBackgroundColor(styleClass); } @@ -1389,6 +777,7 @@ if(value != null) this.setCssProperty(widget, styleClass, "borderTopWidth", value.getCssValue()); } + // sets the border-width style property of this element by using the GWT DOM class at Override public void setBorderRightWidth(Widget widget, AbsoluteNumValue value, String styleClass) throws InvalidGdlSchemaException, ExecutionException { if(value != null) this.setCssProperty(widget, styleClass, "borderRightWidth", value.getCssValue()); Added: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectCssService.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectCssService.java Tue Nov 22 06:56:14 2011 (r1034) @@ -0,0 +1,968 @@ +package us.isidor.gdl.anaToMia.Widgets.base; + +import com.google.gwt.dom.client.Style.Display; +import com.google.gwt.dom.client.Style.Float; +import com.google.gwt.dom.client.Style.VerticalAlign; + +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; +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.AutoNumUnitValue; +import us.isidor.gdl.anaToMia.Widgets.value.AutoNumValue; +import us.isidor.gdl.anaToMia.Widgets.value.BorderStyleValue; +import us.isidor.gdl.anaToMia.Widgets.value.ClearValue; +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; + +public class GdlVisibleObjectCssService { + private GdlVisibleObject owner = null; + + @SuppressWarnings("unused") + private GdlVisibleObjectCssService() {} + + + public GdlVisibleObjectCssService(GdlVisibleObject owner) throws ExecutionException{ + if(owner == null) throw new ExecutionException("owner must not be null"); + this.owner = owner; + } + + + // returns a Display instance of a gdl:display occurrence. + // If no gdl:display occurrence is set, the default value is returned + public Display getDisplay() throws InvalidGdlSchemaException { + Occurrence displayOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlDisplay); + + if(displayOcc != null){ + String value = displayOcc.getValue().toLowerCase(); + if(value.equals("none")){ + return Display.NONE; + } else if (value.equals("inline")){ + return Display.INLINE; + } else if (value.equals("inline-block")){ + return Display.INLINE_BLOCK; + } else if(value.equals("block")){ + return Display.BLOCK; + } else { + throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlDisplay + " must be set to one of \"none\", \"inline\", \"inline-block\" or \"block\", but is \"" + displayOcc.getValue() + "\""); + } + } else { + return Display.INLINE_BLOCK; + } + } + + + // returns an AutoNumValue instance of a gdl:z-index occurrence. + // If no gdl:z-index occurrence is set, the default value is returned + public AutoNumValue getZindex() throws InvalidGdlSchemaException { + Occurrence zOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlZindex); + if(zOcc != null){ + return new AutoNumValue(zOcc.getValue()); + } else { + return new AutoNumValue(); + } + } + + + // returns a Float instance of a gdl:float occurrence or the default value for + // this property if no gdl:float occurrence is available + public Float getFloat() throws InvalidGdlSchemaException { + Occurrence floatOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlFloat); + + if(floatOcc != null){ + String value = floatOcc.getValue().toLowerCase(); + if(value.equals("none")){ + return Float.NONE; + } else if (value.equals("left")){ + return Float.LEFT; + } else if (value.equals("right")){ + return Float.RIGHT; + } else { + throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlFloat + " must be set to one of \"none\", \"left\" or \"right\", but is \"" + floatOcc.getValue() + "\""); + } + } else { + return Float.NONE; + } + } + + + // returns a ClearValue instance of a gdl:clear occurrence or the default value for + // this property if no gdl:clear occurrence is available + public ClearValue getClear() throws InvalidGdlSchemaException { + Occurrence clearOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlClear); + + if(clearOcc != null){ + try{ + return ClearValue.valueOf(clearOcc.getValue().toUpperCase()); + }catch(IllegalArgumentException e){ + throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlClear + " must be set to one of \"none\", \"left\", \"right\" or \"both\", but is \"" + clearOcc.getValue() + "\""); + } + } else { + return ClearValue.NONE; + } + } + + + // returns a ContentOrientationValue instance of a gdl:content-orientation occurrence or the default value for + // this property if no gdl:content-orientation occurrence is available + public ContentOrientationValue getContentOrientation() throws InvalidGdlSchemaException { + Occurrence orientationOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlContentOrientation); + + if(orientationOcc != null){ + try{ + return ContentOrientationValue.valueOf(orientationOcc.getValue().toUpperCase()); + }catch(IllegalArgumentException e){ + throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlContentOrientation + " must be set to one of \"horizontal\" or \"vertical\", but is \"" + orientationOcc.getValue() + "\""); + } + } else { + return ContentOrientationValue.VERTICAL; + } + } + + + // returns a VerticalAlign instance of a gdl:vertical-align occurrence + // or the default value for this property if no gdl:vertical-align occurrence + // is available. The styleClass attribute is used as scope for expressing + // a css pseudo-class, if styleClass is null the occurrence must be unscoped + public VerticalAlign getVerticalAlign(String styleClass) throws InvalidGdlSchemaException { + Occurrence vaOcc = null; + if(styleClass != null){ + vaOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlVerticalAlign, styleClass); + } else { + vaOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlVerticalAlign); + } + + if(vaOcc == null && styleClass != null){ + return null; + } else if(vaOcc == null) { + return VerticalAlign.BASELINE; + }else { + String value = vaOcc.getValue().toLowerCase(); + if(value.equals("baseline")){ + return VerticalAlign.BASELINE; + } else if(value.equals("sub")){ + return VerticalAlign.SUB; + } else if(value.equals("super")) { + return VerticalAlign.SUPER; + } else if(value.equals("top")) { + return VerticalAlign.TOP; + }else if(value.equals("text-top")) { + return VerticalAlign.TEXT_TOP; + }else if(value.equals("middle")) { + return VerticalAlign.MIDDLE; + }else if(value.equals("bottom")) { + return VerticalAlign.BOTTOM; + }else if(value.equals("text-bottom")) { + return VerticalAlign.TEXT_BOTTOM; + } else { + throw new InvalidGdlSchemaException("The occurrence " + PSIs.GDL.OccurrenceType.gdlVerticalAlign + " must be set to one of \"baseline\", \"sub\", \"super\", \"top\", \"text-top\", \"middle\", \"bottom\" or \"text-bottom\", but is \"" + vaOcc.getValue() + "\""); + } + } + } + + + // returns a NumUnitValue instance that represents the margin of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. If the styleClass is null and no occurrence was found, the default value for this + // property is returned. + public NumUnitValue getMargin(String styleClass) throws InvalidGdlSchemaException { + Occurrence marginOcc = null; + if(styleClass != null){ + marginOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMargin, styleClass); + } else { + marginOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMargin); + } + + if(marginOcc == null && styleClass != null){ + return null; + } else if(marginOcc == null) { + return new NumUnitValue(); + } else { + return new NumUnitValue(marginOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the margin-top of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. + public NumUnitValue getMarginTop(String styleClass) throws InvalidGdlSchemaException { + Occurrence marginOcc = null; + if(styleClass != null){ + marginOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginTop, styleClass); + } else { + marginOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginTop); + } + + if(marginOcc == null){ + return null; + } else { + return new NumUnitValue(marginOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the margin-right of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. + public NumUnitValue getMarginRight(String styleClass) throws InvalidGdlSchemaException { + Occurrence marginOcc = null; + if(styleClass != null){ + marginOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginRight, styleClass); + } else { + marginOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginRight); + } + + if(marginOcc == null){ + return null; + } else { + return new NumUnitValue(marginOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the margin-bottom of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. + public NumUnitValue getMarginBottom(String styleClass) throws InvalidGdlSchemaException { + Occurrence marginOcc = null; + if(styleClass != null){ + marginOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginBottom, styleClass); + } else { + marginOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginBottom); + } + + if(marginOcc == null){ + return null; + } else { + return new NumUnitValue(marginOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the margin-left of this element. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // or null. + public NumUnitValue getMarginLeft(String styleClass) throws InvalidGdlSchemaException { + Occurrence marginOcc = null; + if(styleClass != null){ + marginOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginLeft, styleClass); + } else { + marginOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMarginLeft); + } + + if(marginOcc == null){ + return null; + } else { + return new NumUnitValue(marginOcc.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. + public ColorValue getBorderColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderColor); + } + + if(colorOcc == null && styleClass != null){ + return null; + } else if(colorOcc == null) { + return new ColorValue(); + } else { + return new ColorValue(colorOcc.getValue()); + } + } + + + // returns a ColorValue instance that represents the color of this element's border-top. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public ColorValue getBorderTopColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopColor); + } + + if(colorOcc == null ){ + return null; + } else { + return new ColorValue(colorOcc.getValue()); + } + } + + + // returns a ColorValue instance that represents the color of this element's border-right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public ColorValue getBorderRightColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightColor); + } + + if(colorOcc == null ){ + return null; + } else { + return new ColorValue(colorOcc.getValue()); + } + } + + + // returns a ColorValue instance that represents the color of this element's border-bottom. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public ColorValue getBorderBottomColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomColor); + } + + if(colorOcc == null ){ + return null; + } else { + return new ColorValue(colorOcc.getValue()); + } + } + + + // returns a ColorValue instance that represents the color of this element's border-left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public ColorValue getBorderLeftColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftColor); + } + + if(colorOcc == null ){ + return null; + } 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 = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderStyle, styleClass); + } else { + styleOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderStyle); + } + + if(styleOcc == null && styleClass != null){ + return null; + } else if(styleOcc == null) { + return BorderStyleValue.NONE; + } 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 ColorValue instance that represents the style of this element's border-top. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public BorderStyleValue getBorderTopStyle(String styleClass) throws InvalidGdlSchemaException { + Occurrence styleOcc = null; + if(styleClass != null){ + styleOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopStyle, styleClass); + } else { + styleOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopStyle); + } + + if(styleOcc == null){ + return null; + } 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-top-style must be set to one of " + values + ", but is " + styleOcc.getValue()); + } + } + } + + + // returns a ColorValue instance that represents the style of this element's border-right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public BorderStyleValue getBorderRightStyle(String styleClass) throws InvalidGdlSchemaException { + Occurrence styleOcc = null; + if(styleClass != null){ + styleOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightStyle, styleClass); + } else { + styleOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightStyle); + } + + if(styleOcc == null){ + return null; + } 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-right-style must be set to one of " + values + ", but is " + styleOcc.getValue()); + } + } + } + + + // returns a ColorValue instance that represents the style of this element's border-bottom. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public BorderStyleValue getBorderBottomStyle(String styleClass) throws InvalidGdlSchemaException { + Occurrence styleOcc = null; + if(styleClass != null){ + styleOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomStyle, styleClass); + } else { + styleOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomStyle); + } + + if(styleOcc == null){ + return null; + } 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-bottom-style must be set to one of " + values + ", but is " + styleOcc.getValue()); + } + } + } + + + // returns a ColorValue instance that represents the style of this element's border-left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public BorderStyleValue getBorderLeftStyle(String styleClass) throws InvalidGdlSchemaException { + Occurrence styleOcc = null; + if(styleClass != null){ + styleOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftStyle, styleClass); + } else { + styleOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftStyle); + } + + if(styleOcc == null){ + return null; + } 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-left-style must be set to one of " + values + ", but is " + styleOcc.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 = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderWidth); + } + + if(widthOcc == null && styleClass != null){ + return null; + } else if(widthOcc == null) { + return new AbsoluteNumValue(); + } else { + return new AbsoluteNumValue(widthOcc.getValue()); + } + } + + + // returns a AbsoluteNumValue instance that represents the width of this element's border-top. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public AbsoluteNumValue getBorderTopWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopWidth); + } + + if(widthOcc == null){ + return null; + } else { + return new AbsoluteNumValue(widthOcc.getValue()); + } + } + + + // returns a AbsoluteNumValue instance that represents the width of this element's border-right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public AbsoluteNumValue getBorderRightWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRightWidth); + } + + if(widthOcc == null){ + return null; + } else { + return new AbsoluteNumValue(widthOcc.getValue()); + } + } + + + // returns a AbsoluteNumValue instance that represents the width of this element's border-bottom. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public AbsoluteNumValue getBorderBottomWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomWidth); + } + + if(widthOcc == null){ + return null; + } else { + return new AbsoluteNumValue(widthOcc.getValue()); + } + } + + + // returns a AbsoluteNumValue instance that represents the width of this element's border-left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public AbsoluteNumValue getBorderLeftWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderLeftWidth); + } + + if(widthOcc == null){ + return null; + } else { + return new AbsoluteNumValue(widthOcc.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 = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRadius, styleClass); + } else { + radiusOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null) { + return new NumUnitValue(); + } else { + return new NumUnitValue(radiusOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the radius of this element's border-top-left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getBorderTopLeftRadius(String styleClass) throws InvalidGdlSchemaException { + Occurrence radiusOcc = null; + if(styleClass != null){ + radiusOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopLeftRadius, styleClass); + } else { + radiusOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopLeftRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null){ + return null; + } else { + return new NumUnitValue(radiusOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the radius of this element's border-top-right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getBorderTopRightRadius(String styleClass) throws InvalidGdlSchemaException { + Occurrence radiusOcc = null; + if(styleClass != null){ + radiusOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopRightRadius, styleClass); + } else { + radiusOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderTopRightRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null){ + return null; + } else { + return new NumUnitValue(radiusOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the radius of this element's border-bottom-left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getBorderBottomLeftRadius(String styleClass) throws InvalidGdlSchemaException { + Occurrence radiusOcc = null; + if(styleClass != null){ + radiusOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomLeftRadius, styleClass); + } else { + radiusOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomLeftRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null){ + return null; + } else { + return new NumUnitValue(radiusOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the radius of this element's border-bottom-right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getBorderBottomRightRadius(String styleClass) throws InvalidGdlSchemaException { + Occurrence radiusOcc = null; + if(styleClass != null){ + radiusOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomRightRadius, styleClass); + } else { + radiusOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBorderBottomRightRadius); + } + + if(radiusOcc == null && styleClass != null){ + return null; + } else if(radiusOcc == null){ + return null; + } else { + return new NumUnitValue(radiusOcc.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. + public NumUnitValue getPadding(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPadding, styleClass); + } else { + paddingOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPadding); + } + + if(paddingOcc == null && styleClass != null){ + return null; + } else if(paddingOcc == null) { + return new NumUnitValue(); + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the padding of this element's top. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getPaddingTop(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingTop, styleClass); + } else { + paddingOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingTop); + } + + if(paddingOcc == null){ + return null; + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the padding of this element's right. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getPaddingRight(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingRight, styleClass); + } else { + paddingOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingRight); + } + + if(paddingOcc == null){ + return null; + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the padding of this element's bottom. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getPaddingBottom(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingBottom, styleClass); + } else { + paddingOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingBottom); + } + + if(paddingOcc == null){ + return null; + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns a NumUnitValue instance that represents the padding of this element's left. + // If a styleClass is set, only the corresponding value of the scoped occurrence is returned + // null, null otherwise. + public NumUnitValue getPaddingLeft(String styleClass) throws InvalidGdlSchemaException { + Occurrence paddingOcc = null; + if(styleClass != null){ + paddingOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingLeft, styleClass); + } else { + paddingOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlPaddingLeft); + } + + if(paddingOcc == null){ + return null; + } else { + return new NumUnitValue(paddingOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the width 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 AutoNumUnitValue getWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlWidth); + } + + if(widthOcc == null && styleClass != null){ + return null; + } else if(widthOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(widthOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the min-width 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 AutoNumUnitValue getMinWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMinWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMinWidth); + } + + if(widthOcc == null && styleClass != null){ + return null; + } else if(widthOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(widthOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the max-width 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 AutoNumUnitValue getMaxWidth(String styleClass) throws InvalidGdlSchemaException { + Occurrence widthOcc = null; + if(styleClass != null){ + widthOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMaxWidth, styleClass); + } else { + widthOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMaxWidth); + } + + if(widthOcc == null && styleClass != null){ + return null; + } else if(widthOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(widthOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the height 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 AutoNumUnitValue getHeight(String styleClass) throws InvalidGdlSchemaException { + Occurrence heightOcc = null; + if(styleClass != null){ + heightOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlHeight, styleClass); + } else { + heightOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlHeight); + } + + if(heightOcc == null && styleClass != null){ + return null; + } else if(heightOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(heightOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the min-height 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 AutoNumUnitValue getMinHeight(String styleClass) throws InvalidGdlSchemaException { + Occurrence heightOcc = null; + if(styleClass != null){ + heightOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMinHeight, styleClass); + } else { + heightOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMinHeight); + } + + if(heightOcc == null && styleClass != null){ + return null; + } else if(heightOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(heightOcc.getValue()); + } + } + + + // returns an AutoNumUnitValue instance that represents the max-height 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 AutoNumUnitValue getMaxHeight(String styleClass) throws InvalidGdlSchemaException { + Occurrence heightOcc = null; + if(styleClass != null){ + heightOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMaxHeight, styleClass); + } else { + heightOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlMaxHeight); + } + + if(heightOcc == null && styleClass != null){ + return null; + } else if(heightOcc == null) { + return new AutoNumUnitValue(); + } else { + return new AutoNumUnitValue(heightOcc.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 = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlCursor, styleClass); + } else { + cursorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlCursor); + } + + if(cursorOcc == null && styleClass != null){ + return null; + } else if(cursorOcc == null) { + return CursorValue.AUTO; + } 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 ColorValue instance that represents the background-color 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 ColorValue getBackgroundColor(String styleClass) throws InvalidGdlSchemaException { + Occurrence colorOcc = null; + if(styleClass != null){ + colorOcc = TmHelper.getNoneOrOneScopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBackgroundColor, styleClass); + } else { + colorOcc = TmHelper.getNoneOrOneUnscopedOccurrence(this.owner.getTmRepresentative(), PSIs.GDL.OccurrenceType.gdlBackgroundColor); + } + + if(colorOcc == null && styleClass != null){ + return null; + } else if(colorOcc == null) { + return new ColorValue("#ffffff"); + } else { + return new ColorValue(colorOcc.getValue()); + } + } +} Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Thu Nov 17 01:54:38 2011 (r1033) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Tue Nov 22 06:56:14 2011 (r1034) @@ -35,6 +35,67 @@ } + // a helper method that returns one occurrence of the type bound to the passed PSI and scoped + // by the theme bound to the passed PSI. If no such occurrence exist, the default value is null + public static Occurrence getNoneOrOneScopedOccurrence(Topic owner, String occurrenceType, String theme) throws InvalidGdlSchemaException{ + if(owner == null || occurrenceType == null) return null; + + TopicMap tm = owner.getTopicMap(); + + Topic themeTopic = tm.getTopicBySubjectIdentifier(tm.createLocator(theme)); + Topic occType = tm.getTopicBySubjectIdentifier(tm.createLocator(occurrenceType)); + if(themeTopic == null || occType == null){ + return null; + } else { + JsArray occurrences = owner.getOccurrences(occType); + ArrayList matchedOccurrences = new ArrayList(); + for(int i = 0; i != occurrences.length(); ++i){ + for(int j = 0; j != occurrences.get(i).getScope().length(); ++j){ + if(occurrences.get(i).getScope().get(j).equals(themeTopic)){ + matchedOccurrences.add(occurrences.get(i)); + break; + } + } + } + + if(matchedOccurrences.size() > 1){ + throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(owner) + "must be bound to none or one occurrence of the type " + occurrenceType + " and the scope " + theme + " but is bound " + matchedOccurrences.size() + " times to it"); + } else if(matchedOccurrences.size() == 1){ + return matchedOccurrences.get(0); + } else { + return null; + } + } + } + + + // a helper method that returns one occurrence of the type bound to the passed PSI. + // If more than one occurrence is available an InvalidGdlSchemaException is thrown. + // If nor occurrence is available the return value is null + public static Occurrence getNoneOrOneUnscopedOccurrence(Topic owner, String occurrenceType) throws InvalidGdlSchemaException{ + if(owner == null || occurrenceType == null) return null; + + TopicMap tm = owner.getTopicMap(); + + Topic occType = tm.getTopicBySubjectIdentifier(tm.createLocator(occurrenceType)); + if(occType == null) return null; + + JsArray occs = owner.getOccurrences(occType); + ArrayList unscopedOccs = new ArrayList(); + for(int i = 0; i != occs.length(); ++i){ + if(occs.get(i).getScope().length() == 0) unscopedOccs.add(occs.get(i)); + } + + if(unscopedOccs.size() > 1){ + throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(owner) + " 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 { + return null; + } + } + + // a helper that returns the topic bound to the identifier via a subject locator public static Topic getTopicBySl(String subjectLocator, TopicMap tm){ if(subjectLocator == null || tm == null) return null; Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Thu Nov 17 01:54:38 2011 (r1033) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Nov 22 06:56:14 2011 (r1034) @@ -10,6 +10,7 @@ import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.GdlHiddenValue; @@ -304,12 +305,7 @@ // returns the string value of a gdl:id occurrence public String getId() throws InvalidGdlSchemaException { - JsArray idOccs = getOccurrences(PSIs.GDL.OccurrenceType.gdlId); - if(idOccs.length() != 1){ - throw new InvalidGdlSchemaException("The topic " + TmHelper.getAnyIdOfTopic(this.tmRepresentative) + " must be bound to exactly one occurrence of the type " + PSIs.GDL.OccurrenceType.gdlId + ", but is bound " + idOccs.length() + " times to it"); - } else { - return idOccs.get(0).getValue() + "__GDL_" + this.indexInParent; - } + return super.getId() + "__GDL_" + this.indexInParent; } From lgiessmann at common-lisp.net Tue Nov 22 21:11:08 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Tue, 22 Nov 2011 13:11:08 -0800 Subject: [isidorus-cvs] r1035 - in trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base view Message-ID: Author: lgiessmann Date: Tue Nov 22 13:11:07 2011 New Revision: 1035 Log: gdl-frontend: Widgets: refactoring of GdlVisibleObject => implemented the class GdlVisbleObjectTmService for processing all GDL and TMCL constraints Added: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Tue Nov 22 06:56:14 2011 (r1034) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Tue Nov 22 13:11:07 2011 (r1035) @@ -10,7 +10,6 @@ import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Reifiable; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ReifiableStub; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ScopedStub; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; @@ -76,11 +75,12 @@ public abstract class GdlVisibleObject extends Composite implements GdlDescriptor, HasClickHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasFocusHandlers, HasMouseDownHandlers, HasMouseUpHandlers, HasBlurHandlers{ private GdlVisibleObject gdlParent = null; + private GdlVisibleObjectCssService cssService = null; + private GdlVisibleObjectTmService tmService = null; protected AbsolutePanel mainPanel = new AbsolutePanel(); protected Panel containerPanel = null; protected Topic tmRepresentative = null; protected TopicMap tm = null; - protected GdlVisibleObjectCssService cssService = null; protected ArrayList> activeCssNamesAndStyles = new ArrayList>(); protected ArrayList> focusCssNamesAndStyles = new ArrayList>(); protected ArrayList> hoverCssNamesAndStyles = new ArrayList>(); @@ -89,32 +89,6 @@ protected ArrayList> actionButtonsAndPositions = null; protected ArrayList infoElements = new ArrayList(); protected Construct receivedData = null; - protected Topic valueGroupTopic = null; - protected boolean valueGroupTopicSet = false; - protected Topic constraintTopic = null; - protected boolean constraintTopicSet = false; - protected Topic rootConstraintTopic = null; - protected boolean rootConstraintTopicSet = false; - protected Topic defaultTmValueTopic = null; - protected boolean defaultTmValueTopicSet = false; - protected Topic defaultLiteralValueTopic = null; - protected boolean defaultLiteralValueTopicSet = false; - protected ArrayList tmValueTopics = new ArrayList(); - protected boolean tmValueTopicsSet = false; - protected ArrayList literalValueTopics = new ArrayList(); - protected boolean literalValueTopicsSet = false; - protected ArrayList preferredScopes = new ArrayList(); - protected boolean prefferedScopesSet = false; - protected Topic displayByConstraint = null; - protected boolean displayByConstraintSet = false; - protected ArrayList literals = new ArrayList(); - protected boolean literalsSet = false; - protected int cardMin = 0; - protected boolean cardMinSet = false; - protected int cardMax = 0; - protected boolean cardMaxSet = false; - protected ArrayList rawTmValues = new ArrayList(); - protected boolean rawTmValuesSet = false; // some constructors @@ -133,6 +107,7 @@ if(!(receivedData instanceof Topic) && !(receivedData instanceof Association) && !(receivedData instanceof Name) && !(receivedData instanceof Variant) && !(receivedData instanceof Occurrence) && !(receivedData instanceof Role) && receivedData != null) throw new ExecutionException("receivedData must be either a Topic, Association, Topic-Name, Name-Variant, Topic-Occurrence or Association-Role, but is: " + receivedData.getClass()); this.receivedData = receivedData; + this.tmService = new GdlVisibleObjectTmService(this); this.cssService = new GdlVisibleObjectCssService(this); this.setId(this.getId()); @@ -1610,118 +1585,61 @@ public int getCardMin() throws InvalidGdlSchemaException { - if(this.cardMinSet){ - return this.cardMin; - } else { - this.cardMaxSet = true; - return TmHelper.getCardMin(this.getRootConstraint()); - } + return this.tmService.getCardMin(); } public int getCardMax() throws InvalidGdlSchemaException { - if(this.cardMaxSet){ - return this.cardMax; - } else { - this.cardMaxSet = true; - return TmHelper.getCardMax(this.getRootConstraint()); - } + return this.tmService.getCardMax(); } // returns the topic instance of gdlt:Value-Group that is bound to this // visible element, or null if it is unbound public Topic getValueGroup() throws InvalidGdlSchemaException { - if(this.valueGroupTopicSet){ - return this.valueGroupTopic; - } else { - this.valueGroupTopic = TmHelper.getValueGroupOf(this.tmRepresentative); - this.valueGroupTopicSet = true; - return this.valueGroupTopic; - } + return this.tmService.getValueGroup(); } // returns the direct (first) constraint that is bound to the value-group // of this element - or null if it is unbound public Topic getConstraint() throws InvalidGdlSchemaException { - if(this.constraintTopicSet){ - return this.constraintTopic; - } else { - this.constraintTopic = TmHelper.getConstraintOfValueGroup(this.getValueGroup()); - this.constraintTopicSet = true; - return this.constraintTopic; - } + return this.tmService.getConstraint(); } // returns the root (last) constraint that is bound to the value-group // of this element - or null if it is unbound public Topic getRootConstraint() throws InvalidGdlSchemaException { - if(this.rootConstraintTopicSet){ - return this.rootConstraintTopic; - } else { - this.rootConstraintTopic = TmHelper.getRootConstraintOfValueGroup(this.getValueGroup(), this.getConstraint()); - this.rootConstraintTopicSet = true; - return this.rootConstraintTopic; - } + return this.tmService.getRootConstraint(); } // returns the topic that represents the default topic maps value of // the value-group that is bound to this element - null if it is unbound public Topic getDefaultTmValue() throws InvalidGdlSchemaException { - if(this.defaultTmValueTopicSet){ - return this.defaultTmValueTopic; - } else { - this.defaultTmValueTopic = TmHelper.getDefaultTmValue(this.getValueGroup()); - this.defaultTmValueTopicSet = true; - return this.defaultTmValueTopic; - } + return this.tmService.getDefaultTmValue(); } // returns the topic that represents the default literal value of the // value-group that is bound to this element - or null if it is unbound public Topic getDefaultLiteralValue() throws InvalidGdlSchemaException { - if(this.defaultLiteralValueTopicSet){ - return this.defaultLiteralValueTopic; - } else { - this.defaultLiteralValueTopic = TmHelper.getDefaultLiteralValue(this.getValueGroup()); - this.defaultLiteralValueTopicSet = true; - return this.defaultLiteralValueTopic; - } + return this.tmService.getDefaultLiteralValue(); } // returns the topic that represents the default value of // the value-group that is bound to this element - null if it is unbound public Topic getDefaultValue() throws InvalidGdlSchemaException { - if(this.getDefaultLiteralValue() != null && this.getDefaultTmValue() != null) throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.getValueGroup()) + " must be bound to maximal one " + PSIs.GDL.TopicType.gdlDefaultValue + ", but is: 2"); - else if(this.getDefaultLiteralValue() != null) return this.getDefaultLiteralValue(); - else return this.getDefaultTmValue(); + return this.tmService.getDefaultValue(); } // returns true if the default value is fixed // otherwise the return value is false public boolean fixedDefaultValue() throws InvalidGdlSchemaException{ - Topic defVal = this.getDefaultValue(); - - if(defVal == null) return false; - - TopicMap tm = defVal.getTopicMap(); - Occurrence fixedOcc = TmHelper.getSingleOccurrence(defVal, TmHelper.getTopicByPsi(PSIs.GDL.OccurrenceType.gdlFixed, tm)); - - if(fixedOcc != null){ - try{ - return Boolean.valueOf(fixedOcc.getValue().toLowerCase()); - }catch(Exception e){ - throw new InvalidGdlSchemaException("the occurrence of type " + PSIs.GDL.OccurrenceType.gdlFixed + " bound to the topic " + TmHelper.getAnyIdOfTopic(defVal) + " must be set to either true or false, but is: " + fixedOcc.getValue()); - } - } else { - return false; - } + return this.tmService.fixedDefaultValue(); } @@ -1729,65 +1647,41 @@ // that are valid and declared for the value-group of this element - or // an empty ArrayList public ArrayList getTmValues() throws InvalidGdlSchemaException { - if(this.tmValueTopicsSet){ - return this.tmValueTopics; - } else { - this.tmValueTopics = TmHelper.getTmValues(this.getValueGroup()); - this.tmValueTopicsSet = true; - return this.tmValueTopics; - } + return this.tmService.getTmValues(); } // returns all topics that represents literal values for this value-group - or // an empty ArrayList public ArrayList getLiteralValues() throws InvalidGdlSchemaException { - if(this.literalValueTopicsSet){ - return this.literalValueTopics; - } else { - this.literalValueTopics = TmHelper.getLiteralValues(this.getValueGroup()); - this.literalValueTopicsSet = true; - return this.literalValueTopics; - } + return this.tmService.getLiteralValues(); } // returns an ArrayList of strings that are set to a value group as literal values public ArrayList getLiterals() throws InvalidGdlSchemaException { - if(this.literalsSet){ - return this.literals; - } else { - this.literalsSet = true; - this.literals = TmHelper.getLiterals(this.getValueGroup()); - return this.literals; - } + return this.tmService.getLiterals(); } // returns the valid topic maps value for the constraint bound // to the value-group that is bound to this element - or an empty ArrayList public ArrayList getTmValuesForConstraint() throws InvalidGdlSchemaException, ExecutionException { - return TmHelper.getTmValuesForConstraint(this.getConstraint(), this.getValueGroup()); + return this.tmService.getTmValuesForConstraint(); } // returns the regular expression that is set for the constraint bound to the // value-group of this element public String getLiteralValueForConstraint() throws InvalidGdlSchemaException { - return TmHelper.getLiteralValueForConstraint(this.getConstraint()); + return this.tmService.getLiteralValueForConstraint(); } // returns the display-by schema that is defined for the value-group that // is bound to this element public Topic getDisplayByOfValueGroup() throws InvalidGdlSchemaException { - if(this.displayByConstraintSet){ - return this.displayByConstraint; - } else { - this.displayByConstraintSet = true; - this.displayByConstraint = TmHelper.getDisplayByTopicOf(this.getValueGroup()); - return this.displayByConstraint; - } + return this.tmService.getDisplayByOfValueGroup(); } @@ -1801,13 +1695,7 @@ // returns the preferred scope that is bound to the value-group of // this element - or an empty ArrayList public ArrayList getPreferredScopeOfValueGroup() throws InvalidGdlSchemaException { - if(this.prefferedScopesSet){ - return this.preferredScopes; - } else { - this.prefferedScopesSet = true; - this.preferredScopes = TmHelper.getPrefferedScopesForTopicOf(this.getValueGroup()); - return this.preferredScopes; - } + return this.tmService.getPreferredScopeOfValueGroup(); } @@ -1828,448 +1716,22 @@ // returns the strings of the control that are entered/selected // returns the strings of the control that are entered/selected public abstract ArrayList getSelectedValues(); - - - // validates names, occurrences and identifiers for the passed value - private void validateLiteralValue(String selectedValue) throws InvalidContentException, InvalidGdlSchemaException{ - if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){ - Pattern pattern = new Pattern(TmHelper.getRegExp(this.getConstraint())); - if(!pattern.matches(selectedValue)) throw new InvalidContentException("The value \"" + selectedValue + "\" does not satisfy the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " with the regular expression: " + TmHelper.getRegExp(this.getConstraint())); - } else { - ArrayList validLiteralValues = new ArrayList(); - for (String literal : this.getLiterals()) validLiteralValues.add(new Pattern(literal)); - if(validLiteralValues.size() == 0) validLiteralValues.add(new Pattern(this.getLiteralValueForConstraint())); - int i = 0; - for( ; i != validLiteralValues.size(); ++i) if(validLiteralValues.get(i).matches(selectedValue)) break; - - if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ - if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-name " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues)); - } else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ - if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-occurrence " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues)); - } - } - } - - - // validates the the tm values of a constraint - private void validateTmValue(Topic selectedPlayer) throws InvalidContentException, InvalidGdlSchemaException, ExecutionException { - if(this.getRawTmValues().size() != 0 && !this.getRawTmValues().contains(selectedPlayer)){ - throw new InvalidContentException("the topic " + TmHelper.getAnyIdOfTopic(selectedPlayer) + " does not satisfy the contraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and the topic values: " + Utils.topicArrayToString(this.getRawTmValues())); - } else { - if(!this.getTmValuesForConstraint().contains(selectedPlayer)){ - throw new InvalidContentException("the topic " + TmHelper.getAnyIdOfTopic(selectedPlayer) + " does not satisfy the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and topic values: " + Utils.topicArrayToString(this.getTmValuesForConstraint())); - } - } - } - - - // returns the actual topics that are set as possible tm-values - private ArrayList getRawTmValues() throws InvalidGdlSchemaException{ - if(this.rawTmValuesSet){ - return this.rawTmValues; - } else { - this.rawTmValuesSet = true; - ArrayList tmValues = this.getTmValues(); - for (Topic tmValue : tmValues) this.rawTmValues = Utils.union(this.rawTmValues, TmHelper.getValuesForTmValue(tmValue)); - return this.rawTmValues; - } - } - - - // returns all locators contained in the passed locators array, which match the - // passed regular expression value - private ArrayList filterLocators(String pattern, JsArray locators){ - ArrayList result = new ArrayList(); - if(locators == null || locators.length() == 0) return result; - Pattern patternObject = new Pattern(pattern == null ? ".*" : pattern); - - for(int i = 0; i != locators.length(); ++i){ - if(patternObject.matches(locators.get(i).getReference())) result.add(locators.get(i)); - } - - return result; - } - - - // handles the getContent call for subject identifiers and subject locators - private void getTopicIdentifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); - JsArray identifiers = null; - - ArrayList filteredIdentifiers = null; - boolean isPsiConstraint = false; - if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ - isPsiConstraint = true; - identifiers = carrier.getSubjectIdentifiers(); - filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); - } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ - identifiers = carrier.getSubjectLocators(); - filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); - } else { - throw new ExecutionException("Only the constraints " + PSIs.TMCL.tmclSubjectIdentifierConstraint + " and " + PSIs.TMCL.tmclSubjectLocatorConstraint + " are supported by the function getTopicIdentifierContent"); - } - - Locator changedIdentifier = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(filteredIdentifiers.size() > selectedValueIndex){ - changedIdentifier = filteredIdentifiers.get(selectedValueIndex); - if(isPsiConstraint) carrier.removeSubjectIdentifier(changedIdentifier); - else carrier.removeSubjectLocator(changedIdentifier); - } - - changedIdentifier = carrier.getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); - if(isPsiConstraint) carrier.addSubjectIdentifier(changedIdentifier); - else carrier.addSubjectLocator(changedIdentifier); - contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); - } - - - // handles the getContent call for item identifiers - private void getItemIdentifierContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(this.receivedData instanceof Reifiable) || !(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Reifiable, but is: " + receivedData.getClass()); - - // get type - Topic constrainedTopicType = TmHelper.getConstrainedTopicType(this.getConstraint()); - - int typeIdx = -1; - JsArray types = null; - if((carrier instanceof Topic)){ - types = ((Topic)carrier).getTypes(); - if(types.length() != 0){ - for(typeIdx = 0; typeIdx != types.length(); ++typeIdx) if(types.get(typeIdx).equals(constrainedTopicType)) break; - } - } - - JsArray identifiers = null; - ArrayList filteredIdentifiers = null; - if((carrier instanceof Topic) && types != null && typeIdx != types.length()){ - identifiers = ((Topic)carrier).getItemIdentifiers(); - filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); - - Locator changedIdentifier = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(filteredIdentifiers.size() > selectedValueIndex){ - changedIdentifier = filteredIdentifiers.get(selectedValueIndex); - ((Topic)carrier).removeItemIdentifier(changedIdentifier); - } - - changedIdentifier = ((Topic)carrier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); - ((Topic)carrier).addItemIdentifier(changedIdentifier); - contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); - } else { - // search for the topic type - Reifiable ref = null; - - // search for the characteristics type - if(carrier instanceof Topic){ - JsArray names = ((Topic)carrier).getNames(constrainedTopicType); - if(names.length() != 0){ - ref = names.get(0); - } else { - JsArray occs = ((Topic)carrier).getOccurrences(constrainedTopicType); - if(occs.length() != 0) ref = occs.get(0); - } - } else if(carrier instanceof Association){ - JsArray roles = ((Association)carrier).getRoles(constrainedTopicType); - if(roles.length() != 0) ref = roles.get(0); - } - if(ref == null) return; - - // search for item-identifiers of the found topic type or characteristics - identifiers = ((ReifiableStub)ref).getItemIdentifiers(); - filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); - - Locator changedIdentifier = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(filteredIdentifiers.size() > selectedValueIndex){ - changedIdentifier = filteredIdentifiers.get(selectedValueIndex); - ((ReifiableStub)carrier).removeItemIdentifier(changedIdentifier); - } - - changedIdentifier = ((ReifiableStub)carrier).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); - ((ReifiableStub)carrier).addItemIdentifier(changedIdentifier); - contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); - } - } - - - // handles the getContent call for item identifiers of variant-names - private void getVariantIdentifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); - ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); - if(possibleVariants.size() != 0){ - Variant variant = possibleVariants.get(0); - JsArray identifiers = null; - - ArrayList filteredIdentifiers = null; - - identifiers = variant.getItemIdentifiers(); - filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); - - Locator changedIdentifier = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(filteredIdentifiers.size() > selectedValueIndex){ - changedIdentifier = filteredIdentifiers.get(selectedValueIndex); - variant.removeItemIdentifier(changedIdentifier); - } - - changedIdentifier = variant.getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex)); - variant.addItemIdentifier(changedIdentifier); - contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); - } - } - // handles the getContent call for item identifiers of variant-names - private void getVariantReifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); - ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); - if(possibleVariants.size() != 0){ - Variant variant = possibleVariants.get(0); - Topic reifier = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); - - if(reifier != null && !variant.getReifier().equals(reifier)) variant.setReifier(reifier); - contents.add(new Pair(variant, TopicMapsTypes.Variant)); - } - } - - - // handles the getContent call for occurrence and name values - private void getTopicCharacteristicContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); - Topic characteristicType = TmHelper.getConstrainedStatement(this.getConstraint()); - - boolean isOccConstraint = true; - if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ - isOccConstraint = true; - } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ - isOccConstraint = false; - } else { - throw new ExecutionException("the function getTopicCharacteristicContent can operate only on constraints of the type " + PSIs.TMCL.tmclTopicOccurrenceConstraint + " or " + PSIs.TMCL.tmclTopicNameConstraint + ", but is called with " + TmHelper.getAnyIdOfTopic(this.getConstraint())); - } - - JsArray names = null; - JsArray occurrences = null; - if(isOccConstraint) occurrences = carrier.getOccurrences(characteristicType); - else names = carrier.getNames(characteristicType); - - - Construct changedConstruct = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); + // handles the getContent call for a Datatye value + private void getDatatypeContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass()); - if(isOccConstraint){ - if(occurrences.length() > selectedValueIndex){ - changedConstruct = occurrences.get(selectedValueIndex); - ((Occurrence)changedConstruct).setValue(this.getSelectedValues().get(selectedValueIndex)); - }else { - changedConstruct = carrier.createOccurrence(characteristicType, this.getSelectedValues().get(selectedValueIndex), null); - } - } else { - if(names.length() > selectedValueIndex){ - changedConstruct = names.get(selectedValueIndex); - ((Name)changedConstruct).setValue(this.getSelectedValues().get(selectedValueIndex)); - }else { - changedConstruct = carrier.createName(this.getSelectedValues().get(selectedValueIndex), characteristicType, null); - } - } - contents.add(new Pair(changedConstruct, isOccConstraint ? TopicMapsTypes.Occurrence : TopicMapsTypes.Name)); + ArrayList variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint()); + Topic occType = TmHelper.getConstrainedStatement(this.getRootConstraint()); + ArrayList occs = Utils.jsArrayToArrayList(((Topic)this.receivedData).getOccurrences(occType)); + this.tmService.getDatatypeContent(contents, validate, carrier, selectedValueIndex, variants, occs); } - // handles the getContent call for subject identifiers and subject locators private void getVariantNameContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(this.receivedData instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass()); - ArrayList variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getConstraint()); - - Variant changedVariant = null; - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(variants.size() > selectedValueIndex){ - changedVariant = variants.get(selectedValueIndex); - changedVariant.setValue(this.getSelectedValues().get(selectedValueIndex)); - }else { - Topic nameType = TmHelper.getConstrainedStatement(this.getConstraint()); - JsArray names = carrier.getNames(nameType); - Name owner = names.get(0); - Topic scope = TmHelper.getConstrainedScopeTopic(this.getConstraint()); - @SuppressWarnings("unchecked") - JsArray scopes = (JsArray) JsArray.createArray(); - scopes.push(scope); - changedVariant = owner.createVariant(this.getSelectedValues().get(selectedValueIndex), scopes); - } - contents.add(new Pair(changedVariant, TopicMapsTypes.Variant)); - } - - - // handles the getContent call for role players - private void getRolePlayerContent(ArrayList> contents, boolean validate, Association carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Association)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to an Association, but is: " + carrier.getClass()); - - if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint))throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a root constraint of the type " + PSIs.TMCL.tmclTopicRoleConstraint + ", but is: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint())); - Pair roleAndPlayerType = TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(this.getRootConstraint()); - Topic roleType = roleAndPlayerType.getFirst(); - Topic playerType = roleAndPlayerType.getSecond(); - - JsArray typedRoles = carrier.getRoles(roleType); - ArrayList roles = new ArrayList(); - for(int i = 0; i != typedRoles.length(); ++i) - if(TmHelper.isInstanceOf(typedRoles.get(i).getPlayer(), playerType)) roles.add(typedRoles.get(i)); - - Role changedRole = null; - - Topic player = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); - if(validate) this.validateTmValue(player); - if(roles.size() > selectedValueIndex){ - changedRole = roles.get(selectedValueIndex); - changedRole.setPlayer(player); - } else { - changedRole = carrier.createRole(roleType, player); - } - contents.add(new Pair(changedRole, TopicMapsTypes.Role)); - } - - - // handles the getContent call for scope topics of variant-names - private void getVariantNameScopeContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); - ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); - if(possibleVariants.size() != 0){ - Variant variant = possibleVariants.get(0); - JsArray scopes = variant.getScope(); - - if(validate) this.validateLiteralValue(this.getSelectedValues().get(selectedValueIndex)); - - if(scopes.length() > selectedValueIndex){ - Topic oldScope = scopes.get(selectedValueIndex); - Topic newScope = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); - - if(!oldScope.equals(newScope)){ - variant.removeTheme(oldScope); - variant.addTheme(newScope); - } - } - contents.add(new Pair(variant, TopicMapsTypes.Variant)); - } - } - - - // handles the getContent call for scope topics - private void getScopeContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - Topic type = TmHelper.getConstrainedStatement(this.getConstraint()); - - JsArray scopes = null; - Construct owner = null; - TopicMapsTypes ownerType = null; - if(carrier instanceof Topic){ - JsArray names = ((Topic)carrier).getNames(type); - if(names.length() != 0){ - scopes = names.get(0).getScope(); - owner = names.get(0); - ownerType = TopicMapsTypes.Name; - } - if(scopes == null){ - JsArray occs = ((Topic)carrier).getOccurrences(type); - if(occs.length() != 0){ - scopes = occs.get(0).getScope(); - owner = occs.get(0); - ownerType = TopicMapsTypes.Occurrence; - } - } - } else if(carrier instanceof Association){ - if(((Association)carrier).getType().equals(type)){ - scopes = ((Association)carrier).getScope(); - owner = carrier; - ownerType = TopicMapsTypes.Association; - } - } else { - throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + carrier.getClass()); - } - - Topic newScope = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); - Topic oldScope = null; - if(scopes.length() > selectedValueIndex){ - oldScope = scopes.get(selectedValueIndex); - if(!newScope.equals(oldScope)){ - ((ScopedStub)owner).removeTheme(oldScope); - ((ScopedStub)owner).addTheme(newScope); - } - } else { - ((ScopedStub)owner).addTheme(newScope); - } - contents.add(new Pair(owner, ownerType)); - } - - - // handles the getContent call for a reifier topic - private void getReifierContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - Topic type = TmHelper.getConstrainedStatement(this.getConstraint()); - - Construct owner = null; - TopicMapsTypes ownerType = null; - if(carrier instanceof Topic){ - JsArray names = ((Topic)carrier).getNames(type); - if(names.length() != 0){ - owner = names.get(0); - ownerType = TopicMapsTypes.Name; - } else { - JsArray occs = ((Topic)carrier).getOccurrences(type); - if(occs.length() != 0){ - owner = occs.get(0); - ownerType = TopicMapsTypes.Occurrence; - } - } - } else if(carrier instanceof Association){ - if(((Association)carrier).getType().equals(type)){ - owner = carrier; - ownerType = TopicMapsTypes.Association; - } else { - JsArray roles = ((Association)carrier).getRoles(type); - if(roles.length() != 0){ - owner = roles.get(0); - ownerType = TopicMapsTypes.Role; - } - } - } else { - throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + carrier.getClass()); - } - - Topic newReifier = TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); - if(!newReifier.equals(((ReifiableStub)owner).getReifier())) ((ReifiableStub)owner).setReifier(newReifier); - contents.add(new Pair(owner, ownerType)); - } - - - // handles the getContent call for a Datatye value - // handles the getContent call for scope topics - private void getDatatypeContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ - if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + receivedData.getClass()); - - Construct owner = null; - TopicMapsTypes ownerType = null; - if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){ - ArrayList variants = TmHelper.getVariantsForConstraint((Topic)this.receivedData, this.getRootConstraint()); - if(variants.size() != 0){ - owner = variants.get(0); - variants.get(0).setValue(variants.get(0).getValue(), variants.get(0).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex))); - ownerType = TopicMapsTypes.Variant; - } - } else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclOccurrenceConstraint)){ - Topic occType = TmHelper.getConstrainedStatement(this.getRootConstraint()); - JsArray occs = ((Topic)this.receivedData).getOccurrences(occType); - if(occs.length() != 0){ - owner = occs.get(0); - occs.get(0).setValue(occs.get(0).getValue(), occs.get(0).getTopicMap().createLocator(this.getSelectedValues().get(selectedValueIndex))); - ownerType = TopicMapsTypes.Occurrence; - } - } else { - throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + " or " + PSIs.TMCL.tmclOccurrenceConstraint + ", but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint())); - } - contents.add(new Pair(owner, ownerType)); + this.tmService.getVariantNameContent(contents, validate, carrier, selectedValueIndex, variants); } @@ -2325,33 +1787,33 @@ for (int idx = 0; idx != this.getSelectedValues().size(); ++idx){ if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){ - this.getItemIdentifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getItemIdentifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ - this.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ - this.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getTopicIdentifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ - this.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){ this.getVariantNameContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclScopeConstraint)){ - this.getScopeContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getScopeContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclReifierConstraint)){ - this.getReifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getReifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlDatatype)){ this.getDatatypeContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlType)){ this.getTypeContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameScope)){ - this.getVariantNameScopeContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getVariantNameScopeContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameReifier)){ - this.getVariantReifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getVariantReifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlVariantNameIdentifiers)){ - this.getVariantIdentifierContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getVariantIdentifierContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ - this.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); + this.tmService.getTopicCharacteristicContent(result, validate, (Topic)localCarrier, idx); } else if (TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlRolePlayer)){ - this.getRolePlayerContent(result, validate, (Association)localCarrier, idx); + this.tmService.getRolePlayerContent(result, validate, (Association)localCarrier, idx); } else { throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " is not supported"); } Added: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java Tue Nov 22 13:11:07 2011 (r1035) @@ -0,0 +1,693 @@ +package us.isidor.gdl.anaToMia.Widgets.base; + +import java.util.ArrayList; +import com.google.gwt.core.client.JsArray; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Locator; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Name; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Reifiable; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ReifiableStub; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.ScopedStub; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; +import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Variant; +import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; +import us.isidor.gdl.anaToMia.Widgets.environment.InvalidContentException; +import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; +import us.isidor.gdl.anaToMia.Widgets.environment.Pair; +import us.isidor.gdl.anaToMia.Widgets.environment.Pattern; + + +public class GdlVisibleObjectTmService { + private GdlVisibleObject owner = null; + private Topic valueGroupTopic = null; + private boolean valueGroupTopicSet = false; + private Topic tmRepresentative = null; + private Topic constraintTopic = null; + private boolean constraintTopicSet = false; + private Topic rootConstraintTopic = null; + private boolean rootConstraintTopicSet = false; + private Topic defaultTmValueTopic = null; + private boolean defaultTmValueTopicSet = false; + private Topic defaultLiteralValueTopic = null; + private boolean defaultLiteralValueTopicSet = false; + private ArrayList tmValueTopics = new ArrayList(); + private boolean tmValueTopicsSet = false; + private ArrayList literalValueTopics = new ArrayList(); + private boolean literalValueTopicsSet = false; + private ArrayList literals = new ArrayList(); + private boolean literalsSet = false; + private int cardMin = 0; + private boolean cardMinSet = false; + private int cardMax = 0; + private boolean cardMaxSet = false; + private Topic displayByConstraint = null; + private boolean displayByConstraintSet = false; + private ArrayList preferredScopes = new ArrayList(); + private boolean prefferedScopesSet = false; + private ArrayList rawTmValues = new ArrayList(); + private boolean rawTmValuesSet = false; + + + @SuppressWarnings("unused") + private GdlVisibleObjectTmService() {} + + + public GdlVisibleObjectTmService(GdlVisibleObject owner) throws ExecutionException { + if(owner == null) throw new ExecutionException("owner must not be null"); + this.owner = owner; + this.tmRepresentative = this.owner.getTmRepresentative(); + } + + + // returns the topic instance of gdlt:Value-Group that is bound to this + // visible element, or null if it is unbound + public Topic getValueGroup() throws InvalidGdlSchemaException { + if(this.valueGroupTopicSet){ + return this.valueGroupTopic; + } else { + this.valueGroupTopic = TmHelper.getValueGroupOf(this.tmRepresentative); + this.valueGroupTopicSet = true; + return this.valueGroupTopic; + } + } + + + // returns the direct (first) constraint that is bound to the value-group + // of this element - or null if it is unbound + public Topic getConstraint() throws InvalidGdlSchemaException { + if(this.constraintTopicSet){ + return this.constraintTopic; + } else { + this.constraintTopic = TmHelper.getConstraintOfValueGroup(this.getValueGroup()); + this.constraintTopicSet = true; + return this.constraintTopic; + } + } + + + // returns the root (last) constraint that is bound to the value-group + // of this element - or null if it is unbound + public Topic getRootConstraint() throws InvalidGdlSchemaException { + if(this.rootConstraintTopicSet){ + return this.rootConstraintTopic; + } else { + this.rootConstraintTopic = TmHelper.getRootConstraintOfValueGroup(this.getValueGroup(), this.getConstraint()); + this.rootConstraintTopicSet = true; + return this.rootConstraintTopic; + } + } + + + // returns the topic that represents the default topic maps value of + // the value-group that is bound to this element - null if it is unbound + public Topic getDefaultTmValue() throws InvalidGdlSchemaException { + if(this.defaultTmValueTopicSet){ + return this.defaultTmValueTopic; + } else { + this.defaultTmValueTopic = TmHelper.getDefaultTmValue(this.getValueGroup()); + this.defaultTmValueTopicSet = true; + return this.defaultTmValueTopic; + } + } + + + // returns the topic that represents the default literal value of the + // value-group that is bound to this element - or null if it is unbound + public Topic getDefaultLiteralValue() throws InvalidGdlSchemaException { + if(this.defaultLiteralValueTopicSet){ + return this.defaultLiteralValueTopic; + } else { + this.defaultLiteralValueTopic = TmHelper.getDefaultLiteralValue(this.getValueGroup()); + this.defaultLiteralValueTopicSet = true; + return this.defaultLiteralValueTopic; + } + } + + + // returns the topic that represents the default value of + // the value-group that is bound to this element - null if it is unbound + public Topic getDefaultValue() throws InvalidGdlSchemaException { + if(this.getDefaultLiteralValue() != null && this.getDefaultTmValue() != null) throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.getValueGroup()) + " must be bound to maximal one " + PSIs.GDL.TopicType.gdlDefaultValue + ", but is: 2"); + else if(this.getDefaultLiteralValue() != null) return this.getDefaultLiteralValue(); + else return this.getDefaultTmValue(); + } + + + // returns true if the default value is fixed + // otherwise the return value is false + public boolean fixedDefaultValue() throws InvalidGdlSchemaException{ + Topic defVal = this.getDefaultValue(); + + if(defVal == null) return false; + + TopicMap tm = defVal.getTopicMap(); + Occurrence fixedOcc = TmHelper.getSingleOccurrence(defVal, TmHelper.getTopicByPsi(PSIs.GDL.OccurrenceType.gdlFixed, tm)); + + if(fixedOcc != null){ + try{ + return Boolean.valueOf(fixedOcc.getValue().toLowerCase()); + }catch(Exception e){ + throw new InvalidGdlSchemaException("the occurrence of type " + PSIs.GDL.OccurrenceType.gdlFixed + " bound to the topic " + TmHelper.getAnyIdOfTopic(defVal) + " must be set to either true or false, but is: " + fixedOcc.getValue()); + } + } else { + return false; + } + } + + + // returns all topic maps values represented by topics of the type gdlt:Tm-Value + // that are valid and declared for the value-group of this element - or + // an empty ArrayList + public ArrayList getTmValues() throws InvalidGdlSchemaException { + if(this.tmValueTopicsSet){ + return this.tmValueTopics; + } else { + this.tmValueTopics = TmHelper.getTmValues(this.getValueGroup()); + this.tmValueTopicsSet = true; + return this.tmValueTopics; + } + } + + + // returns all topics that represents literal values for this value-group - or + // an empty ArrayList + public ArrayList getLiteralValues() throws InvalidGdlSchemaException { + if(this.literalValueTopicsSet){ + return this.literalValueTopics; + } else { + this.literalValueTopics = TmHelper.getLiteralValues(this.getValueGroup()); + this.literalValueTopicsSet = true; + return this.literalValueTopics; + } + } + + + // returns an ArrayList of strings that are set to a value group as literal values + public ArrayList getLiterals() throws InvalidGdlSchemaException { + if(this.literalsSet){ + return this.literals; + } else { + this.literalsSet = true; + this.literals = TmHelper.getLiterals(this.getValueGroup()); + return this.literals; + } + } + + + public int getCardMin() throws InvalidGdlSchemaException { + if(this.cardMinSet){ + return this.cardMin; + } else { + this.cardMaxSet = true; + return TmHelper.getCardMin(this.getRootConstraint()); + } + } + + + public int getCardMax() throws InvalidGdlSchemaException { + if(this.cardMaxSet){ + return this.cardMax; + } else { + this.cardMaxSet = true; + return TmHelper.getCardMax(this.getRootConstraint()); + } + } + + + // returns the valid topic maps value for the constraint bound + // to the value-group that is bound to this element - or an empty ArrayList + public ArrayList getTmValuesForConstraint() throws InvalidGdlSchemaException, ExecutionException { + return TmHelper.getTmValuesForConstraint(this.getConstraint(), this.getValueGroup()); + } + + + // returns the regular expression that is set for the constraint bound to the + // value-group of this element + public String getLiteralValueForConstraint() throws InvalidGdlSchemaException { + return TmHelper.getLiteralValueForConstraint(this.getConstraint()); + } + + + // returns the display-by schema that is defined for the value-group that + // is bound to this element + public Topic getDisplayByOfValueGroup() throws InvalidGdlSchemaException { + if(this.displayByConstraintSet){ + return this.displayByConstraint; + } else { + this.displayByConstraintSet = true; + this.displayByConstraint = TmHelper.getDisplayByTopicOf(this.getValueGroup()); + return this.displayByConstraint; + } + } + + + // returns all locators contained in the passed locators array, which match the + // passed regular expression value + public ArrayList filterLocators(String pattern, JsArray locators){ + ArrayList result = new ArrayList(); + if(locators == null || locators.length() == 0) return result; + Pattern patternObject = new Pattern(pattern == null ? ".*" : pattern); + + for(int i = 0; i != locators.length(); ++i){ + if(patternObject.matches(locators.get(i).getReference())) result.add(locators.get(i)); + } + + return result; + } + + + // returns the preferred scope that is bound to the value-group of + // this element - or an empty ArrayList + public ArrayList getPreferredScopeOfValueGroup() throws InvalidGdlSchemaException { + if(this.prefferedScopesSet){ + return this.preferredScopes; + } else { + this.prefferedScopesSet = true; + this.preferredScopes = TmHelper.getPrefferedScopesForTopicOf(this.getValueGroup()); + return this.preferredScopes; + } + } + + + // validates names, occurrences and identifiers for the passed value + public void validateLiteralValue(String selectedValue) throws InvalidContentException, InvalidGdlSchemaException{ + if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint) || TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclItemIdentifierConstraint)){ + Pattern pattern = new Pattern(TmHelper.getRegExp(this.getConstraint())); + if(!pattern.matches(selectedValue)) throw new InvalidContentException("The value \"" + selectedValue + "\" does not satisfy the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " with the regular expression: " + TmHelper.getRegExp(this.getConstraint())); + } else { + ArrayList validLiteralValues = new ArrayList(); + for (String literal : this.getLiterals()) validLiteralValues.add(new Pattern(literal)); + if(validLiteralValues.size() == 0) validLiteralValues.add(new Pattern(this.getLiteralValueForConstraint())); + int i = 0; + for( ; i != validLiteralValues.size(); ++i) if(validLiteralValues.get(i).matches(selectedValue)) break; + + if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ + if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-name " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues)); + } else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ + if(i == validLiteralValues.size()) throw new InvalidContentException("the user data " + selectedValue + " for the topic-occurrence " + TmHelper.getAnyIdOfTopic(TmHelper.getConstrainedStatement(this.getConstraint())) + " does not satisfy any of the constraints: " + Utils.arrayToString(validLiteralValues)); + } + } + } + + + // validates the the tm values of a constraint + public void validateTmValue(Topic selectedTopic) throws InvalidContentException, InvalidGdlSchemaException, ExecutionException { + if(this.getRawTmValues().size() != 0 && !this.getRawTmValues().contains(selectedTopic)){ + throw new InvalidContentException("the topic " + TmHelper.getAnyIdOfTopic(selectedTopic) + " does not satisfy the contraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and the topic values: " + Utils.topicArrayToString(this.getRawTmValues())); + } else { + if(!this.getTmValuesForConstraint().contains(selectedTopic)){ + throw new InvalidContentException("the topic " + TmHelper.getAnyIdOfTopic(selectedTopic) + " does not satisfy the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " and topic values: " + Utils.topicArrayToString(this.getTmValuesForConstraint())); + } + } + } + + + // returns the actual topics that are set as possible tm-values + public ArrayList getRawTmValues() throws InvalidGdlSchemaException{ + if(this.rawTmValuesSet){ + return this.rawTmValues; + } else { + this.rawTmValuesSet = true; + ArrayList tmValues = this.getTmValues(); + for (Topic tmValue : tmValues) this.rawTmValues = Utils.union(this.rawTmValues, TmHelper.getValuesForTmValue(tmValue)); + return this.rawTmValues; + } + } + + + // handles the getContent call for subject identifiers and subject locators + public void getTopicIdentifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); + JsArray identifiers = null; + + ArrayList filteredIdentifiers = null; + boolean isPsiConstraint = false; + if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectIdentifierConstraint)){ + isPsiConstraint = true; + identifiers = carrier.getSubjectIdentifiers(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclSubjectLocatorConstraint)){ + identifiers = carrier.getSubjectLocators(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + } else { + throw new ExecutionException("Only the constraints " + PSIs.TMCL.tmclSubjectIdentifierConstraint + " and " + PSIs.TMCL.tmclSubjectLocatorConstraint + " are supported by the function getTopicIdentifierContent"); + } + + Locator changedIdentifier = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(filteredIdentifiers.size() > selectedValueIndex){ + changedIdentifier = filteredIdentifiers.get(selectedValueIndex); + if(isPsiConstraint) carrier.removeSubjectIdentifier(changedIdentifier); + else carrier.removeSubjectLocator(changedIdentifier); + } + + changedIdentifier = carrier.getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex)); + if(isPsiConstraint) carrier.addSubjectIdentifier(changedIdentifier); + else carrier.addSubjectLocator(changedIdentifier); + contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); + } + + + // handles the getContent call for item identifiers + public void getItemIdentifierContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + // get type + Topic constrainedTopicType = TmHelper.getConstrainedTopicType(this.getConstraint()); + + int typeIdx = -1; + JsArray types = null; + if((carrier instanceof Topic)){ + types = ((Topic)carrier).getTypes(); + if(types.length() != 0){ + for(typeIdx = 0; typeIdx != types.length(); ++typeIdx) if(types.get(typeIdx).equals(constrainedTopicType)) break; + } + } + + JsArray identifiers = null; + ArrayList filteredIdentifiers = null; + if((carrier instanceof Topic) && types != null && typeIdx != types.length()){ + identifiers = ((Topic)carrier).getItemIdentifiers(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + + Locator changedIdentifier = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(filteredIdentifiers.size() > selectedValueIndex){ + changedIdentifier = filteredIdentifiers.get(selectedValueIndex); + ((Topic)carrier).removeItemIdentifier(changedIdentifier); + } + + changedIdentifier = ((Topic)carrier).getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex)); + ((Topic)carrier).addItemIdentifier(changedIdentifier); + contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); + } else { + // search for the topic type + Reifiable ref = null; + + // search for the characteristics type + if(carrier instanceof Topic){ + JsArray names = ((Topic)carrier).getNames(constrainedTopicType); + if(names.length() != 0){ + ref = names.get(0); + } else { + JsArray occs = ((Topic)carrier).getOccurrences(constrainedTopicType); + if(occs.length() != 0) ref = occs.get(0); + } + } else if(carrier instanceof Association){ + JsArray roles = ((Association)carrier).getRoles(constrainedTopicType); + if(roles.length() != 0) ref = roles.get(0); + } + if(ref == null) return; + + // search for item-identifiers of the found topic type or characteristics + identifiers = ((ReifiableStub)ref).getItemIdentifiers(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + + Locator changedIdentifier = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(filteredIdentifiers.size() > selectedValueIndex){ + changedIdentifier = filteredIdentifiers.get(selectedValueIndex); + ((ReifiableStub)carrier).removeItemIdentifier(changedIdentifier); + } + + changedIdentifier = ((ReifiableStub)carrier).getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex)); + ((ReifiableStub)carrier).addItemIdentifier(changedIdentifier); + contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); + } + } + + + // handles the getContent call for item identifiers of variant-names + public void getVariantIdentifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); + ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); + if(possibleVariants.size() != 0){ + Variant variant = possibleVariants.get(0); + JsArray identifiers = null; + + ArrayList filteredIdentifiers = null; + + identifiers = variant.getItemIdentifiers(); + filteredIdentifiers = this.filterLocators(TmHelper.getRegExp(this.getConstraint()), identifiers); + + Locator changedIdentifier = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(filteredIdentifiers.size() > selectedValueIndex){ + changedIdentifier = filteredIdentifiers.get(selectedValueIndex); + variant.removeItemIdentifier(changedIdentifier); + } + + changedIdentifier = variant.getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex)); + variant.addItemIdentifier(changedIdentifier); + contents.add(new Pair(changedIdentifier, TopicMapsTypes.Locator)); + } + } + + + // handles the getContent call for item identifiers of variant-names + public void getVariantReifierContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); + ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); + if(possibleVariants.size() != 0){ + Variant variant = possibleVariants.get(0); + Topic reifier = TmHelper.getTopicFromStringRepresentation(this.owner.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); + + if(reifier != null && !variant.getReifier().equals(reifier)) variant.setReifier(reifier); + contents.add(new Pair(variant, TopicMapsTypes.Variant)); + } + } + + + // handles the getContent call for occurrence and name values + public void getTopicCharacteristicContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); + Topic characteristicType = TmHelper.getConstrainedStatement(this.getConstraint()); + + boolean isOccConstraint = true; + if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicOccurrenceConstraint)){ + isOccConstraint = true; + } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.TMCL.tmclTopicNameConstraint)){ + isOccConstraint = false; + } else { + throw new ExecutionException("the function getTopicCharacteristicContent can operate only on constraints of the type " + PSIs.TMCL.tmclTopicOccurrenceConstraint + " or " + PSIs.TMCL.tmclTopicNameConstraint + ", but is called with " + TmHelper.getAnyIdOfTopic(this.getConstraint())); + } + + JsArray names = null; + JsArray occurrences = null; + if(isOccConstraint) occurrences = carrier.getOccurrences(characteristicType); + else names = carrier.getNames(characteristicType); + + + Construct changedConstruct = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(isOccConstraint){ + if(occurrences.length() > selectedValueIndex){ + changedConstruct = occurrences.get(selectedValueIndex); + ((Occurrence)changedConstruct).setValue(this.owner.getSelectedValues().get(selectedValueIndex)); + }else { + changedConstruct = carrier.createOccurrence(characteristicType, this.owner.getSelectedValues().get(selectedValueIndex), null); + } + } else { + if(names.length() > selectedValueIndex){ + changedConstruct = names.get(selectedValueIndex); + ((Name)changedConstruct).setValue(this.owner.getSelectedValues().get(selectedValueIndex)); + }else { + changedConstruct = carrier.createName(this.owner.getSelectedValues().get(selectedValueIndex), characteristicType, null); + } + } + contents.add(new Pair(changedConstruct, isOccConstraint ? TopicMapsTypes.Occurrence : TopicMapsTypes.Name)); + } + + + // handles the getContent call for subject identifiers and subject locators + public void getVariantNameContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex, ArrayList variants) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(variants == null) return; + + Variant changedVariant = null; + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(variants.size() > selectedValueIndex){ + changedVariant = variants.get(selectedValueIndex); + changedVariant.setValue(this.owner.getSelectedValues().get(selectedValueIndex)); + }else { + Topic nameType = TmHelper.getConstrainedStatement(this.getConstraint()); + JsArray names = carrier.getNames(nameType); + Name owner = names.get(0); + Topic scope = TmHelper.getConstrainedScopeTopic(this.getConstraint()); + @SuppressWarnings("unchecked") + JsArray scopes = (JsArray) JsArray.createArray(); + scopes.push(scope); + changedVariant = owner.createVariant(this.owner.getSelectedValues().get(selectedValueIndex), scopes); + } + contents.add(new Pair(changedVariant, TopicMapsTypes.Variant)); + } + + + // handles the getContent call for role players + public void getRolePlayerContent(ArrayList> contents, boolean validate, Association carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Association)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to an Association, but is: " + carrier.getClass()); + + if(!TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclTopicRoleConstraint))throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a root constraint of the type " + PSIs.TMCL.tmclTopicRoleConstraint + ", but is: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint())); + Pair roleAndPlayerType = TmHelper.getConstrainedRoleAndPlayerTypeOfConstraint(this.getRootConstraint()); + Topic roleType = roleAndPlayerType.getFirst(); + Topic playerType = roleAndPlayerType.getSecond(); + + JsArray typedRoles = carrier.getRoles(roleType); + ArrayList roles = new ArrayList(); + for(int i = 0; i != typedRoles.length(); ++i) + if(TmHelper.isInstanceOf(typedRoles.get(i).getPlayer(), playerType)) roles.add(typedRoles.get(i)); + + Role changedRole = null; + + Topic player = TmHelper.getTopicFromStringRepresentation(this.owner.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); + if(validate) this.validateTmValue(player); + if(roles.size() > selectedValueIndex){ + changedRole = roles.get(selectedValueIndex); + changedRole.setPlayer(player); + } else { + changedRole = carrier.createRole(roleType, player); + } + contents.add(new Pair(changedRole, TopicMapsTypes.Role)); + } + + + // handles the getContent call for scope topics of variant-names + public void getVariantNameScopeContent(ArrayList> contents, boolean validate, Topic carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + if(!(carrier instanceof Topic)) throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a Topic, but is: " + carrier.getClass()); + ArrayList possibleVariants = TmHelper.getVariantsForConstraint(carrier, this.getRootConstraint()); + if(possibleVariants.size() != 0){ + Variant variant = possibleVariants.get(0); + JsArray scopes = variant.getScope(); + + if(validate) this.validateLiteralValue(this.owner.getSelectedValues().get(selectedValueIndex)); + + if(scopes.length() > selectedValueIndex){ + Topic oldScope = scopes.get(selectedValueIndex); + Topic newScope = TmHelper.getTopicFromStringRepresentation(this.owner.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); + + if(!oldScope.equals(newScope)){ + variant.removeTheme(oldScope); + variant.addTheme(newScope); + } + } + contents.add(new Pair(variant, TopicMapsTypes.Variant)); + } + } + + + // handles the getContent call for scope topics + public void getScopeContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + Topic type = TmHelper.getConstrainedStatement(this.getConstraint()); + + JsArray scopes = null; + Construct owner = null; + TopicMapsTypes ownerType = null; + if(carrier instanceof Topic){ + JsArray names = ((Topic)carrier).getNames(type); + if(names.length() != 0){ + scopes = names.get(0).getScope(); + owner = names.get(0); + ownerType = TopicMapsTypes.Name; + } + if(scopes == null){ + JsArray occs = ((Topic)carrier).getOccurrences(type); + if(occs.length() != 0){ + scopes = occs.get(0).getScope(); + owner = occs.get(0); + ownerType = TopicMapsTypes.Occurrence; + } + } + } else if(carrier instanceof Association){ + if(((Association)carrier).getType().equals(type)){ + scopes = ((Association)carrier).getScope(); + owner = carrier; + ownerType = TopicMapsTypes.Association; + } + } else { + throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + carrier.getClass()); + } + + Topic newScope = TmHelper.getTopicFromStringRepresentation(this.owner.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); + Topic oldScope = null; + if(scopes.length() > selectedValueIndex){ + oldScope = scopes.get(selectedValueIndex); + if(!newScope.equals(oldScope)){ + ((ScopedStub)owner).removeTheme(oldScope); + ((ScopedStub)owner).addTheme(newScope); + } + } else { + ((ScopedStub)owner).addTheme(newScope); + } + contents.add(new Pair(owner, ownerType)); + } + + + // handles the getContent call for a reifier topic + public void getReifierContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + Topic type = TmHelper.getConstrainedStatement(this.getConstraint()); + + Construct owner = null; + TopicMapsTypes ownerType = null; + if(carrier instanceof Topic){ + JsArray names = ((Topic)carrier).getNames(type); + if(names.length() != 0){ + owner = names.get(0); + ownerType = TopicMapsTypes.Name; + } else { + JsArray occs = ((Topic)carrier).getOccurrences(type); + if(occs.length() != 0){ + owner = occs.get(0); + ownerType = TopicMapsTypes.Occurrence; + } + } + } else if(carrier instanceof Association){ + if(((Association)carrier).getType().equals(type)){ + owner = carrier; + ownerType = TopicMapsTypes.Association; + } else { + JsArray roles = ((Association)carrier).getRoles(type); + if(roles.length() != 0){ + owner = roles.get(0); + ownerType = TopicMapsTypes.Role; + } + } + } else { + throw new ExecutionException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a topic or association, but is: " + carrier.getClass()); + } + + Topic newReifier = TmHelper.getTopicFromStringRepresentation(this.owner.getSelectedValues().get(selectedValueIndex), this.getValueGroup()); + if(!newReifier.equals(((ReifiableStub)owner).getReifier())) ((ReifiableStub)owner).setReifier(newReifier); + contents.add(new Pair(owner, ownerType)); + } + + + // handles the getContent call for a Datatye value + public void getDatatypeContent(ArrayList> contents, boolean validate, Construct carrier, int selectedValueIndex, ArrayList variants, ArrayList occurrences) throws InvalidGdlSchemaException, InvalidContentException, ExecutionException{ + Construct owner = null; + TopicMapsTypes ownerType = null; + if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclVariantNameConstraint)){ + if(variants.size() != 0){ + owner = variants.get(0); + variants.get(0).setValue(variants.get(0).getValue(), variants.get(0).getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex))); + ownerType = TopicMapsTypes.Variant; + } + } else if(TmHelper.isInstanceOf(this.getRootConstraint(), PSIs.TMCL.tmclOccurrenceConstraint)){ + if(occurrences.size() != 0){ + owner = occurrences.get(0); + occurrences.get(0).setValue(occurrences.get(0).getValue(), occurrences.get(0).getTopicMap().createLocator(this.owner.getSelectedValues().get(selectedValueIndex))); + ownerType = TopicMapsTypes.Occurrence; + } + } else { + throw new InvalidGdlSchemaException("the constraint " + TmHelper.getAnyIdOfTopic(this.getConstraint()) + " must be bound to a constraint of the type " + PSIs.TMCL.tmclVariantNameConstraint + " or " + PSIs.TMCL.tmclOccurrenceConstraint + ", but is bound to: " + TmHelper.getAnyIdOfTopic(this.getRootConstraint())); + } + contents.add(new Pair(owner, ownerType)); + } +} Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java Tue Nov 22 06:56:14 2011 (r1034) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/Utils.java Tue Nov 22 13:11:07 2011 (r1035) @@ -124,6 +124,15 @@ } + public static ArrayList jsArrayToArrayList(JsArray input){ + ArrayList result = new ArrayList(); + + if(input != null) for(int i = 0; i != input.length(); ++i) result.add(input.get(i)); + + return result; + } + + // returns a list that contains a union of both lists public static ArrayList intersection(ArrayList fst, ArrayList snd){ ArrayList result = new ArrayList(); Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Nov 22 06:56:14 2011 (r1034) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java Tue Nov 22 13:11:07 2011 (r1035) @@ -7,10 +7,8 @@ import com.google.gwt.user.client.ui.Widget; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Association; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Occurrence; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Role; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; -import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.GdlHiddenValue; From lgiessmann at common-lisp.net Wed Nov 23 09:03:20 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Wed, 23 Nov 2011 01:03:20 -0800 Subject: [isidorus-cvs] r1036 - in trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets: base environment Message-ID: Author: lgiessmann Date: Wed Nov 23 01:03:19 2011 New Revision: 1036 Log: gdl-frontend: Widgets: refactoring of GdlPanel Deleted: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/GdlErrorTypes.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Tue Nov 22 13:11:07 2011 (r1035) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Nov 23 01:03:19 2011 (r1036) @@ -5,7 +5,6 @@ import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; -import us.isidor.gdl.anaToMia.Widgets.environment.GdlErrorTypes; import us.isidor.gdl.anaToMia.Widgets.environment.GdlInstantiator; import us.isidor.gdl.anaToMia.Widgets.environment.ICommitCallback; import us.isidor.gdl.anaToMia.Widgets.environment.IDeleteCallback; @@ -192,7 +191,7 @@ this.loadSchemaCallback.loadSchema(this, this.requestedTopicToEdit, this.requestedTopicsToCreate); }catch(Exception e){ for (IOnErrorCallback handler : localOnErrorContainer) { - handler.onError(GdlErrorTypes.LoadError, e); + handler.onError(e); } } } @@ -201,78 +200,51 @@ // this method is responsible for committing the Topic Map by using the // commitCallback. After a successfully commit operation the // onCommitHandlers are executed - public void doCommit(){ - try{ - if(tmEngine == null || requestedSchemaTm == null){ - throw new ExecutionException("No Topic Maps engine was set yet"); - } - if(this.commitCallback == null){ - throw new ExecutionException("No CommitCallback was set yet"); - } - ArrayList> data = new ArrayList>(); - data.add(new Pair(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); - this.commitCallback.commitTmConstruct(data, null, this.tmEngine); - }catch(Exception e){ - for (IOnErrorCallback handler : localOnErrorContainer) { - handler.onError(GdlErrorTypes.CommitError, e); - } + public void doCommit() throws ExecutionException{ + if(tmEngine == null || requestedSchemaTm == null){ + throw new ExecutionException("No Topic Maps engine was set yet"); + } + if(this.commitCallback == null){ + throw new ExecutionException("No CommitCallback was set yet"); } + ArrayList> data = new ArrayList>(); + data.add(new Pair(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); + this.commitCallback.commitTmConstruct(data, null, this.tmEngine); } // this method is responsible for validating the Topic Map by calling the // view's validate method. After a successfully validate operation the // onValidateHandlers are executed - public void doValidate() { - try{ - if(tmEngine == null || requestedSchemaTm == null) - throw new ExecutionException("No Topic Maps engine was set yet"); + public void doValidate() throws ExecutionException { + if(tmEngine == null || requestedSchemaTm == null) + throw new ExecutionException("No Topic Maps engine was set yet"); // TODO: validate // throw new InvalidContentException("The topic map content is not valid:\n" + tmEngine.exportTm(view.getContent())); - - //}catch(InvalidContentException e){ - // for (IOnErrorCallback handler : localOnErrorContainer) - // handler.onError(GdlErrorTypes.ValidateError, e); - } catch(Exception e){ - for (IOnErrorCallback handler : localOnErrorContainer) - handler.onError(GdlErrorTypes.ExecutionError, e); - } } // this method is responsible for deleting the Topic Map by using the // deleteCallback. After a successfully delete operation the // onDeleteHandlers are executed and the panel's content is removed - public void doDelete() { - try{ - if(tmEngine == null || requestedSchemaTm == null) - throw new ExecutionException("No Topic Maps engine was set yet"); - - if(this.deleteCallback == null) - throw new ExecutionException("No DeleteCallback was set yet"); - - ArrayList> data = new ArrayList>(); - data.add(new Pair(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); - this.deleteCallback.deleteTmConstruct(data, this.getTmEngine(), null); - }catch(Exception e){ - for (IOnErrorCallback handler : localOnErrorContainer) - handler.onError(GdlErrorTypes.DeleteError, e); - } + public void doDelete() throws ExecutionException { + if(tmEngine == null || requestedSchemaTm == null) + throw new ExecutionException("No Topic Maps engine was set yet"); + + if(this.deleteCallback == null) + throw new ExecutionException("No DeleteCallback was set yet"); + + ArrayList> data = new ArrayList>(); + data.add(new Pair(this.requestedSchemaTm, TopicMapsTypes.TopicMap)); + this.deleteCallback.deleteTmConstruct(data, this.getTmEngine(), null); } - + // this method is responsible for generating a Topic Map fo the user's // data by using the view's getContent method. public ArrayList> getContent(boolean validate) throws Exception { - try{ - return this.view.getContent(null, validate); - }catch(Exception e){ - for (IOnErrorCallback handler : localOnErrorContainer) { - handler.onError(GdlErrorTypes.TopicMapsGenerationError, e); - } - throw e; - } + return this.view.getContent(null, validate); } @@ -288,7 +260,7 @@ Window.alert("could not create a view (" + e.getClass() + "): " + e.getMessage()); e.printStackTrace(); for (IOnErrorCallback handler : localOnErrorContainer) { - handler.onError(GdlErrorTypes.ViewCreationError, e); + handler.onError(e); } } } Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java Tue Nov 22 13:11:07 2011 (r1035) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/environment/IOnErrorCallback.java Wed Nov 23 01:03:19 2011 (r1036) @@ -2,5 +2,5 @@ public interface IOnErrorCallback { - public void onError(GdlErrorTypes errorType, Exception errorInformation); + public void onError(Exception exception); } From lgiessmann at common-lisp.net Mon Nov 28 15:02:51 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Mon, 28 Nov 2011 07:02:51 -0800 Subject: [isidorus-cvs] r1037 - in trunk/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 Message-ID: Author: lgiessmann Date: Mon Nov 28 07:02:47 2011 New Revision: 1037 Log: gdl-frontend: Widgets: fixed a bug when collecting all topic instances of a particular type of a TM; implemented GdlRadioButton; added a test for GdlRadioButton Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Mon Nov 28 07:02:47 2011 (r1037) @@ -1,7 +1,7 @@ * test GdlCechkBox * test GdlRadioButton -* implement export of Fragments, e.g. exportJTM11Fragment(ArrayList topics, ArrayList associaitions), +* implement export of Fragments, e.g. exportJTM11Fragment(ArrayList topics, ArrayList associations), e.i. the passed topics and associations must be exported with all characteristics and associations, and all referenced topics must be exported as stubs * finalise GdlTopicView.getContent() @@ -26,5 +26,4 @@ * finalise GdlDefaultCreatorTopicView * finalise GdlDefaultEditorTopicView * finalise GdlAssociationView.getContent() -* inmplement GdlPanel.OnErrorHandler -* Fix css-pseudo-class-handlers \ No newline at end of file +* finalise css-pseudo-class-handlers \ No newline at end of file Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlPanel.java Mon Nov 28 07:02:47 2011 (r1037) @@ -217,8 +217,7 @@ // view's validate method. After a successfully validate operation the // onValidateHandlers are executed public void doValidate() throws ExecutionException { - if(tmEngine == null || requestedSchemaTm == null) - throw new ExecutionException("No Topic Maps engine was set yet"); + if(tmEngine == null || requestedSchemaTm == null) throw new ExecutionException("No Topic Maps engine was set yet"); // TODO: validate // throw new InvalidContentException("The topic map content is not valid:\n" + tmEngine.exportTm(view.getContent())); Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java Mon Nov 28 07:02:47 2011 (r1037) @@ -75,8 +75,8 @@ public abstract class GdlVisibleObject extends Composite implements GdlDescriptor, HasClickHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasFocusHandlers, HasMouseDownHandlers, HasMouseUpHandlers, HasBlurHandlers{ private GdlVisibleObject gdlParent = null; - private GdlVisibleObjectCssService cssService = null; - private GdlVisibleObjectTmService tmService = null; + protected GdlVisibleObjectCssService cssService = null; + protected GdlVisibleObjectTmService tmService = null; protected AbsolutePanel mainPanel = new AbsolutePanel(); protected Panel containerPanel = null; protected Topic tmRepresentative = null; Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObjectTmService.java Mon Nov 28 07:02:47 2011 (r1037) @@ -690,4 +690,23 @@ } contents.add(new Pair(owner, ownerType)); } + + + // returns an array list of strings that contains all possible values + public ArrayList getAllPossibleValues() throws InvalidGdlSchemaException, ExecutionException { + ArrayList result = new ArrayList(); + ArrayList tmValues = this.getRawTmValues(); + ArrayList literalValues = this.getLiterals(); + + + if(tmValues.size() != 0 || literalValues.size() != 0){ + for (String literal : literalValues) result.add(literal); + for (Topic tmValue : tmValues) result.add(TmHelper.getTopicRepresentation(tmValue, this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup())); + } else { + ArrayList tops = TmHelper.getTmValuesForConstraint(this.getConstraint(), this.getValueGroup()); + for (Topic top : tops) result.add(TmHelper.getTopicRepresentation(top, this.getDisplayByOfValueGroup(), this.getPreferredScopeOfValueGroup())); + } + + return result; + } } Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java Mon Nov 28 07:02:47 2011 (r1037) @@ -1232,7 +1232,7 @@ throw new InvalidGdlSchemaException("the constraint " + getAnyIdOfTopic(rootConstraint) + " must be bound extactly once to an occurrence or name type, but is: " + typeTopics.size()); } else { // add the direct specified type - result.add(typeTopics.get(0)); + //result.add(typeTopics.get(0)); // get subtypes of typeTopic JsArray allTopics = tm.getTopics(); @@ -1258,7 +1258,7 @@ throw new InvalidGdlSchemaException("the constraint " + getAnyIdOfTopic(variantNameReifierConstraint) + " must be bound extactly once to a topic type, but is: " + reifierTypeTopics.size()); } else { // add the direct specified type - result.add(reifierTypeTopics.get(0)); + //result.add(reifierTypeTopics.get(0)); // get subtypes of typeTopic JsArray allTopics = tm.getTopics(); @@ -1283,7 +1283,7 @@ throw new InvalidGdlSchemaException("the constraint " + getAnyIdOfTopic(variantNameScopeConstraint) + " must be bound extactly once to a topic type, but is: " + scopeTypeTopics.size()); } else { // add the direct specified type - result.add(scopeTypeTopics.get(0)); + //result.add(scopeTypeTopics.get(0)); // get subtypes of typeTopic JsArray allTopics = tm.getTopics(); Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 07:02:47 2011 (r1037) @@ -3,9 +3,10 @@ import java.util.ArrayList; import com.google.gwt.user.client.ui.CheckBox; - +import com.google.gwt.user.client.ui.Widget; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; +import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; @@ -20,15 +21,15 @@ public GdlCheckBox(Topic tmRepresentative, Construct receivedData, GdlVisibleObject gdlParent) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative, receivedData, gdlParent); // TODO: create a check box for each tm construct - this.createcheckBox().setText("Check Box 1"); - this.createcheckBox().setText("Check Box 2"); - this.createcheckBox().setText("Check Box 3"); + this.createCheckBox().setText("Check Box 1"); + this.createCheckBox().setText("Check Box 2"); + this.createCheckBox().setText("Check Box 3"); this.setNthButtons(); } - public CheckBox createcheckBox() throws InvalidGdlSchemaException, ExecutionException{ + public CheckBox createCheckBox() throws InvalidGdlSchemaException, ExecutionException{ CheckBox cb = new CheckBox(); cb.setName(this.getGroupName()); this.addToContainerPanel(cb); @@ -52,6 +53,13 @@ @Override public void fixValue(){ - // TODO: implement + for (Widget elem : this.subElements) { + ButtonableObject bo = (ButtonableObject)elem; + Widget wdgt = bo.getMainObject(); + if(wdgt instanceof CheckBox){ + CheckBox cb = (CheckBox)wdgt; + cb.setEnabled(false); + } + } } } Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java Mon Nov 28 07:02:47 2011 (r1037) @@ -2,11 +2,11 @@ import java.util.ArrayList; - import com.google.gwt.user.client.ui.RadioButton; - +import com.google.gwt.user.client.ui.Widget; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; +import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject; import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; @@ -20,10 +20,10 @@ public GdlRadioButton(Topic tmRepresentative, Construct receivedData, GdlVisibleObject gdlParent) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative, receivedData, gdlParent); - // TODO: create a radio button for each tm construct - this.createRadioButton().setText("Radio Button 1"); - this.createRadioButton().setText("Radio Button 2"); - this.createRadioButton().setText("Radio Button 3"); + + if(receivedData != null && this.getConstraint() != null) this.setReceivedData(); + else this.setDefaultValue(); + this.setNthButtons(); } @@ -38,19 +38,48 @@ @Override public void addSubItem(String value) throws InvalidGdlSchemaException, ExecutionException { - // TODO: implement + RadioButton rb = this.createRadioButton(); + rb.setText(value); + rb.setValue(true); + } + + public void addUncheckedSubItem(String value) throws InvalidGdlSchemaException, ExecutionException { + this.createRadioButton().setText(value); + } + + + @Override + protected void setReceivedData() throws InvalidGdlSchemaException, ExecutionException { + super.setReceivedData(); + ArrayList options = this.tmService.getAllPossibleValues(); + + for (String opt : options) this.addUncheckedSubItem(opt); } @Override public ArrayList getSelectedValues(){ - // TODO: implement - return new ArrayList(); + ArrayList result = new ArrayList(); + + for (Widget elem : this.subElements) { + ButtonableObject bo = (ButtonableObject)elem; + Widget wdgt = bo.getMainObject(); + if((wdgt instanceof RadioButton) && ((RadioButton)wdgt).getValue()) result.add(((RadioButton)wdgt).getText()); + } + + return result; } @Override public void fixValue(){ - // TODO: implement + for (Widget elem : this.subElements) { + ButtonableObject bo = (ButtonableObject)elem; + Widget wdgt = bo.getMainObject(); + if(wdgt instanceof RadioButton){ + RadioButton rb = (RadioButton)wdgt; + rb.setEnabled(false); + } + } } } Modified: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Wed Nov 23 01:03:19 2011 (r1036) +++ trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Mon Nov 28 07:02:47 2011 (r1037) @@ -171,6 +171,9 @@ {"subject_identifiers":["[gdlt:Button]"]}, {"subject_identifiers":["[gdlt:Action-Button]"]}, {"subject_identifiers":["[gdlt:Commit-Button]"]}, + {"subject_identifiers":["[gdlt:Input-Button]"]}, + {"subject_identifiers":["[gdlt:Check-Box]"]}, + {"subject_identifiers":["[gdlt:Radio-Button]"]}, {"subject_identifiers":["[gdlsrv:service-schema]"], "instance_of":["si:[gdlt:Schema]"], "names":[{"type":"si:[gdl:schema-name]", "value":"GDL Schema for a Service UI"}]}, {"subject_identifiers":["[gdlsrv:service-default-editor-topic-view]"], "instance_of":["si:[gdlt:Default-Editor-Topic-View]"], "names":[{"type":"si:[gdl:view-name]", "value":"GDL Default Editor Topic View for instances of http://services.org/serviceregistry/model/types/Service"}], "occurrences":[{"type":"si:[gdl:id]", "value":"service_default_editor_topic_view_id"}, {"type":"si:[gdl:width]", "value":"552px"}, {"type":"si:[gdl:height]", "value":"800px"},{"type":"si:[gdl:background-color]", "value":"gray"}]}, @@ -228,7 +231,7 @@ {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-ii-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Identifiers]"]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text]"], "instance_of":["si:[gdlt:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}]}, {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-reifier-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Reifier]"]}, @@ -300,6 +303,9 @@ {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Text-Object]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Button]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Action-Button]"}]}, {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Action-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Commit-Button]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Input-Button]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Input-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Radio-Button]"}]}, + {"type":"si:[tmdm:supertype-subtype]", "roles":[{"type":"si:[tmdm:supertype]", "player":"si:[gdlt:Input-Button]"},{"type":"si:[tmdm:subtype]", "player":"si:[gdlt:Check-Box]"}]}, {"type":"si:[tmcl:constrained-topic-type]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[model:service-psi-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[types:Service]"}]}, From lgiessmann at common-lisp.net Mon Nov 28 15:07:21 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Mon, 28 Nov 2011 07:07:21 -0800 Subject: [isidorus-cvs] r1038 - in trunk/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets/button war/gdl_widgets Message-ID: Author: lgiessmann Date: Mon Nov 28 07:07:19 2011 New Revision: 1038 Log: gdl-frontend: Widgets: updated the test-gdl-schema for a test for GdlRadioButton Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 07:02:47 2011 (r1037) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 07:07:19 2011 (r1038) @@ -1,7 +1,6 @@ package us.isidor.gdl.anaToMia.Widgets.button; import java.util.ArrayList; - import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.Widget; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; @@ -20,10 +19,10 @@ public GdlCheckBox(Topic tmRepresentative, Construct receivedData, GdlVisibleObject gdlParent) throws InvalidGdlSchemaException, ExecutionException{ super(tmRepresentative, receivedData, gdlParent); - // TODO: create a check box for each tm construct - this.createCheckBox().setText("Check Box 1"); - this.createCheckBox().setText("Check Box 2"); - this.createCheckBox().setText("Check Box 3"); + + if(receivedData != null && this.getConstraint() != null) this.setReceivedData(); + else this.setDefaultValue(); + this.setNthButtons(); } @@ -40,14 +39,23 @@ @Override public void addSubItem(String value) throws InvalidGdlSchemaException, ExecutionException { - // TODO: implement + CheckBox cb = this.createCheckBox(); + cb.setText(value); + cb.setValue(true); } @Override public ArrayList getSelectedValues(){ - // TODO: implement - return new ArrayList(); + ArrayList result = new ArrayList(); + + for (Widget elem : this.subElements) { + ButtonableObject bo = (ButtonableObject)elem; + Widget wdgt = bo.getMainObject(); + if((wdgt instanceof CheckBox) && ((CheckBox)wdgt).getValue()) result.add(((CheckBox)wdgt).getText()); + } + + return result; } Modified: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Mon Nov 28 07:02:47 2011 (r1037) +++ trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Mon Nov 28 07:07:19 2011 (r1038) @@ -231,9 +231,9 @@ {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-ii-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Identifiers]"]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text]"], "instance_of":["si:[gdlt:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button]"], "instance_of":["si:[gdlt:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-reifier-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Reifier]"]}, {"subject_identifiers":["[gdlsrv:service-editor-commit-button]"], "instance_of":["si:[gdlt:Commit-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_creator_commit_button_id"}, {"type":"si:[gdl:height]", "value":"30px"}, {"type":"si:[gdl:width]", "value":"80px"}, {"type":"si:[gdl:font-size]", "value":"12px"}]}, @@ -433,16 +433,16 @@ {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-iis-text-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-ii-constraint]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[model:service-variant-name-ii-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-constraint]"}]}, - {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-variant-name-reifier-text]"}]}, - {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-reifier-text-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-iis-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-reifier-text]"}]}, - {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-reifier-text-value-group]"},{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-reifier-text]"}]}, - {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-reifier-text-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-reifier-constraint]"}]}, + {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button]"}]}, + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-iis-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button]"}]}, + {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button-value-group]"},{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button]"}]}, + {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-reifier-constraint]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[model:service-variant-name-reifier-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-constraint]"}]}, {"type":"si:[tmcl:allowed-reifier]", "roles":[{"type":"si:[tmcl:allows]", "player":"si:[model:service-variant-name-reifier-constraint]"},{"type":"si:[tmcl:allowed]", "player":"si:[types:Reifier-Type]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-editor-commit-button]"}]}, - {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-editor-commit-button-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-reifier-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-editor-commit-button]"}]} + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-editor-commit-button-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-reifier-radio-button]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-editor-commit-button]"}]} From lgiessmann at common-lisp.net Mon Nov 28 16:22:10 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Mon, 28 Nov 2011 08:22:10 -0800 Subject: [isidorus-cvs] r1039 - in trunk/src/anaToMia/GDL_Widgets: src/us/isidor/gdl/anaToMia/Widgets src/us/isidor/gdl/anaToMia/Widgets/button war/gdl_widgets Message-ID: Author: lgiessmann Date: Mon Nov 28 08:22:07 2011 New Revision: 1039 Log: gdl-frontend: Widgets: updated the test-gdl-schema for a test for GdlCheckBox; added a test for GdlCheckbox; implemented GdlCheckBox Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Mon Nov 28 07:07:19 2011 (r1038) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/TODO.txt Mon Nov 28 08:22:07 2011 (r1039) @@ -1,15 +1,10 @@ -* test GdlCechkBox -* test GdlRadioButton - * implement export of Fragments, e.g. exportJTM11Fragment(ArrayList topics, ArrayList associations), e.i. the passed topics and associations must be exported with all characteristics and associations, and all referenced topics must be exported as stubs * finalise GdlTopicView.getContent() * finalise GdlPanel.doValidate() -* finalise GdlCheckBox * finalise GdlCommitButton * finalise GdlCreateButton -* finalise GdlRadioButton * finalise GdlUnit * finalise GdlTitle.setWidth() * finalise GdlTitle.getSelectedValues() Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 07:07:19 2011 (r1038) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 08:22:07 2011 (r1039) @@ -45,6 +45,20 @@ } + public void addUncheckedSubItem(String value) throws InvalidGdlSchemaException, ExecutionException { + this.createCheckBox().setText(value); + } + + + @Override + protected void setReceivedData() throws InvalidGdlSchemaException, ExecutionException { + super.setReceivedData(); + ArrayList options = this.tmService.getAllPossibleValues(); + + for (String opt : options) this.addUncheckedSubItem(opt); + } + + @Override public ArrayList getSelectedValues(){ ArrayList result = new ArrayList(); Modified: trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Mon Nov 28 07:07:19 2011 (r1038) +++ trunk/src/anaToMia/GDL_Widgets/war/gdl_widgets/Service_GDL_Schema.jtm Mon Nov 28 08:22:07 2011 (r1039) @@ -70,6 +70,7 @@ {"subject_identifiers":["[types:Language]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[model:german]"], "instance_of":["si:[types:Language]"]}, {"subject_identifiers":["[model:english]"], "instance_of":["si:[types:Language]"]}, + {"subject_identifiers":["[model:polish]"], "instance_of":["si:[types:Language]"]}, {"subject_identifiers":["[types:Priority]"], "instance_of":["si:[tmcl:topic-type]"]}, {"subject_identifiers":["[model:first]"], "instance_of":["si:[types:Priority]"]}, {"subject_identifiers":["[model:second]"], "instance_of":["si:[types:Priority]"]}, @@ -221,18 +222,18 @@ {"subject_identifiers":["[gdlsrv:service-variant-name-dt-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-dt-constraint]"], "instance_of":["si:[gdlt:Datatype]"]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-scope-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_scope_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-scope-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"390px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-scope-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-scope-check-box]"], "instance_of":["si:[gdlt:Check-Box]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_scope_text_id"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-scope-check-box-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"390px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-scope-check-box-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-scope-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Scope]"]}, {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text]"], "instance_of":["si:[gdlt:Text]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_ii_text_id"}, {"type":"si:[gdl:readonly]", "value":"false"}, {"type":"si:[gdl:width]", "value":"470px"},{"type":"si:[gdl:cursor]", "value":"text"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"450px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"600px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, {"subject_identifiers":["[gdlsrv:service-variant-name-iis-text-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-ii-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Identifiers]"]}, {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button]"], "instance_of":["si:[gdlt:Radio-Button]"], "occurrences":[{"type":"si:[gdl:id]", "value":"service_variant_name_reifier_text_id"}]}, - {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"490px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, + {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button-position]"], "instance_of":["si:[gdlt:Position]"], "occurrences":[{"type":"si:[gdl:position-style]", "value":"absolute"}, {"type":"si:[gdl:top]", "value":"640px"}, {"type":"si:[gdl:left]", "value":"10px"}]}, {"subject_identifiers":["[gdlsrv:service-variant-name-reifier-radio-button-value-group]"], "instance_of":["si:[gdlt:Value-Group]"]}, {"subject_identifiers":["[model:service-variant-name-reifier-constraint]"], "instance_of":["si:[gdlt:Variant-Name-Reifier]"]}, @@ -420,15 +421,15 @@ {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-dt-text-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-dt-constraint]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[model:service-variant-name-dt-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-constraint]"}]}, - {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-variant-name-scope-text]"}]}, - {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-scope-text-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-dt-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-scope-text]"}]}, - {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-scope-text-value-group]"},{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-scope-text]"}]}, - {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-scope-text-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-scope-constraint]"}]}, + {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-variant-name-scope-check-box]"}]}, + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-scope-check-box-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-dt-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-scope-check-box]"}]}, + {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-scope-check-box-value-group]"},{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-scope-check-box]"}]}, + {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-scope-check-box-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-scope-constraint]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[model:service-variant-name-scope-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-constraint]"}]}, {"type":"si:[tmcl:constrained-scope]", "roles":[{"type":"si:[tmcl:constraint]", "player":"si:[model:service-variant-name-scope-constraint]"},{"type":"si:[tmcl:constrained]", "player":"si:[types:Scope-Type]"}]}, {"type":"si:[gdl:contains]", "roles":[{"type":"si:[gdl:container]", "player":"si:[gdlsrv:service-default-editor-topic-view]"},{"type":"si:[gdl:containee]", "player":"si:[gdlsrv:service-variant-name-iis-text]"}]}, - {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-iis-text-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-scope-text]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-iis-text]"}]}, + {"type":"si:[gdl:position]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-iis-text-position]"},{"type":"si:[gdl:ancestor]", "player":"si:[gdlsrv:service-variant-name-scope-check-box]"},{"type":"si:[gdl:descendant]", "player":"si:[gdlsrv:service-variant-name-iis-text]"}]}, {"type":"si:[gdl:view-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-iis-text-value-group]"},{"type":"si:[gdl:descriptor]", "player":"si:[gdlsrv:service-variant-name-iis-text]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:value-group]", "player":"si:[gdlsrv:service-variant-name-iis-text-value-group]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-ii-constraint]"}]}, {"type":"si:[gdl:tm-binding]", "roles":[{"type":"si:[gdl:descriptor]", "player":"si:[model:service-variant-name-ii-constraint]"},{"type":"si:[gdl:tm-construct]", "player":"si:[model:service-variant-name-constraint]"}]}, From lgiessmann at common-lisp.net Mon Nov 28 16:25:07 2011 From: lgiessmann at common-lisp.net (lgiessmann at common-lisp.net) Date: Mon, 28 Nov 2011 08:25:07 -0800 Subject: [isidorus-cvs] r1040 - trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button Message-ID: Author: lgiessmann Date: Mon Nov 28 08:25:06 2011 New Revision: 1040 Log: gdl-frontend: Widgets: refactored GdlCheckBox, GdlRadioButton and GdlInputButton Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlInputButton.java trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 08:22:07 2011 (r1039) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCheckBox.java Mon Nov 28 08:25:06 2011 (r1040) @@ -51,15 +51,6 @@ @Override - protected void setReceivedData() throws InvalidGdlSchemaException, ExecutionException { - super.setReceivedData(); - ArrayList options = this.tmService.getAllPossibleValues(); - - for (String opt : options) this.addUncheckedSubItem(opt); - } - - - @Override public ArrayList getSelectedValues(){ ArrayList result = new ArrayList(); Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlInputButton.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlInputButton.java Mon Nov 28 08:22:07 2011 (r1039) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlInputButton.java Mon Nov 28 08:25:06 2011 (r1040) @@ -1,5 +1,7 @@ package us.isidor.gdl.anaToMia.Widgets.button; +import java.util.ArrayList; + import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; import us.isidor.gdl.anaToMia.Widgets.base.GdlVisibleObject; @@ -20,4 +22,16 @@ public String getGroupName() throws InvalidGdlSchemaException{ return this.getId() + "__RB__GROUP"; } + + + public abstract void addUncheckedSubItem(String value) throws InvalidGdlSchemaException, ExecutionException; + + + @Override + protected void setReceivedData() throws InvalidGdlSchemaException, ExecutionException { + super.setReceivedData(); + ArrayList options = this.tmService.getAllPossibleValues(); + + for (String opt : options) this.addUncheckedSubItem(opt); + } } Modified: trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java ============================================================================== --- trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java Mon Nov 28 08:22:07 2011 (r1039) +++ trunk/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlRadioButton.java Mon Nov 28 08:25:06 2011 (r1040) @@ -49,15 +49,6 @@ @Override - protected void setReceivedData() throws InvalidGdlSchemaException, ExecutionException { - super.setReceivedData(); - ArrayList options = this.tmService.getAllPossibleValues(); - - for (String opt : options) this.addUncheckedSubItem(opt); - } - - - @Override public ArrayList getSelectedValues(){ ArrayList result = new ArrayList();