Author: mareshkau
Date: 2009-04-24 10:58:53 -0400 (Fri, 24 Apr 2009)
New Revision: 14903
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/correctCustomTags.xhtml.xml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/tags/facelets.taglib.xml
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.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/VpeTemplateManager.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDParser.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-3197, attribute processing was added
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -59,7 +59,7 @@
SUPPORTED_IDS.add(JSF_CONVERT_URL_TO_PATH);
SUPPORTED_IDS.add(JSF_GET_TAGLIBS);
}
- public final String PROVIDER_ID = "jsf";
+ public final static String PROVIDER_ID = "jsf"; //$NON-NLS-1$
public boolean isSupporting(String id) {
return id != null && SUPPORTED_IDS.contains(id);
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/correctCustomTags.xhtml.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/correctCustomTags.xhtml.xml 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/correctCustomTags.xhtml.xml 2009-04-24
14:58:53 UTC (rev 14903)
@@ -2,7 +2,7 @@
<test id="correctCustomTags">
<DIV ID="correctCustomTags" STYLE="-moz-user-modify: read-write;"
>
<!-- Test case when custom template defined -->
-<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;">
+<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;" >
<TABLE BORDER="0" STYLE="margin-right: auto; margin-left: auto;
-moz-user-modify: read-only;">
<TBODY>
<TR>
@@ -22,7 +22,7 @@
<DIV VPE:INCLUDE-ELEMENT="yes" STYLE="-moz-user-modify:
read-only;" >
<SPAN STYLE="-moz-user-modify: read-only;">
<SPAN CLASS="vpe-text" STYLE="-moz-user-modify: read-only;">
-${echo}
+Echo
</SPAN>
</SPAN>
</DIV>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/tags/facelets.taglib.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/tags/facelets.taglib.xml 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/tags/facelets.taglib.xml 2009-04-24
14:58:53 UTC (rev 14903)
@@ -11,7 +11,7 @@
<tag-name>paginator</tag-name>
<source>components/paginator.xhtml</source>
</tag>
- <tag>
- <tag-name>test1</tag-name>
- </tag>
+<!-- <tag>-->
+<!-- <tag-name>test1</tag-name>-->
+<!-- </tag>-->
</facelet-taglib>
\ No newline at end of file
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -1387,7 +1387,7 @@
return Status.OK_STATUS;
}
};
- visualRefreshJob.setRule(new GreedyRule(this));
+// visualRefreshJob.setRule(new GreedyRule(this));
visualRefreshJob.setPriority(Job.SHORT);
visualRefreshJob.schedule();
}
@@ -2664,7 +2664,7 @@
return Status.OK_STATUS;
}
};
- reinitJob.setRule(new GreedyRule(this));
+// reinitJob.setRule(new GreedyRule(this));
reinitJob.schedule();
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -414,7 +414,7 @@
* <code>create</code>
* @param pageContext Contains the information on edited page.
*/
- public void validate(VpePageContext pageContext, Node sourceNode,
+ public void validate(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument, VpeCreationData data) {
}
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-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -10,19 +10,26 @@
******************************************************************************/
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.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.common.el.core.ELReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReference;
import org.jboss.tools.vpe.VpePlugin;
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.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
/**
@@ -45,12 +52,16 @@
IPath pathToFile = CustomTLDReference
.getCustomElementPath(sourceNode, pageContext);
-
if (pathToFile != null) {
+ //add attributes to EL list
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(
pathToFile);
if (file != null && file.exists()) {
+
+
+
if (!pageContext.getVisualBuilder().isFileInIncludeStack(
file)) {
Document document = pageContext.getVisualBuilder()
@@ -65,7 +76,8 @@
if (document != null) {
VpeCreationData creationData = createInclude(
document, visualDocument);
- creationData.setData(file);
+ ResourceReference [] oldResourceReferences =
VpeCustomTemplate.addAttributesToELExcpressions(sourceNode, file);
+ creationData.setData(new TransferObject(oldResourceReferences, file));
pageContext.getVisualBuilder().pushIncludeStack(
new VpeIncludeInfo((Element) sourceNode,
file, document));
@@ -92,7 +104,46 @@
}
}
}
+
+ @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());
+ }
+
+ super.validate(pageContext, sourceNode, visualDocument, data);
+ }
+
/**
+ * Temparary add to attribute for custom el expressions
+ * @param pageContext Page Context
+ * @param sourceNode source Node
+ * @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
+ 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);
+ }
+ ELReferenceList.getInstance().setAllResources(processedFile,addedAttrToElExpressions.toArray(new
ResourceReference[0]));
+ return resourceReferences;
+ }
+ /**
* Looks for file to open on each editor, for open on click
* @param pageContext
* @param sourceElement
@@ -105,15 +156,60 @@
IFile file =null;
if(pathToFile!=null) {
- file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(
pathToFile);
}
//if we cann't find source file, then just open tld definition file
if(file==null || !file.exists()) {
pathToFile = CustomTLDReference.getCustomTLDPath(pageContext, sourceElement);
- file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(
+ file = ResourcesPlugin.getWorkspace().getRoot().getFile(
pathToFile);
}
return file;
}
+
+ @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) {
+ file = (IFile) data;
+ }
+ super.beforeRemove(pageContext, sourceNode, visualNode, file);
+ }
+
+ /**
+ * Object which used to passing argument throw template event processing,
+ * restore el expressions after processing custom template
+ *
+ * @author mareshkau
+ *
+ */
+ private 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-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -93,6 +93,7 @@
return creationData;
}
+ @Override
public void validate(VpePageContext pageContext, Node sourceNode, nsIDOMDocument
visualDocument, VpeCreationData data) {
if (data.getData() != null) {
VpeIncludeInfo includeInfo = pageContext.getVisualBuilder().popIncludeStack();
@@ -102,16 +103,13 @@
}
}
+ @Override
public void beforeRemove(VpePageContext pageContext, Node sourceNode, nsIDOMNode
visualNode, Object data) {
IFile file = (IFile)data;
if (file != null) {
pageContext.getEditPart().getController().getIncludeList().removeIncludeModel(file);
}
}
-
- public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument, nsIDOMElement visualNode, Object data, String name, String
value) {
- return true;
- }
protected VpeCreationData createInclude(Document sourceDocument, nsIDOMDocument
visualDocument) {
nsIDOMElement visualNewElement = visualDocument.createElement(HTML.TAG_DIV);
@@ -146,6 +144,7 @@
return new VpeCreationData(visualNewElement);
}
+ @Override
public void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object
data) {
if (sourceElement != null && fileNameExpression != null) {
VpeValue vpeValue;
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplateManager.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -385,7 +385,7 @@
String templateTaglibPrefix = getTemplateTaglibPrefix(sourceNodeUri);
if(templateTaglibPrefix != null) {
- return templateTaglibPrefix + ":" + sourceNode.getLocalName();
//$NON-NLS-1
+ return templateTaglibPrefix + ":" + sourceNode.getLocalName();
//$NON-NLS-1$
}
return null;
default :
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDParser.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDParser.java 2009-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDParser.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -42,7 +42,7 @@
*/
public static final String getNameSpace(IPath pathToFile){
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(pathToFile);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(pathToFile);
if(file!=null && file.exists()) {
Document document=null;
try {
@@ -71,7 +71,7 @@
* @return source value if exists or null otherwise
*/
public static final String getSourceValuetInTag(IPath pathToFile, String name){
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(pathToFile);
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(pathToFile);
Document document=null;
if(file!=null &&file.exists()) {
try{
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-04-24
14:45:21 UTC (rev 14902)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/custom/CustomTLDReference.java 2009-04-24
14:58:53 UTC (rev 14903)
@@ -15,6 +15,7 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.ui.IEditorInput;
@@ -59,7 +60,7 @@
if (customTLDData == null) {
return null;
}
- IPath pathToSourceFile = (IPath) customTLDData.getTldFilePath();
+ IPath pathToSourceFile = customTLDData.getTldFilePath();
pathToSourceFile = pathToSourceFile.removeLastSegments(1);
String sourceParamValue = CustomTLDParser.getSourceValuetInTag(
customTLDData.getTldFilePath(), sourceNode.getLocalName());
@@ -129,8 +130,13 @@
for (String faceletLib : libs) {
IPath rootPath = VpeStyleUtil
.getRootPath(iEditorInput);
+ IPath projectPath =
((IFileEditorInput)iEditorInput).getFile().getProject().getLocation();
+
IPath pathToCustonTld = new Path(faceletLib);
+
pathToCustonTld = rootPath.append(pathToCustonTld);
+ pathToCustonTld = pathToCustonTld.makeRelativeTo(projectPath);
+ pathToCustonTld =
((IFileEditorInput)iEditorInput).getFile().getProject().getFile(pathToCustonTld).getFullPath();
CustomTLDData customTLDData = new CustomTLDData(
pathToCustonTld, CustomTLDParser
.getNameSpace(pathToCustonTld));