// is already selected
if (selectedEntityList.contains(entity) == true) {
// OWL issue #177: send an empty context event to ensure that
// any visible context menus are hidden in this case
MouseEvent mouseEvent = (MouseEvent) ((MouseEvent3D) event).getAwtEvent();
inputManager.postEvent(new ContextEvent(new LinkedList(), mouseEvent));
return;
}
// Clear out the list, add the new Entity and fire an event
selectedEntityList.clear();
selectedEntityList.add(entity);
inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
return;
}
else if (policy.isMultiSelection(event) == true) {
// If the Entity is already selected, then remove it from the
// selection list. If not already present, then add it
// Reset the selection possible. If the entity is not selected,
// then select it (only). If the entity is selected, then do
// nothing (if it is part of a group of selected entities)
if (selectedEntityList.contains(entity) == false) {
selectedEntityList.add(entity);
}
else {
selectedEntityList.remove(entity);
}
inputManager.postEvent(new SelectionEvent(new LinkedList(selectedEntityList)));
return;
}
else if (policy.isEnter(event) == true) {
enterEntity = entity;
inputManager.postEvent(new EnterExitEvent(entity, true));
}
else if (policy.isExit(event) == true) {
Entity eventEntity = enterEntity;
enterEntity = null;
inputManager.postEvent(new EnterExitEvent(eventEntity, false));
}
else if (policy.isActivation(event) == true) {
inputManager.postEvent(new ActivatedEvent(entity));
}
else if (policy.isContext(event) == true) {
// We use the context event to clear the selected entity list first
selectedEntityList.clear();
// If there is an entity for the mouse event, then add the entity to
// the list and pass a Selection event too.
if (entity != null) {
selectedEntityList.add(entity);
LinkedList entityList = new LinkedList(selectedEntityList);
inputManager.postEvent(new SelectionEvent(entityList));
}
// Pass the mouse event for now so we know where the event was
// fired. We sent this even if the entity is null, so the context
// menu can be cleared.
LinkedList entityList = new LinkedList(selectedEntityList);
MouseEvent mouseEvent = (MouseEvent) ((MouseEvent3D) event).getAwtEvent();
inputManager.postEvent(new ContextEvent(entityList, mouseEvent));
}
}