Author: yradtsevich
Date: 2008-10-15 10:34:45 -0400 (Wed, 15 Oct 2008)
New Revision: 10857
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
Log:
Method getClasses extracted from VpePanelGridCreator and placed into new class
VpeClassUtil.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-10-15
14:21:11 UTC (rev 10856)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpePanelGridCreator.java 2008-10-15
14:34:45 UTC (rev 10857)
@@ -23,6 +23,7 @@
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionInfo;
import org.jboss.tools.vpe.editor.template.expression.VpeValue;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.VpeClassUtil;
import org.mozilla.interfaces.nsIDOMAttr;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
@@ -350,9 +351,9 @@
.createElement(HTML.TAG_TBODY);
visualTable.appendChild(visualBody);
- List rowClasses = getClasses(rowClassesExpr, sourceNode,
+ List<String> rowClasses = VpeClassUtil.getClasses(rowClassesExpr, sourceNode,
pageContext);
- List columnClasses = getClasses(columnClassesExpr, sourceNode,
+ List<String> columnClasses = VpeClassUtil.getClasses(columnClassesExpr,
sourceNode,
pageContext);
int rci = 0; // index of row class
@@ -421,22 +422,6 @@
return creatorInfo;
}
- private List getClasses(VpeExpression expression, Node sourceNode,
- VpePageContext pageContext) throws VpeExpressionException {
- List b = new ArrayList();
- if (expression != null && sourceNode != null) {
- String classes = expression.exec(pageContext, sourceNode)
- .stringValue();
- String[] a = classes.split(",");
- for (int i = 0; i < a.length; i++) {
- if (a[i].trim().length() > 0) {
- b.add(a[i].trim());
- }
- }
- }
- return b;
- }
-
private void makeSpecial(Node header, nsIDOMElement visualHead,
nsIDOMDocument visualDocument, int tableSize,
VpeCreatorInfo creatorInfo, String cellTag,
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeClassUtil.java 2008-10-15
14:34:45 UTC (rev 10857)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.editor.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpression;
+import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
+import org.w3c.dom.Node;
+
+/**
+ * @author yradtsevich
+ *
+ */
+public class VpeClassUtil {
+ /**
+ *
+ */
+ private static final String CLASSES_DELIMITER = ","; //$NON-NLS-1$
+
+ /**
+ * Extracts class names from <code>sourceNode</code> specified by a string
given
+ * by <code>expression</code>
+ *
+ * @param expression
+ * @param sourceNode
+ * @param pageContext
+ * @return names of style classes
+ * @throws VpeExpressionException
+ */
+ public static List<String> getClasses(VpeExpression expression, Node sourceNode,
+ VpePageContext pageContext) throws VpeExpressionException {
+ List<String> ret = new ArrayList<String>();
+ if (expression != null && sourceNode != null) {
+ String classes = expression.exec(pageContext, sourceNode)
+ .stringValue();
+ String[] a = classes.split(CLASSES_DELIMITER);
+ for (int i = 0; i < a.length; i++) {
+ String className = a[i].trim();
+ if (className.length() > 0) {
+ ret.add(className);
+ }
+ }
+ }
+ return ret;
+ }
+}