Changeset 1295
- Timestamp:
- 07/07/08 22:42:02 (4 years ago)
- Location:
- trunk/Rapla/src/org/rapla/gui/internal
- Files:
-
- 2 modified
-
MenuFactoryImpl.java (modified) (3 diffs)
-
action/RaplaObjectAction.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Rapla/src/org/rapla/gui/internal/MenuFactoryImpl.java
r1189 r1295 84 84 Object focusedObject = context.getFocusedObject(); 85 85 Point p = context.getPoint(); 86 87 88 89 boolean allocatableType = false; 90 boolean reservationType = false; 91 if ( focusedObject instanceof DynamicType) 92 { 93 DynamicType type = (DynamicType) focusedObject; 94 String classificationType = type.getAnnotation( DynamicTypeAnnotations.KEY_CLASSIFICATION_TYPE ); 95 allocatableType = classificationType.equals( DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION ) || classificationType.equals( DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION ); 96 reservationType = classificationType.equals( DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION ); 97 } 98 boolean allocatableNodeContext = allocatableType || focusedObject instanceof Allocatable || focusedObject == CalendarSelectionModel.ALLOCATABLES_ROOT; 86 99 if ( isRegisterer() || isAdmin()) { 87 menu.addSeparator(); 88 addAllocatableMenuNew( menu, parent,p, focusedObject); 89 } 100 if ( allocatableNodeContext) 101 { 102 menu.addSeparator(); 103 addAllocatableMenuNew( menu, parent,p, focusedObject); 104 } 105 } 106 boolean reservationNodeContext = reservationType || (focusedObject!= null && focusedObject.equals( getString("reservations" ))); 90 107 if ( isAdmin() ) 91 108 { 92 menu.addSeparator(); 93 addUserMenuNew( menu , parent, p, focusedObject); 94 addPeriodMenuNew( menu , parent, p, focusedObject ); 95 } 96 97 addTypeMenuNew(menu, parent, p, focusedObject); 109 boolean userNodeContext = focusedObject instanceof User || (focusedObject != null && focusedObject.equals( getString("users"))); 110 boolean periodNodeContext = focusedObject instanceof Period || (focusedObject != null && focusedObject.equals( getString("periods"))); 111 if (userNodeContext || periodNodeContext || allocatableNodeContext || reservationNodeContext) 112 { 113 menu.addSeparator(); 114 } 115 if ( userNodeContext) 116 { 117 addUserMenuNew( menu , parent, p, focusedObject); 118 } 119 if ( periodNodeContext) 120 { 121 addPeriodMenuNew( menu , parent, p, focusedObject ); 122 } 123 if (allocatableNodeContext) 124 { 125 addTypeMenuNew(menu, DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION 126 ,parent, p, focusedObject); 127 addTypeMenuNew(menu, DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION 128 ,parent, p, focusedObject); 129 130 } 131 if ( reservationNodeContext) 132 { 133 addTypeMenuNew(menu, DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION 134 ,parent, p, focusedObject); 135 } 136 } 98 137 99 138 return menu; … … 191 230 RaplaObjectAction newResource = addAction(menu,parent,p).setNew( Allocatable.TYPE ); 192 231 newResource.changeObject( obj ); 193 newResource.putValue(Action.NAME,getString("resource")); 232 DynamicType[] types = newResource.guessTypes(); 233 if (types.length == 1) 234 { 235 DynamicType type = types[0]; 236 newResource.putValue(Action.NAME,type.getName( getLocale() )); 237 return; 238 } 239 DynamicType[] resourceType= getQuery().getDynamicTypes(DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION ); 240 if ( resourceType.length == 1) 241 { 242 newResource.putValue(Action.NAME,resourceType[0].getName( getLocale() )); 243 } 244 else 245 { 246 newResource.putValue(Action.NAME,getString("resource")); 247 } 194 248 195 249 RaplaObjectAction newPerson = addAction(menu,parent,p).setNew( Allocatable.TYPE ); 196 250 newPerson.setPerson( true ); 197 251 newPerson.changeObject( obj ); 198 newPerson.putValue(Action.NAME,getString("person")); 252 DynamicType[] personType= getQuery().getDynamicTypes(DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION ); 253 if ( personType.length == 1) 254 { 255 newPerson.putValue(Action.NAME,personType[0].getName( getLocale())); 256 } 257 else 258 { 259 newPerson.putValue(Action.NAME,getString("person")); 260 } 199 261 200 262 } … … 209 271 210 272 211 private void addTypeMenuNew(MenuInterface menu,Component parent,Point p,Object obj) throws RaplaException { 212 if ( isAdmin() ) { 213 menu.addSeparator(); 214 215 DynamicTypeAction newResourceType = newDynamicTypeAction(parent,p); 216 menu.add(new JMenuItem(newResourceType)); 217 newResourceType.setNewClassificationType( DynamicTypeAnnotations.VALUE_RESOURCE_CLASSIFICATION); 218 newResourceType.putValue(Action.NAME,getString("resource_type")); 219 220 DynamicTypeAction newPersonType = newDynamicTypeAction(parent,p); 221 menu.add(new JMenuItem(newPersonType)); 222 newPersonType.setNewClassificationType(DynamicTypeAnnotations.VALUE_PERSON_CLASSIFICATION); 223 newPersonType.putValue(Action.NAME,getString("person_type")); 224 273 private void addTypeMenuNew(MenuInterface menu,String classificationType,Component parent,Point p,Object obj) throws RaplaException { 225 274 DynamicTypeAction newReservationType = newDynamicTypeAction(parent,p); 226 275 menu.add(new JMenuItem(newReservationType)); 227 newReservationType.setNewClassificationType(DynamicTypeAnnotations.VALUE_RESERVATION_CLASSIFICATION); 228 newReservationType.putValue(Action.NAME,getString("reservation_type")); 229 } 276 newReservationType.setNewClassificationType(classificationType); 277 newReservationType.putValue(Action.NAME,getString(classificationType + "_type")); 230 278 } 231 279 -
trunk/Rapla/src/org/rapla/gui/internal/action/RaplaObjectAction.java
r1091 r1295 190 190 */ 191 191 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 { 192 204 DynamicType dynamicType = null; 193 205 getLogger().debug("Guessing DynamicType from " + object); … … 199 211 dynamicType = classification.getType(); 200 212 } 213 if (dynamicType != null) 214 { 215 return new DynamicType[] {dynamicType}; 216 } 201 217 String classificationType = null; 202 218 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 } 210 226 } 211 227 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 221 230 } 222 231
![(please configure the [header_logo] section in trac.ini)](/chrome/site/rapla.jpg)