⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aggregatedlayoutmanager.java

📁 uPortal是开放源码的Portal门户产品
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	  if ( value < tmpPriority && value >= nextRange[0] ) {		nextNode.setPriority(value);		tmpPriority = value;	  } else		  return false;	  nextId = nextNode.getNextNodeId();	}	     return true;  	  }	  /**		 * Change if it's possible priority values for all the sibling nodes defined by the collection		 * @param nodes a <code>Vector</code> instance with ALNode objects		 * @return a boolean value		 * @exception PortalException if an error occurs		 */	protected boolean changeSiblingNodesPriorities( Vector nodes ) throws PortalException {         	  int tmpPriority = Integer.MAX_VALUE;	  // Fill out the vector by priority values	  int size = nodes.size();	  for ( int i = 0; i < size; i++ ) {		ALNode nextNode = (ALNode) nodes.get(i);		if ( nextNode == null ) return false;		int[] nextRange = getPriorityRestriction(nextNode).getRange();		int value = Math.min(nextRange[1],tmpPriority-1);		if ( value < tmpPriority && value >= nextRange[0] ) {		  nextNode.setPriority(value);		  tmpPriority = value;		} else			return false;	  }	  	   return true;  	   }	     /** 	   * Change priority values for all the sibling nodes when trying to add a new node	   * @param node a <code>ALNode</code> a node to be added	   * @param parentNodeId a <code>String</code> parent node ID	   * @param nextNodeId a <code>String</code> next sibling node ID	   * @return a boolean value	   * @exception PortalException if an error occurs	   */	protected synchronized boolean changeSiblingNodesPriorities(ALNode node, String parentNodeId, String nextNodeId ) throws PortalException {		ALNode firstNode = null, nextNode = null;			String firstNodeId = null;			int priority = 0, nextPriority = 0, prevPriority = 0, range[] = null, prevRange[] = null, nextRange[] = null;			PriorityRestriction priorityRestriction = null;			String nodeId = node.getId();			ALFolder parent = getLayoutFolder(parentNodeId);			if ( parentNodeId != null ) {				firstNodeId = parent.getFirstChildNodeId();				// if the node is equal the first node in the sibling line we get the next node				if ( nodeId.equals(firstNodeId) )					firstNodeId = node.getNextNodeId();				if ( firstNodeId == null ) return true;			} else				 return false;			firstNode = getLayoutNode(firstNodeId);			if ( nextNodeId != null ) {			  nextNode = getLayoutNode(nextNodeId);			  nextPriority = nextNode.getPriority();			  priorityRestriction = getPriorityRestriction(nextNode);			  nextRange = priorityRestriction.getRange();			}			priority = node.getPriority();			priorityRestriction = getPriorityRestriction(node);			range = priorityRestriction.getRange();			// If we add a new node to the beginning of the sibling line			if ( firstNodeId.equals(nextNodeId) ) {			  if ( range[1] <= nextRange[0] ) return false;			  if ( priority > nextPriority ) return true;			  if ( range[1] > nextPriority ) {				   node.setPriority(range[1]);				   return true;			  }			  if ( (nextPriority+1) <= range[1] && (nextPriority+1) >= range[0] ) {					 node.setPriority(nextPriority+1);					 return true;			  }			}			// If we add a new node to the end of the sibling line			if ( nextNode == null ) {			  // Getting the last node			  ALNode lastNode = getLastSiblingNode(firstNodeId);			  int lastPriority = lastNode.getPriority();			  PriorityRestriction lastPriorityRestriction = getPriorityRestriction(lastNode);			  int[] lastRange = lastPriorityRestriction.getRange();			  if ( range[0] >= lastRange[1] ) return false;			  if ( priority < lastPriority )  return true;			  if ( range[0] < lastPriority ) {				   node.setPriority(range[0]);				   return true;			  }			  if ( (lastPriority-1) <= range[1] && (lastPriority-1) >= range[0] ) {					 node.setPriority(range[0]);					 return true;			  }			}			// If we add a new node in a general case			if ( nextNode != null && !nextNode.equals(firstNode) && !nodeId.equals(nextNodeId) ) {			  // Getting the last node			  ALNode prevNode = getLayoutNode(nextNode.getPreviousNodeId());			  prevPriority = prevNode.getPriority();			  PriorityRestriction lastPriorityRestriction = getPriorityRestriction(prevNode);			  prevRange = lastPriorityRestriction.getRange();			  if ( range[1] <= nextRange[0] || range[0] >= prevRange[1] ) return false;			  if ( priority < prevPriority && priority > nextPriority ) return true;			  int maxPossibleLowValue = Math.max(range[0],nextPriority+1);			  int minPossibleHighValue = Math.min(range[1],prevPriority-1);			  if ( minPossibleHighValue >= maxPossibleLowValue ) {				   node.setPriority(minPossibleHighValue);				   return true;			  }			}	 	  Vector nodes = new Vector();	  for ( String nextId = firstNodeId; nextId != null; ) {	  	if ( !nextId.equals(nodeId) ) {		  if ( nextId.equals(nextNodeId) )		   nodes.add(node);		   nodes.add(getLayoutNode(nextId));	  	}   		  nextId = getLayoutNode(nextId).getNextNodeId();  	  }    	  if ( nextNodeId == null )	   nodes.add(node);   	  return changeSiblingNodesPriorities(nodes); 	}  /**     * Change the sibling nodes order depending on their priority values     * @param firstNodeId a <code>String</code> first node ID in the sibling line     * @return a boolean value     * @exception PortalException if an error occurs     */  protected boolean changeSiblingNodesOrder(String firstNodeId) throws PortalException {    if ( firstNodeId == null )      throw new PortalException ( "The first node ID in the sibling line cannot be NULL!" );    ALNode firstNode = getLayoutNode(firstNodeId);    String parentNodeId = firstNode.getParentNodeId();    boolean rightOrder = true;    ALNode node = null;    for ( String nextNodeId = firstNodeId; nextNodeId != null; ) {      node = getLayoutNode(nextNodeId);      nextNodeId = node.getNextNodeId();      if ( nextNodeId != null ) {       ALNode nextNode = getLayoutNode(nextNodeId);       if ( node.getPriority() <= nextNode.getPriority() ) {           rightOrder = false;           break;       }      }    }    if ( rightOrder ) return true;    // Check if the current order is right    if ( changeSiblingNodesPriorities(firstNodeId) ) return true;         Set movedNodes = new HashSet();     //	Choosing more suitable order of the nodes in the sibling line     for ( String lastNodeId = getLastSiblingNode(firstNodeId).getId(); lastNodeId != null; ) {       	   for ( String curNodeId = lastNodeId; curNodeId != null; ) {		if ( !lastNodeId.equals(curNodeId) && !movedNodes.contains(lastNodeId) ) {		 if ( moveNode(lastNodeId,parentNodeId,curNodeId) ) {		  if ( changeSiblingNodesPriorities(getLayoutFolder(parentNodeId).getFirstChildNodeId()) ) 			   return true;		  movedNodes.add(lastNodeId);	 		  lastNodeId = getLastSiblingNode(curNodeId).getId();		  curNodeId = lastNodeId;		 }  		}		curNodeId = getLayoutNode(curNodeId).getPreviousNodeId();			  }	   	  if ( !movedNodes.contains(lastNodeId) ) {			if ( moveNode(lastNodeId,parentNodeId,null) ) {		 if ( changeSiblingNodesPriorities(getLayoutFolder(parentNodeId).getFirstChildNodeId()) ) 				return true;			  movedNodes.add(lastNodeId);			}	  }  	   	  lastNodeId = getLayoutNode(lastNodeId).getPreviousNodeId();	 }		  	         return false;          }   /**     * Return a cache key, uniqly corresponding to the composition and the structure of the user layout.     *     * @return a <code>String</code> value     * @exception PortalException if an error occurs     */  public String getCacheKey() throws PortalException {      return cacheKey;  }  /**     * Output a tree of a user layout (with appropriate markings) defined by a particular node into     * a <code>ContentHandler</code>     * @param contentHandler a <code>ContentHandler</code> value     * @exception PortalException if an error occurs     */  public void getUserLayout(ContentHandler contentHandler) throws PortalException {    layout.writeTo(contentHandler);  }  /**     * Output subtree of a user layout (with appropriate markings) defined by a particular node into     * a <code>ContentHandler</code>     *     * @param nodeId a <code>String</code> a node determining a user layout subtree.     * @param contentHandler a <code>ContentHandler</code> value     * @exception PortalException if an error occurs     */  public void getUserLayout(String nodeId, ContentHandler contentHandler) throws PortalException {     layout.writeTo(nodeId,contentHandler);  }    private ALNode getLayoutNode(String nodeId) {     return layout.getLayoutNode(nodeId);    }    private ALFolder getLayoutFolder(String folderId) {     return layout.getLayoutFolder(folderId);    }    private ALNode getLastSiblingNode ( String nodeId ) {     return layout.getLastSiblingNode(nodeId);    }    private ALNode getFirstSiblingNode ( String nodeId ) {     return layout.getFirstSiblingNode(nodeId);    }    public Document getUserLayoutDOM() throws PortalException {      Document document = DocumentFactory.getNewDocument();      layout.writeTo(document);      return document;    }    private void setUserLayoutDOM( Node n, String parentNodeId, Hashtable layoutData ) throws PortalException {      Element node = (Element) n;      NodeList childNodes = node.getChildNodes();      IALNodeDescription nodeDesc = ALNode.createUserLayoutNodeDescription(node);      String nodeId = node.getAttribute("ID");      nodeDesc.setId(nodeId);      nodeDesc.setName(node.getAttribute("name"));      nodeDesc.setFragmentId(node.getAttribute("fragmentID"));      nodeDesc.setHidden(CommonUtils.strToBool(node.getAttribute("hidden")));      nodeDesc.setImmutable(CommonUtils.strToBool(node.getAttribute("immutable")));      nodeDesc.setUnremovable(CommonUtils.strToBool(node.getAttribute("unremovable")));      nodeDesc.setHidden(CommonUtils.strToBool(node.getAttribute("hidden")));      ALNode layoutNode = null;      IALChannelDescription channelDesc = null;      if (nodeDesc instanceof IALChannelDescription)          channelDesc = (IALChannelDescription) nodeDesc;        // Getting parameters and restrictions        for ( int i = 0; i < childNodes.getLength(); i++ ) {          Element childNode = (Element)childNodes.item(i);          String nodeName = childNode.getNodeName();          if ( IAggregatedLayout.PARAMETER.equals(nodeName) && channelDesc != null ) {           String paramName = childNode.getAttribute("name");           String paramValue = childNode.getAttribute("value");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -