📄 xmlportlets.java
字号:
getParameterValue(portletNode, "title"), getParameterValue(portletNode, "icon_url"), getParameterValue(portletNode, "bgcolor"), getParameterValue(portletNode, "bgimage_url"), getParameterValue(portletNode, "font"), getParameterValue(portletNode, "fontsize"), getParameterValue(portletNode, "fontcolor"), Integer.parseInt(getParameterValue(portletNode, "skin_id")), Integer.parseInt(getParameterValue(portletNode, "scrollable")), Integer.parseInt(getParameterValue(portletNode, "resizable")), Integer.parseInt(getParameterValue(portletNode, "fixed")), Integer.parseInt(getParameterValue(portletNode, "innerspace")), Integer.parseInt(getParameterValue(portletNode, "x")), Integer.parseInt(getParameterValue(portletNode, "y")), Integer.parseInt(getParameterValue(portletNode, "w")), Integer.parseInt(getParameterValue(portletNode, "h")))); } portletNode = portletNode.getNextSibling(); } } } portletgroupNode = portletgroupNode.getNextSibling(); } } catch (NumberFormatException n) { throw new JahiaException(ERROR_READING_PLML_FILE_MSG, "Invalid Integer !!!", JahiaException.CRITICAL, JahiaException.CONFIG_ERROR); } if (!isPortletGroupNode) { addPortletGroup(); getPortletList(); } return thePortletList; } // end getPortletList() //-------------------------------------------------------------------------- /** * Retrieves a list of portlet settings for the specified column * * @author Jerome Bedat * */ public Vector getPortletListFromColumn(int theColumn) throws JahiaException { thePortletList = new Vector(); boolean isPortletGroupNode = false; portletgroupNode = plmlNode.getFirstChild(); try { while (portletgroupNode != null) { if (portletgroupNode.getNodeType() == Node.ELEMENT_NODE && portletgroupNode.getNodeName().equalsIgnoreCase(PORTLETLIST_TAG)) { if (Integer.parseInt(getParameterValue(portletgroupNode, "page_id")) == thePageID) { isPortletGroupNode = true; Node portletNode = portletgroupNode.getFirstChild(); int RowSpace = 0; int RowCounter = 1; int MaxRow = 0; while (portletNode != null) { // we are going through the portletgroup tags which represent list of portlets if (portletNode.getNodeType() == Node.ELEMENT_NODE && portletNode.getNodeName().equalsIgnoreCase(PORTLET_TAG)) { // we are now on a PORTLET tag if (Integer.parseInt(getParameterValue(portletNode, "column_position")) == theColumn) { if (Integer.parseInt(getParameterValue(portletNode, "row_position")) == RowCounter) { paramAttrNode = getAttributeValue(portletNode, PARAMETER_TAG_ID_ATTRIBUTE); thePortletList.addElement(new PortletObj(Integer.parseInt(paramAttrNode), Integer.parseInt(getParameterValue(portletNode, "source_id")), Integer.parseInt(getParameterValue(portletNode, "active")), getParameterValue(portletNode, "title"), getParameterValue(portletNode, "icon_url"), getParameterValue(portletNode, "bgcolor"), getParameterValue(portletNode, "bgimage_url"), getParameterValue(portletNode, "font"), getParameterValue(portletNode, "fontsize"), getParameterValue(portletNode, "fontcolor"), Integer.parseInt(getParameterValue(portletNode, "innerspace")), Integer.parseInt(getParameterValue(portletNode, "column_position")), Integer.parseInt(getParameterValue(portletNode, "row_position")))); RowCounter++; } if (Integer.parseInt(getParameterValue(portletNode, "row_position")) > MaxRow) { MaxRow = Integer.parseInt(getParameterValue(portletNode, "row_position")); } } } if (portletNode.getNextSibling() == null && MaxRow >= RowCounter) { portletNode = portletgroupNode.getFirstChild(); if (RowSpace == RowCounter) { RowCounter++; } RowSpace = RowCounter; } else { portletNode = portletNode.getNextSibling(); } } } } portletgroupNode = portletgroupNode.getNextSibling(); } } catch (NumberFormatException n) { throw new JahiaException(ERROR_READING_PLML_FILE_MSG, "Invalid Integer !!!", JahiaException.CRITICAL, JahiaException.CONFIG_ERROR); } if (!isPortletGroupNode) { addPortletGroup(); getPortletListFromColumn(theColumn); } return thePortletList; } // end getPortletListFromColumn() //-------------------------------------------------------------------------- /** * Move the portlet to the right column in the Portlets XML file Descriptor * * @author Jerome Bedat * */ public void moveRightPortlet(int thePortletID) throws JahiaException { portletgroupNode = plmlNode.getFirstChild(); Node theNode; try { while (portletgroupNode != null) { if (portletgroupNode.getNodeType() == Node.ELEMENT_NODE && portletgroupNode.getNodeName().equalsIgnoreCase(PORTLETLIST_TAG)) { if (Integer.parseInt(getParameterValue(portletgroupNode, "page_id")) == thePageID) { Node portletNode = portletgroupNode.getFirstChild(); int Column = 0; while (portletNode != null) { // we are going through the portletgroup tags which represent list of portlets if (portletNode.getNodeType() == Node.ELEMENT_NODE && portletNode.getNodeName().equalsIgnoreCase(PORTLET_TAG)) { // we are now on a PORTLET tag paramAttrNode = getAttributeValue(portletNode, PARAMETER_TAG_ID_ATTRIBUTE); if (paramAttrNode.equals(new Integer(thePortletID).toString())) { Column = Integer.parseInt(getParameterValue(portletNode, "column_position")); break; } } portletNode = portletNode.getNextSibling(); } portletNode = portletgroupNode.getFirstChild(); int MaxRow = 0; while (portletNode != null) { // we are going through the portletgroup tags which represent list of portlets if (portletNode.getNodeType() == Node.ELEMENT_NODE && portletNode.getNodeName().equalsIgnoreCase(PORTLET_TAG)) { // we are now on a PORTLET tag if (Integer.parseInt(getParameterValue(portletNode, "column_position")) == Column + 1) { if (Integer.parseInt(getParameterValue(portletNode, "row_position")) > MaxRow) { MaxRow = Integer.parseInt(getParameterValue(portletNode, "row_position")); } } } portletNode = portletNode.getNextSibling(); } portletNode = portletgroupNode.getFirstChild(); while (portletNode != null) { // we are going through the portletgroup tags which represent list of portlets if (portletNode.getNodeType() == Node.ELEMENT_NODE && portletNode.getNodeName().equalsIgnoreCase(PORTLET_TAG)) { // we are now on a PORTLET tag paramAttrNode = getAttributeValue(portletNode, PARAMETER_TAG_ID_ATTRIBUTE); if (paramAttrNode.equals(new Integer(thePortletID).toString())) { Node paramNode = portletNode.getFirstChild(); while (paramNode != null) { if (paramNode.getNodeType() == Node.ELEMENT_NODE && paramNode.getNodeName().equalsIgnoreCase(PARAMETER_TAG)) { paramAttrNode = getAttributeValue(paramNode, PARAMETER_TAG_NAME_ATTRIBUTE); if (paramAttrNode.equals("column_position")) { theNode = paramNode.getFirstChild(); while (theNode != null) { if (theNode.getNodeType() == Node.TEXT_NODE) { theTextNode = xmlDocument.createTextNode(new Integer(Column + 1).toString()); paramNode.replaceChild(theTextNode, theNode); break; } theNode = theNode.getNextSibling(); } } if (paramAttrNode.equals("row_position")) { theNode = paramNode.getFirstChild(); while (theNode != null) { if (theNode.getNodeType() == Node.TEXT_NODE) { theTextNode = xmlDocument.createTextNode(new Integer(MaxRow + 1).toString()); paramNode.replaceChild(theTextNode, theNode); break; } theNode = theNode.getNextSibling(); } } } paramNode = paramNode.getNextSibling(); } break; } } portletNode = portletNode.getNextSibling(); } saveFile(xmlDocument,theFile.getAbsolutePath()); return; } } portletgroupNode = portletgroupNode.getNextSibling(); } } catch (NumberFormatException n) { throw new JahiaException(ERROR_READING_PLML_FILE_MSG, "Invalid Integer in moveRightPortlet !!! : " + n.toString(), JahiaException.CRITICAL, JahiaException.CONFIG_ERROR); } } // end moveRightPortlet //-------------------------------------------------------------------------- /** * Move the portlet to the left column in the Portlets XML file Descriptor * * @author Jerome Bedat * */ public void moveLeftPortlet(int thePortletID) throws JahiaException { portletgroupNode = plmlNode.getFirstChild(); Node theNode; try { while (portletgroupNode != null) { if (portletgroupNode.getNodeType() == Node.ELEMENT_NODE && portletgroupNode.getNodeName().equalsIgnoreCase(PORTLETLIST_TAG)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -