Author: estherbin
Date: 2008-07-15 05:14:12 -0400 (Tue, 15 Jul 2008)
New Revision: 9140
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
Log:
Write service for EL substitution for
http://jira.jboss.com/jira/browse/JBIDE-2010 issue.
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2008-07-15
09:14:12 UTC (rev 9140)
@@ -0,0 +1,66 @@
+package org.jboss.tools.vpe.editor.util;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
+import org.jboss.tools.vpe.editor.css.ELReferenceList;
+import org.jboss.tools.vpe.editor.css.ResourceReference;
+
+/**
+ * The {@link IELService} implementation.
+ *
+ * @author Eugeny Stherbin
+ */
+public final class ElService implements IELService {
+
+ /** The Constant INSTANCE. */
+ private static final ElService INSTANCE = new ElService();
+
+ /**
+ * Gets the singleton instance.
+ *
+ * @return the singleton instance
+ */
+ public static IELService getInstance(){
+ return INSTANCE;
+ }
+
+ /**
+ *
+ * @see IELService#getReplacedElValue(IFile, String)
+ */
+ public String replaceEl(IFile resourceFile, String resourceString) {
+ Assert.isNotNull(resourceString);
+ Assert.isNotNull(resourceFile);
+ String rst = resourceString;
+
+ final ResourceReference[] references =
ELReferenceList.getInstance().getAllResources(resourceFile);
+
+ if((references!=null) && (references.length > 0)){
+ rst = replace(resourceString,references);
+ }
+ return rst;
+ }
+
+ /**
+ * Replace.
+ *
+ * @param resourceString the resource string
+ * @param references the references
+ *
+ * @return the string
+ */
+ private String replace(String resourceString, ResourceReference[] references) {
+ String result = resourceString;
+
+ for (ResourceReference rf : references) {
+ if (resourceString.contains(rf.getProperties())) {
+ result = result.replace(rf.getProperties(), rf.getLocation());
+ }
+ }
+ return result;
+ }
+
+
+
+
+}
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2008-07-15
09:14:12 UTC (rev 9140)
@@ -0,0 +1,30 @@
+
+
+package org.jboss.tools.vpe.editor.util;
+
+
+import org.eclipse.core.resources.IFile;
+
+
+/**
+ * The service that substitute El values in vpe source editor.
+ * For more details see issues
+ *
http://jira.jboss.com/jira/browse/JBIDE-2010
+ * and
+ *
http://jira.jboss.com/jira/browse/JBIDE-1410
+ *
+ * @author Eugeny Stherbin
+ */
+public interface IELService {
+
+ /**
+ * Return the {@link String} with substitued el values for given resource.
+ *
+ * @param resourceFile the resource file where resource
+ * @param resourceString the source string that will be substitute
+ *
+ * @return string where el values was substituted.
+ */
+ String replaceEl(IFile resourceFile, String resourceString);
+
+}
Property changes on:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native