Author: yradtsevich
Date: 2008-10-07 09:11:50 -0400 (Tue, 07 Oct 2008)
New Revision: 10708
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeElementCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelLayoutCreator.java
Log:
JBIDE-2815 bug fixed.
Wrong signatures of isRecreateAtAttrChange, getNodeForUptate and validate changed to right
ones.
Code cleaning up made.
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDefineTemplate.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -23,6 +23,7 @@
public class VpeDefineTemplate extends VpeAbstractTemplate {
+ @Override
protected void init(Element templateElement) {
children = true;
modify = true;
@@ -43,7 +44,14 @@
return sourceNode.getParentNode();
}
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNode, Object data, String name, String value) {
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMElement, java.lang.Object, java.lang.String,
java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
return true;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDataTableColumnCreator.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -144,14 +144,26 @@
return index;
}
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNode, Object data, String name, String value) {
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name, String value) {
return true;
}
- public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode, Node
visualNode, Map visualNodeMap) {
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#getNodeForUptate(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode, java.util.Map)
+ */
+ @Override
+ public Node getNodeForUptate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMNode visualNode, Map visualNodeMap) {
return sourceNode.getParentNode();
}
+ @Override
public void removeElement(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap) {
Object elements = visualNodeMap.get(this);
if (elements != null && elements instanceof VisualColumnElements) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeElementCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeElementCreator.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeElementCreator.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -7,13 +7,12 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.Map;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -27,6 +26,7 @@
import org.jboss.tools.vpe.editor.template.expression.VpeValue;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
public class VpeElementCreator extends VpeAbstractCreator {
private boolean caseSensitive;
@@ -36,7 +36,7 @@
this.caseSensitive = caseSensitive;
build(element, dependencyMap);
}
-
+
private void build(Element element, VpeDependencyMap dependencyMap) {
Attr nameAttr = element.getAttributeNode(VpeTemplateManager.ATTR_ELEMENT_NAME);
if (nameAttr != null) {
@@ -50,6 +50,7 @@
}
}
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) throws
VpeExpressionException {
if (expression != null) {
visualNodeMap.put(this, visualElement);
@@ -62,7 +63,14 @@
return null;
}
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNde, Object data, String name, String value) {
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name, String value) {
return true;
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeFacetCreator.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.util.Map;
@@ -19,7 +19,6 @@
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMNodeList;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -31,12 +30,13 @@
this.caseSensitive = caseSensitive;
}
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
VpeCreatorInfo creatorInfo = null;
boolean isHeader = false;
boolean isFooter = false;
-
+
Node nameAttr = sourceNode.getAttributes().getNamedItem("name");
if (nameAttr != null) {
String name = nameAttr.getNodeValue();
@@ -55,7 +55,7 @@
nsIDOMNode header = null;
nsIDOMNode footer = null;
-
+
if (visualParent != null &&
visualParent.getNodeName().equalsIgnoreCase("table")) {
nsIDOMNodeList children = visualParent.getChildNodes();
long count = children != null ? children.getLength() : 0;
@@ -76,7 +76,7 @@
}
nsIDOMElement cell = null;
- int columnsCount = getColumnsCount(sourceParent);
+ int columnsCount = getColumnsCount(sourceParent);
if (isHeader) {
cell = makeCell(columnsCount, HTML.TAG_TH, visualDocument);
} else if (isFooter) {
@@ -95,7 +95,15 @@
return creatorInfo;
}
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNode, Object data, String name, String value) {
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name, String value) {
return true;
}
@@ -110,7 +118,7 @@
}
}
}
-
+
private String getTableAttrValue(Node dataTableNode, String attrName) {
if (dataTableNode != null) {
Node attr = dataTableNode.getAttributes().getNamedItem(attrName);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -26,8 +26,8 @@
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -36,7 +36,7 @@
public class VpePanelGridCreator extends VpeAbstractCreator {
private final String REDUNDANT_TEXT_SEPARATOR = "\n\n"; //$NON-NLS-1$
-
+
private boolean caseSensitive;
private VpeExpression tableSizeExpr;
private VpeExpression captionClassExpr;
@@ -187,6 +187,7 @@
}
}
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, nsIDOMElement visualElement,
Map visualNodeMap) throws VpeExpressionException {
@@ -214,7 +215,7 @@
td.appendChild(div);
tr.appendChild(td);
selectionTable.appendChild(tr);
-
+
nsIDOMElement visualTable = visualDocument
.createElement(HTML.TAG_TABLE);
@@ -225,7 +226,7 @@
VpeCreator creator = (VpeCreator) propertyCreators.get(i);
if (creator != null) {
VpeCreatorInfo info = creator.create(pageContext,
- (Element) sourceNode, visualDocument, visualTable,
+ sourceNode, visualDocument, visualTable,
visualNodeMap);
if (info != null && info.getVisualNode() != null) {
nsIDOMAttr attr = (nsIDOMAttr) info.getVisualNode();
@@ -257,10 +258,10 @@
int type = node.getNodeType();
if (type == Node.ELEMENT_NODE || type == Node.TEXT_NODE
&& node.getNodeValue().trim().length() > 0) {
-
+
/*
* Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944
- * author: Denis Maliarevich
+ * author: Denis Maliarevich
* Finds all unattended text nodes
*/
if (type == Node.TEXT_NODE) {
@@ -285,7 +286,7 @@
}
}
}
-
+
/*
* Fixes
http://jira.jboss.com/jira/browse/JBIDE-1944
* author: Denis Maliarevich
@@ -301,7 +302,7 @@
div.appendChild(visualDocument.createTextNode(redundantText));
}
div.appendChild(visualTable);
-
+
if (childrenCount > 0) {
if (tableSize == 0) {
tableSize = childrenCount;
@@ -311,7 +312,7 @@
nsIDOMElement visualHead = null;
nsIDOMElement visualFoot = null;
nsIDOMElement visualCaption = null;
-
+
if (caption != null) {
visualCaption = visualDocument
.createElement(HTML.TAG_CAPTION);
@@ -348,16 +349,16 @@
nsIDOMElement visualBody = visualDocument
.createElement(HTML.TAG_TBODY);
visualTable.appendChild(visualBody);
-
+
List rowClasses = getClasses(rowClassesExpr, sourceNode,
pageContext);
List columnClasses = getClasses(columnClassesExpr, sourceNode,
pageContext);
-
+
int rci = 0; // index of row class
for (int i = 0; i < rowCount; i++) {
- int cci = 0; // index of column class. Reset on every new row.
-
+ int cci = 0; // index of column class. Reset on every new row.
+
nsIDOMElement visualRow = visualDocument
.createElement(HTML.TAG_TR);
if (rowClasses.size() > 0) {
@@ -404,7 +405,7 @@
VpeCreator creator = (VpeCreator) propertyCreators.get(i);
if (creator != null) {
VpeCreatorInfo info = creator.create(pageContext,
- (Element) sourceNode, visualDocument,
+ sourceNode, visualDocument,
visualTable, visualNodeMap);
if (info != null && info.getVisualNode() != null) {
nsIDOMAttr attr = (nsIDOMAttr) info.getVisualNode();
@@ -471,9 +472,14 @@
return null;
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
public boolean isRecreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, Document visualDocument, Node visualNde,
- Object data, String name, String value) {
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name, String value) {
return true;
}
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelLayoutCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelLayoutCreator.java 2008-10-07
13:06:58 UTC (rev 10707)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelLayoutCreator.java 2008-10-07
13:11:50 UTC (rev 10708)
@@ -7,7 +7,7 @@
*
* Contributors:
* Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.vpe.editor.template;
import java.io.IOException;
@@ -26,6 +26,7 @@
import org.jboss.tools.vpe.editor.util.FileUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -35,67 +36,67 @@
public class VpePanelLayoutCreator extends VpeAbstractCreator {
-
-
+
+
public static final String ATTR_LAYOUT_DEFAULT_VALUE = "classic";
public static final String EMPTY_ATTR_VALUE = "";
-
- public static final String CSS_CLASS_HEADER_DEFAULT = "pageHeader";
+
+ public static final String CSS_CLASS_HEADER_DEFAULT = "pageHeader";
public static final String CSS_CLASS_NAVIGATOR_DEFAULT = "pageNavigation";
public static final String CSS_CLASS_BODY_DEFAULT = "pageBody";
- public static final String CSS_CLASS_FOOTER_DEFAULT = "pageFooter";
+ public static final String CSS_CLASS_FOOTER_DEFAULT = "pageFooter";
- // layout | header | navigation | body | footer
- //==================|========|============|=======|========
- // classic (Default)| top | left | right | bottom
- // navigationRight | top | right | left | bottom
- // upsideDown | bottom | left | right | top
- public static final String ATTR_PL_LAYOUT = "layout";
-
+ // layout | header | navigation | body | footer
+ //==================|========|============|=======|========
+ // classic (Default)| top | left | right | bottom
+ // navigationRight | top | right | left | bottom
+ // upsideDown | bottom | left | right | top
+ public static final String ATTR_PL_LAYOUT = "layout";
+
public static final String ATTR_PL_CLASS = "class";
public static final String ATTR_PL_STYLE = "style";
// TAGS for layout attribute
- public static final String LAYOUT_CLASSIC_ATTR_VALUE = "classic";
+ public static final String LAYOUT_CLASSIC_ATTR_VALUE = "classic";
public static final String LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE =
"navigationRight";
public static final String LAYOUT_UPSIDEDOWN_VALUE = "upsideDown";
-
+
// Attributes wil mapped for body td
public static final String ATTR_PL_BODY_CLASS = "bodyClass"; // CSS class to
be used for the table cell.
public static final String ATTR_PL_BODY_STYLE = "bodyStyle"; // CSS style to
be used for the table cell.
-
+
public static final String[][] MAP_ATTR_TO_BODY = {
- {ATTR_PL_CLASS,ATTR_PL_BODY_CLASS,CSS_CLASS_BODY_DEFAULT},
+ {ATTR_PL_CLASS,ATTR_PL_BODY_CLASS,CSS_CLASS_BODY_DEFAULT},
{ATTR_PL_STYLE,ATTR_PL_BODY_STYLE,EMPTY_ATTR_VALUE}
};
-
- // Attributes wil mapped for footer td
+
+ // Attributes wil mapped for footer td
public static final String ATTR_PL_FOOTER_CLASS = "footerClass"; // CSS class
to be used for the table cell.
public static final String ATTR_PL_FOOTER_STYLE = "footerStyle"; // CSS style
to be used for the table cell.
public static final String[][] MAP_ATTR_TO_FOOTER = {
- {ATTR_PL_CLASS,ATTR_PL_FOOTER_CLASS,CSS_CLASS_FOOTER_DEFAULT},
+ {ATTR_PL_CLASS,ATTR_PL_FOOTER_CLASS,CSS_CLASS_FOOTER_DEFAULT},
{ATTR_PL_STYLE,ATTR_PL_FOOTER_STYLE,EMPTY_ATTR_VALUE}
};
-
- // Attributes wil mapped for header td
+
+ // Attributes wil mapped for header td
public static final String ATTR_PL_HEADER_CLASS = "headerClass"; // CSS class
to be used for the table cell.
public static final String ATTR_PL_HEADER_STYLE = "headerStyle"; // CSS style
to be used for the table cell.
-
+
public static final String[][] MAP_ATTR_TO_HEADER = {
- {ATTR_PL_CLASS,ATTR_PL_HEADER_CLASS,CSS_CLASS_HEADER_DEFAULT},
+ {ATTR_PL_CLASS,ATTR_PL_HEADER_CLASS,CSS_CLASS_HEADER_DEFAULT},
{ATTR_PL_STYLE,ATTR_PL_HEADER_STYLE,EMPTY_ATTR_VALUE}
};
-
- // Attributes wil mapped for navigation td
+
+ // Attributes wil mapped for navigation td
public static final String ATTR_PL_NAVIGATION_CLASS = "navigationClass"; //
CSS class to be used for the table cell.
public static final String ATTR_PL_NAVIOGATION = "navigationStyle"; // CSS
style to be used for the table cell.
public static final String[][] MAP_ATTR_TO_NAVIGATION = {
- {ATTR_PL_CLASS,ATTR_PL_NAVIGATION_CLASS,CSS_CLASS_NAVIGATOR_DEFAULT},
+ {ATTR_PL_CLASS,ATTR_PL_NAVIGATION_CLASS,CSS_CLASS_NAVIGATOR_DEFAULT},
{ATTR_PL_STYLE,ATTR_PL_NAVIOGATION,EMPTY_ATTR_VALUE}
};
-
- // Attributes will mapped to <table>
+
+ // Attributes will mapped to <table>
public static final String ATTR_PL_ID = "id"; // Every component may have an
unique id. Automatically created if omitted.
public static final String ATTR_PL_DIR = "dir"; // No Description
public static final String ATTR_PL_LANG = "lang"; // No Description
@@ -105,8 +106,8 @@
public static final String ATTR_PL_BGCOLOR = "bgcolor"; // No Description
public static final String ATTR_PL_BORDER = "border"; // No Description
public static final String ATTR_PL_CELLPADDING = "cellpadding"; // No
Description
- public static final String ATTR_PL_CELLSPACING = "cellspacing"; // No
Description
-
+ public static final String ATTR_PL_CELLSPACING = "cellspacing"; // No
Description
+
public static final String[][] MAP_ATTR_TO_TABLE = {
{ATTR_PL_ID,ATTR_PL_ID,EMPTY_ATTR_VALUE},
{ATTR_PL_DIR,ATTR_PL_DIR,EMPTY_ATTR_VALUE},
@@ -120,8 +121,8 @@
{ATTR_PL_CELLPADDING,ATTR_PL_CELLPADDING,EMPTY_ATTR_VALUE},
{ATTR_PL_CELLSPACING,ATTR_PL_CELLSPACING,EMPTY_ATTR_VALUE}
};
-
- // Not Mapped Attributes
+
+ // Not Mapped Attributes
// event is never mapped
public static final String ATTR_PL_ONCLICK = "onclick"; // No Description
public static final String ATTR_PL_ONDBCLICK = "ondblclick"; // No
Description
@@ -135,7 +136,7 @@
public static final String ATTR_PL_ONMOUSEUP = "onmouseup"; // No Description
public static final String ATTR_PL_RENDERED = "rendered"; // If false, this
component will not be rendered.
// Unknown attributes
- public static final String ATTR_PL_FRAME = "frame"; // No Description
+ public static final String ATTR_PL_FRAME = "frame"; // No Description
public static final String ATTR_PL_RULES = "rules"; // No Description
public static final String ATTR_PL_SUMMARY = "summary"; // No Description
public static final String ATTR_PL_TITLE = "title"; // No Description
@@ -153,75 +154,80 @@
build(panelLayout, dependencyMap);
}
- public boolean isRecreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
Document visualDocument, Node visualNde, Object data, String name, String value) {
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#isRecreateAtAttrChange(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMNode, java.lang.Object, java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name, String value) {
Map visualNodeMap = (Map)data;
if(name.equals(ATTR_PL_LAYOUT)) {
String layoutName = (String)visualNodeMap.get(ATTR_PL_LAYOUT);
- if(!value.equals(this.LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE)
- && !value.equals(this.LAYOUT_UPSIDEDOWN_VALUE)) {
+ if(!value.equals(VpePanelLayoutCreator.LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE)
+ && !value.equals(VpePanelLayoutCreator.LAYOUT_UPSIDEDOWN_VALUE)) {
value = LAYOUT_CLASSIC_ATTR_VALUE;
}
return !layoutName.equals(value);
} return false;
}
-
-
+ @Override
public VpeCreatorInfo create(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, nsIDOMElement visualElement, Map visualNodeMap) {
VpePanelLayoutElements layoutElements = new VpePanelLayoutElements(sourceNode,
pageContext);
visualNodeMap.put(ATTR_PL_LAYOUT, layoutElements.getLayoutName());
PanelLayoutTable layout = new PanelLayoutTable(visualDocument,sourceNode);
visualNodeMap.put(this,layout);
-
+
if(LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE.equals(layoutElements.getLayoutName())) {
layout.setTop(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.setRight(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.setLeft(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.setBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.setBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
} else if(LAYOUT_UPSIDEDOWN_VALUE.equals(layoutElements.getLayoutName())) {
layout.setBottom(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.setLeft(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.setRight(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.setTop(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.setTop(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
} else { // LAYOUT_CLASSIC_ATTR_VALUE
layout.setTop(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.setLeft(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.setRight(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.setBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.setBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
}
return layout.getVpeCreatorInfo();
}
public static class VpePanelLayoutElements {
-
+
Node layout = null;
Node header = null;
- Node footer = null;
+ Node footer = null;
Node navigation = null;
Node body = null;
VpePageContext pageContext = null;
-
+
public VpePanelLayoutElements(Node source,VpePageContext context) {
pageContext = context;
init(source);
layout = source;
-
+
}
-
+
public Node getLayoutNode() {
return layout;
}
-
+
public String getLayoutName() {
String name = getAttributeValue(layout,ATTR_PL_LAYOUT, ATTR_LAYOUT_DEFAULT_VALUE);
- if(name.equals(LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE)
+ if(name.equals(LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE)
|| name.equals(LAYOUT_UPSIDEDOWN_VALUE)) {
return name;
}
return LAYOUT_CLASSIC_ATTR_VALUE;
}
-
+
private void init(Node source){
init(source, null);
}
@@ -236,7 +242,7 @@
boolean isFacet = node.getNodeName().indexOf(":facet") > 0;
boolean isInclude = node.getNodeName().indexOf("jsp:include") >=0 ||
node.getNodeName().indexOf("jsp:directive.include")>=0;
Node attrName = node.getAttributes().getNamedItem("name");
- if(isFacet && attrName!=null) {
+ if(isFacet && attrName!=null) {
String nodeValue = attrName.getNodeValue();
if("header".equals(nodeValue)) {
if(include != null) header = include;
@@ -247,7 +253,7 @@
} else if("body".equals(nodeValue)) {
if(include != null) body = include;
else body = node;
- } else if("footer".equals(nodeValue)) {
+ } else if("footer".equals(nodeValue)) {
if(include != null) footer = include;
else footer = node;
}
@@ -257,17 +263,17 @@
if (page == null) {
page = ((Element)node).getAttributeNode("file");
}
-
-
+
+
if(page != null){
String pageName = page.getNodeValue();
IEditorInput input = pageContext.getEditPart().getEditorInput();
IFile resource = FileUtil.getFile(input, pageName);
- if(resource != null && ((IFile)resource).exists()){
+ if(resource != null && (resource).exists()){
try{
wtpModel =
(IDOMModel)StructuredModelManager.getModelManager().getModelForRead(resource);
if(wtpModel != null){
- init(wtpModel.getDocument(), node);
+ init(wtpModel.getDocument(), node);
}
} catch(IOException ex) {
VpePlugin.reportProblem(ex);
@@ -279,17 +285,17 @@
}
}
- }
+ }
}
}
}
}
}
-
+
public Node getHeaderFacet() {
return header;
}
-
+
public Node getFooterFacet() {
return footer;
}
@@ -297,15 +303,15 @@
public Node getNavigationFacet() {
return navigation;
}
-
+
public Node getBodyFacet() {
return body;
}
-
+
public String getPanelLayoutAttribute(String nodeName, String defaultValue) {
return VpePanelLayoutElements.getAttributeValue(this.layout,nodeName,defaultValue);
}
-
+
// TODO Move to Util Class
static String getAttributeValue(Node node, String attributeName, String defaultValue)
{
NamedNodeMap attrs = node.getAttributes();
@@ -316,120 +322,120 @@
return defaultValue;
}
public static int DEST=0, SOURCE=1, DEFAULT =2;
-
+
static void mapAttributes(nsIDOMElement dest, Node source, String[][] map) {
for (int i = 0;i<map.length;i++) {
dest.setAttribute(map[i][DEST],getAttributeValue(source,map[i][SOURCE],map[i][DEFAULT]));
}
}
}
-
+
public class PanelLayoutTable {
-
+
public static final String TABLE = "table";
public static final String TR = "tr";
public static final String TD = "td";
- public static final String CLASS_ATTR = "class";
- public static final String STYLE_ATTR = "style";
-
+ public static final String CLASS_ATTR = "class";
+ public static final String STYLE_ATTR = "style";
+
Table table;
Td top;
Td bottom;
Td left;
Td right;
-
+
VpeChildrenInfo topInfo;
VpeChildrenInfo bottomInfo;
VpeChildrenInfo rightInfo;
- VpeChildrenInfo leftInfo;
+ VpeChildrenInfo leftInfo;
VpeCreatorInfo creatorInfo;
-
+
Document sourceDocument;
-
-
+
+
public PanelLayoutTable(nsIDOMDocument visualDocument, Node source) {
table = new Table(visualDocument, source);
- creatorInfo = new VpeCreatorInfo(table.getDomElement());
+ creatorInfo = new VpeCreatorInfo(table.getDomElement());
Tr tr = table.crateRow();
top = tr.createCell(2);
tr = table.crateRow();
left = tr.createCell();
- right = tr.createCell();
+ right = tr.createCell();
tr = table.crateRow();
bottom = tr.createCell(2);
sourceDocument = source.getOwnerDocument();
}
-
+
public void setTop(Node node, String[][] styleMap) {
if(node==null) return;
- topInfo = new VpeChildrenInfo(top.getDomElement());
+ topInfo = new VpeChildrenInfo(top.getDomElement());
addVpeCreatorInfoChild(topInfo,top,node,styleMap);
}
-
+
public void setBottom(Node node,String[][] styleMap) {
- if(node==null) return;
- bottomInfo = new VpeChildrenInfo(bottom.getDomElement());
- addVpeCreatorInfoChild(bottomInfo,bottom,node,styleMap);
+ if(node==null) return;
+ bottomInfo = new VpeChildrenInfo(bottom.getDomElement());
+ addVpeCreatorInfoChild(bottomInfo,bottom,node,styleMap);
}
-
+
public void setLeft(Node node, String[][] styleMap) {
- if(node==null) return;
- leftInfo = new VpeChildrenInfo(left.getDomElement());
- addVpeCreatorInfoChild(leftInfo,left,node,styleMap);
+ if(node==null) return;
+ leftInfo = new VpeChildrenInfo(left.getDomElement());
+ addVpeCreatorInfoChild(leftInfo,left,node,styleMap);
}
-
+
public void setRight(Node node, String[][] styleMap) {
- if(node==null) return;
- rightInfo = new VpeChildrenInfo(right.getDomElement());
+ if(node==null) return;
+ rightInfo = new VpeChildrenInfo(right.getDomElement());
addVpeCreatorInfoChild(rightInfo,right,node,styleMap);
}
-
+
public void updateTop(Node node, String[][] styleMap) {
if(node==null) return;
VpePanelLayoutElements.mapAttributes(top.getDomElement(),node,styleMap);
}
-
+
public void updateBottom(Node node,String[][] styleMap) {
- if(node==null) return;
- VpePanelLayoutElements.mapAttributes(bottom.getDomElement(),node,styleMap);
+ if(node==null) return;
+ VpePanelLayoutElements.mapAttributes(bottom.getDomElement(),node,styleMap);
}
-
+
public void updateLeft(Node node, String[][] styleMap) {
- if(node==null) return;
- VpePanelLayoutElements.mapAttributes(left.getDomElement(),node,styleMap);
+ if(node==null) return;
+ VpePanelLayoutElements.mapAttributes(left.getDomElement(),node,styleMap);
}
-
+
public void updateRight(Node node, String[][] styleMap) {
- if(node==null) return;
+ if(node==null) return;
VpePanelLayoutElements.mapAttributes(right.getDomElement(),node,styleMap);
- }
-
+ }
+
public void update(Node node, String[][] styleMap) {
- VpePanelLayoutElements.mapAttributes(table.getDomElement(),node,styleMap);
+ VpePanelLayoutElements.mapAttributes(table.getDomElement(),node,styleMap);
}
-
+
public VpeCreatorInfo getVpeCreatorInfo() {
return creatorInfo;
}
-
+
private void addVpeCreatorInfoChild(VpeChildrenInfo info,Td td, Node source, String[][]
styleMap) {
info.addSourceChild(source);
VpePanelLayoutElements.mapAttributes(td.getDomElement(),source,styleMap);
creatorInfo.addChildrenInfo(info);
}
}
-
+
public interface ElementWrapper {
public nsIDOMElement getDomElement();
- public nsIDOMDocument getOwnerDocument();
+ public nsIDOMDocument getOwnerDocument();
public void setAttributeValue(String name, String value);
}
-
+
public class DefaultNodeWrapper implements ElementWrapper {
-
+
protected nsIDOMElement element;
-
+
public DefaultNodeWrapper(nsIDOMElement element) {
this.element = element;
}
@@ -437,7 +443,7 @@
public nsIDOMElement getDomElement() {
return element;
}
-
+
public nsIDOMDocument getOwnerDocument() {
return element.getOwnerDocument();
}
@@ -445,11 +451,11 @@
public void setAttributeValue(String name, String value) {
getDomElement().setAttribute(name,value);
}
-
+
}
-
+
public class Table extends DefaultNodeWrapper {
-
+
public Table(nsIDOMDocument visualDocument,Node source ) {
super(visualDocument.createElement(PanelLayoutTable.TABLE));
VpePanelLayoutElements.mapAttributes(
@@ -458,76 +464,84 @@
MAP_ATTR_TO_TABLE
);
}
-
+
public Tr crateRow() {
nsIDOMElement tr = getOwnerDocument().createElement(PanelLayoutTable.TR);
getDomElement().appendChild(tr);
return new Tr(tr);
}
-
+
}
-
+
public class Tr extends DefaultNodeWrapper {
public Tr(nsIDOMElement rowNode) {
super(rowNode);
}
-
+
public Td createCell() {
nsIDOMElement tr = getOwnerDocument().createElement(PanelLayoutTable.TD);
getDomElement().appendChild(tr);
return new Td(tr);
}
-
+
public Td createCell(int colspanNumber) {
Td td = createCell();
td.setAttributeValue("colspan",""+colspanNumber);
return td;
}
-
+
}
-
+
public class Td extends DefaultNodeWrapper {
nsIDOMElement cell = null;
-
+
public Td(nsIDOMElement cellNode) {
super(cellNode);
cell = cellNode;
}
}
-
+
private void build(Element element, VpeDependencyMap dependencyMap) {
Set attrs = new HashSet();
for(int i=0;i<MAP_ATTR_TO_TABLE.length;i++) {
attrs.add(VpeExpressionBuilder.attrSignature(MAP_ATTR_TO_TABLE[i][0],caseSensitive));
}
- dependencyMap.setCreator(this, attrs);
+ dependencyMap.setCreator(this, attrs);
}
-
+
+ @Override
public void setAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name, String value) {
PanelLayoutTable layout = (PanelLayoutTable)visualNodeMap.get(this);
- VpePanelLayoutElements layoutElements = new VpePanelLayoutElements(sourceElement,
pageContext);
+ VpePanelLayoutElements layoutElements = new VpePanelLayoutElements(sourceElement,
pageContext);
layout.update(sourceElement,MAP_ATTR_TO_TABLE);
if(LAYOUT_NAVIGATION_RIGHT_ATTR_VALUE.equals(layoutElements.getLayoutName())) {
layout.updateTop(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.updateLeft(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.updateRight(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.updateBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.updateBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
} else if(LAYOUT_UPSIDEDOWN_VALUE.equals(layoutElements.getLayoutName())) {
layout.updateBottom(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.updateLeft(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.updateRight(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.updateTop(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.updateTop(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
} else { // LAYOUT_CLASSIC_ATTR_VALUE
layout.updateTop(layoutElements.getHeaderFacet(),MAP_ATTR_TO_HEADER);
layout.updateLeft(layoutElements.getNavigationFacet(),MAP_ATTR_TO_NAVIGATION);
layout.updateRight(layoutElements.getBodyFacet(),MAP_ATTR_TO_BODY);
- layout.updateBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
+ layout.updateBottom(layoutElements.getFooterFacet(),MAP_ATTR_TO_FOOTER);
}
}
- public void validate(VpePageContext pageContext, Element sourceElement, Document
visualDocument, Element visualParent, Element visualElement, Map visualNodeMap) {
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractCreator#validate(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Element, org.mozilla.interfaces.nsIDOMDocument,
org.mozilla.interfaces.nsIDOMElement, org.mozilla.interfaces.nsIDOMElement,
java.util.Map)
+ */
+ @Override
+ public void validate(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMElement visualParent,
+ nsIDOMElement visualElement, Map visualNodeMap) {
}
-
+
+ @Override
public void removeAttribute(VpePageContext pageContext, Element sourceElement, Map
visualNodeMap, String name) {
}
}