JBoss Tools SVN: r6593 - in trunk/jsf/tests: org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-02-27 06:38:19 -0500 (Wed, 27 Feb 2008)
New Revision: 6593
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1548/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1548/JBIDE-1548.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/Jbide1548Test.java
Removed:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/jsfTest/WebContent/pages/JBIDE/1548/
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1548Test.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
Log:
replace junit for 1548 from jsf test to richfaces test
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2008-02-27 11:16:08 UTC (rev 6592)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2008-02-27 11:38:19 UTC (rev 6593)
@@ -26,7 +26,6 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1467Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1501Test;
-import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1548Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JsfJbide1568Test;
import org.jboss.tools.vpe.ui.test.VpeTestSetup;
import org.jboss.tools.vpe.ui.test.beans.ImportBean;
@@ -48,7 +47,6 @@
suite.addTestSuite(JsfJbide1467Test.class);
suite.addTestSuite(JsfJbide1501Test.class);
suite.addTestSuite(JBIDE1484Test.class);
- suite.addTestSuite(JsfJbide1548Test.class);
suite.addTestSuite(JsfJbide1568Test.class);
suite.addTestSuite(JBIDE1615Test.class);
suite.addTestSuite(JBIDE1479Test.class);
Deleted: trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1548Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1548Test.java 2008-02-27 11:16:08 UTC (rev 6592)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JsfJbide1548Test.java 2008-02-27 11:38:19 UTC (rev 6593)
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.jsf.vpe.jsf.test.jbide;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.part.FileEditorInput;
-import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
-import org.jboss.tools.vpe.editor.util.HTML;
-import org.jboss.tools.vpe.ui.test.TestUtil;
-import org.jboss.tools.vpe.ui.test.VpeTest;
-import org.mozilla.interfaces.nsIDOMDocument;
-import org.mozilla.interfaces.nsIDOMElement;
-import org.mozilla.interfaces.nsIDOMNode;
-
-/**
- * Class for testing all jsf bugs
- *
- * @author sdzmitrovich
- *
- * test for http://jira.jboss.com/jira/browse/JBIDE-1548
- *
- *
- */
-public class JsfJbide1548Test extends VpeTest {
-
- // type of input tag
-
- // import project name
-
- public static final String IMPORT_PROJECT_NAME = "jsfTest";
-
- public JsfJbide1548Test(String name) {
- super(name);
- }
-
- /*
- * JBIDE's test cases
- */
-
- public void testJbide() throws Throwable {
-
- // wait
- TestUtil.waitForJobs();
- // set exception
- setException(null);
-
- // get test page path
- IFile file = (IFile) TestUtil.getComponentPath(
- "JBIDE/1548/JBIDE-1548.jsp", IMPORT_PROJECT_NAME);
-
- assertNotNull("Could not open specified file " + file.getFullPath(),
- file);
-
- IEditorInput input = new FileEditorInput(file);
-
- assertNotNull("Editor input is null", input);
- // open and get editor
- JSPMultiPageEditor part = openEditor(input);
-
- // get dom document
- nsIDOMDocument document = getVpeVisualDocument(part);
- nsIDOMElement element = document.getDocumentElement();
-
- assertNotNull(element);
-
- // get root node
- nsIDOMNode node = (nsIDOMNode) element
- .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
-
- List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
-
- // find "table" elements
- TestUtil.findElementsByName(node, elements, HTML.TAG_TABLE);
-
- assertEquals(2, elements.size());
-
- // get first table. It has default attributes (minValue=0, maxValue=100)
- nsIDOMNode defaultInputSlider = elements.get(0);
- // check min-,max- values
- checkMinMaxValue(defaultInputSlider, 0, 100);
-
- // get first table. It has edited attributes (minValue=-10,
- // maxValue=200)
- nsIDOMNode editedInputSlider = elements.get(1);
- // check min-,max- values
- checkMinMaxValue(editedInputSlider, -10, 200);
-
- // check exception
- if (getException() != null) {
- throw getException();
- }
-
- }
-
- /**
- * check minValue and maxValue
- *
- * inputNumberSlider has next structure
- *
- * <code>
- * <table>
- * <tr>
- * <td>minValue</td>
- * <td>maxValue</td>
- * </tr>
- * ....
- * </table>
- * </code>
- *
- */
- private void checkMinMaxValue(nsIDOMNode defaultInputSlider,
- int expectedMinValue, int expectedMaxValue) {
-
- // get "tr" element
- nsIDOMNode trNode = defaultInputSlider.getChildNodes().item(0);
- assertNotNull(trNode);
- // get first "td" element which contain minValue
- nsIDOMNode td1Node = trNode.getChildNodes().item(0);
- assertNotNull(td1Node);
-
- // get second "td" element which contain maxValue
- nsIDOMNode td2Node = trNode.getChildNodes().item(1);
- assertNotNull(td2Node);
-
- // get minValue
- nsIDOMNode minValue = td1Node.getChildNodes().item(0);
- assertNotNull(minValue);
-
- // get maxValue
- nsIDOMNode maxValue = td2Node.getChildNodes().item(0);
- assertNotNull(maxValue);
-
- // check min value
- String minValueString = minValue.getNodeValue();
- assertNotNull(minValueString);
- assertEquals(expectedMinValue, Integer.parseInt(minValueString));
-
- // check max value
- String maxValueString = maxValue.getNodeValue();
- assertNotNull(maxValueString);
- assertEquals(expectedMaxValue, Integer.parseInt(maxValueString));
-
- return;
- }
-
-}
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1548/JBIDE-1548.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1548/JBIDE-1548.xhtml (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/JBIDE/1548/JBIDE-1548.xhtml 2008-02-27 11:38:19 UTC (rev 6593)
@@ -0,0 +1,17 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:rich="http://richfaces.org/rich">
+
+<head>
+</head>
+<body>
+ <!-- Input Number Slider -->
+ <rich:inputNumberSlider />
+
+ <rich:inputNumberSlider minValue="-10" maxValue="200" value="40" />
+</body>
+</html>
\ No newline at end of file
Added: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/Jbide1548Test.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/Jbide1548Test.java (rev 0)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/src/org/jboss/tools/jsf/vpe/richfaces/test/jbide/Jbide1548Test.java 2008-02-27 11:38:19 UTC (rev 6593)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.jsf.vpe.richfaces.test.jbide;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
+import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+
+/**
+ * Class for testing all jsf bugs
+ *
+ * @author sdzmitrovich
+ *
+ * test for http://jira.jboss.com/jira/browse/JBIDE-1548
+ *
+ *
+ */
+public class Jbide1548Test extends VpeTest {
+
+ // type of input tag
+
+ // import project name
+
+ public static final String IMPORT_PROJECT_NAME = "richFacesTest";
+
+ public Jbide1548Test(String name) {
+ super(name);
+ }
+
+ /*
+ * JBIDE's test cases
+ */
+
+ public void testJbide() throws Throwable {
+
+ // wait
+ TestUtil.waitForJobs();
+ // set exception
+ setException(null);
+
+ // get test page path
+ IFile file = (IFile) TestUtil.getComponentPath(
+ "JBIDE/1548/JBIDE-1548.xhtml", IMPORT_PROJECT_NAME);
+
+ assertNotNull("Could not open specified file " + file.getFullPath(),
+ file);
+
+ IEditorInput input = new FileEditorInput(file);
+
+ assertNotNull("Editor input is null", input);
+ // open and get editor
+ JSPMultiPageEditor part = openEditor(input);
+
+ // get dom document
+ nsIDOMDocument document = getVpeVisualDocument(part);
+ nsIDOMElement element = document.getDocumentElement();
+
+ assertNotNull(element);
+
+ // get root node
+ nsIDOMNode node = (nsIDOMNode) element
+ .queryInterface(nsIDOMNode.NS_IDOMNODE_IID);
+
+ List<nsIDOMNode> elements = new ArrayList<nsIDOMNode>();
+
+ // find "table" elements
+ TestUtil.findElementsByName(node, elements, HTML.TAG_TABLE);
+
+ assertEquals(2, elements.size());
+
+ // get first table. It has default attributes (minValue=0, maxValue=100)
+ nsIDOMNode defaultInputSlider = elements.get(0);
+ // check min-,max- values
+ checkMinMaxValue(defaultInputSlider, 0, 100);
+
+ // get first table. It has edited attributes (minValue=-10,
+ // maxValue=200)
+ nsIDOMNode editedInputSlider = elements.get(1);
+ // check min-,max- values
+ checkMinMaxValue(editedInputSlider, -10, 200);
+
+ // check exception
+ if (getException() != null) {
+ throw getException();
+ }
+
+ }
+
+ /**
+ * check minValue and maxValue
+ *
+ * inputNumberSlider has next structure
+ *
+ * <code>
+ * <table>
+ * <tr>
+ * <td>minValue</td>
+ * <td>maxValue</td>
+ * </tr>
+ * ....
+ * </table>
+ * </code>
+ *
+ */
+ private void checkMinMaxValue(nsIDOMNode defaultInputSlider,
+ int expectedMinValue, int expectedMaxValue) {
+
+ // get "tr" element
+ nsIDOMNode trNode = defaultInputSlider.getChildNodes().item(0);
+ assertNotNull(trNode);
+ // get first "td" element which contain minValue
+ nsIDOMNode td1Node = trNode.getChildNodes().item(0);
+ assertNotNull(td1Node);
+
+ // get second "td" element which contain maxValue
+ nsIDOMNode td2Node = trNode.getChildNodes().item(1);
+ assertNotNull(td2Node);
+
+ // get minValue
+ nsIDOMNode minValue = td1Node.getChildNodes().item(0);
+ assertNotNull(minValue);
+
+ // get maxValue
+ nsIDOMNode maxValue = td2Node.getChildNodes().item(0);
+ assertNotNull(maxValue);
+
+ // check min value
+ String minValueString = minValue.getNodeValue();
+ assertNotNull(minValueString);
+ assertEquals(expectedMinValue, Integer.parseInt(minValueString));
+
+ // check max value
+ String maxValueString = maxValue.getNodeValue();
+ assertNotNull(maxValueString);
+ assertEquals(expectedMaxValue, Integer.parseInt(maxValueString));
+
+ return;
+ }
+
+}
17 years, 7 months
JBoss Tools SVN: r6592 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-02-27 06:16:08 -0500 (Wed, 27 Feb 2008)
New Revision: 6592
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSliderTemplate.java
Log:
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSliderTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSliderTemplate.java 2008-02-27 10:43:07 UTC (rev 6591)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesInputNumberSliderTemplate.java 2008-02-27 11:16:08 UTC (rev 6592)
@@ -782,22 +782,4 @@
return true;
}
- @Override
- public void setSourceAttributeSelection(VpePageContext pageContext,
- Element sourceElement, int offset, int length, Object data) {
- System.out.print("\n sourceElement:" + sourceElement.getNodeName()
- + "\toffset:" + offset + "\tlength:" + length + "\tdata : "
- + data);
- VpeSourceDomBuilder sourceBuilder = pageContext.getSourceBuilder();
- sourceBuilder.setAttributeSelection(sourceElement.getAttributeNode("value"), offset, length);
- super.setSourceAttributeSelection(pageContext, sourceElement, offset,
- length, data);
- }
- @Override
- public void refreshBundleValues(VpePageContext pageContext,
- Element sourceElement, Object data) {
- System.out.print("\nrefresh");
- // TODO Auto-generated method stub
- super.refreshBundleValues(pageContext, sourceElement, data);
- }
}
\ No newline at end of file
17 years, 7 months
JBoss Tools SVN: r6591 - in trunk: jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: dsakovich
Date: 2008-02-27 05:43:07 -0500 (Wed, 27 Feb 2008)
New Revision: 6591
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneMenuTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneRadioTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneListbox.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1720
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java 2008-02-27 07:06:46 UTC (rev 6590)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfRadioSelectItemTemplate.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -59,7 +59,7 @@
nsIDOMDocument visualDocument) {
// create span element
- nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+ nsIDOMElement span = visualDocument.createElement(HTML.TAG_TABLE);
// add title attribute to span
span.setAttribute(HTML.ATTR_TITLE, getTitle(sourceNode));
span.setAttribute(HTML.ATTR_STYLE, SPAN_STYLE_VALUE);
@@ -84,8 +84,10 @@
// label exist
if (null != label) {
// add label to span
+ nsIDOMElement labelElement = visualDocument.createElement(HTML.TAG_LABEL);
nsIDOMText text = visualDocument.createTextNode(label);
- span.appendChild(text);
+ span.appendChild(labelElement);
+ labelElement.appendChild(text);
}
return new VpeCreationData(span);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneListbox.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneListbox.java 2008-02-27 07:06:46 UTC (rev 6590)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneListbox.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -1,18 +1,22 @@
/*******************************************************************************
-* Copyright (c) 2007 Red Hat, Inc.
-* Distributed under license by Red Hat, Inc. All rights reserved.
-* This program is made available under the terms of the
-* Eclipse Public License v1.0 which accompanies this distribution,
-* and is available at http://www.eclipse.org/legal/epl-v10.html
-*
-* Contributors:
-* Red Hat, Inc. - initial API and implementation
-******************************************************************************/
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.jsf.vpe.jsf.template;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
@@ -20,6 +24,8 @@
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.xpcom.XPCOMException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -37,6 +43,9 @@
*/
private static final String ATTR_SIZE = "size"; //$NON-NLS-1$
+ private static final String ATTR_DISABLED_CLASS = "disabledClass";
+ private static final String ATTR_ENABLED_CLASS = "enabledClass";
+
/**
* list of visible children
*/
@@ -50,11 +59,13 @@
/**
* list of copied attributes
*/
- private static List<String> ATTR_LIST_COPY = new ArrayList<String>();
+ private static Map<String, String> ATTR_LIST_COPY = new HashMap<String, String>();
static {
- ATTR_LIST_COPY.add("style"); //$NON-NLS-1$
- ATTR_LIST_COPY.add("styleClass"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("style", "style"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("styleClass", "class"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("disabled", "disabled"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("dir", "dir"); //$NON-NLS-1$
}
/**
@@ -80,14 +91,24 @@
Element element = (Element) sourceNode;
// import attributes from source
- for (String attributeName : ATTR_LIST_COPY) {
+ Set<String> jsfAttributes = ATTR_LIST_COPY.keySet();
+ for (String attributeName : jsfAttributes) {
+
// get attribute
String attr = element.getAttribute(attributeName);
// add attribute to "select"
- if (attr != null)
- select.setAttribute(HTML.ATTR_STYLE, attr);
+ if (attr != null) {
+ if (attributeName.equalsIgnoreCase(HTML.ATTR_DISABLED)) {
+ if (attr.equalsIgnoreCase("true")) {
+ select.setAttribute(ATTR_LIST_COPY.get(attributeName),
+ "disabled");
+ }
+ continue;
+ }
+ select.setAttribute(ATTR_LIST_COPY.get(attributeName), attr);
+ }
}
@@ -144,4 +165,35 @@
// remove attribute
select.removeAttribute(name);
}
+
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ if (data.getNode() != null) {
+ applyChildAttributes((Element) sourceNode, data.getNode());
+ }
+ }
+
+ private void applyChildAttributes(Element sourceElement, nsIDOMNode node) {
+ boolean disabled = false;
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ disabled = ComponentUtil.string2boolean(ComponentUtil.getAttribute(
+ sourceElement, HTML.ATTR_DISABLED));
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_OPTION)) {
+ element.setAttribute(HTML.ATTR_CLASS, disabled ? ComponentUtil
+ .getAttribute(sourceElement, ATTR_DISABLED_CLASS)
+ : ComponentUtil.getAttribute(sourceElement,
+ ATTR_ENABLED_CLASS));
+ }
+ for (int i = 0; i < list.getLength(); i++) {
+ applyChildAttributes(sourceElement, list.item(i));
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
+ }
}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneMenuTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneMenuTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneMenuTemplate.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -0,0 +1,163 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.template;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.xpcom.XPCOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ *
+ * template for selectOneMenu select item
+ *
+ */
+public class JsfSelectOneMenuTemplate extends VpeAbstractTemplate {
+
+ /**
+ * "size" attribute
+ */
+
+ private static final String ATTR_DISABLED_CLASS = "disabledClass";
+ private static final String ATTR_ENABLED_CLASS = "enabledClass";
+
+ /**
+ * list of visible children
+ */
+ private static List<String> CHILDREN_LIST = new ArrayList<String>();
+
+ static {
+ CHILDREN_LIST.add("selectItem"); //$NON-NLS-1$
+ CHILDREN_LIST.add("selectItems"); //$NON-NLS-1$
+ }
+
+ /**
+ * list of copied attributes
+ */
+ private static Map<String, String> ATTR_LIST_COPY = new HashMap<String, String>();
+
+ static {
+ ATTR_LIST_COPY.put("style", "style"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("styleClass", "class"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("disabled", "disabled"); //$NON-NLS-1$
+ ATTR_LIST_COPY.put("dir", "dir"); //$NON-NLS-1$
+
+ }
+
+ /**
+ *
+ */
+ public JsfSelectOneMenuTemplate() {
+
+ // TODO Auto-generated constructor stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ // create select element
+ nsIDOMElement select = visualDocument.createElement(HTML.TAG_SELECT);
+ select.setAttribute(HTML.ATTR_SIZE, "1");
+ Element element = (Element) sourceNode;
+
+ // import attributes from source
+ Set<String> jsfAttributes = ATTR_LIST_COPY.keySet();
+
+ for (String attributeName : jsfAttributes) {
+
+ // get attribute
+ String attr = element.getAttribute(attributeName);
+
+ // add attribute to "select"
+ if (attr != null) {
+ if (attributeName.equalsIgnoreCase(HTML.ATTR_DISABLED)) {
+ if (attr.equalsIgnoreCase("true")) {
+ select.setAttribute(ATTR_LIST_COPY.get(attributeName),
+ "disabled");
+
+ }
+ continue;
+ }
+ select.setAttribute(ATTR_LIST_COPY.get(attributeName), attr);
+ }
+
+ }
+
+ return new VpeCreationData(select);
+ }
+
+ /**
+ *
+ */
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+
+ // get DOMElement(root element is select)
+ nsIDOMElement select = (nsIDOMElement) visualNode
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+
+ // remove attribute
+ select.removeAttribute(name);
+ }
+
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ if (data.getNode() != null) {
+ applyChildAttributes((Element) sourceNode, data.getNode());
+ }
+ }
+
+ private void applyChildAttributes(Element sourceElement, nsIDOMNode node) {
+ boolean disabled = false;
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ disabled = ComponentUtil.string2boolean(ComponentUtil.getAttribute(
+ sourceElement, HTML.ATTR_DISABLED));
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_OPTION)) {
+ element.setAttribute(HTML.ATTR_CLASS, disabled ? ComponentUtil
+ .getAttribute(sourceElement, ATTR_DISABLED_CLASS)
+ : ComponentUtil.getAttribute(sourceElement,
+ ATTR_ENABLED_CLASS));
+ }
+ for (int i = 0; i < list.getLength(); i++) {
+ applyChildAttributes(sourceElement, list.item(i));
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
+ }
+}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneRadioTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneRadioTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfSelectOneRadioTemplate.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.template;
+
+import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.mozilla.interfaces.nsIDOMNodeList;
+import org.mozilla.xpcom.XPCOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Class for creating selectOneRadio template
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ *
+ */
+
+public class JsfSelectOneRadioTemplate extends VpeAbstractTemplate {
+
+ private static final String VAL_PAGE_DIRECTION = "pageDirection";
+ private static final String ATTR_LAYOUT = "layout";
+ private static final String ATTR_BORDER = "border";
+ private static final String ATTR_DISABLED_CLASS = "disabledClass";
+ private static final String ATTR_ENABLED_CLASS = "enabledClass";
+ private static final String ATTR_STYLE_CLASS = "styleClass";
+
+ private static final String ATTR_DIR_RIGHT_TO_LEFT = "rtl";
+ private static final String ATTR_DIR_LEFT_TO_RIGHT = "ltr";
+ private static final String ATTR_DISABLED_VALUE = "disabled";
+
+ public JsfSelectOneRadioTemplate() {
+ super();
+
+ }
+
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ Element sourceElement = (Element) sourceNode;
+
+ boolean layoutHorizontal = true;
+
+ String layout = sourceElement.getAttribute(ATTR_LAYOUT);
+
+ layoutHorizontal = !VAL_PAGE_DIRECTION.equalsIgnoreCase(layout);
+
+ nsIDOMElement visualTable = visualDocument
+ .createElement(HTML.TAG_TABLE);
+ VpeCreationData creatorInfo = new VpeCreationData(visualTable);
+
+ visualTable.setAttribute(HTML.ATTR_CLASS, ComponentUtil.getAttribute(
+ sourceElement, ATTR_STYLE_CLASS));
+ visualTable.setAttribute(HTML.ATTR_STYLE, ComponentUtil.getAttribute(
+ sourceElement, HTML.ATTR_STYLE));
+ String border = sourceElement.getAttribute(ATTR_BORDER);
+ if (border != null)
+ visualTable.setAttribute(ATTR_BORDER, border);
+
+ NodeList children = sourceNode.getChildNodes();
+ int count = children != null ? children.getLength() : 0;
+ if (count > 0) {
+ Node[] sourceChildren = new Node[count];
+ int childrenCount = 0;
+ for (int i = 0; i < count; i++) {
+ Node node = children.item(i);
+ int type = node.getNodeType();
+ if (type == Node.ELEMENT_NODE || type == Node.TEXT_NODE
+ && node.getNodeValue().trim().length() > 0) {
+ sourceChildren[childrenCount] = node;
+ childrenCount++;
+ }
+ }
+ if (childrenCount > 0) {
+ int rowCount;
+ int rowLength;
+ int tableSize = childrenCount;
+ if (layoutHorizontal) {
+ rowCount = (childrenCount + tableSize - 1) / tableSize;
+ rowLength = tableSize;
+ } else {
+ rowCount = tableSize;
+ rowLength = (childrenCount + tableSize - 1) / tableSize;
+ }
+ for (int i = 0; i < rowCount; i++) {
+ nsIDOMElement visualRow = visualDocument
+ .createElement(HTML.TAG_TR);
+ for (int j = 0; j < rowLength; j++) {
+ nsIDOMElement visualCell = visualDocument
+ .createElement(HTML.TAG_TD);
+ visualRow.appendChild(visualCell);
+ int sourceIndex = layoutHorizontal ? rowLength * i + j
+ : rowCount * j + i;
+ if (sourceIndex < childrenCount) {
+ VpeChildrenInfo childrenInfo = new VpeChildrenInfo(
+ visualCell);
+ childrenInfo
+ .addSourceChild(sourceChildren[sourceIndex]);
+ creatorInfo.addChildrenInfo(childrenInfo);
+ }
+ }
+ visualTable.appendChild(visualRow);
+ }
+ }
+ }
+ return creatorInfo;
+ }
+
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ if (data.getNode() != null) {
+ applyChildAttributes((Element) sourceNode, data.getNode());
+ }
+ }
+
+ private void applyChildAttributes(Element sourceElement, nsIDOMNode node) {
+ boolean disabled = false;
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ nsIDOMElement element = (nsIDOMElement) node
+ .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID);
+ disabled = ComponentUtil.string2boolean(ComponentUtil.getAttribute(
+ sourceElement, HTML.ATTR_DISABLED));
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_INPUT)) {
+ element
+ .setAttribute(
+ HTML.ATTR_DIR,
+ (ComponentUtil.getAttribute(sourceElement,
+ HTML.ATTR_DIR) == ATTR_DIR_LEFT_TO_RIGHT) ? ATTR_DIR_LEFT_TO_RIGHT
+ : ATTR_DIR_RIGHT_TO_LEFT);
+ element.setAttribute(HTML.ATTR_SIZE, ComponentUtil
+ .getAttribute(sourceElement, HTML.ATTR_SIZE));
+ if (disabled)
+ element.setAttribute(HTML.ATTR_DISABLED,
+ ATTR_DISABLED_VALUE);
+
+ }
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_LABEL)) {
+ element.setAttribute(HTML.ATTR_CLASS, disabled ? ComponentUtil
+ .getAttribute(sourceElement, ATTR_DISABLED_CLASS)
+ : ComponentUtil.getAttribute(sourceElement,
+ ATTR_ENABLED_CLASS));
+ }
+
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_TABLE)) {
+ element.setAttribute(HTML.ATTR_STYLE, ComponentUtil
+ .getAttribute(sourceElement, HTML.ATTR_STYLE));
+ }
+
+ for (int i = 0; i < list.getLength(); i++) {
+ applyChildAttributes(sourceElement, list.item(i));
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
+ }
+
+}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/util/ComponentUtil.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.template.util;
+
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Element;
+
+/**
+ * Utilities for jsf templates
+ *
+ * @author Dzmitry Sakovich (dsakovich(a)exadel.com)
+ *
+ */
+public class ComponentUtil {
+
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(Element sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = "";
+ }
+ return attribute;
+ }
+
+ /**
+ * Returns value of attribute.
+ *
+ * @param sourceElement
+ * @param attributeName
+ * @return
+ */
+ public static String getAttribute(nsIDOMElement sourceElement,
+ String attributeName) {
+ String attribute = sourceElement.getAttribute(attributeName);
+ if (attribute == null) {
+ attribute = "";
+ }
+ return attribute;
+ }
+
+ /**
+ * Parses string value retrieved from sourceElement.getAttribure(..) method
+ * to its boolean value.
+ * <p>
+ * <code>false</code> is returned only if it specified explicitly,
+ * otherwise <code>true</code> is returned.
+ *
+ * @param str
+ * the string to parse
+ * @return boolean value from string
+ */
+ public static boolean string2boolean(String str) {
+ if ((str == null) || ("".equals(str))) {
+ return false;
+ } else if (("true".equalsIgnoreCase(str))
+ || ("false".equalsIgnoreCase(str))) {
+ return new Boolean(str).booleanValue();
+ }
+ return false;
+ }
+}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-02-27 07:06:46 UTC (rev 6590)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/templates/vpe-templates-jsf.xml 2008-02-27 10:43:07 UTC (rev 6591)
@@ -561,9 +561,7 @@
</vpe:tag>
<vpe:tag name="h:selectOneRadio" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
- <vpe:grid layout="{@layout}" border="{@border}" title="{tagstring()}"/>
- <vpe:breaker type="ignore"/>
+ <vpe:template children="yes" modify="yes" class="org.jboss.tools.jsf.vpe.jsf.template.JsfSelectOneRadioTemplate">
<vpe:dnd>
<vpe:drag start-enable="yes"/>
<vpe:drop container="yes">
@@ -671,8 +669,8 @@
</vpe:tag>
<vpe:tag name="h:selectOneMenu" case-sensitive="yes">
- <vpe:template children="yes" modify="yes">
- <select style="{@style}" class="{@styleClass}" title="{tagstring()}"/>
+ <vpe:template class="org.jboss.tools.jsf.vpe.jsf.template.JsfSelectOneMenuTemplate"
+ children="yes" modify="yes">
<vpe:resize>
<vpe:width width-attr="style.width" />
<vpe:height height-attr="style.height" />
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-02-27 07:06:46 UTC (rev 6590)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-02-27 10:43:07 UTC (rev 6591)
@@ -61,12 +61,12 @@
public static final String ATTR_ID = "ID"; //$NON-NLS-1$
public static final String ATTR_TYPE = "TYPE"; //$NON-NLS-1$
public static final String ATTR_TEXT = "TEXT"; //$NON-NLS-1$
- public static final String ATTR_CLASS = "CLASS"; //$NON-NLS-1$
+ public static final String ATTR_CLASS = "class"; //$NON-NLS-1$
public static final String ATTR_TITLE = "TITLE"; //$NON-NLS-1$
public static final String ATTR_NAME = "NAME"; //$NON-NLS-1$
public static final String ATTR_VALUE = "VALUE"; //$NON-NLS-1$
- public static final String ATTR_STYLE = "STYLE"; //$NON-NLS-1$
- public static final String ATTR_SIZE = "SIZE"; //$NON-NLS-1$
+ public static final String ATTR_STYLE = "style"; //$NON-NLS-1$
+ public static final String ATTR_SIZE = "size"; //$NON-NLS-1$
public static final String ATTR_MULTIPLE = "MULTIPLE"; //$NON-NLS-1$
public static final String ATTR_COLSPAN = "colspan"; //$NON-NLS-1$
public static final String ATTR_CELLSPACING = "cellspacing"; //$NON-NLS-1$
@@ -75,6 +75,7 @@
public static final String ATTR_HEIGHT = "HEIGHT"; //$NON-NLS-1$
public static final String ATTR_BORDER = "BORDER"; //$NON-NLS-1$
public static final String ATTR_FOR = "FOR";
- public static final String ATTR_DIR = "DIR";
+ public static final String ATTR_DIR = "dir";
+ public static final String ATTR_DISABLED = "disabled";
}
\ No newline at end of file
17 years, 7 months
JBoss Tools SVN: r6590 - in trunk/documentation: qa and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-02-27 02:06:46 -0500 (Wed, 27 Feb 2008)
New Revision: 6590
Added:
trunk/documentation/qa/test-strategy/
Removed:
trunk/documentation/movies/test-strategy/
Log:
Copied: trunk/documentation/qa/test-strategy (from rev 6589, trunk/documentation/movies/test-strategy)
17 years, 7 months
JBoss Tools SVN: r6588 - trunk/documentation/qa.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-02-27 02:04:17 -0500 (Wed, 27 Feb 2008)
New Revision: 6588
Added:
trunk/documentation/qa/test-plan/
Removed:
trunk/documentation/qa/jbide-testplan/
Log:
Copied: trunk/documentation/qa/test-plan (from rev 6587, trunk/documentation/qa/jbide-testplan)
17 years, 7 months
JBoss Tools SVN: r6587 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2008-02-26 20:55:24 -0500 (Tue, 26 Feb 2008)
New Revision: 6587
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF
Log:
fix JUnit test configuration errors
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF 2008-02-26 18:18:13 UTC (rev 6586)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF 2008-02-27 01:55:24 UTC (rev 6587)
@@ -12,4 +12,5 @@
org.mozilla.xpcom,
org.jboss.tools.jst.jsp
Eclipse-LazyStart: true
-Export-Package: org.jboss.tools.jsf.vpe.myfaces.template
+Export-Package: org.jboss.tools.jsf.vpe.myfaces,
+ org.jboss.tools.jsf.vpe.myfaces.template
17 years, 7 months
JBoss Tools SVN: r6586 - in trunk/seam: tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-02-26 13:18:13 -0500 (Tue, 26 Feb 2008)
New Revision: 6586
Added:
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java
trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1696 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-02-26 18:05:45 UTC (rev 6585)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-02-26 18:18:13 UTC (rev 6586)
@@ -23,10 +23,12 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.Flags;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -354,10 +356,24 @@
for (ISeamComponentDeclaration declaration : declarations) {
if(declaration instanceof ISeamJavaComponentDeclaration) {
ISeamJavaComponentDeclaration jd = (ISeamJavaComponentDeclaration)declaration;
- boolean sourceJavaDeclaration = !((IType)jd.getSourceMember()).isBinary();
+ IType type = (IType)jd.getSourceMember();
+ boolean sourceJavaDeclaration = !type.isBinary();
if(sourceJavaDeclaration) {
// Save link between component name and java source file.
validationContext.addLinkedCoreResource(componentName, declaration.getSourcePath());
+ // Save link between component name and all supers of java declaration.
+ try {
+ ITypeHierarchy typeHierarchy = type.newSupertypeHierarchy(new NullProgressMonitor());
+ IType[] superTypes = typeHierarchy == null ? null : typeHierarchy.getAllSupertypes(type);
+ for (int i = 0; superTypes != null && i < superTypes.length; i++) {
+ if(!superTypes[i].isBinary()) {
+ IPath path = superTypes[i].getResource().getFullPath();
+ validationContext.addLinkedCoreResource(componentName, path);
+ }
+ }
+ } catch (JavaModelException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
}
if(declaration!=firstJavaDeclaration) {
// Validate @Name
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java 2008-02-26 18:18:13 UTC (rev 6586)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.domain.SeamWebWarTestProject.session;
+
+import javax.ejb.Stateful;
+
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+@Stateful
+@Name("testComponentJBIDE1696")
+public class SubclassTestComponent extends SuperclassTestComponent {
+
+ @Destroy public void foo1() {}
+}
\ No newline at end of file
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java 2008-02-26 18:18:13 UTC (rev 6586)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.domain.SeamWebWarTestProject.session;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+public class SuperclassTestComponent {
+
+}
\ No newline at end of file
Added: trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove (rev 0)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/projects/SeamWebWarTestProject/src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove 2008-02-26 18:18:13 UTC (rev 6586)
@@ -0,0 +1,23 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.domain.SeamWebWarTestProject.session;
+
+import javax.ejb.Remove;
+
+/**
+ * Test component for JBIDE-1696
+ * @author Alexey Kazakov
+ */
+public class SuperclassTestComponent {
+
+ @Remove void foo() {}
+}
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-02-26 18:05:45 UTC (rev 6585)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/SeamValidatorsTest.java 2008-02-26 18:18:13 UTC (rev 6586)
@@ -83,13 +83,31 @@
assertTrue("Problem marker was found in varAttributes.xhtml file. Validator did not recognize 'var' attribute.", number == 0);
}
+ public void testJiraJbide1696() throws CoreException {
+ getSeamProject(project);
+
+ // Test for http://jira.jboss.com/jira/browse/JBIDE-1696
+ IFile subclassComponentFile = project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SubclassTestComponent.java");
+ assertMarkerIsCreated(subclassComponentFile, null, "Stateful component \"testComponentJBIDE1696\" must have a method marked @Remove", 25);
+ IFile superclassComponentFile = project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.java");
+ IFile superclassComponentFileWithRemove = project.getFile("src/action/org/domain/SeamWebWarTestProject/session/SuperclassTestComponent.withRemove");
+ try{
+ superclassComponentFile.setContents(superclassComponentFileWithRemove.getContents(), true, false, new NullProgressMonitor());
+ }catch(Exception e){
+ JUnitUtils.fail("Error during changing 'SuperclassTestComponent.java' content to 'SuperclassTestComponent.withRemove'", e);
+ }
+ refreshProject(project);
+ int number = getMarkersNumber(subclassComponentFile);
+ assertTrue("We changed super class of component but it still don't see changes.", number == 0);
+ }
+
public void testJiraJbide1631() throws CoreException {
// Test for http://jira.jboss.com/jira/browse/JBIDE-1631
IFile jbide1631XHTMLFile = project.getFile("WebContent/JBIDE-1631.xhtml");
assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo1\" cannot be resolved", 16 );
assertMarkerIsCreated(jbide1631XHTMLFile, null, "\"foo2\" cannot be resolved", 17 );
}
-
+
public void testComponentsValidator() {
ISeamProject seamProject = getSeamProject(project);
17 years, 7 months
JBoss Tools SVN: r6585 - trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-02-26 13:05:45 -0500 (Tue, 26 Feb 2008)
New Revision: 6585
Modified:
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1812
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-02-26 18:03:50 UTC (rev 6584)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/ContentAssistantTestCase.java 2008-02-26 18:05:45 UTC (rev 6585)
@@ -100,7 +100,7 @@
}
}
- assertTrue("Content Assistant peturned no proposals", (result != null && result.length > 0));
+ assertTrue("Content Assistant returned no proposals", (result != null && result.length > 0));
for (int i = 0; i < proposals.length; i++) {
assertTrue("Proposal "+proposals[i]+" not found!", compareProposal(proposals[i], result));
Modified: trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-26 18:03:50 UTC (rev 6584)
+++ trunk/jst/tests/org.jboss.tools.jst.jsp.test/src/org/jboss/tools/jst/jsp/test/ca/JstJspJbide1585Test.java 2008-02-26 18:05:45 UTC (rev 6585)
@@ -71,7 +71,7 @@
errorMessage= p.getErrorMessage();
}
- assertTrue("Content Assistant peturned no proposals", (result != null && result.length > 0));
+ assertTrue("Content Assistant returned no proposals", (result != null && result.length > 0));
for (int i = 0; i < result.length; i++) {
assertTrue("Content Assistant returned proposals which type (" + result[i].getClass().getName() + ") differs from RedHatCustomCompletionProposal", (result[i] instanceof AutoContentAssistantProposal));
17 years, 7 months
JBoss Tools SVN: r6584 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-02-26 13:03:50 -0500 (Tue, 26 Feb 2008)
New Revision: 6584
Added:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1718
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/AbstractOutputJsfTemplate.java 2008-02-26 18:03:50 UTC (rev 6584)
@@ -0,0 +1,92 @@
+package org.jboss.tools.jsf.vpe.jsf.template;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.jboss.tools.vpe.editor.bundle.BundleMap;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+public abstract class AbstractOutputJsfTemplate extends AbstractJsfTemplate {
+
+ /**
+ * name of "value" attribute
+ */
+ protected static final String VALUE_ATTR_NAME = "value";
+
+ /**
+ * name of "binding" attribute
+ */
+ protected static final String BINDING_ATTR_NAME = "binding";
+
+ /**
+ * name of "escape" attribute
+ */
+ protected static final String ESCAPE_ATTR_NAME = "escape";
+
+ /**
+ * name of "dir" attribute
+ */
+ protected static final String DIR_ATTR_NAME = "dir";
+
+ /**
+ *
+ * @param element
+ * @return
+ */
+ protected Attr getOutputAttributeNode(Element element) {
+
+ if (element.hasAttribute(VALUE_ATTR_NAME))
+ return element.getAttributeNode(VALUE_ATTR_NAME);
+ else if (element.hasAttribute(BINDING_ATTR_NAME))
+ return element.getAttributeNode(BINDING_ATTR_NAME);
+
+ return null;
+
+ }
+
+ /**
+ * get bundle
+ *
+ * @param pageContext
+ * @param attr
+ * @return
+ */
+ protected String getBundleValue(VpePageContext pageContext, Attr attr) {
+
+ return getBundleValue(pageContext, attr.getNodeValue(),
+ ((IDOMAttr) attr).getValueRegionStartOffset());
+
+ }
+
+ /**
+ *
+ * @param pageContext
+ * @param value
+ * @param offfset
+ * @return
+ */
+ protected String getBundleValue(VpePageContext pageContext, String value,
+ int offfset) {
+
+ BundleMap bundle = pageContext.getBundle();
+
+ return bundle.getBundleValue(value, offfset);
+
+ }
+
+ /**
+ * copy outputAttributes
+ *
+ * @param visualElement
+ * @param sourceElement
+ */
+ protected void copyOutputJsfAttributes(nsIDOMElement visualElement,
+ Element sourceElement) {
+ copyGeneralJsfAttributes(visualElement, sourceElement);
+ copyAttribute(visualElement, sourceElement, DIR_ATTR_NAME,
+ HTML.ATTR_DIR);
+
+ }
+}
Added: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jsf/src/org/jboss/tools/jsf/vpe/jsf/template/JsfOutputFormatTemplate.java 2008-02-26 18:03:50 UTC (rev 6584)
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.jsf.vpe.jsf.template;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
+import org.jboss.tools.jsf.vpe.jsf.template.util.NodeProxyUtil;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.mapping.VpeNodeMapping;
+import org.jboss.tools.vpe.editor.template.VpeChildrenInfo;
+import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.HTML;
+import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Sergey Dzmitrovich
+ *
+ * template for <h:outputFormat .../> jsf tag
+ *
+ */
+public class JsfOutputFormatTemplate extends AbstractOutputJsfTemplate {
+
+ /**
+ * name of "param" tag
+ */
+ private static final String PARAM_NAME = "param";
+
+ /**
+ * name of "choice"
+ */
+ private static final String CHOICE_NAME = "choice";
+
+ /**
+ * message format elements separator
+ */
+ private static final String MESSAGE_FORMAT_ELEMENTS_SEPARATOR = ",";
+
+ /**
+ * choices separator
+ */
+ private static final String CHOICES_SEPARATOR = "\\|";
+
+ /**
+ * choices separator
+ */
+ private static final String CHOICE_PAIR_SEPARATOR = "#";
+
+ /**
+ * message format elements pattern
+ */
+ private static final String MESSAGE_FORMAT_ELEMENTS_PATTERN = "\\{(\\d+)(,.*?){0,2}?\\}";
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.tools.vpe.editor.template.VpeTemplate#create(org.jboss.tools.vpe.editor.context.VpePageContext,
+ * org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMDocument)
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+
+ Element element = (Element) sourceNode;
+
+ List<VpeNodeMapping> attributesMapping = new ArrayList<VpeNodeMapping>();
+
+ // create span element
+ nsIDOMElement span = visualDocument.createElement(HTML.TAG_SPAN);
+
+ // creation data
+ VpeCreationData creationData = new VpeCreationData(span);
+
+ // copy attributes
+ copyOutputJsfAttributes(span, element);
+
+ // get attribute to represent
+ Attr attr = getOutputAttributeNode(element);
+
+ if (attr != null) {
+
+ // offset of attr
+ int offset = ((IDOMAttr) attr).getValueRegionStartOffset();
+
+ // value of attribute
+ String value = attr.getNodeValue();
+
+ // find parameters and update value
+ String newValue = updateNodeValue(value, getParams(element));
+ // if escape then contents of value (or other attribute) is only
+ // text
+ if (!element.hasAttribute(ESCAPE_ATTR_NAME)
+ || "true".equalsIgnoreCase(element
+ .getAttribute(ESCAPE_ATTR_NAME))) {
+
+ // get bundle value
+ newValue = getBundleValue(pageContext, newValue, offset);
+
+ nsIDOMText text;
+ // if bundleValue differ from value then will be represent
+ // bundleValue, but text will be not edit
+ if (!value.equals(newValue)) {
+
+ text = visualDocument.createTextNode(newValue);
+
+ } else {
+
+ text = visualDocument.createTextNode(value);
+ // add attribute for ability of editing
+ attributesMapping.add(new VpeNodeMapping(attr, text));
+ }
+ span.appendChild(text);
+ }
+ // then text can be html code
+ else {
+
+ // create info
+ VpeChildrenInfo spanInfo = new VpeChildrenInfo(span);
+
+ // reparse attribute's value
+ NodeList list = NodeProxyUtil.reparseAttributeValue(newValue,
+ offset);
+
+ // add children to info
+ for (int i = 0; i < list.getLength(); i++) {
+
+ Node child = list.item(i);
+
+ spanInfo.addSourceChild(child);
+ }
+
+ creationData.addChildrenInfo(spanInfo);
+
+ }
+
+ }
+
+ creationData.setData(attributesMapping);
+
+ return creationData;
+
+ }
+
+ @Override
+ public boolean isRecreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+
+ return true;
+ }
+
+ /**
+ * find message format elements and update value
+ *
+ * @param nodeValue
+ * @param paramList
+ * @return
+ */
+ private String updateNodeValue(String nodeValue, List<Element> paramList) {
+
+ // matcher
+ Matcher matcher = Pattern.compile(MESSAGE_FORMAT_ELEMENTS_PATTERN)
+ .matcher(nodeValue);
+
+ int lastPos = 0;
+ StringBuilder sb = new StringBuilder();
+
+ while (matcher.find()) {
+
+ // get next message format elements
+ String messageFormatElement = matcher.group();
+ // set end and start
+ int start = matcher.start();
+ int end = matcher.end();
+
+ // get value of message format element
+ String value = parseMessageFormatElement(messageFormatElement,
+ paramList);
+
+ // update value
+ sb.append(nodeValue.substring(lastPos, start));
+ sb.append(value);
+
+ lastPos = end;
+ }
+
+ sb.append(nodeValue.substring(lastPos));
+
+ return sb.toString();
+
+ }
+
+ /**
+ * get value of message format element
+ *
+ * @param messageFormatElement
+ * @param paramList
+ * @return
+ */
+ private String parseMessageFormatElement(String messageFormatElement,
+ List<Element> paramList) {
+ String value = null;
+
+ // separate message format element
+ String[] parametres = messageFormatElement
+ .split(MESSAGE_FORMAT_ELEMENTS_SEPARATOR);
+
+ // if this is "choice" format
+ if (parametres.length > 2) {
+ String format = parametres[1].trim();
+ if (CHOICE_NAME.equalsIgnoreCase(format)) {
+
+ // get "choice" as value
+ String choice = getChoice(parametres[2]);
+ if (choice != null)
+ value = choice;
+
+ }
+ }
+
+ // if this is not "choice" format
+ if (value == null) {
+
+ // get number of param
+ String paramNumber = parametres[0].trim();
+ paramNumber = paramNumber.replaceAll("[\\{\\}]", "");
+
+ try {
+ // decode
+ int num = Integer.decode(paramNumber);
+
+ if (num < paramList.size()) {
+ // get param's value
+ value = paramList.get(num).getAttribute(VALUE_ATTR_NAME);
+ }
+ } catch (NumberFormatException e) {
+ // illegal param value
+ }
+ }
+
+ // return or value or starting value
+ return value != null ? value : messageFormatElement;
+
+ }
+
+ /**
+ * get choice
+ *
+ * @param choiceString
+ * @return
+ */
+ private String getChoice(String choiceString) {
+
+ // separate all choices
+ String[] choices = choiceString.split(CHOICES_SEPARATOR);
+
+ // separate first choice pair(choice value / choice string)
+ String[] choice = choices[0].split(CHOICE_PAIR_SEPARATOR);
+
+ // return choice string
+ if (choice.length > 1)
+ return choice[1];
+
+ return null;
+
+ }
+
+ /**
+ * get all <f:param .../> tags
+ *
+ * @param sourcElement
+ * @return
+ */
+ private List<Element> getParams(Element sourcElement) {
+
+ NodeList nodeList = sourcElement.getChildNodes();
+
+ List<Element> params = new ArrayList<Element>();
+
+ for (int i = 0; i < nodeList.getLength(); i++) {
+
+ Node child = nodeList.item(i);
+
+ if (PARAM_NAME.equals(child.getLocalName()))
+ params.add((Element) child);
+
+ }
+
+ return params;
+
+ }
+}
17 years, 7 months