protected void handlePopup(final MouseEvent e) {
if (e.isPopupTrigger()) {
Component popup = null;
final Component popupForModel;
final MapView mapView = (MapView) Controller.getCurrentController().getMapViewManager().getMapViewComponent();
final ModeController modeController = Controller.getCurrentController().getModeController();
if(mapView != null){
final java.lang.Object obj = mapView.detectCollision(e.getPoint());
popupForModel= LinkController.getController(modeController).getPopupForModel(obj);
}
else{
popupForModel = null;
}
if (popupForModel != null) {
final ControllerPopupMenuListener popupListener = new ControllerPopupMenuListener();
popupForModel.addHierarchyListener(popupListener);
popup = popupForModel;
}
else {
popup = modeController.getUserInputListenerFactory().getMapPopup();
}
Component component = e.getComponent();
if(popup instanceof JPopupMenu) {
((JPopupMenu)popup).show(component, e.getX(), e.getY());
}