Author: dsakovich
Date: 2007-11-05 10:05:02 -0500 (Mon, 05 Nov 2007)
New Revision: 4707
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
Log:
http://jira.jboss.org/jira/browse/JBIDE-1250
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java 2007-11-05
15:02:49 UTC (rev 4706)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelBarTemplate.java 2007-11-05
15:05:02 UTC (rev 4707)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import java.util.HashMap;
@@ -15,6 +15,7 @@
import java.util.Map;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
@@ -25,106 +26,153 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-public class RichFacesPanelBarTemplate extends VpeAbstractTemplate implements
VpeToggableTemplate {
+public class RichFacesPanelBarTemplate extends VpeAbstractTemplate implements
+ VpeToggableTemplate {
- private static Map toggleMap = new HashMap();
+ private static Map toggleMap = new HashMap();
+ @Override
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
+ Element sourceElement = (Element) sourceNode;
- Element sourceElement = (Element)sourceNode;
+ nsIDOMElement div = visualDocument.createElement("table");
- nsIDOMElement div = visualDocument.createElement("div");
+ VpeCreationData creationData = new VpeCreationData(div);
- VpeCreationData creationData = new VpeCreationData(div);
+ ComponentUtil.setCSSLink(pageContext, "panelBar/panelBar.css",
+ "richFacesPanelBar");
+ String styleClass = sourceElement.getAttribute("styleClass");
+ div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-b "
+ + (styleClass == null ? "" : styleClass));
- ComponentUtil.setCSSLink(pageContext, "panelBar/panelBar.css",
"richFacesPanelBar");
- String styleClass = sourceElement.getAttribute("styleClass");
- div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-b " +
(styleClass==null?"":styleClass));
+ // Set style attribute
+ StringBuffer styleValue = new StringBuffer("padding: 0px; ");
+ styleValue.append(height(sourceElement)).append(" ").append(
+ width(sourceElement)).append(" ").append(
+ ComponentUtil.getAttribute(sourceElement, "style"));
- // Set style attribute
- StringBuffer styleValue = new StringBuffer("padding: 0px; ");
- styleValue.append(height(sourceElement)).append(" ").
- append(width(sourceElement)).append(" ").
- append(ComponentUtil.getAttribute(sourceElement, "style"));
+ // Encode Body
+ List<Node> children = ComponentUtil.getChildren(sourceElement);
+ int activeId = getActiveId(sourceElement, children);
+ int i = 0;
+ for (Node child : children) {
+ boolean active = (i == activeId);
- // Encode Body
- List<Node> children = ComponentUtil.getChildren(sourceElement);
- int activeId = getActiveId(sourceElement, children);
- int i = 0;
- for (Node child : children) {
- boolean active = (i == activeId);
-
- if(child.getNodeName().endsWith(":panelBarItem")) {
-
- RichFacesPanelItemTemplate.encode(creationData, (Element)child, visualDocument, div,
active,
- ComponentUtil.getAttribute((Element)child, "styleClass"),
- ComponentUtil.getAttribute((Element)child, "style"),
- ComponentUtil.getAttribute((Element)child, "headerClass"),
- ComponentUtil.getAttribute((Element)child, "headerStyle"),
- ComponentUtil.getAttribute((Element)child, "headerClassActive"),
- ComponentUtil.getAttribute((Element)child, "headerStyleActive"),
- ComponentUtil.getAttribute((Element)child, "contentClass"),
- ComponentUtil.getAttribute((Element)child, "contentStyle"),
- String.valueOf(i));
- i++;
- }
- }
+ if (child.getNodeName().endsWith(":panelBarItem")) {
- div.setAttribute("style", styleValue.toString());
- return creationData;
+ RichFacesPanelItemTemplate.encode(creationData,
+ (Element) child, visualDocument, div, active,
+ ComponentUtil.getAttribute((Element) child,
+ "styleClass"), ComponentUtil.getAttribute(
+ (Element) child, "style"), ComponentUtil
+ .getAttribute((Element) child, "headerClass"),
+ ComponentUtil.getAttribute((Element) child,
+ "headerStyle"), ComponentUtil.getAttribute(
+ (Element) child, "headerClassActive"),
+ ComponentUtil.getAttribute((Element) child,
+ "headerStyleActive"), ComponentUtil
+ .getAttribute((Element) child, "contentClass"),
+ ComponentUtil.getAttribute((Element) child,
+ "contentStyle"), String.valueOf(i));
+ i++;
+ }
}
- private String height(Element sourceElement) {
- String height = sourceElement.getAttribute("height");
- if (height == null || height.length() == 0 || height.equals("100%")) {
- height = "100%";
- }
- return "height: " + height + ";";
+ div.setAttribute("style", styleValue.toString());
+ return creationData;
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private String height(Element sourceElement) {
+ String height = sourceElement.getAttribute("height");
+ if (height == null || height.length() == 0 || height.equals("100%")) {
+ height = "100%";
}
+ return "height: " + height + ";";
+ }
- public String width(Element sourceElement) {
- String width = sourceElement.getAttribute("width");
- if (width == null || width.length() == 0) {
- width = "100%";
- }
- return "width: " + width + ";";
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ public String width(Element sourceElement) {
+ String width = sourceElement.getAttribute("width");
+ if (width == null || width.length() == 0) {
+ width = "100%";
}
+ return "width: " + width + ";";
+ }
- public void toggle(VpeVisualDomBuilder builder, Node sourceNode, String toggleId) {
- toggleMap.put(sourceNode, toggleId);
+ /**
+ *
+ */
+ public void toggle(VpeVisualDomBuilder builder, Node sourceNode,
+ String toggleId) {
+ toggleMap.put(sourceNode, toggleId);
+ }
+
+ /**
+ *
+ */
+ public void stopToggling(Node sourceNode) {
+ toggleMap.remove(sourceNode);
+ }
+
+ /**
+ *
+ * @param sourceElement
+ * @param children
+ * @return
+ */
+ private int getActiveId(Element sourceElement, List<Node> children) {
+ int activeId = -1;
+ try {
+ activeId = Integer.valueOf((String) toggleMap.get(sourceElement));
+ } catch (NumberFormatException nfe) {
+ activeId = -1;
}
- public void stopToggling(Node sourceNode) {
- toggleMap.remove(sourceNode);
+ if (activeId == -1)
+ activeId = 0;
+
+ int count = getChildrenCount(children);
+ if (count - 1 < activeId) {
+ activeId = count - 1;
}
-
- private int getActiveId(Element sourceElement, List<Node> children) {
- int activeId = -1;
- try {
- activeId = Integer.valueOf((String)toggleMap.get(sourceElement));
- } catch (NumberFormatException nfe) {
- activeId = -1;
- }
- if (activeId == -1)
- activeId = 0;
-
- int count = getChildrenCount(children);
- if (count - 1 < activeId) {
- activeId = count - 1;
- }
-
- return activeId;
+ return activeId;
+ }
+
+ /**
+ *
+ * @param children
+ * @return
+ */
+ private int getChildrenCount(List<Node> children) {
+ int count = 0;
+ for (Node child : children) {
+ if (child.getNodeName().endsWith(":panelBarItem")) {
+ count++;
+ }
}
-
- private int getChildrenCount(List<Node> children) {
- int count = 0;
- for (Node child : children) {
- if (child.getNodeName().endsWith(":panelBarItem")) {
- count++;
- }
- }
- return count;
- }
+ return count;
+ }
+
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ if (name.equalsIgnoreCase(HtmlComponentUtil.HTML_WIDTH_ATTR)
+ || name.equalsIgnoreCase(HtmlComponentUtil.HTML_HEIGHT_ATTR)
+ || name.equalsIgnoreCase(HtmlComponentUtil.HTML_STYLE_ATTR))
+ return true;
+ return false;
+ }
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2007-11-05
15:02:49 UTC (rev 4706)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2007-11-05
15:05:02 UTC (rev 4707)
@@ -7,12 +7,13 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.richfaces.template;
import java.util.List;
import org.jboss.tools.jsf.vpe.richfaces.ComponentUtil;
+import org.jboss.tools.jsf.vpe.richfaces.HtmlComponentUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
@@ -24,92 +25,161 @@
public class RichFacesPanelItemTemplate extends VpeAbstractTemplate {
- public static VpeCreationData encode(VpeCreationData creationData, Element
sourceElement, nsIDOMDocument visualDocument, nsIDOMElement parentVisualElement, boolean
active,
- String barStyleClass, String barStyle,
- String barHeaderStyleClass, String barHeaderStyle,
- String barHeaderActiveStyleClass, String barHeaderActiveStyle,
- String barContentStyleClass,
- String barContentStyle,
- String toggleId) {
-
- nsIDOMElement div = visualDocument.createElement("div");
+ /**
+ *
+ * @param creationData
+ * @param sourceElement
+ * @param visualDocument
+ * @param parentVisualElement
+ * @param active
+ * @param barStyleClass
+ * @param barStyle
+ * @param barHeaderStyleClass
+ * @param barHeaderStyle
+ * @param barHeaderActiveStyleClass
+ * @param barHeaderActiveStyle
+ * @param barContentStyleClass
+ * @param barContentStyle
+ * @param toggleId
+ * @return
+ */
+ public static VpeCreationData encode(VpeCreationData creationData,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement parentVisualElement, boolean active,
+ String barStyleClass, String barStyle, String barHeaderStyleClass,
+ String barHeaderStyle, String barHeaderActiveStyleClass,
+ String barHeaderActiveStyle, String barContentStyleClass,
+ String barContentStyle, String toggleId) {
- if(creationData==null) {
- creationData = new VpeCreationData(div);
- } else {
- parentVisualElement.appendChild(div);
- }
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
- div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-ext "
+ barStyleClass);
- div.setAttribute("style", barStyle);
- div.setAttribute("vpe-user-toggle-id", toggleId);
+ if (creationData == null) {
+ creationData = new VpeCreationData(div);
+ } else {
+ parentVisualElement.appendChild(div);
+ }
- // Encode Header
- String headerActivetStyleClass = "dr-pnlbar-h-act rich-panelbar-header-act "
+ barHeaderActiveStyleClass + " " + ComponentUtil.getAttribute(sourceElement,
"headerClassActive");
- String headerActivetStyle = barHeaderStyle + " " +
ComponentUtil.getAttribute(sourceElement, "headerStyle") + " " +
barHeaderActiveStyle + " " + ComponentUtil.getAttribute(sourceElement,
"headerStyleActive") + " " +
ComponentUtil.getHeaderBackgoundImgStyle();
- String headerStyleClass = "dr-pnlbar-h rich-panelbar-header " +
barHeaderStyleClass + " " + ComponentUtil.getAttribute(sourceElement,
"headerClass");
- String headerStyle = barHeaderStyle + " " +
ComponentUtil.getAttribute(sourceElement, "headerStyle") + " " +
ComponentUtil.getHeaderBackgoundImgStyle();
- if(active) {
- encodeHeader(sourceElement, visualDocument, div, headerActivetStyleClass,
headerActivetStyle, toggleId);
- } else {
- encodeHeader(sourceElement, visualDocument, div, headerStyleClass, headerStyle,
toggleId);
- }
+ div.setAttribute("class", "dr-pnlbar rich-panelbar dr-pnlbar-ext "
+ + barStyleClass);
+ div.setAttribute("style", barStyle);
+ div.setAttribute("vpe-user-toggle-id", toggleId);
- // Encode Body
- if(active) {
- nsIDOMElement bodyDiv = visualDocument.createElement("div");
- div.appendChild(bodyDiv);
- bodyDiv.setAttribute("style", "width: 100%;");
+ // Encode Header
+ String headerActivetStyleClass = "dr-pnlbar-h-act rich-panelbar-header-act "
+ + barHeaderActiveStyleClass
+ + " "
+ + ComponentUtil
+ .getAttribute(sourceElement, "headerClassActive");
+ String headerActivetStyle = barHeaderStyle
+ + " "
+ + ComponentUtil.getAttribute(sourceElement, "headerStyle")
+ + " "
+ + barHeaderActiveStyle
+ + " "
+ + ComponentUtil
+ .getAttribute(sourceElement, "headerStyleActive") + " "
+ + ComponentUtil.getHeaderBackgoundImgStyle();
+ String headerStyleClass = "dr-pnlbar-h rich-panelbar-header "
+ + barHeaderStyleClass + " "
+ + ComponentUtil.getAttribute(sourceElement, "headerClass");
+ String headerStyle = barHeaderStyle + " "
+ + ComponentUtil.getAttribute(sourceElement, "headerStyle")
+ + " " + ComponentUtil.getHeaderBackgoundImgStyle();
+ if (active) {
+ encodeHeader(sourceElement, visualDocument, div,
+ headerActivetStyleClass, headerActivetStyle, toggleId);
+ } else {
+ encodeHeader(sourceElement, visualDocument, div, headerStyleClass,
+ headerStyle, toggleId);
+ }
- nsIDOMElement table = visualDocument.createElement("table");
- bodyDiv.appendChild(table);
- table.setAttribute("cellpadding", "0");
- table.setAttribute("width", "100%");
- table.setAttribute("style", "height: 100%;");
+ // Encode Body
+ if (active) {
- nsIDOMElement tbody = visualDocument.createElement("tbody");
- table.appendChild(tbody);
-
- nsIDOMElement tr = visualDocument.createElement("tr");
- tbody.appendChild(tr);
-
- nsIDOMElement td = visualDocument.createElement("td");
- tr.appendChild(td);
+ nsIDOMElement tr2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ nsIDOMElement td2 = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr2.appendChild(td2);
+ tr2.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
+ tr2.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
+ if (creationData == null) {
+ creationData = new VpeCreationData(tr2);
+ } else {
+ parentVisualElement.appendChild(tr2);
+ }
- String tdClass = "dr-pnlbar-c rich-panelbar-content " + barContentStyleClass
+ " " + ComponentUtil.getAttribute(sourceElement, "contentClass");
- String tdStyle = barContentStyle + " " +
ComponentUtil.getAttribute(sourceElement, "contentStyle");
+ nsIDOMElement table = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TABLE);
+ td2.appendChild(table);
+ table.setAttribute("cellpadding", "0");
+ table.setAttribute(HtmlComponentUtil.HTML_WIDTH_ATTR, "100%");
+ table.setAttribute(HtmlComponentUtil.HTML_HEIGHT_ATTR, "100%");
- td.setAttribute("class", tdClass);
- td.setAttribute("style", tdStyle);
+ nsIDOMElement tbody = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TBODY);
+ table.appendChild(tbody);
- List<Node> children = ComponentUtil.getChildren(sourceElement, true);
- VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td);
- for (Node child : children) {
- bodyInfo.addSourceChild(child);
- }
- creationData.addChildrenInfo(bodyInfo);
- }
- return creationData;
- }
+ nsIDOMElement tr = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TR);
+ tbody.appendChild(tr);
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- return encode(null, (Element)sourceNode, visualDocument, null, false, "",
"", "", "", "", "", "",
"", "0");
+ nsIDOMElement td = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_TD);
+ tr.appendChild(td);
+
+ String tdClass = "dr-pnlbar-c rich-panelbar-content "
+ + barContentStyleClass + " "
+ + ComponentUtil.getAttribute(sourceElement, "contentClass");
+ String tdStyle = barContentStyle + " "
+ + ComponentUtil.getAttribute(sourceElement, "contentStyle");
+
+ td.setAttribute("class", tdClass);
+ td.setAttribute("style", tdStyle);
+
+ List<Node> children = ComponentUtil
+ .getChildren(sourceElement, true);
+ VpeChildrenInfo bodyInfo = new VpeChildrenInfo(td);
+ for (Node child : children) {
+ bodyInfo.addSourceChild(child);
+ }
+ creationData.addChildrenInfo(bodyInfo);
}
+ return creationData;
+ }
- private static void encodeHeader(Element sourceElement, nsIDOMDocument visualDocument,
nsIDOMElement parentDiv, String styleClass, String style, String toggleId) {
- try {
- nsIDOMElement div = visualDocument.createElement("div");
- parentDiv.appendChild(div);
- div.setAttribute("class", styleClass);
- div.setAttribute("style", style);
- div.setAttribute("vpe-user-toggle-id", toggleId);
+ @Override
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ return encode(null, (Element) sourceNode, visualDocument, null, false,
+ "", "", "", "", "", "",
"", "", "0");
+ }
- String label = sourceElement.getAttribute("label");
- if(label!=null) {
- div.appendChild(visualDocument.createTextNode(label));
- }
- }catch(Throwable t) {
- t.printStackTrace();
- }
+ /**
+ *
+ * @param sourceElement
+ * @param visualDocument
+ * @param parentDiv
+ * @param styleClass
+ * @param style
+ * @param toggleId
+ */
+ private static void encodeHeader(Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMElement parentDiv,
+ String styleClass, String style, String toggleId) {
+
+ nsIDOMElement div = visualDocument
+ .createElement(HtmlComponentUtil.HTML_TAG_DIV);
+ parentDiv.appendChild(div);
+ div.setAttribute("class", styleClass);
+ div.setAttribute("style", style);
+ div.setAttribute("vpe-user-toggle-id", toggleId);
+
+ String label = sourceElement.getAttribute("label");
+ if (label != null) {
+ div.appendChild(visualDocument.createTextNode(label));
}
+
+ }
}
\ No newline at end of file
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-11-05
15:02:49 UTC (rev 4706)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2007-11-05
15:05:02 UTC (rev 4707)
@@ -374,8 +374,8 @@
<vpe:tag name="rich:panelBar" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesPanelBarTemplate">
<vpe:resize>
- <vpe:width width-attr="style.width" />
- <vpe:height height-attr="style.height" />
+ <vpe:width width-attr="width" />
+ <vpe:height height-attr="height" />
</vpe:resize>
<vpe:drag start-enable="yes"/>
<vpe:drop container="no"/>