Author: mareshkau
Date: 2009-07-17 09:58:24 -0400 (Fri, 17 Jul 2009)
New Revision: 16651
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3247Test.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/VpeCustomStringStorage.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeIncludeInfo.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
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
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3247, support for custom tags from jar files has
been added
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/ComponentUtil.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -275,10 +275,11 @@
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
Constants.EMPTY); //$NON-NLS-1$
IFile file = null;
- if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
- file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
- .getFile();
-
+ if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null
+ &&(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage()
instanceof IFile)) {
+ file = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getStorage();
+ }
if (file == null)
return resolvedValue;
@@ -588,10 +589,11 @@
IEditorInput input = pageContext.getEditPart().getEditorInput();
IPath inputPath = getInputParentPath(input);
//Fix For JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
+ ||!(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage()
instanceof IFile)) {
return;
}
- String path =
ElService.getInstance().replaceEl(pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile(),
fileImageName);
+ String path =
ElService.getInstance().replaceEl((IFile)pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage(),
fileImageName);
File file = new File(inputPath.toOSString() + File.separator + path);
if (file.exists()) {
img.setAttribute(HTML.ATTR_SRC, HtmlComponentUtil.FILE_PROTOCOL +
inputPath.toString() + "/" //$NON-NLS-1$
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelItemTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -217,7 +217,7 @@
if (attr != null) {
String itemLabel = attr.getNodeValue();
String bundleValue = ResourceUtil.getBundleValue(pageContext,
- attr);
+ attr.getValue());
nsIDOMText text;
// if bundleValue differ from value then will be represent
// bundleValue, but text will be not edit
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuGroupTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -257,7 +257,7 @@
if (null != labelAttr) {
labelValue = labelAttr.getNodeValue();
bundleValue = ResourceUtil.getBundleValue(pageContext,
- labelAttr);
+ labelAttr.getValue());
}
if (ComponentUtil.isNotBlank(labelValue)) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelMenuItemTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -230,7 +230,7 @@
if (null != labelAttr) {
labelValue = labelAttr.getNodeValue();
bundleValue = ResourceUtil.getBundleValue(pageContext,
- labelAttr);
+ labelAttr.getValue());
}
if (ComponentUtil.isNotBlank(labelValue)) {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesTabTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -270,7 +270,7 @@
} else if (sourceElement.hasAttribute(LABEL)) {
Attr labelAttr = sourceElement.getAttributeNode(LABEL);
if (null != labelAttr) {
- String bundleValue = ResourceUtil.getBundleValue(pageContext, labelAttr);
+ String bundleValue = ResourceUtil.getBundleValue(pageContext, labelAttr.getValue());
mainTd.appendChild(visualDocument.createTextNode(bundleValue));
}
} else {
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml 2009-07-17
13:58:24 UTC (rev 16651)
@@ -7,8 +7,11 @@
xmlns:c="http://mydomain.com/jsf/myproject">
<body>
<!-- custom tags -->
+<div id="custom_tags">
<ma:paginator/>
-<ma:echo msg="Helle Custom Tags" />
+<ma:echo msg="Hello, Custom Tags!" />
<c:inputCurrency value="100"/>
+<ma:echo msg="Echo custom tag" />
+</div>
</body>
</html>
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml.xml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/JBIDE3247/WebContent/pages/index.xhtml.xml 2009-07-17
13:58:24 UTC (rev 16651)
@@ -0,0 +1,53 @@
+<tests>
+<test id="custom_tags">
+<DIV ID="custom_tags" STYLE="-moz-user-modify: read-write;" >
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<!-- h:inputHidden id="currentPage" replace, because if on page two fields,
two elements with equal id has been used, but should be used only one -->
+<TABLE BORDER="0" STYLE="margin-right: auto; margin-left: auto;
-moz-user-modify: read-only;">
+<TBODY>
+<TR>
+<TD>
+<INPUT TYPE="submit" VALUE="<<"
STYLE="-moz-user-modify: read-only;"/>
+
+</TD>
+<TD>
+<INPUT TYPE="submit" VALUE="<"
STYLE="-moz-user-modify: read-only;"/>
+
+</TD>
+<TD>
+<INPUT TYPE="submit" VALUE=">"
STYLE="-moz-user-modify: read-only;"/>
+
+</TD>
+<TD>
+<INPUT TYPE="submit" VALUE=">>"
STYLE="-moz-user-modify: read-only;"/>
+
+</TD>
+</TR>
+</TBODY>
+</TABLE>
+</DIV>
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<SPAN CLASS="message" STYLE="-moz-user-modify: read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+Hello, Custom Tags!
+</SPAN>
+</SPAN>
+</DIV>
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+$
+</SPAN>
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+100
+</SPAN>
+</DIV>
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<SPAN CLASS="message" STYLE="-moz-user-modify: read-only;">
+<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
+Echo custom tag
+</SPAN>
+</SPAN>
+</DIV>
+</DIV>
+</test>
+</tests>
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -45,6 +45,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3144Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3163Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3197Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3247Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3376Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3396Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3441Test;
@@ -153,6 +154,7 @@
suite.addTestSuite(JBIDE4509Test.class);
suite.addTestSuite(JBIDE4510Test.class);
suite.addTestSuite(JBIDE4534Test.class);
+ suite.addTestSuite(JBIDE3247Test.class);
// $JUnit-END$
// added by Max Areshkau
// add here projects which should be imported for junit tests
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3247Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3247Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE3247Test.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.jsf.vpe.jsf.test.jbide;
+
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.ui.test.ComponentContentTest;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class JBIDE3247Test extends ComponentContentTest{
+
+ public JBIDE3247Test(String name) {
+ super(name);
+ }
+
+ public void testJBIDE3247() throws Throwable {
+ performContentTest("index.xhtml"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected String getTestProjectName() {
+ return JsfAllTests.IMPORT_JBIDE3247_PROJECT_NAME;
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeIncludeInfo.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeIncludeInfo.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeIncludeInfo.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -10,27 +10,27 @@
******************************************************************************/
package org.jboss.tools.vpe.editor;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class VpeIncludeInfo {
private Element element;
- private IFile file;
+ private IStorage storage;
private Document document;
- public VpeIncludeInfo(Element element, IFile file, Document document) {
+ public VpeIncludeInfo(Element element, IStorage storage, Document document) {
this.element = element;
- this.file = file;
+ this.storage = storage;
this.document = document;
}
public Element getElement() {
- return element;
+ return this.element;
}
- public IFile getFile() {
- return file;
+ public IStorage getStorage() {
+ return this.storage;
}
public Document getDocument() {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Point;
@@ -160,7 +161,7 @@
}
private VpeDnd dropper;
- private Map<IFile, Document> includeDocuments = new HashMap<IFile,
Document>();
+ private Map<IStorage, Document> includeDocuments = new HashMap<IStorage,
Document>();
private boolean showInvisibleTags;
public VpeVisualDomBuilder(VpeDomMapping domMapping,
@@ -461,7 +462,6 @@
Node sourceNodeProxy = null;
// FIX FOR JBIDE-1568, added by Max Areshkau
try {
-
if (ElService.getInstance().isELNode(getPageContext(),
sourceNode)) {
@@ -2114,11 +2114,11 @@
return includeInfo;
}
- public boolean isFileInIncludeStack(IFile file) {
+ public boolean isFileInIncludeStack(IStorage file) {
if (file == null)
return false;
for (int i = 0; i < includeStack.size(); i++) {
- if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getFile())) {
+ if (file.equals(((VpeIncludeInfo) includeStack.get(i)).getStorage())) {
return true;
}
}
@@ -2264,7 +2264,7 @@
this.xulRunnerEditor = xulRunnerEditor;
}
- public Map<IFile, Document> getIncludeDocuments() {
+ public Map<IStorage, Document> getIncludeDocuments() {
return includeDocuments;
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/context/VpePageContext.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -11,9 +11,11 @@
package org.jboss.tools.vpe.editor.context;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -21,9 +23,6 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.wst.xml.core.internal.document.ElementImpl;
import org.jboss.tools.common.kb.KbConnectorFactory;
import org.jboss.tools.common.kb.KbConnectorType;
@@ -33,18 +32,14 @@
import org.jboss.tools.jst.jsp.editor.IVisualContext;
import org.jboss.tools.jst.jsp.preferences.VpePreference;
import org.jboss.tools.jst.web.tld.TaglibData;
-import org.jboss.tools.jst.web.tld.VpeTaglibListener;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeEditorPart;
import org.jboss.tools.vpe.editor.VpeSourceDomBuilder;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
-import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
-import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.XmlUtil;
import org.jboss.tools.vpe.resref.core.AbsoluteFolderReferenceList;
-import org.jboss.tools.vpe.resref.core.CSSReferenceList;
import org.jboss.tools.vpe.resref.core.RelativeFolderReferenceList;
import org.jboss.tools.vpe.resref.core.TaglibReferenceList;
import org.mozilla.interfaces.nsIDOMNode;
@@ -64,7 +59,14 @@
private VpeEditorPart editPart;
WtpKbConnector connector;
private nsIDOMNode currentVisualNode;
+ /**
+ * Created to store custom element attributes and use it in time of
+ * rendering
+ * @author mareshkau
+ */
+ private Map<String,String> customElementsAttributes;
+
public VpePageContext(BundleMap bundle, VpeEditorPart editPart) {
this.bundle = bundle;
this.editPart = editPart;
@@ -79,6 +81,22 @@
else return false;
}
+ /**
+ * Adds attribute to element attribute map
+ * @param key
+ * @param value
+ */
+ public void addAttributeInCustomElementsMap(String key, String value){
+ getCustomElementsAttributes().put(key, value);
+ }
+ /**
+ * Removes attribute from custom attribute map
+ * @param sourceBuilder
+ */
+ public void removeAttributeFromCustomElementMap(String key) {
+ getCustomElementsAttributes().remove(key);
+ }
+
public void setSourceDomBuilder(VpeSourceDomBuilder sourceBuilder) {
this.sourceBuilder = sourceBuilder;
refreshConnector();
@@ -244,28 +262,12 @@
}
- private void fireTaglibChanged(VpeTaglibListener taglibListener, List newTaglibs, List
delTaglibs) {
- Iterator iter = delTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.removeTaglib(taglib.getUri(), taglib.getPrefix());
- }
- iter = newTaglibs.iterator();
- while (iter.hasNext()) {
- TaglibData taglib = (TaglibData)iter.next();
- taglibListener.addTaglib(taglib.getUri(), taglib.getPrefix());
- }
- }
-
public WtpKbConnector getConnector() {
- return connector;
+ return this.connector;
}
- public void addTaglibListener(VpeTaglibListener listener) {
- // TODO Auto-generated method stub
-
- }
+
public List<TaglibData> getTagLibs(Node sourceNode) {
return XmlUtil.getTaglibsForNode(sourceNode, this);
@@ -275,7 +277,7 @@
* @return the currentVisualNode
*/
public nsIDOMNode getCurrentVisualNode() {
- return currentVisualNode;
+ return this.currentVisualNode;
}
/**
@@ -300,4 +302,14 @@
}
}
+ /**
+ * @return the customElementsAttributes
+ */
+ public Map<String, String> getCustomElementsAttributes() {
+ if(this.customElementsAttributes==null) {
+ this.customElementsAttributes = new HashMap<String, String>();
+ }
+ return this.customElementsAttributes;
+ }
+
}
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/proxy/VpeNodeInvocationHandler.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -12,10 +12,8 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import org.eclipse.core.resources.IFile;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.util.ElService;
-import org.jboss.tools.vpe.editor.util.ResourceUtil;
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@@ -43,15 +41,15 @@
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
- Object result = method.invoke(node, args);
+ Object result = method.invoke(this.node, args);
if(result instanceof String) {
String processedStr = (String) result;
result = replaceEL(processedStr);
} else if(result instanceof Attr) {
- result = VpeProxyUtil.createProxyForELExpressionNode(pageContext,
+ result = VpeProxyUtil.createProxyForELExpressionNode(this.pageContext,
(Node)result);
} else if(result instanceof NamedNodeMap) {
- result = VpeProxyUtil.createProxyForNamedNodeMap(pageContext, (NamedNodeMap)result);
+ result = VpeProxyUtil.createProxyForNamedNodeMap(this.pageContext,
(NamedNodeMap)result);
}
return result;
}
@@ -62,16 +60,7 @@
*/
private String replaceEL(String toReplace) {
- String result = toReplace;
-
- result = ResourceUtil.getBundleValue(pageContext, toReplace);
-
- //mareshkau,fix for JBIDE-3030, el doesn't works for external files.
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
- return result;
- }
- final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
- return ElService.getInstance().replaceEl(file, result);
+ return ElService.getInstance().replaceElAndResources(this.pageContext,
toReplace);
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCreatorUtil.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -15,12 +15,17 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jface.text.BadLocationException;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.custom.VpeCustomStringStorage;
import org.jboss.tools.vpe.editor.util.FileUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -125,11 +130,12 @@
IEditorInput input = pageContext.getEditPart().getEditorInput();
IFile file = null;
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
+ || !(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage() instanceof
IFile)) {
file = FileUtil.getFile(input, fileName);
} else {
IFile includedFile =
- pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
file = FileUtil.getFile(fileName, includedFile);
}
@@ -167,7 +173,26 @@
}
return null;
}
+ /**
+ * Return dom document for read, document shoud be released from read
+ * @see VpeCreatorUtil#releaseDocumentFromRead(Document)
+ * @param file
+ * @return dom document for read
+ */
+ public static Document getDocumentForRead(String content) {
+ IDOMModel wtpModel = null;
+ IModelManager modelManager = StructuredModelManager.getModelManager();
+
+ wtpModel = (IDOMModel) modelManager
+ .createUnManagedStructuredModelFor("org.eclipse.wst.html.core.htmlsource");
//$NON-NLS-1$
+ IStructuredDocument document = wtpModel.getStructuredDocument();
+ document.set(content);
+ if (wtpModel != null)
+ return wtpModel.getDocument();
+ return null;
+ }
+
public static int getFacetType(Node node, VpePageContext pageContext) {
if (VpeCreatorUtil.isFacet(node)) {
return getFacetType(node);
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -10,19 +10,14 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template;
-import java.util.ArrayList;
-import java.util.List;
-
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.resources.IStorage;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
-import org.jboss.tools.common.el.core.ELReferenceList;
-import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.vpe.editor.VpeIncludeInfo;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.custom.CustomTLDReference;
+import org.jboss.tools.vpe.editor.template.custom.VpeCustomStringStorage;
import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMNode;
@@ -50,14 +45,13 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- IPath pathToFile = CustomTLDReference
+ IStorage sourceFileStorage = CustomTLDReference
.getCustomElementPath(sourceNode, pageContext);
- if (pathToFile != null) {
- //add attributes to EL list
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
- pathToFile);
- if (file != null && file.exists()) {
+ if (sourceFileStorage instanceof IFile) {
+ //add attributes to EL list
+ IFile file =(IFile) sourceFileStorage;
+ if (file.exists()) {
if (!pageContext.getVisualBuilder().isFileInIncludeStack(
file)) {
Document document = pageContext.getVisualBuilder()
@@ -69,38 +63,56 @@
.getIncludeDocuments().put(file, document);
}
if (document != null) {
- VpeCreationData creationData = createInclude(
- document, visualDocument);
- ResourceReference [] oldResourceReferences
- = VpeCustomTemplate
- .addAttributesToELExcpressions(
- sourceNode, file);
- creationData.setData(new TransferObject(
- oldResourceReferences, file));
- pageContext.getVisualBuilder().pushIncludeStack(
- new VpeIncludeInfo((Element) sourceNode,
- file, document));
- return creationData;
+ return createCreationData(pageContext, sourceNode, file, document,
visualDocument);
}
}
}
+ }else if(sourceFileStorage instanceof VpeCustomStringStorage) {
+ VpeCustomStringStorage customStringStorage = (VpeCustomStringStorage)
sourceFileStorage;
+ if (!pageContext.getVisualBuilder().isFileInIncludeStack(
+ customStringStorage)) {
+ Document document = pageContext.getVisualBuilder()
+ .getIncludeDocuments().get(customStringStorage);
+ if (document == null) {
+ document =
VpeCreatorUtil.getDocumentForRead(customStringStorage.getContentString());
+ if (document != null)
+ pageContext.getVisualBuilder()
+ .getIncludeDocuments().put(customStringStorage, document);
+ }
+ if (document != null) {
+ return createCreationData(pageContext, sourceNode, customStringStorage, document,
visualDocument);
+ }
+ }
}
-
VpeCreationData creationData = createStub(sourceNode.getNodeName(),
visualDocument);
creationData.setData(null);
return creationData;
- }
+ }
+
+ private VpeCreationData createCreationData(VpePageContext pageContext,Node sourceNode,
+ IStorage storage,
+ Document document, nsIDOMDocument visualDocument) {
+ VpeCreationData creationData = createInclude(
+ document, visualDocument);
+
+ VpeCustomTemplate.addAttributesToELExcpressions(
+ sourceNode, pageContext);
+ creationData.setData(storage);
+ pageContext.getVisualBuilder().pushIncludeStack(
+ new VpeIncludeInfo((Element) sourceNode,
+ storage, document));
+ return creationData;
+ }
+
@Override
public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data){
- if(data.getData() instanceof TransferObject) {
- TransferObject trObject = (TransferObject) data.getData();
- ELReferenceList.getInstance().setAllResources(
- trObject.getCustomFile(), trObject.getResourceReferebces());
- data.setData(trObject.getCustomFile());
- }
-
+ NamedNodeMap attributesMap = sourceNode.getAttributes();
+ for(int i=0;i<attributesMap.getLength();i++) {
+ Attr attr = (Attr) attributesMap.item(i);
+ pageContext.removeAttributeFromCustomElementMap(attr.getName());
+ }
super.validate(pageContext, sourceNode, visualDocument, data);
}
@@ -111,36 +123,21 @@
* @param processedFile processed File
* @return resourceReferences - unchanged resource references
*/
- private static final ResourceReference[] addAttributesToELExcpressions(
- final Node sourceNode, final IFile processedFile){
-
- //obtain old resource references for this file
- ResourceReference[] resourceReferences = ELReferenceList.getInstance()
- .getAllResources(processedFile);
- //obtain attribute resource references for file
+ private static final void addAttributesToELExcpressions(
+ final Node sourceNode, final VpePageContext vpePageContext){
NamedNodeMap attributesMap = sourceNode.getAttributes();
- List<ResourceReference> addedAttrToElExpressions
- = new ArrayList<ResourceReference>();
+
for(int i=0;i<attributesMap.getLength();i++) {
Attr attr = (Attr) attributesMap.item(i);
- //adds attribute if such attribute not exists for page
- ResourceReference resRef = new ResourceReference(attr.getName(),
- ResourceReference.FILE_SCOPE);
- resRef.setProperties(attr.getValue());
- addedAttrToElExpressions.add(resRef);
+ vpePageContext.addAttributeInCustomElementsMap(attr.getName(), attr.getValue());
}
- ELReferenceList.getInstance().setAllResources(processedFile,
- addedAttrToElExpressions.toArray(new ResourceReference[0]));
- return resourceReferences;
}
@Override
public void beforeRemove(VpePageContext pageContext, Node sourceNode,
nsIDOMNode visualNode, Object data) {
IFile file = null;
- if(data instanceof TransferObject) {
- file = ((TransferObject)data).getCustomFile();
- } else if(data instanceof IFile) {
+ if(data instanceof IFile) {
file = (IFile) data;
}
super.beforeRemove(pageContext, sourceNode, visualNode, file);
@@ -160,38 +157,4 @@
offset+=sourceNode.getPrefix().length()+1+1;
return new Region(offset, 0);
}
-
- /**
- * Object which used to passing argument throw template event processing,
- * restore el expressions after processing custom template
- *
- * @author mareshkau
- *
- */
- private static class TransferObject {
- private ResourceReference [] resourceReferebces;
- private IFile customFile;
-
- /**
- * @param resourceReferebces
- * @param customFile
- */
- public TransferObject(ResourceReference[] resourceReferebces,
- IFile customFile) {
- this.resourceReferebces = resourceReferebces;
- this.customFile = customFile;
- }
- /**
- * @return the resourceReferebces
- */
- public ResourceReference[] getResourceReferebces() {
- return this.resourceReferebces;
- }
- /**
- * @return the customFile
- */
- public IFile getCustomFile() {
- return this.customFile;
- }
- }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -63,8 +63,8 @@
if (vpeValue != null && vpeValue.stringValue().length() > 0) {
fileName = vpeValue.stringValue();
VpeIncludeInfo info = pageContext.getVisualBuilder().getCurrentIncludeInfo();
- if(info != null) {
- IFile templateFile = info.getFile();
+ if(info != null && info.getStorage() instanceof IFile) {
+ IFile templateFile = (IFile) info.getStorage();
IFile file = FileUtil.getFile(fileName, templateFile);
if (file != null) {
@@ -102,7 +102,7 @@
if (data.getData() != null) {
VpeIncludeInfo includeInfo = pageContext.getVisualBuilder().popIncludeStack();
if (includeInfo != null) {
- //VpeCreatorUtil.releaseDocumentFromRead(includeInfo.getDocument());
+// VpeCreatorUtil.releaseDocumentFromRead(includeInfo.getDocument());
}
}
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -12,12 +12,17 @@
import java.util.List;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
+import org.jboss.tools.common.model.filesystems.impl.RecognizedFileImpl;
import org.jboss.tools.common.model.filesystems.impl.SimpleFileImpl;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -42,7 +47,7 @@
* @param sourceNode
* @return full path to custom template if exist or null if not exist
*/
- public static IPath getCustomElementPath(Node sourceNode,
+ public static IStorage getCustomElementPath(Node sourceNode,
VpePageContext pageContext) {
List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(sourceNode,
pageContext);
@@ -52,7 +57,7 @@
XModelObject xmodel = getCustomTaglibObject(pageContext,uri);
XModelObject o = xmodel.getChildByPath(sourceNode.getLocalName()
- + "/declaration"); //$NON-NLS-1$
+ +XModelObjectConstants.SEPARATOR +"declaration"); //$NON-NLS-1$
String sourceAttributeValue = null;
if (o != null) {
sourceAttributeValue = o.getAttributeValue("source"); //$NON-NLS-1$
@@ -62,14 +67,28 @@
return null;
}
if (xmodel instanceof SimpleFileImpl) {
- IPath pathToSourceFile = ((SimpleFileImpl) xmodel).getFile()
- .getFullPath();
+ IFile iFile = ((SimpleFileImpl) xmodel).getFile();
+ if(iFile==null) {
+ //possibly it's a jar file
+
+ XModelObject sourceFile =
xmodel.getParent().getParent().getChildByPath(sourceAttributeValue.substring(1));
+ if(sourceFile instanceof RecognizedFileImpl) {
+ String content = ((RecognizedFileImpl)sourceFile).getAsText();
+ String name =((RecognizedFileImpl)sourceFile).getPresentationString();
+ IStorage customStorage = new VpeCustomStringStorage(content, name);
+ return customStorage;
+ }
+ return null;
+ }
+ IPath pathToSourceFile = iFile.getFullPath();
// pathToSourceFile now smth like this
// /customFaceletsTestProject/WebContent/tags/facelets.taglib.xml
// so we remove facelet taglib name now
pathToSourceFile = pathToSourceFile.removeLastSegments(1);
pathToSourceFile = pathToSourceFile.append(sourceAttributeValue);
- return pathToSourceFile;
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
+ pathToSourceFile);
+ return file;
}
return null;
}
Added:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/VpeCustomStringStorage.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/VpeCustomStringStorage.java
(rev 0)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/VpeCustomStringStorage.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2009 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.template.custom;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @author mareshkau
+ *
+ */
+public class VpeCustomStringStorage implements IStorage {
+
+ private String jarFileContent;
+ private String name;
+
+ public VpeCustomStringStorage(String input,String resourceName) {
+ this.jarFileContent = input;
+ this.name = resourceName;
+ }
+
+ public InputStream getContents() throws CoreException {
+ return new ByteArrayInputStream(this.jarFileContent.getBytes());
+ }
+
+ public IPath getFullPath() {
+ return null;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ /**
+ *
+ * @return content of file in jar archive
+ */
+ public String getContentString() {
+ return this.jarFileContent;
+ }
+
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/expression/VpeFunctionSrc.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -210,10 +210,11 @@
protected String resolveEL(VpePageContext pageContext, String value) {
String resolvedValue =
value.replaceFirst("^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
""); //$NON-NLS-1$ //$NON-NLS-2$
//Fix for JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null){
+ if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null
+ || !(pageContext.getVisualBuilder().getCurrentIncludeInfo() instanceof
IFile)){
return resolvedValue;
}
- final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
resolvedValue = ElService.getInstance().replaceEl(file, resolvedValue);
return resolvedValue;
Modified:
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 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ElService.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -19,6 +19,7 @@
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.ui.texteditor.TextNavigationAction;
import org.jboss.tools.common.el.core.ELReferenceList;
import org.jboss.tools.common.el.core.GlobalELReferenceList;
import org.jboss.tools.common.resref.core.ResourceReference;
@@ -27,6 +28,7 @@
import org.w3c.dom.Attr;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+import org.w3c.dom.Text;
/**
@@ -172,18 +174,58 @@
*/
public boolean isELNode(VpePageContext pageContext,Node sourceNode) {
boolean rst = false;
+ if(isInCustomElementsAttributes(pageContext,sourceNode)){
+ return true;
+ }
// fix for JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ if((pageContext.getVisualBuilder().getCurrentIncludeInfo())==null
+ || !(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage()
instanceof IFile)) {
return rst;
}
- final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
- if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file))) || isInResourcesBundle(pageContext, sourceNode)){
+ if (((this.isAvailable(file) && this.isAvailableForNode(sourceNode,
file)))
+ || isInResourcesBundle(pageContext, sourceNode)){
rst = true;
}
return rst;
}
+ /**
+ * Checks is node exist in source custom element attribute map and if so,
+ * then retrun true
+ * @param pageContext
+ * @param sourceNode
+ * @return
+ */
+ private static boolean isInCustomElementsAttributes(VpePageContext pageContext,Node
sourceNode){
+
+ String textValue = null;
+ if(sourceNode.getNodeType() == Node.TEXT_NODE) {
+ textValue = sourceNode.getNodeValue();
+ if (textValue != null) {
+ for(String key : pageContext.getCustomElementsAttributes().keySet()){
+ if(equalsExppression(textValue,key)){
+ return true;
+ }
+ }
+ }
+ }else if(sourceNode.getNodeType() == Node.ELEMENT_NODE) {
+ NamedNodeMap attributesMap = sourceNode.getAttributes();
+ for(int i=0;i<attributesMap.getLength();i++) {
+ Attr attr = (Attr) attributesMap.item(i);
+ textValue =attr.getValue();
+ if(textValue!=null) {
+ for(String key : pageContext.getCustomElementsAttributes().keySet()){
+ if(equalsExppression(textValue,key)){
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
/**
*
* @param pageContext
@@ -333,31 +375,42 @@
}
- public String replaceElAndResources(VpePageContext pageContext, Node attributeNode)
{
+ public String replaceElAndResources(VpePageContext pageContext, String value) {
- String attribuString = null;
- if (attributeNode instanceof Attr) {
- attribuString = ((Attr) attributeNode).getValue();
- } else {
- attribuString = attributeNode.getNodeValue();
- }
- String rst = attribuString;
+ String rst = value;
- rst = ResourceUtil.getBundleValue(pageContext, attributeNode);
+ rst = ResourceUtil.getBundleValue(pageContext, value);
+ //replace custom attributes
+ rst = replaceCustomAttributes(pageContext,rst);
//fix for JBIDE-3030
- if(pageContext.getVisualBuilder().getCurrentIncludeInfo()==null) {
+ if((pageContext.getVisualBuilder().getCurrentIncludeInfo()==null)
+ || !(pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage()
instanceof IFile)) {
return rst;
}
- final IFile file =
pageContext.getVisualBuilder().getCurrentIncludeInfo().getFile();
+ final IFile file = (IFile)
pageContext.getVisualBuilder().getCurrentIncludeInfo().getStorage();
rst = replaceEl(file, rst);
-
+
return rst;
}
+ private String replaceCustomAttributes(VpePageContext pageContext, String value){
+ String result = value;
+ for (String el : pageContext.getCustomElementsAttributes().keySet()) {
+ final String dollarEl = DOLLAR_PREFIX + el + SUFFIX;
+ final String sharpEl = SHARP_PREFIX + el + SUFFIX;
+ if (result.contains(dollarEl)) {
+ result = result.replace(dollarEl,
pageContext.getCustomElementsAttributes().get(el));
+ }
+ if (result.contains(sharpEl)) {
+ result = result.replace(sharpEl,pageContext.getCustomElementsAttributes().get(el));
+ }
+ }
+ return result;
+ }
- private boolean equalsExppression(String value, String expression) {
+ private static boolean equalsExppression(String value, String expression) {
final String dollarEl = String.valueOf(DOLLAR_PREFIX) + expression
+ String.valueOf(SUFFIX);
Modified:
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 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/IELService.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -46,7 +46,7 @@
*
* @return the string
*/
- String replaceElAndResources(VpePageContext pageContext, Node attributeNode);
+ String replaceElAndResources(VpePageContext pageContext, String value);
/**
* Checks if is available.
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/ResourceUtil.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -13,7 +13,6 @@
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.context.VpePageContext;
-import org.w3c.dom.Node;
/**
* @author Evgenij Stherbin
@@ -37,16 +36,4 @@
return bundle.getBundleValue(value);
}
- /**
- * get bundle.
- *
- * @param pageContext the page context
- * @param attr the attr
- *
- * @return the bundle value
- */
- public static String getBundleValue(VpePageContext pageContext, Node attr) {
- return getBundleValue(pageContext,attr.getNodeValue());
- }
-
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-07-17
13:44:20 UTC (rev 16650)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/VpeStyleUtil.java 2009-07-17
13:58:24 UTC (rev 16651)
@@ -377,10 +377,13 @@
endPathIndex);
IFile file = null;
- if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
- file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
- .getFile();
- if (file != null)
+ if ((pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
+ &&(pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getStorage() instanceof IFile)) {
+ file = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getStorage();
+ }
+ if(file!=null)
filePath = processUrl(filePath, file);
String firstPartValue = urls[i].substring(0, startPathIndex + 1);
@@ -827,10 +830,12 @@
"^\\s*(\\#|\\$)\\{facesContext.externalContext.requestContextPath\\}",
Constants.EMPTY); //$NON-NLS-1$
IFile file = null;
- if (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
- file = pageContext.getVisualBuilder().getCurrentIncludeInfo()
- .getFile();
-
+ if ( (pageContext.getVisualBuilder().getCurrentIncludeInfo() != null)
+ &&(pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getStorage() instanceof IFile) ) {
+ file = (IFile) pageContext.getVisualBuilder().getCurrentIncludeInfo()
+ .getStorage();
+ }
if (file == null)
return resolvedValue;