Show
Ignore:
Timestamp:
07/07/08 22:42:02 (4 years ago)
Author:
kohlhaas
Message:

* The new x (reservation, resource, person, user, period, ...) entries in the popup menu are now context sensitive. You can now only create new
objects that make sense in the selected tree node, that means you can only create a new user if you are in the user section of the tree.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Rapla/src/org/rapla/gui/internal/action/RaplaObjectAction.java

    r1091 r1295  
    190190    */ 
    191191    public DynamicType guessType() throws RaplaException { 
     192        DynamicType[] types = guessTypes(); 
     193        if ( types.length > 0) 
     194        { 
     195            return types[0]; 
     196        } 
     197        else 
     198        { 
     199            return null; 
     200        } 
     201    } 
     202     
     203    public DynamicType[] guessTypes() throws RaplaException { 
    192204        DynamicType dynamicType = null; 
    193205        getLogger().debug("Guessing DynamicType from " + object); 
     
    199211            dynamicType = classification.getType(); 
    200212        } 
     213        if (dynamicType != null) 
     214        { 
     215            return new DynamicType[] {dynamicType}; 
     216        } 
    201217        String classificationType = null; 
    202218        if ( Reservation.TYPE.is( raplaType )) { 
    203                 classificationType = DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION; 
    204         } else  if ( Allocatable.TYPE.is( raplaType )) { 
    205                 if ( isPerson ) { 
    206                         classificationType = DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION; 
    207                 } else { 
    208                         classificationType = DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION; 
    209                 } 
     219            classificationType = DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION; 
     220        } else  if ( Allocatable.TYPE.is( raplaType )) { 
     221            if ( isPerson ) { 
     222                classificationType = DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION; 
     223            } else { 
     224                classificationType = DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION; 
     225            } 
    210226        } 
    211227        DynamicType[] dynamicTypes = getQuery().getDynamicTypes( classificationType ); 
    212         if ( dynamicType != null ) 
    213         { 
    214             for (int i=0; i < dynamicTypes.length ; i++) 
    215              { 
    216                  if (dynamicTypes[i].equals(dynamicType)) 
    217                      return dynamicType; 
    218              } 
    219         } 
    220         return dynamicTypes[0]; 
     228        return dynamicTypes; 
     229       
    221230    } 
    222231