📄 xmlportlets.java
字号:
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(); } if (Column == 1) { return; } int MaxRow = 0; 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 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 moveLeftPortlet !!! : " + n.toString(), JahiaException.CRITICAL, JahiaException.CONFIG_ERROR); } } // end moveLeftPortlet //-------------------------------------------------------------------------- /** * Move the portlet to the bottom row in the Portlets XML file Descriptor * * @author Jerome Bedat * */ public void moveBottomPortlet(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; int Row = 0; 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 paramAttrNode = getAttributeValue(portletNode, PARAMETER_TAG_ID_ATTRIBUTE); if (paramAttrNode.equals(new Integer(thePortletID).toString())) { Column = Integer.parseInt(getParameterValue(portletNode, "column_position")); Row = Integer.parseInt(getParameterValue(portletNode, "row_position")); break; } } 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 if (Integer.parseInt(getParameterValue(portletNode, "column_position")) == Column) { if (Integer.parseInt(getParameterValue(portletNode, "row_position")) > MaxRow) { MaxRow = Integer.parseInt(getParameterValue(portletNode, "row_position")); } } } portletNode = portletNode.getNextSibling(); } if (Row == MaxRow) { return; } 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("row_position")) { theNode = paramNode.getFirstChild(); while (theNode != null) { if (theNode.getNodeType() == Node.TEXT_NODE) { theTextNode = xmlDocument.createTextNode(new Integer(Row + 1).toString()); paramNode.replaceChild(theTextNode, theNode); break; } theNode = theNode.getNextSibling(); } } } paramNode = paramNode.getNextSibling(); } break; } } 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 if (Integer.parseInt(getParameterValue(portletNode, "column_position")) == Column) { if (Integer.parseInt(getParameterValue(portletNode, "row_position")) == (Row + 1)) { 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("row_position")) { theNode = paramNode.getFirstChild(); while (theNode != null) { if (theNode.getNodeType() == Node.TEXT_NODE) { theTextNode = xmlDocument.createTextNode(new Integer(Row).toString()); paramNode.replaceChild(theTextNode, theNode); break; } theNode = theNode.getNextSibling(); } } } paramNode = paramNode.getNextSibling(); } } } } } 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 moveBottomPortlet !!! : " + n.toString(), JahiaException.CRITICAL, JahiaException.CONFIG_ERROR); }} // end moveBottomPortlet //-------------------------------------------------------------------------- /** * Move the portlet to the top row in the Portlets XML file Descriptor * * @author Jerome Bedat * */ public void moveTopPortlet(int thePortletID) throws JahiaException { portletgroupNode = plmlNode.getFirstChild(); Node theNode;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -