Ignore:
Timestamp:
06/28/11 21:31:22 (13 years ago)
Author:
wschamai
Message:

label provider update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.view.componentstree/src/org/openmodelica/modelicaml/view/componentstree/display/ViewLabelProvider.java

    r855 r860  
    5252import org.eclipse.ui.ISharedImages;
    5353import org.eclipse.ui.PlatformUI;
     54import org.eclipse.uml2.uml.Element;
    5455import org.eclipse.uml2.uml.Port;
     56import org.eclipse.uml2.uml.PrimitiveType;
    5557import org.eclipse.uml2.uml.Property;
    5658import org.eclipse.uml2.uml.Region;
     
    381383    public boolean hasErrors(TreeParent treeParent) {
    382384        HashSet<TreeObject> list = new HashSet<TreeObject>();
    383         list.addAll(findNextInvalidItem(treeParent));
     385        list.addAll(findNextInvalidItem(treeParent, false));
    384386        if (list.size() > 0 ) {
    385387//          for (TreeObject treeObject : list) {
     
    392394   
    393395   
    394     private HashSet<TreeObject> findNextInvalidItem(TreeParent treeParent){
     396    private HashSet<TreeObject> findNextInvalidItem(TreeParent treeParent, boolean parentIsInput){
    395397        HashSet<TreeObject> list = new HashSet<TreeObject>();
     398        boolean parentIsAnInput = false;
    396399       
    397         // if property has no type
     400        // if property has no type -> indicate error
    398401        if (treeParent.getUmlElement() instanceof Property && treeParent.getComponentType() == null) {
    399402            list.add(treeParent);
     403           
     404            // stop searching here
    400405            return list;
     406        }
     407       
     408        Element umlElement = treeParent.getUmlElement();
     409       
     410        // if one of the parents is input
     411        if ( parentIsInput ) {
     412            if (umlElement != null ) {
     413                // if it is a primitive type -> indicate an error
     414                if ( ((Property)umlElement).getType() instanceof PrimitiveType
     415                        && (treeParent.getDeclaration() == null && treeParent.getFinalModificationRightHand() == null)) {
     416                    list.add(treeParent);
     417                }
     418            }
    401419        }
    402420       
    403421        // if property is input and has no declaration and no binding equation exists for it in its first level component modification
    404422        if (treeParent.isInput() && treeParent.getDeclaration() == null && treeParent.getFinalModificationRightHand() == null) {
    405             // TODO: check if the item is a component of a port that has causality input ...
    406             if (treeParent.getUmlElement() != null && !(treeParent.getUmlElement() instanceof Port)) {
    407                 list.add(treeParent);
    408             }
    409             return list;
    410         }
    411 
     423           
     424            if (umlElement != null ) {
     425               
     426                // check if the item is a component of a port that has causality input ...
     427                if (umlElement instanceof Property  && !(umlElement instanceof Port) ) {
     428
     429                    // if it is a primitive type -> indicate an error
     430                    if ( ((Property)umlElement).getType() instanceof PrimitiveType) {
     431                        list.add(treeParent);
     432                       
     433                        // stop here
     434                        return list;
     435                    }
     436                    // not of primitive type -> remember that this parent was an input in order to check its children
     437                    else {
     438
     439//                      System.err.println(treeParent.getDotPath() + " parentIsInput: " + parentIsInput);
     440                        parentIsAnInput = true;
     441                    }
     442                }
     443            }
     444//          // stop here
     445//          return list;
     446        }
     447
     448        // go on with search ...
    412449        TreeObject[] children = treeParent.getChildren();
    413450        for (int i = 0; i < children.length; i++) {
    414451            if (children[i] instanceof TreeParent) {
    415                 list.addAll(findNextInvalidItem( (TreeParent)children[i] ));   
     452                list.addAll(findNextInvalidItem( (TreeParent)children[i] , parentIsAnInput));   
    416453            }
    417454        }
Note: See TracChangeset for help on using the changeset viewer.