| | 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; |
| 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 | } |
| 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 | } |
| 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 { |