JBoss Tools SVN: r34637 - in trunk/as/plugins: org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-09-12 10:17:02 -0400 (Mon, 12 Sep 2011)
New Revision: 34637
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java
Log:
[JBIDE-9510] implemented list cartridges in openshift service. Created integration test
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java 2011-09-12 14:06:22 UTC (rev 34636)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java 2011-09-12 14:17:02 UTC (rev 34637)
@@ -3,6 +3,20 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+
+/**
+ * @author André Dietisheim
+ */
public class JsonSanitizer {
private static final Pattern QUOTED_JSON_OBJECT_PATTERN = Pattern.compile("\"\\{(.+)\\}\"");
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java 2011-09-12 14:17:02 UTC (rev 34637)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.openshift.internal.test.core;
+
+import static org.junit.Assert.fail;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+
+public class CartridgeAsserts {
+
+ public static void assertThatContainsCartridge(String cartridgeName, List<Cartridge> cartridges) {
+ boolean found = false;
+ for (Cartridge cartridge : cartridges) {
+ if (cartridgeName.equals(cartridge.getName())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ fail(MessageFormat.format("Could not find cartridge with name \"{0}\"", cartridgeName));
+ }
+ }
+
+
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/CartridgeAsserts.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java 2011-09-12 14:17:02 UTC (rev 34637)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.ide.eclipse.as.openshift.internal.test.core;
+
+import static org.jboss.ide.eclipse.as.openshift.internal.test.core.CartridgeAsserts.assertThatContainsCartridge;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
+import org.jboss.ide.eclipse.as.openshift.internal.core.OpenshiftService;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ListCartridgesIntegrationTest {
+
+ private OpenshiftService openshiftService;
+
+ private static final String USERNAME = "toolsjboss(a)gmail.com";
+ private static final String PASSWORD = "1q2w3e";
+
+ @Before
+ public void setUp() {
+ this.openshiftService = new OpenshiftService(USERNAME, PASSWORD);
+ }
+
+ @Test
+ public void canListCartridges() throws Exception {
+ List<Cartridge> cartridges = openshiftService.getCartridges();
+ assertNotNull(cartridges);
+ assertTrue(cartridges.size() > 0);
+ assertThatContainsCartridge("jbossas-7.0", cartridges);
+ }
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesIntegrationTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-12 14:06:22 UTC (rev 34636)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-12 14:17:02 UTC (rev 34637)
@@ -10,11 +10,10 @@
******************************************************************************/
package org.jboss.ide.eclipse.as.openshift.internal.test.core;
+import static org.jboss.ide.eclipse.as.openshift.internal.test.core.CartridgeAsserts.assertThatContainsCartridge;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
import java.net.URLEncoder;
-import java.text.MessageFormat;
import java.util.List;
import org.jboss.ide.eclipse.as.openshift.core.Cartridge;
@@ -92,16 +91,4 @@
assertEquals(0, response.getExitCode());
}
- private void assertThatContainsCartridge(String cartridgeName, List<Cartridge> cartridges) {
- boolean found = false;
- for (Cartridge cartridge : cartridges) {
- if (cartridgeName.equals(cartridge.getName())) {
- found = true;
- break;
- }
- }
- if (!found) {
- fail(MessageFormat.format("Could not find cartridge with name \"{0}\"", cartridgeName));
- }
- }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java 2011-09-12 14:06:22 UTC (rev 34636)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/OpenshiftIntegrationTestSuite.java 2011-09-12 14:17:02 UTC (rev 34637)
@@ -18,7 +18,8 @@
@Suite.SuiteClasses({
ApplicationIntegrationTest.class,
CartridgesIntegrationTest.class,
- DomainIntegrationTest.class
+ DomainIntegrationTest.class,
+ ListCartridgesIntegrationTest.class
})
/**
* @author André Dietisheim
14 years, 7 months
JBoss Tools SVN: r34636 - trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-09-12 10:06:22 -0400 (Mon, 12 Sep 2011)
New Revision: 34636
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
Log:
[JBIDE-9510] added json sanitzier to handle invalid json responses from openshift service
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java 2011-09-12 14:02:24 UTC (rev 34635)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java 2011-09-12 14:06:22 UTC (rev 34636)
@@ -15,7 +15,7 @@
/**
* Corrects erroneously quoted json objects in the given string.
* <p>
- * "{ \"property\": \"value\" }"
+ * corrects: "{ \"property\": \"value\" }" to { "propery" : "value" }
*
* @param json
* @return
14 years, 7 months
JBoss Tools SVN: r34635 - trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-09-12 10:02:24 -0400 (Mon, 12 Sep 2011)
New Revision: 34635
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
Log:
https://issues.jboss.org/browse/JBIDE-9674 , generated property key was corrected
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2011-09-12 14:01:34 UTC (rev 34634)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsUtils.java 2011-09-12 14:02:24 UTC (rev 34635)
@@ -100,7 +100,7 @@
public static final String NONAME = "noname"; //$NON-NLS-1$
public static final char[] REPLACED_CHARACTERS = new char[] {'~', '!', '@', '#',
- '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '{', '}', '[', ']', ':', ';', ',', '.', '?', '\\', '/', '"', '\''};
+ '$', '%', '^', '&', '*', '(', ')', '-', '+', '=', '{', '}', '[', ']', ':', ';', ',', '.', '?', '\\', '/', '"', '\'', ' '};
public static final char[] LINE_DELEMITERS = new char[] {'\r', '\n', '\t'};
private static CharsetEncoder asciiEncoder;
@@ -439,6 +439,7 @@
* @return the result string
*/
public static String generatePropertyKey(String text) {
+ String result = text.trim();
/*
* If text cannot be represented in standard eclipse encoding
* change the key name to "noname"
@@ -446,18 +447,16 @@
if (null == asciiEncoder) {
asciiEncoder = Charset.forName("ISO-8859-1").newEncoder(); //$NON-NLS-1$
}
- if (!asciiEncoder.canEncode(text)) {
- text = NONAME;
+ if (!asciiEncoder.canEncode(result)) {
+ result = NONAME;
}
-
- String result = text.trim();
/*
* Update text string field.
* Trim the text to remove line breaks and caret returns.
* Replace line delimiters white space
*/
for (char ch : LINE_DELEMITERS) {
- text = text.trim().replace(ch, ' ');
+ result = result.trim().replace(ch, ' ');
}
/*
* Replace all other symbols with '_'
@@ -466,11 +465,6 @@
result = result.replace(ch, '_');
}
/*
- * Replace all white spaces with '_'
- */
- result = result.replaceAll(Constants.WHITE_SPACE,
- Constants.UNDERSCORE);
- /*
* Correct underline symbols:
* show only one of them
*/
14 years, 7 months
JBoss Tools SVN: r34634 - in trunk/as/plugins: org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2011-09-12 10:01:34 -0400 (Mon, 12 Sep 2011)
New Revision: 34634
Added:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/AbstractOpenshiftJsonResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ApplicationResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ListCartridgesResponseUnmarshaller.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
Log:
[JBIDE-9510] added json sanitzier to handle invalid json responses from openshift service
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/OpenshiftService.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -40,6 +40,7 @@
import org.jboss.ide.eclipse.as.openshift.internal.core.request.UserInfoRequest;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.ApplicationResponseUnmarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.DomainResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.internal.core.response.JsonSanitizer;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.ListCartridgesResponseUnmarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.OpenshiftResponse;
@@ -79,6 +80,7 @@
* WARNING: the current server implementation returns invalid json.
*
* @see ListCartridgesResponseUnmarshaller
+ * @see JsonSanitizer#sanitize(String)
*/
@Override
public List<Cartridge> getCartridges() throws OpenshiftException {
@@ -89,7 +91,10 @@
new ListCartridgesRequestJsonMarshaller().marshall(listCartridgesRequest);
String request = new OpenshiftJsonRequestFactory(password, listCartridgesRequestString).create();
String listCatridgesReponse = createHttpClient(url).post(request);
- throw new UnsupportedOperationException();
+ listCatridgesReponse = JsonSanitizer.sanitize(listCatridgesReponse);
+ OpenshiftResponse<List<Cartridge>> response =
+ new ListCartridgesResponseUnmarshaller().unmarshall(listCatridgesReponse);
+ return response.getData();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(url, e, "Could not list available cartridges at \"{0}\"", url);
} catch (HttpClientException e) {
@@ -101,7 +106,7 @@
public SSHKey createKey(String passPhrase, String privateKeyPath, String publicKeyPath) throws OpenshiftException {
return SSHKey.create(passPhrase, privateKeyPath, publicKeyPath);
}
-
+
@Override
public SSHKey loadKey(String privateKeyPath, String publicKeyPath) throws OpenshiftException {
return SSHKey.load(privateKeyPath, publicKeyPath);
@@ -121,7 +126,9 @@
new DomainRequestJsonMarshaller().marshall(request))
.create();
String responseString = createHttpClient(url).post(requestString);
- OpenshiftResponse<Domain> response = new DomainResponseUnmarshaller(responseString, request.getName()).unmarshall();
+ responseString = JsonSanitizer.sanitize(responseString);
+ OpenshiftResponse<Domain> response =
+ new DomainResponseUnmarshaller(request.getName()).unmarshall(responseString);
return response.getData();
} catch (MalformedURLException e) {
throw new OpenshiftEndpointException(url, e, "Could not list available cartridges at \"{0}\"", url);
@@ -150,8 +157,10 @@
new ApplicationRequestJsonMarshaller().marshall(applicationRequest);
String request = new OpenshiftJsonRequestFactory(password, applicationRequestString).create();
String response = createHttpClient(url).post(request);
- OpenshiftResponse<Application> openshiftResponse = new ApplicationResponseUnmarshaller(response, name,
- cartridge).unmarshall();
+
+ response = JsonSanitizer.sanitize(response);
+ OpenshiftResponse<Application> openshiftResponse =
+ new ApplicationResponseUnmarshaller(name, cartridge).unmarshall(response);
return openshiftResponse.getData();
} catch (MalformedURLException e) {
throw new OpenshiftException(
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/AbstractOpenshiftJsonResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/AbstractOpenshiftJsonResponseUnmarshaller.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/AbstractOpenshiftJsonResponseUnmarshaller.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -22,11 +22,7 @@
private String response;
- public AbstractOpenshiftJsonResponseUnmarshaller(String response) {
- this.response = response;
- }
-
- public OpenshiftResponse<OPENSHIFTOBJECT> unmarshall() throws OpenshiftException {
+ public OpenshiftResponse<OPENSHIFTOBJECT> unmarshall(String response) throws OpenshiftException {
try {
ModelNode node = ModelNode.fromJSONString(response);
boolean debug = node.get(IOpenshiftJsonConstants.PROPERTY_DEBUG).asBoolean();
@@ -42,6 +38,8 @@
}
}
+
+
protected abstract OPENSHIFTOBJECT createOpenshiftObject(ModelNode dataNode);
protected String getResponse() {
@@ -51,6 +49,7 @@
protected String getString(String property, ModelNode node) {
ModelNode propertyNode = node.get(property);
if (propertyNode.getType() == ModelType.UNDEFINED) {
+ // replace "undefined" by null
return null;
}
return propertyNode.asString();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ApplicationResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ApplicationResponseUnmarshaller.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ApplicationResponseUnmarshaller.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -22,8 +22,7 @@
private String applicationName;
private Cartridge cartridge;
- public ApplicationResponseUnmarshaller(String response, String applicationName, Cartridge cartridge) {
- super(response);
+ public ApplicationResponseUnmarshaller(String applicationName, Cartridge cartridge) {
this.applicationName = applicationName;
this.cartridge = cartridge;
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/DomainResponseUnmarshaller.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -22,8 +22,7 @@
private String domainName;
- public DomainResponseUnmarshaller(String response, String domainName) {
- super(response);
+ public DomainResponseUnmarshaller(String domainName) {
this.domainName = domainName;
}
Added: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java (rev 0)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -0,0 +1,37 @@
+package org.jboss.ide.eclipse.as.openshift.internal.core.response;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class JsonSanitizer {
+
+ private static final Pattern QUOTED_JSON_OBJECT_PATTERN = Pattern.compile("\"\\{(.+)\\}\"");
+ private static final Pattern ESCAPED_QUOTES_PATTERN = Pattern.compile("\\\"");
+
+ public static String sanitize(String json) {
+ return correctEscapedJsonObjects(json);
+ }
+
+ /**
+ * Corrects erroneously quoted json objects in the given string.
+ * <p>
+ * "{ \"property\": \"value\" }"
+ *
+ * @param json
+ * @return
+ */
+ protected static String correctEscapedJsonObjects(String json) {
+ String sanitizedJson = json;
+ Matcher matcher = QUOTED_JSON_OBJECT_PATTERN.matcher(json);
+ if (matcher.find()
+ && matcher.groupCount() > 0) {
+ sanitizedJson = matcher.replaceAll("{" + unescapeQuotes(matcher.group(1)) + "}");
+ }
+ return sanitizedJson;
+ }
+
+ private static String unescapeQuotes(String responseFragment) {
+ return ESCAPED_QUOTES_PATTERN.matcher(responseFragment).replaceAll("\"");
+ }
+
+}
Property changes on: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/JsonSanitizer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ListCartridgesResponseUnmarshaller.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ListCartridgesResponseUnmarshaller.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.core/src/org/jboss/ide/eclipse/as/openshift/internal/core/response/ListCartridgesResponseUnmarshaller.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -18,20 +18,14 @@
import org.jboss.ide.eclipse.as.openshift.core.IOpenshiftJsonConstants;
/**
+ * WARNING: the current (9-7-2011) response from the openshift rest service is
+ * invalid. It quotes the nested json object in the data property: '"data" :
+ * "{'. My current unmarshalling code does not handle this bad json.
+ *
* @author André Dietisheim
*/
public class ListCartridgesResponseUnmarshaller extends AbstractOpenshiftJsonResponseUnmarshaller<List<Cartridge>> {
- /*
- * WARNING: the current (9-7-2011) response from the openshift rest
- * service is invalid. It quotes the nested json object in the data
- * property: '"data" : "{'. My current unmarshalling code does not
- * handle this bad json.
- */
- public ListCartridgesResponseUnmarshaller(String response) {
- super(response);
- }
-
@Override
protected List<Cartridge> createOpenshiftObject(ModelNode dataNode) {
List<Cartridge> cartridges = new ArrayList<Cartridge>();
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/DomainTest.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -11,17 +11,23 @@
package org.jboss.ide.eclipse.as.openshift.internal.test.core;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import org.jboss.ide.eclipse.as.openshift.core.Domain;
import org.jboss.ide.eclipse.as.openshift.core.OpenshiftException;
import org.jboss.ide.eclipse.as.openshift.core.SSHKey;
+import org.jboss.ide.eclipse.as.openshift.core.User;
import org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.DomainRequestJsonMarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.ChangeDomainRequest;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.CreateDomainRequest;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
+import org.jboss.ide.eclipse.as.openshift.internal.core.response.DomainResponseUnmarshaller;
+import org.jboss.ide.eclipse.as.openshift.internal.core.response.JsonSanitizer;
+import org.jboss.ide.eclipse.as.openshift.internal.core.response.OpenshiftResponse;
import org.jboss.ide.eclipse.as.openshift.internal.test.core.fakes.TestSSHKey;
import org.junit.Test;
@@ -32,12 +38,14 @@
private static final String USERNAME = "toolsjboss(a)gmail.com";
private static final String PASSWORD = "1q2w3e";
+ private static final String UUID = "0c82860dae904a4d87f8e5d87a5af840";
@Test
public void canMarshallDomainCreateRequest() throws IOException, OpenshiftException {
SSHKey sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", false, sshKey.getPublicKeyContent());
-
+ String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", false,
+ sshKey.getPublicKeyContent());
+
CreateDomainRequest request = new CreateDomainRequest("myDomain", sshKey, USERNAME, true);
String requestString =
new OpenshiftJsonRequestFactory(
@@ -46,12 +54,30 @@
.create();
assertEquals(expectedRequestString, requestString);
}
-
+
@Test
+ public void canUnmarshallDomainCreateResponse() throws IOException, OpenshiftException {
+ String domainName = "myDomain";
+ String responseString = createDomainResponseString(USERNAME, UUID);
+
+ responseString = JsonSanitizer.sanitize(responseString);
+ OpenshiftResponse<Domain> response = new DomainResponseUnmarshaller(domainName).unmarshall(responseString);
+
+ assertNotNull(response);
+ Domain domain = response.getData();
+ assertEquals(domainName, domain.getName());
+ User user = domain.getUser();
+ assertNotNull(user);
+ assertEquals(USERNAME, user.getRhlogin());
+ assertEquals(UUID, user.getUuid());
+ }
+
+ @Test
public void canMarshallDomainAlterRequest() throws IOException, OpenshiftException {
SSHKey sshKey = TestSSHKey.create();
- String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", true, sshKey.getPublicKeyContent());
-
+ String expectedRequestString = createDomainRequestString(PASSWORD, USERNAME, true, "myDomain", true,
+ sshKey.getPublicKeyContent());
+
ChangeDomainRequest request = new ChangeDomainRequest("myDomain", sshKey, USERNAME, true);
String requestString =
new OpenshiftJsonRequestFactory(
@@ -61,22 +87,38 @@
assertEquals(expectedRequestString, requestString);
}
- private String createDomainRequestString(String password, String username, boolean debug, String namespace, boolean alter, String sshPublicKey) throws UnsupportedEncodingException {
- String request =
- "password="
+ private String createDomainRequestString(String password, String username, boolean debug, String namespace,
+ boolean alter, String sshPublicKey) throws UnsupportedEncodingException {
+ return "password="
+ password
+ "&json_data=%7B"
+ "%22rhlogin%22+%3A+"
+ "%22"
+ URLEncoder.encode(username, "UTF-8")
+ "%22"
- + "%2C+%22debug%22+%3A+%22" + String.valueOf(debug)+ "%22"
- + "%2C+%22namespace%22+%3A+%22" + URLEncoder.encode(namespace, "UTF-8")+ "%22"
- + "%2C+%22alter%22+%3A+%22" + String.valueOf(alter)+ "%22"
+ + "%2C+%22debug%22+%3A+%22" + String.valueOf(debug) + "%22"
+ + "%2C+%22namespace%22+%3A+%22" + URLEncoder.encode(namespace, "UTF-8") + "%22"
+ + "%2C+%22alter%22+%3A+%22" + String.valueOf(alter) + "%22"
+ "%2C+%22ssh%22+%3A+%22"
+ URLEncoder.encode(sshPublicKey, "UTF-8")
+ "%22"
+ "%7D";
- return request;
}
+
+ /**
+ * WARNING: the response this method returns matches the actual response
+ * from the openshift service (9-12-2011). It is not valid json since it quotes the
+ * nested json object
+ * <p>
+ * "data": "{\"rhlogin\": ...
+ */
+ private String createDomainResponseString(String username, String uuid) {
+ return "{\"messages\":\"\",\"debug\":\"\",\"data\":\""
+ + "{\\\"rhlogin\\\":\\\""
+ + username
+ + "\\\",\\\"uuid\\\":\\\""
+ + uuid
+ + "\\\"}"
+ + "\",\"api\":\"1.1.1\",\"api_c\":[\"placeholder\"],\"result\":null,\"broker\":\"1.1.1\",\"broker_c\":[\"namespace\",\"rhlogin\",\"ssh\",\"app_uuid\",\"debug\",\"alter\",\"cartridge\",\"cart_type\",\"action\",\"app_name\",\"api\"],\"exit_code\":0}";
+ }
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-12 13:45:27 UTC (rev 34633)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.openshift.test/src/org/jboss/ide/eclipse/as/openshift/internal/test/core/ListCartridgesTest.java 2011-09-12 14:01:34 UTC (rev 34634)
@@ -22,6 +22,7 @@
import org.jboss.ide.eclipse.as.openshift.core.internal.marshalling.ListCartridgesRequestJsonMarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.ListCartridgesRequest;
import org.jboss.ide.eclipse.as.openshift.internal.core.request.OpenshiftJsonRequestFactory;
+import org.jboss.ide.eclipse.as.openshift.internal.core.response.JsonSanitizer;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.ListCartridgesResponseUnmarshaller;
import org.jboss.ide.eclipse.as.openshift.internal.core.response.OpenshiftResponse;
import org.junit.Test;
@@ -46,7 +47,7 @@
assertEquals(expectedRequestString, effectiveRequest);
}
-
+
@Test
public void canUnmarshallCartridgeListResponse() throws OpenshiftException {
String cartridgeListResponse =
@@ -54,16 +55,29 @@
+ "\"messages\":\"\","
+ "\"debug\":\"\","
+ "\"data\":"
- + "{\"carts\":[\"perl-5.10\",\"jbossas-7.0\",\"wsgi-3.2\",\"rack-1.1\",\"php-5.3\"]},"
+ + "\"{\\\"carts\\\":[\\\"perl-5.10\\\",\\\"jbossas-7.0\\\",\\\"wsgi-3.2\\\",\\\"rack-1.1\\\",\\\"php-5.3\\\"]}\","
+ "\"api\":\"1.1.1\","
+ "\"api_c\":[\"placeholder\"],"
+ "\"result\":null,"
+ "\"broker\":\"1.1.1\","
- + "\"broker_c\":[\"namespace\",\"rhlogin\",\"ssh\",\"app_uuid\",\"debug\",\"alter\",\"cartridge\",\"cart_type\",\"action\",\"app_name\",\"api\"],"
+ + "\"broker_c\":["
+ + "\"namespace\","
+ + "\"rhlogin\","
+ + "\"ssh\","
+ + "\"app_uuid\","
+ + "\"debug\","
+ + "\"alter\","
+ + "\"cartridge\","
+ + "\"cart_type\","
+ + "\"action\","
+ + "\"app_name\","
+ + "\"api"
+ + "\"],"
+ "\"exit_code\":0}";
- OpenshiftResponse<List<Cartridge>> response = new ListCartridgesResponseUnmarshaller(cartridgeListResponse)
- .unmarshall();
+ cartridgeListResponse = JsonSanitizer.sanitize(cartridgeListResponse);
+ OpenshiftResponse<List<Cartridge>> response =
+ new ListCartridgesResponseUnmarshaller().unmarshall(cartridgeListResponse);
assertEquals("", response.getMessages());
assertEquals(false, response.isDebug());
14 years, 7 months
JBoss Tools SVN: r34632 - workspace/snjeza/discovery.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2011-09-12 09:09:31 -0400 (Mon, 12 Sep 2011)
New Revision: 34632
Added:
workspace/snjeza/discovery/org.jboss.tools.central.discovery_3.3.0.jar
Log:
Added: workspace/snjeza/discovery/org.jboss.tools.central.discovery_3.3.0.jar
===================================================================
(Binary files differ)
Property changes on: workspace/snjeza/discovery/org.jboss.tools.central.discovery_3.3.0.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
14 years, 7 months
JBoss Tools SVN: r34631 - workspace/snjeza.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2011-09-12 09:03:02 -0400 (Mon, 12 Sep 2011)
New Revision: 34631
Added:
workspace/snjeza/discovery/
Log:
Initial import.
14 years, 7 months
JBoss Tools SVN: r34630 - trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-09-12 08:52:44 -0400 (Mon, 12 Sep 2011)
New Revision: 34630
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java
Log:
JBIDE-9414
CA incorrectly inserts a long-named properties from resource bundles
Issue is fixed. JUnit Test is updated due to test the changes made while fixing the issue
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java 2011-09-12 12:15:58 UTC (rev 34629)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java 2011-09-12 12:52:44 UTC (rev 34630)
@@ -96,7 +96,7 @@
}
- public void _testJstJspLongResourceBundlePropertyNamesInTagAttributeValue() {
+ public void testJstJspLongResourceBundlePropertyNamesInTagAttributeValue() {
assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
openEditor(PAGE_NAME);
@@ -118,7 +118,7 @@
}
}
- public void _testJstJspLongResourceBundlePropertyNamesInText() {
+ public void testJstJspLongResourceBundlePropertyNamesInText() {
assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
openEditor(PAGE_NAME);
14 years, 7 months
JBoss Tools SVN: r34629 - in trunk: jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: vrubezhny
Date: 2011-09-12 08:15:58 -0400 (Mon, 12 Sep 2011)
New Revision: 34629
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/CAForCompositeComponentTest/WebContent/pages/greetingLong.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
Log:
JBIDE-9414
CA incorrectly inserts a long-named properties from resource bundles
Issue is fixed. JUnit Test is updated due to test the changes made while fixing the issue
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/CAForCompositeComponentTest/WebContent/pages/greetingLong.xhtml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/CAForCompositeComponentTest/WebContent/pages/greetingLong.xhtml 2011-09-12 11:57:46 UTC (rev 34628)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/projects/CAForCompositeComponentTest/WebContent/pages/greetingLong.xhtml 2011-09-12 12:15:58 UTC (rev 34629)
@@ -12,5 +12,6 @@
<ui:define name="body">
#{msg.}!
</ui:define>
+ <h:outputLabel value="#{msg.
</ui:composition>
</html>
\ No newline at end of file
Modified: trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java 2011-09-12 11:57:46 UTC (rev 34628)
+++ trunk/jsf/tests/org.jboss.tools.jsf.ui.test/src/org/jboss/tools/jsf/jsp/ca/test/JsfJspLongResourceBundlePropertyNamesTest.java 2011-09-12 12:15:58 UTC (rev 34629)
@@ -36,8 +36,10 @@
private static final String PROPOSAL_TO_APPLY_STRING = "['org.jboss.long.named.Property']";
private static final String PREFIX_STRING = "#{msg.";
private static final String ATTR_PREFIX_STRING = "h:outputText";
+ private static final String NOT_CLOSED_ATTR_PREFIX_STRING = "h:outputLabel";
private static final String TEXT_PREFIX_STRING = "<ui:define name=\"body\"";
private static final String COMPARE_STRING = "#{msg['org.jboss.long.named.Property']";
+ private static final String NOT_CLOSED_COMPARE_STRING = "#{msg['org.jboss.long.named.Property']}\"";
public void setUp() throws Exception {
project = ProjectImportTestSetup.loadProject(PROJECT_NAME);
@@ -48,6 +50,7 @@
return new TestSuite(JsfJspLongResourceBundlePropertyNamesTest.class);
}
+ @SuppressWarnings("restriction")
private void doTestLongResourceBundlePropertyNames(String tagName, String prefix, String proposalToApply, String compareString) {
// Find start of <ui:composition> tag
String documentContent = document.get();
@@ -93,7 +96,7 @@
}
- public void testJstJspLongResourceBundlePropertyNamesInTagAttributeValue() {
+ public void _testJstJspLongResourceBundlePropertyNamesInTagAttributeValue() {
assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
openEditor(PAGE_NAME);
@@ -104,11 +107,22 @@
}
}
- public void testJstJspLongResourceBundlePropertyNamesInText() {
+ public void testJstJspLongResourceBundlePropertyNamesInNotClosedTagAttributeValue() {
assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
openEditor(PAGE_NAME);
try {
+ doTestLongResourceBundlePropertyNames(NOT_CLOSED_ATTR_PREFIX_STRING, PREFIX_STRING, PROPOSAL_TO_APPLY_STRING, NOT_CLOSED_COMPARE_STRING);
+ } finally {
+ closeEditor();
+ }
+ }
+
+ public void _testJstJspLongResourceBundlePropertyNamesInText() {
+ assertNotNull("Test project '" + PROJECT_NAME + "' is not prepared", project);
+
+ openEditor(PAGE_NAME);
+ try {
doTestLongResourceBundlePropertyNames(TEXT_PREFIX_STRING, PREFIX_STRING, PROPOSAL_TO_APPLY_STRING, COMPARE_STRING);
} finally {
closeEditor();
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-09-12 11:57:46 UTC (rev 34628)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-09-12 12:15:58 UTC (rev 34629)
@@ -219,8 +219,8 @@
// Need to get the rest of line from context.getInvocationOffset()
IDocument doc = context.getDocument();
- String restOfLine = "";
- String restOfValue = "";
+ String restOfLine = ""; //$NON-NLS-1$
+ String restOfValue = ""; //$NON-NLS-1$
int endPosition = -1;
try {
int line = doc.getLineOfOffset(context.getInvocationOffset());
@@ -252,16 +252,12 @@
replacementString += ']';
}
} else {
- if (replacementString.endsWith("]") && restOfValue.indexOf(']') != -1) {
+ if (replacementString.endsWith("]") && restOfValue.indexOf(']') != -1) { //$NON-NLS-1$
replacementString = replacementString.substring(0, replacementString.length() -1);
cursorPosition = replacementString.length(); // Cursor will be put right after the replacement (not after the closing square bracket in this case)
}
}
- if (prefix.isAttributeValue() && prefix.hasOpenQuote() && endPosition == -1) {
- // Add closing attr-quote
- replacementString += quoteChar;
- }
if (restOfLine.indexOf('}') == -1) {
// Add closing }-char
replacementString += '}';
14 years, 7 months
JBoss Tools SVN: r34628 - in trunk/jsf: plugins/org.jboss.tools.jsf.vpe.richfaces/templates and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2011-09-12 07:57:46 -0400 (Mon, 12 Sep 2011)
New Revision: 34628
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml
Log:
https://issues.jboss.org/browse/JBIDE-8950 , treeModelAdaptors implementation was added, with tests.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesAbstractTreeTemplate.java 2011-09-12 11:57:46 UTC (rev 34628)
@@ -32,657 +32,603 @@
public abstract class RichFacesAbstractTreeTemplate extends VpeAbstractTemplate {
- public static final String TREE = "tree"; //$NON-NLS-1$
- public static final String TREE_NODE = "treeNode"; //$NON-NLS-1$
- public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor"; //$NON-NLS-1$
- public static final String RECURSIVE_TREE_NODES_ADAPTOR = "recursiveTreeNodesAdaptor"; //$NON-NLS-1$
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines"; //$NON-NLS-1$
+ public static final String TREE = "tree"; //$NON-NLS-1$
+ public static final String TREE_NODE = "treeNode"; //$NON-NLS-1$
+ public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor"; //$NON-NLS-1$
+ public static final String RECURSIVE_TREE_NODES_ADAPTOR = "recursiveTreeNodesAdaptor"; //$NON-NLS-1$
+ public static final String TREE_MODEL_ADAPTOR = "treeModelAdaptor"; //$NON-NLS-1$
+ public static final String TREE_MODEL_RECURSIVE_ADAPTOR = "treeModelRecursiveAdaptor"; //$NON-NLS-1$
+ public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines"; //$NON-NLS-1$
+ public static final String NODES_NAME = "nodes"; //$NON-NLS-1$
- public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM"; //$NON-NLS-1$
- public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam"; //$NON-NLS-1$
- public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE = "DEFAULT_ICON_EXPANDED_PARAM"; //$NON-NLS-1$
- public static final String UNDEFINED_ICON = "/tree/unresolved.gif"; //$NON-NLS-1$
- public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf"; //$NON-NLS-1$
- public static final String ICON_NODE_WITH_LINES = "/tree/iconNodeWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NODE_WITH_LINE = "/tree/iconNodeWithLine.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_WITH_LINES = "/tree/iconCollapsedWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_WITHOUT_LINES = "/tree/iconCollapsed.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITH_LINES = "/tree/iconNotCollapsedWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITH_ALL_LINES = "/tree/iconNotCollapsedWithAllLines.gif"; //$NON-NLS-1$
- public static final String ICON_NOT_EXPANDED_WITHOUT_LINES = "/tree/iconNotCollapsed.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_ADAPTER_WITH_LINES = "/tree/iconClosedNodeWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES = "/tree/iconClosedNode.gif"; //$NON-NLS-1$
- public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeafWithLines.gif"; //$NON-NLS-1$
- public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif"; //$NON-NLS-1$
- public static final String ICON_LEFT_LINE = "/tree/leftLine.gif"; //$NON-NLS-1$
- public static final String ICON_LINE = "/tree/line.gif"; //$NON-NLS-1$
- public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.gif"; //$NON-NLS-1$
- protected static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME = "treePictureStyle"; //$NON-NLS-1$
- protected static final String STYLE_CLASS_FOR_NODE_TITLE = "treeNodeNameStyle"; //$NON-NLS-1$
- protected static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass"; //$NON-NLS-1$
- protected static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded"; //$NON-NLS-1$
- protected static final String NODE_ICON_ATTR_NAME = "icon"; //$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px"; //$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px"; //$NON-NLS-1$
- protected static final String TREE_TABLE_ATR_BORDER_VALUE = "0px"; //$NON-NLS-1$
- protected static final String NODE_LINES_STYLE = "background-position: center; background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String DEFAULT_ICON_PARAM_VALUE = "DEFAULT_ICON_PARAM"; //$NON-NLS-1$
+ public static final String ICON_PARAM_NAME = "richFacesTreeNodeParam"; //$NON-NLS-1$
+ public static final String DEFAULT_ICON_EXPANDED_PARAM_VALUE = "DEFAULT_ICON_EXPANDED_PARAM"; //$NON-NLS-1$
+ public static final String UNDEFINED_ICON = "/tree/unresolved.gif"; //$NON-NLS-1$
+ public static final String NODE_ICON_LEAF_ATTR_NAME = "iconLeaf"; //$NON-NLS-1$
+ public static final String ICON_NODE_WITH_LINES = "/tree/iconNodeWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NODE_WITH_LINE = "/tree/iconNodeWithLine.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_WITH_LINES = "/tree/iconCollapsedWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NODE_WITHOUT_LINES = "/tree/iconNode.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_WITHOUT_LINES = "/tree/iconCollapsed.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITH_LINES = "/tree/iconNotCollapsedWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITH_ALL_LINES = "/tree/iconNotCollapsedWithAllLines.gif"; //$NON-NLS-1$
+ public static final String ICON_NOT_EXPANDED_WITHOUT_LINES = "/tree/iconNotCollapsed.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_ADAPTER_WITH_LINES = "/tree/iconClosedNodeWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_EXPANDED_ADAPTER_WITHOUT_LINES = "/tree/iconClosedNode.gif"; //$NON-NLS-1$
+ public static final String ICON_LEAF_WITH_LINES = "/tree/iconLeafWithLines.gif"; //$NON-NLS-1$
+ public static final String ICON_RIGHT_LINE = "/tree/rightLine.gif"; //$NON-NLS-1$
+ public static final String ICON_LEFT_LINE = "/tree/leftLine.gif"; //$NON-NLS-1$
+ public static final String ICON_LINE = "/tree/line.gif"; //$NON-NLS-1$
+ public static final String ICON_LEAF_WITHOUT_LINES = "/tree/iconLeaf.gif"; //$NON-NLS-1$
+ protected static final String TREE_TABLE_PICTURE_STYLE_CLASS_NAME = "treePictureStyle"; //$NON-NLS-1$
+ protected static final String STYLE_CLASS_FOR_NODE_TITLE = "treeNodeNameStyle"; //$NON-NLS-1$
+ protected static final String NODE_TITLE_STYLE_CLASS_ATTR_NAME = "nodeClass"; //$NON-NLS-1$
+ protected static final String NODE_ICON_EXPANDED_ATTR_NAME = "iconExpanded"; //$NON-NLS-1$
+ protected static final String NODE_ICON_ATTR_NAME = "icon"; //$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_CELLSPACING_VALUE = "0px"; //$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_CELLPADDING_VALUE = "0px"; //$NON-NLS-1$
+ protected static final String TREE_TABLE_ATR_BORDER_VALUE = "0px"; //$NON-NLS-1$
+ protected static final String NODE_LINES_STYLE = "background-position: center; background-repeat: repeat-y;"; //$NON-NLS-1$
- /**
- * Get showConnectingLines attribute
- *
- * @param sourceNode
- * @return
- */
- protected boolean getShowLinesAttr(Node sourceNode) {
- String treeName = sourceNode.getPrefix() + Constants.COLON + TREE;
- do {
- sourceNode = sourceNode.getParentNode();
- if (!(sourceNode instanceof Element)) {
- return true;
- }
- } while (!sourceNode.getNodeName().equals(treeName));
-
- String showLinesParam = ((Element) sourceNode)
- .getAttribute(SHOW_LINES_ATTR_NAME);
-
- boolean showLinesValue = true;
- if (showLinesParam != null
- && Constants.FALSE.equalsIgnoreCase(showLinesParam)) {
- showLinesValue = false;
+ /**
+ * Get showConnectingLines attribute
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean getShowLinesAttr(Node sourceNode) {
+ String treeName = sourceNode.getPrefix() + Constants.COLON + TREE;
+ do {
+ sourceNode = sourceNode.getParentNode();
+ if (!(sourceNode instanceof Element)) {
+ return true;
+ }
+ } while (!sourceNode.getNodeName().equals(treeName));
+ String showLinesParam = ((Element) sourceNode)
+ .getAttribute(SHOW_LINES_ATTR_NAME);
+ boolean showLinesValue = true;
+ if (showLinesParam != null
+ && Constants.FALSE.equalsIgnoreCase(showLinesParam)) {
+ showLinesValue = false;
+ }
+ return showLinesValue;
}
- return showLinesValue;
- }
- /**
- * Is adapter between treeNodes
- *
- * @param sourceNode
- * @return
- */
- protected boolean isAdapterBetweenNodes(Node sourceNode) {
- Node parentNode = sourceNode.getParentNode();
- NodeList childs = parentNode.getChildNodes();
- Node beforeAdapterNode = null;
- Node afterAdapterNode = null;
- Node adapterNode = null;
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODE;
- for (int i = 0; i < childs.getLength(); i++) {
- Node el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- if (el.equals(sourceNode)) {
- adapterNode = el;
- } else {
- if (el.getNodeName().equals(treeNodeName)) {
- if (adapterNode == null) {
- beforeAdapterNode = el;
- } else {
- afterAdapterNode = el;
- }
+ /**
+ * Is adapter between treeNodes
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isAdapterBetweenNodes(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ NodeList childs = parentNode.getChildNodes();
+ Node beforeAdapterNode = null;
+ Node afterAdapterNode = null;
+ Node adapterNode = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ Node el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (el.equals(sourceNode)) {
+ adapterNode = el;
+ } else {
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)) {
+ if (adapterNode == null) {
+ beforeAdapterNode = el;
+ } else {
+ afterAdapterNode = el;
+ }
+ }
+ }
}
-
- }
-
+ if (beforeAdapterNode != null && afterAdapterNode != null) {
+ return true;
+ }
+ return false;
}
- if (beforeAdapterNode != null && afterAdapterNode != null) {
- return true;
- }
- return false;
- }
+ /**
+ * Next element is Adaptor
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasNextAdaptorElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
- /**
- * Next element is Adaptor
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasNextAdaptorElement(Node sourceNode) {
- Node parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (lastElement != null) {
+ break;
+ }
+ if (sourceNode.equals(el)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- NodeList childs = parentTree.getChildNodes();
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
+ /**
+ * Has Next element
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasNextParentAdaptorElement(Node sourceNode) {
+ Node tree = sourceNode.getParentNode();
+ if (!(tree instanceof Element)) {
+ return true;
+ }
+ Node parentTree = tree.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
- if (lastElement != null) {
- break;
- }
-
- if (sourceNode.equals(el)) {
- lastElement = el;
- }
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (lastElement != null) {
+ break;
+ }
+ if (el.equals(tree)) {
+ lastElement = el;
+ }
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- if (el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- return true;
- }
- return false;
- }
- /**
- * Has Next element
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasNextParentAdaptorElement(Node sourceNode) {
- Node tree = sourceNode.getParentNode();
- if (!(tree instanceof Element)) {
- return true;
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isHasParentAdapter(Node sourceNode) {
+ Node node = sourceNode.getParentNode();
+ if (node.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || node.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- Node parentTree = tree.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
- }
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
-
- if (lastElement != null) {
- break;
- }
- if (el.equals(tree)) {
- lastElement = el;
- }
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ protected void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentElement) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ int lenght = nodeList.getLength();
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ if (element.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || element.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ } else if (element.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentElement);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ }
+ }
}
- if (el.getNodeName().equals(treeNodeName)
- || el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- return true;
- }
- return false;
- }
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ protected void createBasicTree(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, nsIDOMElement treeRow,
+ Node sourceNode, VpeCreationData vpeCreationData) {
+ // creates icon node
+ String backgroundLinePath = null;
- /**
- *
- * @param sourceNode
- * @return
- */
- protected boolean isHasParentAdapter(Node sourceNode) {
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node node = sourceNode.getParentNode();
- if (node.getNodeName().equals(treeNodesAdaptorName)
- || node.getNodeName().equals(recursiveTreeNodesAdaptorName)) {
- return true;
- }
- return false;
- }
+ boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
+ nsIDOMElement iconNode = visualDocument.createElement(HTML.TAG_TD);
+ // creates icon with status of node(collapsed or not) node
+ nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
+ // sets icon node
+ if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && !isHasNextAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINE
+ : ICON_NODE_WITHOUT_LINES);
+ } else if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
+ && isHasNextAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
+ : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LEFT_LINE;
+ iconNode.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
+ + NODE_LINES_STYLE);
+ }
+ } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) && (isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)))
+ || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))
+ || (isAdaptorChild(sourceNode) && isOnlyOneNodeInAdaptor(sourceNode))) {
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- protected void parseTree(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
- nsIDOMElement parentElement) {
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- int lenght = nodeList.getLength();
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- VpeChildrenInfo vpeChildrenInfo = null;
- for (int i = 0; i < lenght; i++) {
- if (!(nodeList.item(i) instanceof Element)) {
- continue;
- }
- element = (Element) nodeList.item(i);
- if (element.getNodeName().equals(treeNodeName)
- || element.getNodeName().equals(
- recursiveTreeNodesAdaptorName)) {
- vpeChildrenInfo = new VpeChildrenInfo(parentElement);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- } else if (element.getNodeName().equals(treeNodesAdaptorName)) {
- vpeChildrenInfo = new VpeChildrenInfo(parentElement);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- }
- }
- }
+ if (isAdaptorChild(sourceNode)
+ && isOnlyOneNodeInAdaptor(sourceNode)
+ && !isLastElementAfterAdaptor(sourceNode)
+ && isHasNextParentAdaptorElement(sourceNode)) {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LINE;
+ setAttributeForPictureNode(
+ pageContext,
+ visualDocument,
+ (Element) sourceNode,
+ td1,
+ NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_NOT_EXPANDED_WITH_ALL_LINES
+ : ICON_NOT_EXPANDED_WITHOUT_LINES);
+ } else {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_RIGHT_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1,
+ NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_NOT_EXPANDED_WITH_LINES
+ : ICON_NOT_EXPANDED_WITHOUT_LINES);
+ }
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ } else {
+ backgroundLinePath = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_RIGHT_LINE;
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- protected void createBasicTree(VpePageContext pageContext,
- nsIDOMDocument visualDocument, nsIDOMElement treeRow,
- Node sourceNode, VpeCreationData vpeCreationData) {
- // creates icon node
- String backgroundLinePath = null;
+ if (showLinesValue) {
+ String path = RichFacesTemplatesActivator
+ .getPluginResourcePath() + ICON_LEFT_LINE;
+ iconNode.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
+ + NODE_LINES_STYLE);
+ }
- boolean showLinesValue = getShowLinesAttr((Element) sourceNode);
- nsIDOMElement iconNode = visualDocument.createElement(HTML.TAG_TD);
- // creates icon with status of node(collapsed or not) node
- nsIDOMElement td1 = visualDocument.createElement(HTML.TAG_TD);
- // sets icon node
- if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
- && !isHasNextAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
- : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINE
- : ICON_NODE_WITHOUT_LINES);
- } else if (!isLastElement(sourceNode) && isAdaptorChild(sourceNode)
- && isHasNextAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_ADAPTER_WITH_LINES
- : ICON_EXPANDED_ADAPTER_WITHOUT_LINES);
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- if (showLinesValue) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LEFT_LINE;
- iconNode.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
- + NODE_LINES_STYLE);
- }
- } else if ((isAdaptorChild(sourceNode) && isLastElement(sourceNode) && (isLastElementAfterAdaptor(sourceNode) == isAdaptorInTree(sourceNode)))
- || (!isAdaptorChild(sourceNode) && isLastElement(sourceNode))
- || (isAdaptorChild(sourceNode) && isOnlyOneNodeInAdaptor(sourceNode))) {
+ setAttributeForPictureNode(pageContext, visualDocument,
+ (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ }
- if (isAdaptorChild(sourceNode)
- && isOnlyOneNodeInAdaptor(sourceNode)
- && !isLastElementAfterAdaptor(sourceNode)
- && isHasNextParentAdaptorElement(sourceNode)) {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LINE;
- setAttributeForPictureNode(
- pageContext,
- visualDocument,
- (Element) sourceNode,
- td1,
- NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_NOT_EXPANDED_WITH_ALL_LINES
- : ICON_NOT_EXPANDED_WITHOUT_LINES);
- } else {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_RIGHT_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1,
- NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_NOT_EXPANDED_WITH_LINES
- : ICON_NOT_EXPANDED_WITHOUT_LINES);
- }
+ if (showLinesValue) {
+ td1.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + backgroundLinePath //$NON-NLS-1$
+ + "); " + NODE_LINES_STYLE); //$NON-NLS-1$
+ }
+ treeRow.appendChild(td1);
+ treeRow.appendChild(iconNode);
+ // creates Tree Node Name Message
+ nsIDOMElement nodeTitle = visualDocument.createElement(HTML.TAG_TD);
+ addBasicNodeTitleAttributes(nodeTitle);
+ // Create mapping to Encode body
+ if (sourceNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || sourceNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ Element sourceElement = (Element) sourceNode;
+ String nodesAttrValue = sourceElement.hasAttribute(NODES_NAME) ? sourceElement.getAttribute(NODES_NAME) : Constants.EMPTY;
+ nsIDOMElement textContainer = VisualDomUtil.createBorderlessContainer(visualDocument);
+ nsIDOMText text = visualDocument.createTextNode(nodesAttrValue);
+ textContainer.appendChild(text);
+ nodeTitle.appendChild(textContainer);
+ } else {
+ VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
+ // Create mapping to Encode body
+ List<Node> children = ComponentUtil.getChildren((Element) sourceNode, true);
+ for (Node child : children) {
+ tdInfo.addSourceChild(child);
+ }
+ vpeCreationData.addChildrenInfo(tdInfo);
+ }
+ treeRow.appendChild(nodeTitle);
+ }
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_LEAF_ATTR_NAME,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- } else {
- backgroundLinePath = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_RIGHT_LINE;
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, td1, NODE_ICON_EXPANDED_ATTR_NAME,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
-
- if (showLinesValue) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_LEFT_LINE;
- iconNode.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
- + NODE_LINES_STYLE);
- }
-
- setAttributeForPictureNode(pageContext, visualDocument,
- (Element) sourceNode, iconNode, NODE_ICON_ATTR_NAME,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
+ /**
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isLastElement(nsIDOMNode sourceNode) {
+ nsIDOMNode parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ nsIDOMNodeList childs = parentTree.getChildNodes();
+ nsIDOMNode lastElement = null;
+ nsIDOMNode el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
}
- if (showLinesValue) {
- td1.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + backgroundLinePath //$NON-NLS-1$
- + "); " + NODE_LINES_STYLE); //$NON-NLS-1$
+ /**
+ * Node is Adaptor child
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorChild(Node sourceNode) {
+ Node parentNode = sourceNode.getParentNode();
+ if (!(parentNode instanceof Element)) {
+ return true;
+ }
+ if (parentNode.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || parentNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ return true;
+ }
+ return false;
}
- treeRow.appendChild(td1);
- treeRow.appendChild(iconNode);
- // creates Tree Node Name Message
- nsIDOMElement nodeTitle = visualDocument.createElement(HTML.TAG_TD);
- addBasicNodeTitleAttributes(nodeTitle);
- // Create mapping to Encode body
- String treeRecursiveNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (sourceNode.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- Element sourceElement = (Element) sourceNode;
- String nodes = sourceElement.hasAttribute(RichFacesRecursiveTreeNodesAdaptorTemplate.NODES_NAME) ?
- sourceElement.getAttribute(RichFacesRecursiveTreeNodesAdaptorTemplate.NODES_NAME) : Constants.EMPTY;
- nsIDOMElement textContainer = VisualDomUtil
- .createBorderlessContainer(visualDocument);
- nsIDOMText text = visualDocument.createTextNode(nodes);
- textContainer.appendChild(text);
- nodeTitle.appendChild(textContainer);
- } else {
- VpeChildrenInfo tdInfo = new VpeChildrenInfo(nodeTitle);
- // Create mapping to Encode body
- List<Node> children = ComponentUtil.getChildren(
- (Element) sourceNode, false);
- for (Node child : children) {
- tdInfo.addSourceChild(child);
- }
- vpeCreationData.addChildrenInfo(tdInfo);
+ /**
+ * Node is last element
+ *
+ * @param parentTree
+ * @param sourceNode
+ * @return
+ */
+ protected boolean isLastElement(Node sourceNode) {
+ Node parentTree = sourceNode.getParentNode();
+ if (!(parentTree instanceof Element)) {
+ return true;
+ }
+ NodeList childs = parentTree.getChildNodes();
+ Node lastElement = null;
+ Node el = null;
+ for (int i = 0; i < childs.getLength(); i++) {
+ el = childs.item(i);
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || el.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ lastElement = el;
+ }
+ }
+ return sourceNode.equals(lastElement);
}
- treeRow.appendChild(nodeTitle);
- }
+ /**
+ * Adds basic attributes to tree
+ *
+ * @param img
+ */
- /**
- *
- * @param parentTree
- * @param sourceNode
- * @return
- */
- protected boolean isLastElement(nsIDOMNode sourceNode) {
- nsIDOMNode parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ private void addBasicAttributesToPicture(nsIDOMElement img) {
+ img.setAttribute(HTML.ATTR_CLASS, TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
}
- nsIDOMNodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- nsIDOMNode lastElement = null;
- nsIDOMNode el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (el.getNodeName().equals(treeNodeName)
- || el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- lastElement = el;
- }
- }
- return sourceNode.equals(lastElement);
- }
- /**
- * Node is Adaptor child
- *
- * @param sourceNode
- * @return
- */
- private boolean isAdaptorChild(Node sourceNode) {
- Node parentNode = sourceNode.getParentNode();
- if (!(parentNode instanceof Element)) {
- return true;
+ /**
+ * Sets attributes for no node title name
+ *
+ * @param nodeTitle
+ */
+ private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
+ nodeTitle.setAttribute(HTML.ATTR_CLASS, STYLE_CLASS_FOR_NODE_TITLE);
}
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = sourceNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (parentNode.getNodeName().equals(treeNodesAdaptorName)
- || parentNode.getNodeName().equals(
- treeRecursiveNodesAdaptorName)) {
- return true;
+ /**
+ * Used for setting images into tree nodes
+ *
+ * @param pageContext
+ * page context
+ * @param visualDocument
+ * visual document
+ * @param sourceNode
+ * treeNode element
+ * @param iconCell
+ * cell were image should be setted
+ * @param nodeAttrName
+ * image attr name( icon, iconExpanded, ...)
+ * @param defaultImage
+ * (image by default)
+ */
+ private void setAttributeForPictureNode(VpePageContext pageContext,
+ nsIDOMDocument visualDocument, Element sourceNode,
+ nsIDOMElement iconCell, String nodeAttrName, String defaultImage) {
+ if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
+ System.out.println("call setAttributeForPictureNode"); //$NON-NLS-1$
+ }
+ nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ // get image from treeNode
+ String imgName = sourceNode.getAttribute(nodeAttrName);
+ // if in tree node image doesn't exist we get image attr from tree
+ if (imgName == null || imgName.length() == 0) {
+ Node parentElement = sourceNode.getParentNode();
+ if (parentElement instanceof Element) {
+ imgName = ((Element) parentElement).getAttribute(nodeAttrName);
+ }
+ } else {
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ }
+ // if we can't get attribute from parent we use default attribute
+ addBasicAttributesToPicture(img);
+ iconCell.appendChild(img);
+ if (imgName == null || imgName.length() == 0) {
+ ComponentUtil.setImg(img, defaultImage);
+ } else {
+ ComponentUtil.setImgFromResources(pageContext, img, imgName,
+ UNDEFINED_ICON);
+ }
+ if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ }
}
- return false;
- }
- /**
- * Node is last element
- *
- * @param parentTree
- * @param sourceNode
- * @return
- */
- protected boolean isLastElement(Node sourceNode) {
- Node parentTree = sourceNode.getParentNode();
- if (!(parentTree instanceof Element)) {
- return true;
+ private boolean isOnlyOneNodeInAdaptor(Node sourceNode) {
+ Node parent = sourceNode.getParentNode();
+ NodeList list = parent.getChildNodes();
+ Node currentNode = null;
+ for (int i = 0; i < list.getLength(); i++) {
+ Node el = list.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ if (el.getNodeName().endsWith(Constants.COLON + TREE_NODE)) {
+ if (currentNode == null) {
+ currentNode = el;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ return true;
}
- NodeList childs = parentTree.getChildNodes();
- String treeNodeName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODE;
- String treeNodesAdaptorName = parentTree.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = parentTree.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- Node lastElement = null;
- Node el = null;
- for (int i = 0; i < childs.getLength(); i++) {
- el = childs.item(i);
- if (el.getNodeName().equals(treeNodeName)
- || el.getNodeName().equals(treeNodesAdaptorName)
- || el.getNodeName().equals(treeRecursiveNodesAdaptorName)) {
- lastElement = el;
- }
- }
- return sourceNode.equals(lastElement);
- }
- /**
- * Adds basic attributes to tree
- *
- * @param img
- */
-
- private void addBasicAttributesToPicture(nsIDOMElement img) {
- img.setAttribute(HTML.ATTR_CLASS, TREE_TABLE_PICTURE_STYLE_CLASS_NAME);
- }
-
- /**
- * Sets attributes for no node title name
- *
- * @param nodeTitle
- */
- private void addBasicNodeTitleAttributes(nsIDOMElement nodeTitle) {
- nodeTitle.setAttribute(HTML.ATTR_CLASS, STYLE_CLASS_FOR_NODE_TITLE);
- }
-
- /**
- * Used for setting images into tree nodes
- *
- * @param pageContext
- * page context
- * @param visualDocument
- * visual document
- * @param sourceNode
- * treeNode element
- * @param iconCell
- * cell were image should be setted
- * @param nodeAttrName
- * image attr name( icon, iconExpanded, ...)
- * @param defaultImage
- * (image by default)
- */
- private void setAttributeForPictureNode(VpePageContext pageContext,
- nsIDOMDocument visualDocument, Element sourceNode,
- nsIDOMElement iconCell, String nodeAttrName, String defaultImage) {
- if (RichFacesTemplatesActivator.getDefault().isDebugging()) {
- System.out.println("call setAttributeForPictureNode"); //$NON-NLS-1$
+ /**
+ * Node has element after adaptor
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isLastElementAfterAdaptor(Node sourceNode) {
+ Node nodeAdaptor = sourceNode.getParentNode();
+ if (!(nodeAdaptor instanceof Element)) {
+ return true;
+ }
+ return isLastElement(nodeAdaptor);
}
- nsIDOMElement img = visualDocument.createElement(HTML.TAG_IMG);
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- // get image from treeNode
- String imgName = sourceNode.getAttribute(nodeAttrName);
- // if in tree node image doesn't exist we get image attr from tree
- if (imgName == null || imgName.length() == 0) {
- Node parentElement = sourceNode.getParentNode();
- if (parentElement instanceof Element) {
- imgName = ((Element) parentElement).getAttribute(nodeAttrName);
- }
- } else {
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
- }
- // if we can't get attribute from parent we use default attribute
- addBasicAttributesToPicture(img);
- iconCell.appendChild(img);
- if (imgName == null || imgName.length() == 0) {
- ComponentUtil.setImg(img, defaultImage);
- } else {
- ComponentUtil.setImgFromResources(pageContext, img, imgName,
- UNDEFINED_ICON);
- }
- if (nodeAttrName.equals(NODE_ICON_EXPANDED_ATTR_NAME)) {
- img
- .setAttribute(ICON_PARAM_NAME,
- DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
- } else if (nodeAttrName.equals(NODE_ICON_LEAF_ATTR_NAME)) {
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
- }
- }
- private boolean isOnlyOneNodeInAdaptor(Node sourceNode) {
- Node parent = sourceNode.getParentNode();
- NodeList list = parent.getChildNodes();
- Node currentNode = null;
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON
- + RichFacesTreeTemplate.TREE_NODE_NAME;
- for (int i = 0; i < list.getLength(); i++) {
- Node el = list.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- if (el.getNodeName().equals(treeNodeName)) {
- if (currentNode == null) {
- currentNode = el;
- } else {
- return false;
+ /**
+ *
+ * @param sourceNode
+ * @return
+ */
+ private boolean isAdaptorInTree(Node sourceNode) {
+ Node adaptorNode = sourceNode.getParentNode();
+ if (!(adaptorNode instanceof Element)) {
+ return true;
}
- } else {
+ if (adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || adaptorNode.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ Node treeNode = adaptorNode.getParentNode();
+ if (treeNode.getNodeName().endsWith(Constants.COLON + TREE)) {
+ return true;
+ }
+ }
return false;
- }
}
- return true;
- }
- /**
- * Node has element after adaptor
- *
- * @param sourceNode
- * @return
- */
- private boolean isLastElementAfterAdaptor(Node sourceNode) {
- Node nodeAdaptor = sourceNode.getParentNode();
- if (!(nodeAdaptor instanceof Element)) {
- return true;
+ /**
+ * Set attributes for treeNode
+ *
+ * @param table
+ */
+ protected void addBasicTreeNodeAttributes(nsIDOMElement table) {
+ if (table == null) {
+ return;
+ }
+ table.setAttribute(HTML.ATTR_CELLPADDING,
+ TREE_TABLE_ATR_CELLPADDING_VALUE);
+ table.setAttribute(HTML.ATTR_CELLSPACING,
+ TREE_TABLE_ATR_CELLSPACING_VALUE);
+ table.setAttribute(HTML.ATTR_BORDER, TREE_TABLE_ATR_BORDER_VALUE);
+ table.setAttribute(HTML.ATTR_CLASS, "dr-tree-full-width"); //$NON-NLS-1$
}
- return isLastElement(nodeAdaptor);
- }
- /**
- *
- * @param sourceNode
- * @return
- */
- private boolean isAdaptorInTree(Node sourceNode) {
- Node adaptorNode = sourceNode.getParentNode();
- if (!(adaptorNode instanceof Element)) {
- return true;
- }
- String treeNodesAdaptorName = adaptorNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String treeRecursiveNodesAdaptorName = adaptorNode.getPrefix()
- + Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR;
- if (adaptorNode.getNodeName().equals(treeNodesAdaptorName)
- || adaptorNode.getNodeName().equals(
- treeRecursiveNodesAdaptorName)) {
- Node treeNode = adaptorNode.getParentNode();
- String treeName = treeNode.getPrefix() + Constants.COLON + TREE;
- if (treeNode.getNodeName().equals(treeName)) {
- return true;
- }
- }
- return false;
- }
+ /**
+ * Checks for attributes for node and if such exist convert it's to html
+ * atributes.
+ *
+ * @param sourceNode
+ * @param tableRow
+ */
+ protected void addAttributeToTableNode(Element sourceNode,
+ nsIDOMElement tableRow) {
- /**
- * Set attributes for treeNode
- *
- * @param table
- */
- protected void addBasicTreeNodeAttributes(nsIDOMElement table) {
- if (table == null) {
- return;
+ if (sourceNode.hasAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME)) {
+ tableRow.setAttribute(HTML.ATTR_CLASS,
+ sourceNode.getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME));
+ }
}
- table.setAttribute(HTML.ATTR_CELLPADDING,
- TREE_TABLE_ATR_CELLPADDING_VALUE);
- table.setAttribute(HTML.ATTR_CELLSPACING,
- TREE_TABLE_ATR_CELLSPACING_VALUE);
- table.setAttribute(HTML.ATTR_BORDER, TREE_TABLE_ATR_BORDER_VALUE);
- table.setAttribute(HTML.ATTR_CLASS, "dr-tree-full-width"); //$NON-NLS-1$
- }
- /**
- * Checks for attributes for node and if such exist convert it's to html
- * atributes.
- *
- * @param sourceNode
- * @param tableRow
- */
- protected void addAttributeToTableNode(Element sourceNode,
- nsIDOMElement tableRow) {
-
- if (sourceNode.hasAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME)) {
- tableRow.setAttribute(HTML.ATTR_CLASS, sourceNode.getAttribute(NODE_TITLE_STYLE_CLASS_ATTR_NAME));
- }
- }
-
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesRecursiveTreeNodesAdaptorTemplate.java 2011-09-12 11:57:46 UTC (rev 34628)
@@ -28,84 +28,71 @@
* @author dsakovich(a)exadel.com
*
*/
-public class RichFacesRecursiveTreeNodesAdaptorTemplate extends
- RichFacesAbstractTreeTemplate {
+public class RichFacesRecursiveTreeNodesAdaptorTemplate extends RichFacesAbstractTreeTemplate {
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
- private static final String ADAPTER_LINES_STYLE = "background-position: left center; background-repeat: repeat-y;"; //$NON-NLS-1$
- public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public static final String NODES_NAME = "nodes"; //$NON-NLS-1$
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
+ private static final String ADAPTER_LINES_STYLE = "background-position: left center; background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- if (isEmptyNode(sourceNode)) {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
- div.appendChild(visualElement);
- nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ VpeCreationData vpeCreationData = null;
+ if (isEmptyNode(sourceNode)) {
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML.TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ div.appendChild(visualElement);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
- visualElement.appendChild(tbody);
- tbody.appendChild(tableRow);
+ nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
- VpeCreationData vpeCreationData = new VpeCreationData(div);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
- } else {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH,
- TREE_NODES_ADAPTOR);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
- if (isHasParentAdapter(sourceNode)) {
- visualElement.setAttribute(HTML.ATTR_CLASS,
- "dr-tree-h-ic-div"); //$NON-NLS-1$
- if (getShowLinesAttr(sourceNode)
- && (isAdapterBetweenNodes(sourceNode) || isHasNextParentAdaptorElement(sourceNode))) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_DIV_LINE;
- visualElement.setAttribute(
- HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
- + ADAPTER_LINES_STYLE);
+ vpeCreationData = new VpeCreationData(div);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,vpeCreationData);
+ } else {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML.TAG_DIV);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
+ if (isHasParentAdapter(sourceNode)) {
+ visualElement.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div"); //$NON-NLS-1$
+ if (getShowLinesAttr(sourceNode)
+ && (isAdapterBetweenNodes(sourceNode) || isHasNextParentAdaptorElement(sourceNode))) {
+ String path = RichFacesTemplatesActivator.getPluginResourcePath() + ICON_DIV_LINE;
+ visualElement.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
+ + ADAPTER_LINES_STYLE);
+ }
+ }
+ vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,visualElement);
}
- }
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
+ return vpeCreationData;
}
- }
- /**
- *
- * @param sourceElement
- * @return
- */
- private boolean isEmptyNode(Node sourceNode) {
-
- NodeList childs = sourceNode.getChildNodes();
- for (int i = 0; i < childs.getLength(); i++) {
- Node el = childs.item(i);
- if (!(el instanceof Element)) {
- continue;
- }
- return false;
+ /**
+ *
+ * @param sourceElement
+ * @return
+ */
+ private boolean isEmptyNode(Node sourceNode) {
+ NodeList childs = sourceNode.getChildNodes();
+ for (int i = 0; i < childs.getLength(); i++) {
+ Node el = childs.item(i);
+ if (!(el instanceof Element)) {
+ continue;
+ }
+ return false;
+ }
+ return true;
}
- return true;
- }
-
- @Override
- public void setPseudoContent(VpePageContext pageContext,
- Node sourceContainer, nsIDOMNode visualContainer,
- nsIDOMDocument visualDocument) {
- // Empty
- }
+ @Override
+ public void setPseudoContent(VpePageContext pageContext,
+ Node sourceContainer, nsIDOMNode visualContainer,
+ nsIDOMDocument visualDocument) {
+ // Empty
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodeTemplate.java 2011-09-12 11:57:46 UTC (rev 34628)
@@ -31,144 +31,147 @@
*/
public class RichFacesTreeNodeTemplate extends RichFacesAbstractTreeTemplate {
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
- nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_TABLE);
- addBasicTreeNodeAttributes(visualElement);
- div.appendChild(visualElement);
- nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HTML.TAG_TABLE);
+ addBasicTreeNodeAttributes(visualElement);
+ div.appendChild(visualElement);
+ nsIDOMElement tbody = visualDocument.createElement(HTML.TAG_TBODY);
- nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
- addAttributeToTableNode((Element) sourceNode, tableRow);
- visualElement.appendChild(tbody);
- tbody.appendChild(tableRow);
+ nsIDOMElement tableRow = visualDocument.createElement(HTML.TAG_TR);
+ addAttributeToTableNode((Element) sourceNode, tableRow);
+ visualElement.appendChild(tbody);
+ tbody.appendChild(tableRow);
- VpeCreationData vpeCreationData = new VpeCreationData(div);
- createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
- vpeCreationData);
- return vpeCreationData;
- }
+ VpeCreationData vpeCreationData = new VpeCreationData(div);
+ createBasicTree(pageContext, visualDocument, tableRow, sourceNode,
+ vpeCreationData);
+ return vpeCreationData;
+ }
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
- String name, String value) {
- /*
- * processed only next attributes iconExpanded and icon, because tree
- * always shows as expanded and information is it leaf or not contains
- * in model
- */
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- nsIDOMElement expandedIconCell = queryInterface(
- visualNode.getChildNodes().item(0), nsIDOMElement.class);
- nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
- } else if (NODE_ICON_ATTR_NAME.equals(name)
- && !isLastElement(visualNode)) {
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
- } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
- && isLastElement(sourceElement)) {
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
- ComponentUtil.setImgFromResources(pageContext, img, value,
- UNDEFINED_ICON);
- img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ /*
+ * processed only next attributes iconExpanded and icon, because tree
+ * always shows as expanded and information is it leaf or not contains
+ * in model
+ */
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
+ nsIDOMElement expandedIconCell = queryInterface(visualNode
+ .getChildNodes().item(0), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes()
+ .item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ } else if (NODE_ICON_ATTR_NAME.equals(name)
+ && !isLastElement(visualNode)) {
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equals(name)
+ && isLastElement(sourceElement)) {
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+ ComponentUtil.setImgFromResources(pageContext, img, value,
+ UNDEFINED_ICON);
+ img.setAttribute(ICON_PARAM_NAME, Constants.EMPTY);
+ }
}
- }
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMNode visualNode, Object data, String name) {
- /*
- * processed only next attributes iconExpanded and icon, because tree
- * always shows as expanded and information is it leaf or not contains
- * in model
- */
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ /*
+ * processed only next attributes iconExpanded and icon, because tree
+ * always shows as expanded and information is it leaf or not contains
+ * in model
+ */
- Element parentElement = (Element) sourceElement.getParentNode();
- boolean showLinesValue = getShowLinesAttr(sourceElement);
- if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
-
- nsIDOMElement expandedIconCell = queryInterface(visualNode
- .getChildNodes().item(0), nsIDOMElement.class);
- nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes().item(0),
- nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_EXPANDED_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_EXPANDED_WITH_LINES
- : ICON_EXPANDED_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_EXPANDED_PARAM_VALUE);
- } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
- && !isLastElement(sourceElement)) {
-
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0),
- nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_NODE_WITH_LINES
- : ICON_NODE_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+ Element parentElement = (Element) sourceElement.getParentNode();
+ boolean showLinesValue = getShowLinesAttr(sourceElement);
+ if (NODE_ICON_EXPANDED_ATTR_NAME.equalsIgnoreCase(name)) {
- } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
- && isLastElement(sourceElement)) {
-
- nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes().item(1),
- nsIDOMElement.class);
- nsIDOMElement img = queryInterface(iconCell.getChildNodes().item(0), nsIDOMElement.class);
-
- if (parentElement.hasAttribute(NODE_ICON_LEAF_ATTR_NAME)) {
- String parentAttrName = parentElement.getAttribute(NODE_ICON_LEAF_ATTR_NAME);
- ComponentUtil.setImgFromResources(pageContext, img,
- parentAttrName, UNDEFINED_ICON);
- } else {
- ComponentUtil.setImg(img,
- showLinesValue == true ? ICON_LEAF_WITH_LINES
- : ICON_LEAF_WITHOUT_LINES);
- }
- img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ nsIDOMElement expandedIconCell = queryInterface(visualNode
+ .getChildNodes().item(0), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(expandedIconCell.getChildNodes()
+ .item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_EXPANDED_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_EXPANDED_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_EXPANDED_WITH_LINES
+ : ICON_EXPANDED_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_EXPANDED_PARAM_VALUE);
+ } else if (NODE_ICON_ATTR_NAME.equalsIgnoreCase(name)
+ && !isLastElement(sourceElement)) {
+
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_NODE_WITH_LINES
+ : ICON_NODE_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, DEFAULT_ICON_PARAM_VALUE);
+
+ } else if (NODE_ICON_LEAF_ATTR_NAME.equalsIgnoreCase(name)
+ && isLastElement(sourceElement)) {
+
+ nsIDOMElement iconCell = queryInterface(visualNode.getChildNodes()
+ .item(1), nsIDOMElement.class);
+ nsIDOMElement img = queryInterface(
+ iconCell.getChildNodes().item(0), nsIDOMElement.class);
+
+ if (parentElement.hasAttribute(NODE_ICON_LEAF_ATTR_NAME)) {
+ String parentAttrName = parentElement
+ .getAttribute(NODE_ICON_LEAF_ATTR_NAME);
+ ComponentUtil.setImgFromResources(pageContext, img,
+ parentAttrName, UNDEFINED_ICON);
+ } else {
+ ComponentUtil.setImg(img,
+ showLinesValue == true ? ICON_LEAF_WITH_LINES
+ : ICON_LEAF_WITHOUT_LINES);
+ }
+ img.setAttribute(ICON_PARAM_NAME, NODE_ICON_LEAF_ATTR_NAME);
+ }
}
- }
-
-}
+}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeNodesAdaptorTemplate.java 2011-09-12 11:57:46 UTC (rev 34628)
@@ -27,33 +27,28 @@
*/
public class RichFacesTreeNodesAdaptorTemplate extends RichFacesAbstractTreeTemplate {
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
- private static final String ADAPTER_LINES_STYLE = "background-position: left center; background-repeat: repeat-y;"; //$NON-NLS-1$
- public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ public static final String ICON_DIV_LINE = "/tree/divLine.gif"; //$NON-NLS-1$
+ private static final String ADAPTER_LINES_STYLE = "background-position: left center; background-repeat: repeat-y;"; //$NON-NLS-1$
+ public static final String ID_ATTR_NAME = "ID"; //$NON-NLS-1$
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML .TAG_DIV);
- visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
- if (isHasParentAdapter(sourceNode)) {
- visualElement.setAttribute(HTML.ATTR_CLASS,
- "dr-tree-h-ic-div"); //$NON-NLS-1$
- if (getShowLinesAttr(sourceNode)
- && (isAdapterBetweenNodes(sourceNode) || isHasNextParentAdaptorElement(sourceNode))) {
- String path = RichFacesTemplatesActivator
- .getPluginResourcePath()
- + ICON_DIV_LINE;
- visualElement.setAttribute(HTML.ATTR_STYLE,
- "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
- + ADAPTER_LINES_STYLE);
- }
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE_NODES_ADAPTOR);
+ nsIDOMElement visualElement = visualDocument.createElement(HTML .TAG_DIV);
+ visualElement.setAttribute(ID_ATTR_NAME, TREE_NODES_ADAPTOR);
+ if (isHasParentAdapter(sourceNode)) {
+ visualElement.setAttribute(HTML.ATTR_CLASS,"dr-tree-h-ic-div"); //$NON-NLS-1$
+ if (getShowLinesAttr(sourceNode)
+ && (isAdapterBetweenNodes(sourceNode) || isHasNextParentAdaptorElement(sourceNode))) {
+ String path = RichFacesTemplatesActivator.getPluginResourcePath() + ICON_DIV_LINE;
+ visualElement.setAttribute(HTML.ATTR_STYLE,
+ "background-image: url(file://" + path + "); " //$NON-NLS-1$ //$NON-NLS-2$
+ + ADAPTER_LINES_STYLE);
+ }
+ }
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData, visualElement);
+ return vpeCreationData;
}
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- return vpeCreationData;
- }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTreeTemplate.java 2011-09-12 11:57:46 UTC (rev 34628)
@@ -34,296 +34,273 @@
* @author dsakovich(a)exadel.com
*
*/
-public class RichFacesTreeTemplate extends VpeAbstractTemplate {
+public class RichFacesTreeTemplate extends RichFacesAbstractTreeTemplate{
- /** Resurces */
+ private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
+ private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
+ private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass"; //$NON-NLS-1$
+ private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded"; //$NON-NLS-1$
- public static final String TREE= "tree"; //$NON-NLS-1$
- public static final String TREE_NODE_NAME = "treeNode"; //$NON-NLS-1$
- public static final String TREE_NODES_ADAPTOR = "treeNodesAdaptor"; //$NON-NLS-1$
- public static final String RECURSIVE_TREE_NODES_ADAPTOR = "recursiveTreeNodesAdaptor"; //$NON-NLS-1$
- public static final String SHOW_LINES_ATTR_NAME = "showConnectingLines"; //$NON-NLS-1$
- private static final String STYLE_PATH = "/tree/tree.css"; //$NON-NLS-1$
- private static final String ICON_ATTR = "icon"; //$NON-NLS-1$
- private static final String TREE_STYLE_CLASS_ATR_NAME = "styleClass"; //$NON-NLS-1$
- private static final String ICON_COLLAPSED_ATTR_NAME = "iconExpanded"; //$NON-NLS-1$
+ /**
+ * Creates a node of the visual tree on the node of the source tree. This
+ * visual node should not have the parent node This visual node can have
+ * child nodes.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @return The information on the created node of the visual tree.
+ */
+ public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument) {
+ // sets css for tree on page
+ ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE);
+ nsIDOMElement visualElement = visualDocument
+ .createElement(HTML.TAG_DIV);
+ Element sourceElement = (Element) sourceNode;
- /**
- * Creates a node of the visual tree on the node of the source tree. This
- * visual node should not have the parent node This visual node can have
- * child nodes.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @return The information on the created node of the visual tree.
- */
- public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument) {
- // sets css for tree on page
- ComponentUtil.setCSSLink(pageContext, STYLE_PATH, TREE);
- nsIDOMElement visualElement = visualDocument
- .createElement(HTML.TAG_DIV);
- Element sourceElement = (Element) sourceNode;
-
- if (sourceElement.hasAttribute(HTML.ATTR_STYLE)) {
- String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
- visualElement.setAttribute(HTML.ATTR_STYLE, style);
+ if (sourceElement.hasAttribute(HTML.ATTR_STYLE)) {
+ String style = sourceElement.getAttribute(HTML.ATTR_STYLE);
+ visualElement.setAttribute(HTML.ATTR_STYLE, style);
+ }
+
+ if (sourceElement.hasAttribute(HTML.ATTR_CLASS)) {
+ String styleClass = sourceElement.getAttribute(HTML.ATTR_CLASS);
+ visualElement.setAttribute(HTML.ATTR_CLASS, styleClass);
+ }
+ VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
+ vpeCreationData.addChildrenInfo(new VpeChildrenInfo(null));
+
+ parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
+ visualElement);
+ setStylesAttributesToTree(visualElement, (Element) sourceNode);
+ return vpeCreationData;
}
-
- if (sourceElement.hasAttribute(HTML.ATTR_CLASS)) {
- String styleClass = sourceElement.getAttribute(HTML.ATTR_CLASS);
- visualElement.setAttribute(HTML.ATTR_CLASS, styleClass);
- }
- VpeCreationData vpeCreationData = new VpeCreationData(visualElement);
- vpeCreationData.addChildrenInfo(new VpeChildrenInfo(null));
-
- parseTree(pageContext, sourceNode, visualDocument, vpeCreationData,
- visualElement);
- setStylesAttributesToTree(visualElement, (Element) sourceNode);
- return vpeCreationData;
- }
- /**
- * Sets to tree basic style attributes
- *
- * @param tree
- * @param sourceNode
- */
- private void setStylesAttributesToTree(nsIDOMElement treeTable,
- Element sourceNode) {
-
+ /**
+ * Sets to tree basic style attributes
+ *
+ * @param tree
+ * @param sourceNode
+ */
+ private void setStylesAttributesToTree(nsIDOMElement treeTable,
+ Element sourceNode) {
if (sourceNode.hasAttribute(HTML.ATTR_STYLE)) {
String styleAttr = sourceNode.getAttribute(HTML.ATTR_STYLE);
- setAttributeToTree(treeTable, HTML.ATTR_STYLE,
- removeFromStyleWithAndHeight(styleAttr));
- treeTable
- .setAttribute(HTML.ATTR_STYLE, styleAttr);
+ setAttributeToTree(treeTable, HTML.ATTR_STYLE,
+ removeFromStyleWithAndHeight(styleAttr));
+ treeTable.setAttribute(HTML.ATTR_STYLE, styleAttr);
}
-
if (sourceNode.hasAttribute(TREE_STYLE_CLASS_ATR_NAME)) {
- String styleClassAttr = sourceNode.getAttribute(TREE_STYLE_CLASS_ATR_NAME);
- setAttributeToTree(treeTable, HTML.ATTR_CLASS,
- styleClassAttr);
+ String styleClassAttr = sourceNode
+ .getAttribute(TREE_STYLE_CLASS_ATR_NAME);
+ setAttributeToTree(treeTable, HTML.ATTR_CLASS, styleClassAttr);
}
- }
+ }
- /**
- *
- * @param styleArgs
- * @return
- */
- private String removeFromStyleWithAndHeight(String styleArgs) {
- StringBuffer result = new StringBuffer();
- String[] mas = styleArgs.split(Constants.SEMICOLON);
- for (String styleAttr : mas) {
- if ((styleAttr.indexOf(HTML.ATTR_WIDTH) != -1)
- || (styleAttr.indexOf(HTML.ATTR_HEIGHT) != -1)) {
- continue;
- }
- result.append(styleAttr + Constants.SEMICOLON);
+ /**
+ *
+ * @param styleArgs
+ * @return
+ */
+ private String removeFromStyleWithAndHeight(String styleArgs) {
+ StringBuffer result = new StringBuffer();
+ String[] mas = styleArgs.split(Constants.SEMICOLON);
+ for (String styleAttr : mas) {
+ if ((styleAttr.indexOf(HTML.ATTR_WIDTH) != -1)
+ || (styleAttr.indexOf(HTML.ATTR_HEIGHT) != -1)) {
+ continue;
+ }
+ result.append(styleAttr + Constants.SEMICOLON);
+ }
+ return result.toString();
}
- return result.toString();
- }
- /**
- * Sets to tree tables attributes
- *
- * @param node
- * @param sourceNode
- * @param attrValue
- */
- private void setAttributeToTree(nsIDOMNode node, String attrName,
- String attrValue) {
- try {
- nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
- if (node.getNodeName().equalsIgnoreCase(
- HTML.TAG_TABLE)) {
- element.setAttribute(attrName, attrValue);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- setAttributeToTree(list2.item(i), attrName, attrValue);
- }
- } catch (XPCOMException exception) {
- // Ignore
- return;
+ /**
+ * Sets to tree tables attributes
+ *
+ * @param node
+ * @param sourceNode
+ * @param attrValue
+ */
+ private void setAttributeToTree(nsIDOMNode node, String attrName,
+ String attrValue) {
+ try {
+ nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_TABLE)) {
+ element.setAttribute(attrName, attrValue);
+ }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ setAttributeToTree(list2.item(i), attrName, attrValue);
+ }
+ } catch (XPCOMException exception) {
+ // Ignore
+ return;
+ }
}
- }
- /**
- * Is invoked after construction of all child nodes of the current visual
- * node.
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceNode
- * The current node of the source tree.
- * @param visualDocument
- * The document of the visual tree.
- * @param data
- * Object <code>VpeCreationData</code>, built by a method
- * <code>create</code>
- */
+ /**
+ * Is invoked after construction of all child nodes of the current visual
+ * node.
+ *
+ * @param pageContext
+ * Contains the information on edited page.
+ * @param sourceNode
+ * The current node of the source tree.
+ * @param visualDocument
+ * The document of the visual tree.
+ * @param data
+ * Object <code>VpeCreationData</code>, built by a method
+ * <code>create</code>
+ */
- @Override
- public void validate(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData data) {
- super.validate(pageContext, sourceNode, visualDocument, data);
- revertTableRows(data.getNode());
- }
+ @Override
+ public void validate(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData data) {
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ revertTableRows(data.getNode());
+ }
- /**
- * Revert tree elements in right order.
- *
- * @param node
- */
- private void revertTableRows(nsIDOMNode node) {
-
- try {
- nsIDOMNodeList list = node.getChildNodes();
- nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
- String id = element.hasAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) ?
- element.getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) :
- Constants.EMPTY;
- if (node.getNodeName().equalsIgnoreCase(
- HTML.TAG_DIV)
- && list.getLength() == 2
- && !(id
- .equalsIgnoreCase(TREE_NODES_ADAPTOR) || id
- .equalsIgnoreCase(RECURSIVE_TREE_NODES_ADAPTOR))) {
- nsIDOMNode table1 = list.item(0);
- nsIDOMNode table2 = list.item(1);
- node.removeChild(table1);
- node.removeChild(table2);
- node.appendChild(table2);
- node.appendChild(table1);
- }
- nsIDOMNodeList list2 = node.getChildNodes();
- for (int i = 0; i < list2.getLength(); i++) {
- revertTableRows(list2.item(i));
- }
- } catch (XPCOMException e) {
- //Ignore
- return;
+ /**
+ * Revert tree elements in right order.
+ *
+ * @param node
+ */
+ private void revertTableRows(nsIDOMNode node) {
+ try {
+ nsIDOMNodeList list = node.getChildNodes();
+ nsIDOMElement element = queryInterface(node, nsIDOMElement.class);
+ String id = element
+ .hasAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME) ? element
+ .getAttribute(RichFacesTreeNodesAdaptorTemplate.ID_ATTR_NAME)
+ : Constants.EMPTY;
+ if (node.getNodeName().equalsIgnoreCase(HTML.TAG_DIV)
+ && list.getLength() == 2
+ && !(id.equalsIgnoreCase(TREE_NODES_ADAPTOR)
+ || id.equalsIgnoreCase(TREE_MODEL_ADAPTOR)
+ || id.equalsIgnoreCase(TREE_MODEL_RECURSIVE_ADAPTOR)
+ || id.equalsIgnoreCase(RECURSIVE_TREE_NODES_ADAPTOR))) {
+ nsIDOMNode table1 = list.item(0);
+ nsIDOMNode table2 = list.item(1);
+ node.removeChild(table1);
+ node.removeChild(table2);
+ node.appendChild(table2);
+ node.appendChild(table1);
+ }
+ nsIDOMNodeList list2 = node.getChildNodes();
+ for (int i = 0; i < list2.getLength(); i++) {
+ revertTableRows(list2.item(i));
+ }
+ } catch (XPCOMException e) {
+ // Ignore
+ return;
+ }
}
- }
- /**
- *
- * Function for parsing tree by tree nodes;
- *
- * @param pageContext
- * @param sourceNode
- * @param visualDocument
- * @return
- */
- public void parseTree(VpePageContext pageContext, Node sourceNode,
- nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
- nsIDOMElement parentDiv) {
- NodeList nodeList = sourceNode.getChildNodes();
- Element element = null;
- nsIDOMElement div = null;
- nsIDOMElement childTree = null;
- nsIDOMElement childLast = null;
- int lenght = nodeList.getLength();
- String treeNodeName = sourceNode.getPrefix() + Constants.COLON + TREE_NODE_NAME;
- String treeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + TREE_NODES_ADAPTOR;
- String recursiveTreeNodesAdaptorName = sourceNode.getPrefix() + Constants.COLON
- + RECURSIVE_TREE_NODES_ADAPTOR;
- VpeChildrenInfo vpeChildrenInfo = null;
- for (int i = 0; i < lenght; i++) {
- if (!(nodeList.item(i) instanceof Element)) {
- continue;
- }
- element = (Element) nodeList.item(i);
- childTree = null;
- if (element.getNodeName().equals(treeNodeName)
- || element.getNodeName().equals(treeNodesAdaptorName)
- || element.getNodeName().equals(
- recursiveTreeNodesAdaptorName)) {
- if (div == null) {
-
- vpeChildrenInfo = new VpeChildrenInfo(parentDiv);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- div = createBasicTree(visualDocument);
- childLast = parentDiv;
- continue;
- } else if (childTree == null) {
-
- vpeChildrenInfo = new VpeChildrenInfo(div);
- vpeCreationData.addChildrenInfo(vpeChildrenInfo);
- vpeChildrenInfo.addSourceChild(element);
- childLast.appendChild(div);
- childLast = div;
- div = createBasicTree(visualDocument);
- continue;
+ /**
+ *
+ * Function for parsing tree by tree nodes;
+ *
+ * @param pageContext
+ * @param sourceNode
+ * @param visualDocument
+ * @return
+ */
+ @Override
+ public void parseTree(VpePageContext pageContext, Node sourceNode,
+ nsIDOMDocument visualDocument, VpeCreationData vpeCreationData,
+ nsIDOMElement parentDiv) {
+ NodeList nodeList = sourceNode.getChildNodes();
+ Element element = null;
+ nsIDOMElement div = null;
+ nsIDOMElement childTree = null;
+ nsIDOMElement childLast = null;
+ int lenght = nodeList.getLength();
+ VpeChildrenInfo vpeChildrenInfo = null;
+ for (int i = 0; i < lenght; i++) {
+ if (!(nodeList.item(i) instanceof Element)) {
+ continue;
+ }
+ element = (Element) nodeList.item(i);
+ childTree = null;
+ if (element.getNodeName().endsWith(Constants.COLON + TREE_NODE)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + RECURSIVE_TREE_NODES_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_ADAPTOR)
+ || element.getNodeName().endsWith(Constants.COLON + TREE_MODEL_RECURSIVE_ADAPTOR)) {
+ if (div == null) {
+ vpeChildrenInfo = new VpeChildrenInfo(parentDiv);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ div = createBasicTree(visualDocument);
+ childLast = parentDiv;
+ continue;
+ } else if (childTree == null) {
+ vpeChildrenInfo = new VpeChildrenInfo(div);
+ vpeCreationData.addChildrenInfo(vpeChildrenInfo);
+ vpeChildrenInfo.addSourceChild(element);
+ childLast.appendChild(div);
+ childLast = div;
+ div = createBasicTree(visualDocument);
+ continue;
+ }
+ }
}
- }
}
- }
- @Override
- public boolean recreateAtAttrChange(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMElement visualNode, Object data, String name, String value) {
- if (ICON_COLLAPSED_ATTR_NAME.equals(name)
- || SHOW_LINES_ATTR_NAME.equals(name)
- || ICON_ATTR.equals(name)
- || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME
- .equals(name)) {
- return true;
+ @Override
+ public boolean recreateAtAttrChange(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMElement visualNode, Object data, String name, String value) {
+ if (ICON_COLLAPSED_ATTR_NAME.equals(name)
+ || SHOW_LINES_ATTR_NAME.equals(name)
+ || ICON_ATTR.equals(name)
+ || RichFacesTreeNodeTemplate.NODE_ICON_LEAF_ATTR_NAME.equals(name)) {
+ return true;
+ }
+ return false;
}
- return false;
- }
- @Override
- public void setAttribute(VpePageContext pageContext, Element sourceElement,
- nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
- String name, String value) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_CLASS,
- value);
- } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_STYLE,
- removeFromStyleWithAndHeight(value));
- nsIDOMElement visualElement = queryInterface(visualNode, nsIDOMElement.class);
- visualElement.setAttribute(
- HTML.ATTR_STYLE, value);
+ @Override
+ public void setAttribute(VpePageContext pageContext, Element sourceElement,
+ nsIDOMDocument visualDocument, nsIDOMNode visualNode, Object data,
+ String name, String value) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_CLASS, value);
+ } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_STYLE,
+ removeFromStyleWithAndHeight(value));
+ nsIDOMElement visualElement = queryInterface(visualNode,
+ nsIDOMElement.class);
+ visualElement.setAttribute(HTML.ATTR_STYLE, value);
+ }
}
- }
- @Override
- public void removeAttribute(VpePageContext pageContext,
- Element sourceElement, nsIDOMDocument visualDocument,
- nsIDOMNode visualNode, Object data, String name) {
- if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_CLASS,
- Constants.EMPTY);
- } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
- setAttributeToTree(visualNode, HTML.ATTR_STYLE,
- Constants.EMPTY);
+ @Override
+ public void removeAttribute(VpePageContext pageContext,
+ Element sourceElement, nsIDOMDocument visualDocument,
+ nsIDOMNode visualNode, Object data, String name) {
+ if (TREE_STYLE_CLASS_ATR_NAME.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_CLASS, Constants.EMPTY);
+ } else if (HTML.ATTR_STYLE.equalsIgnoreCase(name)) {
+ setAttributeToTree(visualNode, HTML.ATTR_STYLE, Constants.EMPTY);
+ }
}
- }
- /**
- * Create simple tree node attribute.Used for creating more complex trees.
- *
- * @param treeNodeTitle
- * @param visualDocument
- * @return tree
- */
- private nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
-
- nsIDOMElement div = visualDocument
- .createElement(HTML.TAG_DIV);
- div.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div"); //$NON-NLS-1$
- return div;
- }
-
-}
+ /**
+ * Create simple tree node attribute.Used for creating more complex trees.
+ *
+ * @param treeNodeTitle
+ * @param visualDocument
+ * @return tree
+ */
+ private nsIDOMElement createBasicTree(nsIDOMDocument visualDocument) {
+ nsIDOMElement div = visualDocument.createElement(HTML.TAG_DIV);
+ div.setAttribute(HTML.ATTR_CLASS, "dr-tree-h-ic-div"); //$NON-NLS-1$
+ return div;
+ }
+}
\ No newline at end of file
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/templates/vpe-templates-richfaces.xml 2011-09-12 11:57:46 UTC (rev 34628)
@@ -393,7 +393,7 @@
</vpe:tag>
<vpe:tag name="rich:hashParam" case-sensitive="yes">
- <vpe:template children="no" modify="no">
+ <vpe:template children="yes" modify="no">
</vpe:template>
</vpe:tag>
@@ -968,7 +968,6 @@
</vpe:template>
</vpe:tag>
-
<vpe:tag name="rich:tree" case-sensitive="yes">
<vpe:template children="yes" modify="no"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeTemplate">
@@ -991,6 +990,30 @@
</vpe:template>
</vpe:tag>
+<vpe:tag name="rich:treeModelAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodesAdaptorTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
+ <vpe:tag name="rich:treeModelRecursiveAdaptor" case-sensitive="yes">
+ <vpe:template children="yes" modify="no"
+ class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesRecursiveTreeNodesAdaptorTemplate">
+ <vpe:dnd>
+ <vpe:drag start-enable="yes" />
+ <vpe:drop container="yes">
+ <vpe:container-child tag-name="treeNode" />
+ </vpe:drop>
+ </vpe:dnd>
+ </vpe:template>
+ </vpe:tag>
+
<vpe:tag name="rich:treeNode" case-sensitive="yes">
<vpe:template children="yes" modify="yes"
class="org.jboss.tools.jsf.vpe.richfaces.template.RichFacesTreeNodeTemplate">
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml
===================================================================
(Binary files differ)
Modified: trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml 2011-09-12 10:48:36 UTC (rev 34627)
+++ trunk/jsf/tests/org.jboss.tools.jsf.vpe.richfaces.test/resources/richFacesTest/WebContent/pages/components/treeNodesAdaptor.xhtml.xml 2011-09-12 11:57:46 UTC (rev 34628)
@@ -1,6 +1,6 @@
<tests>
<test id="project">
- <DIV ID="treeNodesAdaptor" >
+ <DIV ID="treeNodesAdaptor">
<DIV>
<TABLE CELLSPACING="0px" CELLPADDING="0px" BORDER="0px"
CLASS="dr-tree-full-width">
@@ -8,20 +8,19 @@
<TR>
<TD
STYLE="/background-image: url\(.*resources//tree/line.gif\); background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\); background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Project: #{project.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form. </SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -36,20 +35,19 @@
<TR>
<TD
STYLE="/background-image: url\(.*resources//tree/line.gif\); background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\); background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Source directory: #{srcDir.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form. </SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -70,14 +68,14 @@
</TD>
<TD
STYLE="/background-image: url\(.*resources//tree/leftLine.gif\); background-position: center center; background-repeat: repeat-y;/">
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconNodeWithLines.gif/"
RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Package: #{pkg.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form. </SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -97,14 +95,14 @@
RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
</TD>
<TD>
- <IMG CLASS="treePictureStyle"
- SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconLeafWithLines.gif/"
RICHFACESTREENODEPARAM="iconLeaf" />
</TD>
<TD CLASS="treeNodeNameStyle">
<SPAN>
<SPAN> Class: #{class.name} </SPAN>
- <SPAN> : This link is disabled as it is not nested within a JSF form. </SPAN>
+ <SPAN> : This link is disabled as it is not nested within a JSF form.
+ </SPAN>
</SPAN>
</TD>
</TR>
@@ -116,4 +114,97 @@
</DIV>
</DIV>
</test>
+
+ <test id="tMRA">
+
+ <DIV ID="treeNodesAdaptor">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px" BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/line.gif\); background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconClosedNodeWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/leftLine.gif\); background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconNodeWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_PARAM" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item.shortPath}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ <DIV ID="treeNodesAdaptor" CLASS="dr-tree-h-ic-div">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px" BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/rightLine.gif\); background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
+ SRC="/.*resources/tree/iconNotCollapsedWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD>
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ RICHFACESTREENODEPARAM="iconLeaf" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </DIV>
+ </test>
+
+ <test id="tMA">
+
+ <DIV ID="treeNodesAdaptor" CLASS="dr-tree-h-ic-div">
+ <DIV>
+ <TABLE CELLSPACING="0px" CELLPADDING="0px" BORDER="0px"
+ CLASS="dr-tree-full-width">
+ <TBODY>
+ <TR>
+ <TD
+ STYLE="/background-image: url\(.*resources//tree/rightLine.gif\); background-position: center center; background-repeat: repeat-y;/">
+ <IMG CLASS="treePictureStyle"
+ SRC="/.*resources/tree/iconNotCollapsedWithLines.gif/"
+ RICHFACESTREENODEPARAM="DEFAULT_ICON_EXPANDED_PARAM" />
+
+ </TD>
+ <TD>
+ <IMG CLASS="treePictureStyle" SRC="/.*resources/tree/iconLeafWithLines.gif/"
+ RICHFACESTREENODEPARAM="iconLeaf" />
+
+ </TD>
+ <TD CLASS="treeNodeNameStyle">
+ <SPAN CLASS="vpe-text">
+ #{item}
+ </SPAN>
+ </TD>
+ </TR>
+ </TBODY>
+ </TABLE>
+ </DIV>
+ </DIV>
+ </test>
+
</tests>
\ No newline at end of file
14 years, 7 months