Changeset 809
- Timestamp:
- 08/30/11 11:22:52 (14 years ago)
- Location:
- branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlHiddenValue.java ¶
r803 r809 2 2 3 3 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; 4 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; 5 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; 4 6 5 7 public class GdlHiddenValue { … … 12 14 protected Topic defaultLiteralValueTopic = null; 13 15 protected boolean defaultLiteralValueTopicSet = false; 16 protected Topic tmRepresentative = null; 14 17 15 18 19 @SuppressWarnings("unused") 20 private GdlHiddenValue(){} 16 21 17 22 23 public GdlHiddenValue(Topic tmRepresentative) throws ExecutionException{ 24 if(tmRepresentative == null) throw new ExecutionException("tmRepresentative must no be null"); 25 this.tmRepresentative = tmRepresentative; 26 } 27 28 29 public Topic getTmRepresentative(){ 30 return this.tmRepresentative; 31 } 32 33 34 // returns the direct (first) constraint that is bound to the value-group 35 // of this element - or null if it is unbound 36 public Topic getConstraint() throws InvalidGdlSchemaException { 37 if(this.constraintTopicSet){ 38 return this.constraintTopic; 39 } else { 40 this.constraintTopic = TmHelper.getConstraintOfHiddenValue(this.getTmRepresentative()); 41 this.constraintTopicSet = true; 42 return this.constraintTopic; 43 } 44 } 45 46 47 // returns the root (last) constraint that is bound to the value-group 48 // of this element - or null if it is unbound 49 public Topic getRootConstraint() throws InvalidGdlSchemaException { 50 if(this.rootConstraintTopicSet){ 51 return this.rootConstraintTopic; 52 } else { 53 this.rootConstraintTopic = TmHelper.getRootConstraintOfHiddenValue(this.getTmRepresentative(), this.getConstraint()); 54 this.rootConstraintTopicSet = true; 55 return this.rootConstraintTopic; 56 } 57 } 58 59 60 // returns the topic that represents the default topic maps value of 61 // the value-group that is bound to this element - null if it is unbound 62 public Topic getDefaultTmValue() throws InvalidGdlSchemaException { 63 if(this.defaultTmValueTopicSet){ 64 return this.defaultTmValueTopic; 65 } else { 66 this.defaultTmValueTopic = TmHelper.getDefaultTmValueOfHiddenValue(this.getTmRepresentative()); 67 this.defaultTmValueTopicSet = true; 68 return this.defaultTmValueTopic; 69 } 70 } 71 72 73 // returns the topic that represents the default literal value of the 74 // value-group that is bound to this element - or null if it is unbound 75 public Topic getDefaultLiteralValue() throws InvalidGdlSchemaException { 76 if(this.defaultLiteralValueTopicSet){ 77 return this.defaultLiteralValueTopic; 78 } else { 79 this.defaultLiteralValueTopic = TmHelper.getDefaultLiteralValueOfHiddenValue(this.getTmRepresentative()); 80 this.defaultLiteralValueTopicSet = true; 81 return this.defaultLiteralValueTopic; 82 } 83 } 84 85 86 // returns the topic that represents the default value of 87 // the value-group that is bound to this element - null if it is unbound 88 public Topic getDefaultValue() throws InvalidGdlSchemaException { 89 if(this.getDefaultLiteralValue() != null && this.getDefaultTmValue() != null) throw new InvalidGdlSchemaException("the topic " + TmHelper.getAnyIdOfTopic(this.getTmRepresentative()) + " must be bound to maximal one " + PSIs.GDL.TopicType.gdlDefaultValue + ", but is: 2"); 90 else if(this.getDefaultLiteralValue() != null) return this.getDefaultLiteralValue(); 91 else return this.getDefaultTmValue(); 92 } 18 93 } -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/GdlVisibleObject.java ¶
r801 r809 2267 2267 changedRole.setPlayer(TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(idx), this.getValueGroup())); 2268 2268 } else { 2269 changedRole = ((Association)carrier).createRole(roleType, TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(idx), this.get DisplayByOfValueGroup()));2269 changedRole = ((Association)carrier).createRole(roleType, TmHelper.getTopicFromStringRepresentation(this.getSelectedValues().get(idx), this.getValueGroup())); 2270 2270 } 2271 2271 } else if(TmHelper.isInstanceOf(this.getConstraint(), PSIs.GDL.TopicType.gdlType)){ -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/base/TmHelper.java ¶
r801 r809 17 17 import us.isidor.gdl.anaToMia.Widgets.environment.Pattern; 18 18 import us.isidor.gdl.anaToMia.Widgets.environment.TopicIdentifierTypes; 19 import us.isidor.gdl.anaToMia.Widgets.view.GdlTopicView; 19 20 import com.google.gwt.core.client.JsArray; 20 21 … … 594 595 595 596 597 // returns the hidden values that are bound to the representative 598 // of a GdlView instance 599 public static ArrayList<Topic> getHiddenValueOf(Topic viewTopic) { 600 ArrayList<Topic> result = new ArrayList<Topic>(); 601 if(viewTopic == null) return result; 602 603 TopicMap tm = viewTopic.getTopicMap(); 604 Topic containerRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlContainer, tm); 605 Topic containeeRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlContainee, tm); 606 Topic containsAssocType = getTopicByPsi(PSIs.GDL.AssociationType.gdlContains, tm); 607 Topic hiddenValueType = getTopicByPsi(PSIs.GDL.TopicType.gdlHiddenValue, tm); 608 return getOtherPlayerOfBinaryAssociation(viewTopic, containerRoleType, containsAssocType, null, hiddenValueType, containeeRoleType); 609 } 610 611 612 // returns the first constraint of the passed hidden value topic 613 public static Topic getConstraintOfHiddenValue(Topic hiddenValue) throws InvalidGdlSchemaException { 614 if(hiddenValue == null) return null; 615 616 TopicMap tm = hiddenValue.getTopicMap(); 617 Topic hiddenValueRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlHiddenValue, tm); 618 Topic descriptorType = getTopicByPsi(PSIs.GDL.TopicType.gdlDescriptor, tm); 619 Topic tmBindingAssocType = getTopicByPsi(PSIs.GDL.AssociationType.gdlTmBinding, tm); 620 Topic tmclConstraintType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm); 621 Topic tmConstructRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlTmConstruct, tm); 622 ArrayList<Topic> tmclConstraints = getOtherPlayerOfBinaryAssociation(hiddenValue, hiddenValueRoleType, tmBindingAssocType, null, tmclConstraintType, tmConstructRoleType); 623 624 ArrayList<Topic> gdlConstraints = getOtherPlayerOfBinaryAssociation(hiddenValue, hiddenValueRoleType, tmBindingAssocType, null, descriptorType, tmConstructRoleType); 625 626 if(tmclConstraints.size() > 1 || gdlConstraints.size() > 1 || (tmclConstraints.size() == 1 && gdlConstraints.size() == 1)) 627 throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(hiddenValue) + " can be bound only to one constraint, but is " + (tmclConstraints.size() + gdlConstraints.size())); 628 629 if(tmclConstraints.size() == 1) return tmclConstraints.get(0); 630 else if (gdlConstraints.size() == 1) return gdlConstraints.get(0); 631 else return null; 632 } 633 634 635 // returns the last/root constraint that is bound to the passed 636 // hidden value topic 637 public static Topic getRootConstraintOfHiddenValue(Topic hiddenValue, Topic currentConstraint) throws InvalidGdlSchemaException { 638 if(hiddenValue == null) return null; 639 640 Topic localCurrentConstraint = currentConstraint == null ? getConstraintOfHiddenValue(hiddenValue) : currentConstraint; 641 TopicMap tm = hiddenValue.getTopicMap(); 642 Topic tmclConstraintType = getTopicByPsi(PSIs.TMCL.tmclConstraint, tm); 643 644 if(isInstanceOf(localCurrentConstraint, tmclConstraintType)) return localCurrentConstraint; 645 else { 646 // get next constraint and invoke this method recursively 647 Topic descriptorRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlDescriptor, tm); 648 Topic tmBindingAssocType = getTopicByPsi(PSIs.GDL.AssociationType.gdlTmBinding, tm); 649 Topic tmConstructRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlTmConstruct, tm); 650 Topic gdlDescriptor = getTopicByPsi(PSIs.GDL.TopicType.gdlDescriptor, tm); 651 652 ArrayList<Topic> nextTmclConstraints = getOtherPlayerOfBinaryAssociation(localCurrentConstraint, descriptorRoleType, tmBindingAssocType, null, tmclConstraintType, tmConstructRoleType); 653 ArrayList<Topic> nextGdlConstraints = getOtherPlayerOfBinaryAssociation(localCurrentConstraint, descriptorRoleType, tmBindingAssocType, null, gdlDescriptor, tmConstructRoleType); 654 655 if(nextTmclConstraints.size() > 1 || nextGdlConstraints.size() > 1 || (nextTmclConstraints.size() == 1 && nextGdlConstraints.size() == 1)) 656 throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(localCurrentConstraint) + " can be bound only to one constraint, but is " + (nextTmclConstraints.size() + nextGdlConstraints.size())); 657 658 if(nextTmclConstraints.size() == 1) return nextTmclConstraints.get(0); 659 else if(nextGdlConstraints.size() == 1) return getRootConstraintOfValueGroup(hiddenValue, nextGdlConstraints.get(0)); 660 else throw new InvalidGdlSchemaException("the hidden value " + getAnyIdOfTopic(hiddenValue) + " must be bound to exaclty one root constraint of the type " + PSIs.TMCL.tmclConstraint + " but is unbound"); 661 } 662 } 663 664 665 // returns the default value of a hidden value, i.e. the actual value representative 666 public static Topic getDefaultTmValueOfHiddenValue(Topic hiddenValue) throws InvalidGdlSchemaException { 667 if(hiddenValue == null) return null; 668 669 TopicMap tm = hiddenValue.getTopicMap(); 670 Topic valueBindingAssocTopic = getTopicByPsi(PSIs.GDL.AssociationType.gdlValueBinding, tm); 671 Topic hiddenValueRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlHiddenValue, tm); 672 Topic valueRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlValue, tm); 673 Topic defaultTmValueType = getTopicByPsi(PSIs.GDL.TopicType.gdlDefaultTmValue, tm); 674 675 ArrayList<Topic> defaultTmValues = getOtherPlayerOfBinaryAssociation(hiddenValue, hiddenValueRoleType, valueBindingAssocTopic, null, defaultTmValueType, valueRoleType); 676 677 if(defaultTmValues.size() == 1) return defaultTmValues.get(0); 678 else if(defaultTmValues.size() == 0) return null; 679 else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(hiddenValue) + " must be bound none or once to a " + PSIs.GDL.TopicType.gdlDefaultTmValue + ", but is: " + defaultTmValues.size()); 680 } 681 682 683 // returns the default literal value representative of the hidden value 684 public static Topic getDefaultLiteralValueOfHiddenValue(Topic hiddenValue) throws InvalidGdlSchemaException { 685 if(hiddenValue == null) return null; 686 687 TopicMap tm = hiddenValue.getTopicMap(); 688 Topic valueBindingAssocTopic = getTopicByPsi(PSIs.GDL.AssociationType.gdlValueBinding, tm); 689 Topic valueGroupRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlValueGroup, tm); 690 Topic valueRoleType = getTopicByPsi(PSIs.GDL.RoleType.gdlValue, tm); 691 Topic defaultLiteralValueType = getTopicByPsi(PSIs.GDL.TopicType.gdlDefaultLiteralValue, tm); 692 ArrayList<Topic> defaultTmValues = getOtherPlayerOfBinaryAssociation(hiddenValue, valueGroupRoleType, valueBindingAssocTopic, null, defaultLiteralValueType, valueRoleType); 693 694 if(defaultTmValues.size() == 1) return defaultTmValues.get(0); 695 else if(defaultTmValues.size() == 0) return null; 696 else throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(hiddenValue) + " must be bound none or once to a " + PSIs.GDL.TopicType.gdlDefaultLiteralValue + ", but is: " + defaultTmValues.size()); 697 } 698 699 700 // returns a topic that is represented by the nearest instance of GdlTopicView 701 public static Topic getNearestTopic(GdlVisibleObject elem){ 702 if(elem == null) return null; 703 704 GdlTopicView view = null; 705 GdlVisibleObject parent = elem; 706 707 do{ 708 if(parent instanceof GdlTopicView) view = (GdlTopicView)parent; 709 else parent = parent.getGdlParent(); 710 }while(view == null && parent != null); 711 712 if(view == null) return null; 713 else return view.getRepresentedTopic(); 714 } 715 716 596 717 // returns the topic that represents the value group that is bound to the passed 597 718 // topic via a gdl:view-binding association … … 742 863 Topic associationRoleConstraintType = getTopicByPsi(PSIs.TMCL.tmclAssociationRoleConstraint, tm); 743 864 ArrayList<Topic> result = getOtherPlayerOfBinaryAssociation(viewRepresentative, descriptorRoleType, associationViewBindingAssocType, null, associationRoleConstraintType, tmConstructRoleType); 744 865 745 866 if(result.size() == 0) throw new InvalidGdlSchemaException("the topic " + getAnyIdOfTopic(viewRepresentative) + " must be bound to at least one " + PSIs.TMCL.tmclAssociationRoleConstraint + ", but is unbound"); 746 867 else return result; -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/button/GdlCommitButton.java ¶
r792 r809 6 6 import us.isidor.gdl.anaToMia.Widgets.environment.ExecutionException; 7 7 import us.isidor.gdl.anaToMia.Widgets.environment.InvalidGdlSchemaException; 8 import com.google.gwt.event.dom.client.ClickEvent; 9 import com.google.gwt.event.dom.client.ClickHandler; 10 import com.google.gwt.user.client.Window; 8 11 import com.google.gwt.user.client.ui.Button; 12 9 13 10 14 public class GdlCommitButton extends GdlActionButton { … … 19 23 super(tmRepresentative, receivedData, parent); 20 24 ((Button)this.subElements.get(0)).setText("commit"); 25 this.getButton().addClickHandler(new CommitButtonClickHandler(this)); 26 } 27 28 29 protected class CommitButtonClickHandler implements ClickHandler { 30 private GdlCommitButton owner = null; 31 32 public CommitButtonClickHandler(GdlCommitButton owner){ 33 this.owner = owner; 34 } 35 36 37 @Override 38 public void onClick(ClickEvent event) { 39 try{ 40 this.owner.getGdlParent().getContent(null); 41 42 // TODO: implement 43 }catch(Exception e){ 44 e.printStackTrace(); 45 Window.alert("caught: " + e.getMessage()); 46 } 47 } 21 48 } 22 49 } -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlAssociationView.java ¶
r801 r809 198 198 } 199 199 200 // TODO: process hidden values 201 200 202 return result; 201 203 } -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlTopicView.java ¶
r801 r809 6 6 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Construct; 7 7 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.Topic; 8 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMap;9 8 import us.isidor.gdl.anaToMia.TopicMaps.TopicMapsModel.TopicMapsTypes; 10 9 import us.isidor.gdl.anaToMia.Widgets.base.ButtonableObject; … … 18 17 19 18 public abstract class GdlTopicView extends GdlView { 19 protected Topic representedTopic = null; 20 20 21 21 22 public GdlTopicView(Topic tmRepresentative, Topic receivedData, GdlVisibleObject gdlParent) throws InvalidGdlSchemaException, ExecutionException{ … … 80 81 81 82 Topic localCarrier = (Topic)this.receivedData; 82 if(localCarrier == null){ 83 TopicMap tm = this.tmRepresentative.getTopicMap(); 84 localCarrier = tm.createTopicBySubjectIdentifier(tm.createLocator(this.getId())); 85 } 83 if(localCarrier == null) localCarrier = this.getRepresentedTopic(); 86 84 87 85 for (Widget ctrl : this.subElements) { … … 94 92 } 95 93 94 // TODO: process hidden values 95 96 96 return result; 97 97 } 98 99 100 public Topic getRepresentedTopic(){ 101 if(this.receivedData ==null){ 102 if(this.representedTopic == null){ 103 this.representedTopic = this.tmRepresentative.getTopicMap().createTopic(); 104 return this.representedTopic; 105 } else { 106 return this.representedTopic; 107 } 108 } else { 109 return (Topic)this.receivedData; 110 } 111 } 98 112 } -
TabularUnified branches/gdl-frontend/src/anaToMia/GDL_Widgets/src/us/isidor/gdl/anaToMia/Widgets/view/GdlView.java ¶
r800 r809 20 20 21 21 public abstract class GdlView extends GdlVisibleObject implements IGdlContainer { 22 protected boolean hiddenValuesSet = false; 23 protected ArrayList<Topic> hiddenValues = new ArrayList<Topic>(); 24 25 22 26 protected GdlView(){ 23 27 super(); … … 110 114 return TmHelper.topicContains(this.tmRepresentative); 111 115 } 116 117 118 // returns all hidden values that are bound to this view 119 public ArrayList<Topic> getHiddenValues() throws InvalidGdlSchemaException { 120 if(this.hiddenValuesSet) { 121 return this.hiddenValues; 122 } else { 123 this.hiddenValuesSet = true; 124 this.hiddenValues = TmHelper.getHiddenValueOf(this.tmRepresentative); 125 return this.hiddenValues; 126 } 127 } 112 128 }
Note: See TracChangeset
for help on using the changeset viewer.