1 package org.nextime.ion.backoffice.action.content; 2 3 import java.io.IOException ; 4 import java.util.Hashtable ; 5 import java.util.Vector ; 6 7 import javax.servlet.ServletException ; 8 import javax.servlet.http.HttpServletRequest ; 9 import javax.servlet.http.HttpServletResponse ; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionForward; 12 import org.apache.struts.action.ActionMapping; 13 import org.nextime.ion.backoffice.action.BaseAction; 14 15 import org.nextime.ion.framework.business.Publication; 16 import org.nextime.ion.framework.business.Section; 17 import org.nextime.ion.framework.mapping.Mapping; 18 import org.nextime.ion.backoffice.tree.TreeControl; 19 import org.nextime.ion.backoffice.tree.TreeControlNode; 20 import org.nextime.ion.commons.PublicationSorter; 21 22 public class HighlightAction extends BaseAction { 23 24 public ActionForward perform( 25 ActionMapping mapping, 26 ActionForm form, 27 HttpServletRequest request, 28 HttpServletResponse response) 29 throws IOException , ServletException { 30 31 checkUser(request); 33 34 String id = request.getParameter("id"); 35 36 try { 37 38 Mapping.begin(); 39 40 Publication p = Publication.getInstance(id); 41 Section section = (Section) p.listSections().firstElement(); 42 43 TreeControl control = 45 (TreeControl) request.getSession().getAttribute( 46 "treeControlTest"); 47 collapse(control.getRoot()); 48 49 control.selectNode(section.getId()); 50 51 while (section != null) { 53 TreeControlNode node = control.findNode(section.getId()); 54 node.setExpanded(true); 55 section = section.getParent(); 56 } 57 58 section = (Section) p.listSections().firstElement(); 60 Vector ps = PublicationSorter.sortPublications(section); 61 int pos = ps.indexOf(p); 62 int page = pos / ViewSectionAction.pageSize; 63 ((Hashtable ) (request.getSession().getAttribute("pageInfos"))).put( 64 section.getId(), 65 new Integer (page * ViewSectionAction.pageSize)); 66 67 } catch (Exception e) { 68 e.printStackTrace(); 69 } finally { 70 Mapping.rollback(); 71 } 72 73 request.getSession().setAttribute("highlightId", id); 74 75 return (mapping.findForward("ok")); 77 78 } 79 80 private void collapse(TreeControlNode n) { 81 for (int i = 0; i < n.findChildren().length; i++) { 82 n.findChildren()[i].setExpanded(false); 83 collapse(n.findChildren()[i]); 84 } 85 } 86 87 } 88 | Popular Tags |