private void doDelete(EventRequest request, HighlightSelectionHTML _to_delete) { ArrayList<HighlightSelectionHTML> _hightlights = (ArrayList<HighlightSelectionHTML>) request.getPortletSession().getAttribute("highlights"); if (_hightlights != null && _hightlights.size() > 0) { // System.out.println("[PortletWebBrowser.doDelete] _to_delete : " + _to_delete + " selection // : " + _to_delete.getSelection() + " id : " + _to_delete.getId()); for (HighlightSelectionHTML highlight : _hightlights) { // System.out.println("[PortletWebBrowser.doDelete] highlight : " + highlight + " selection // : " + highlight.getSelection()+ " id : " + highlight.getId()); if (highlight.getId().compareTo(_to_delete.getId()) == 0) { _hightlights.remove(highlight); request.getPortletSession().setAttribute("highlights", _hightlights); return; } } } System.out.println("[PortletWebBrowser.doDelete] don't find _to_delete : " + _to_delete); }
public void processEvent(EventRequest request, EventResponse response) { Event event = request.getEvent(); String event_name = event.getName(); // System.out.println("[PortletWebBrowser.processEvent] event : " + event.getName()); if (event_name.equals("tohighlight")) { Object _highlight_event = event.getValue(); // Récupérer la collection de highlights if (_highlight_event instanceof HighlightSelectionHTML) { ArrayList<HighlightSelectionHTML> _hightlights = (ArrayList<HighlightSelectionHTML>) request.getPortletSession().getAttribute("highlights"); if (_hightlights == null) _hightlights = new ArrayList<HighlightSelectionHTML>(); _hightlights.add((HighlightSelectionHTML) _highlight_event); request.getPortletSession().setAttribute("highlights", _hightlights); } } if (event_name.equals("todelete")) { // System.out.println("[PortletWebBrowser.processEvent] event to delete"); if (event.getValue() instanceof HighlightSelectionHTML) doDelete(request, (HighlightSelectionHTML) event.getValue()); } if (event_name.equals("toLoadUrl")) { if (event.getValue() instanceof String) { String url = (String) event.getValue(); if (url.startsWith("http://")) { request.getPortletSession().setAttribute("current_url", url); // response.setRenderParameter("url", url.toLowerCase()); request.getPortletSession().removeAttribute("highlights"); request.removeAttribute("highlights"); // gestion de la consultation if (request.getPortletSession().getAttribute("consult_url") != null) // si une consultation a déjà commencé { if (!url.equalsIgnoreCase( (String) request .getPortletSession() .getAttribute("consult_url"))) // si on change de page à consulter { if (request.getPortletSession().getAttribute("user") != null) { // creates consultation // URI uri = // CREATOR_URI.createAndGetURI((String)request.getPortletSession().getAttribute("consult_url")); // CREATOR_CONSULTATION.createsConsultation((UserAccount)request.getPortletSession().getAttribute("user"), (Date)request.getPortletSession().getAttribute("start_consult") , new Date(), uri, "[PortletWebBrowse]"); URI uri = daoResource.createAndGetURI( (String) request.getPortletSession().getAttribute("consult_url")); daoConsultation.createsConsultation( (UserAccount) request.getPortletSession().getAttribute("user"), (Date) request.getPortletSession().getAttribute("start_consult"), new Date(), uri, "[PortletWebBrowse]"); } request.getPortletSession().setAttribute("consult_url", url); request.getPortletSession().setAttribute("start_consult", new Date()); } } else // si c'est la première consultation { request.getPortletSession().setAttribute("consult_url", url); request.getPortletSession().setAttribute("start_consult", new Date()); } } } } if (event_name.equalsIgnoreCase("UserLog")) { if (event.getValue() instanceof UserAccount) { UserAccount _current_user = (UserAccount) event.getValue(); if (_current_user.getId() != null) request.getPortletSession().setAttribute("user", _current_user); } } if (event_name.equalsIgnoreCase("UserUnLog")) { request.getPortletSession().removeAttribute("user"); } }