Author: dmaliarevich
Date: 2010-07-26 08:31:23 -0400 (Mon, 26 Jul 2010)
New Revision: 23723
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/dialog/ExternalizeStringsWizardPage.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
Log:
https://jira.jboss.org/browse/JBIDE-6287 , initialization of the page with facelet's
<ui:composition> tag has been corrected.
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 2010-07-26
12:06:20 UTC (rev 23722)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2010-07-26
12:31:23 UTC (rev 23723)
@@ -223,14 +223,15 @@
refreshExternalLinks();
-// if (isFacelet()) {
/*
*
https://jira.jboss.org/jira/browse/JBIDE-4398
* Additional check for facelet's taglibs should be added
* to distinguish it from custom tags and pages without facelets support.
*/
Element root = FaceletUtil.findComponentElement(sourceDocument.getDocumentElement());
- if ((root != null) && (isFacelet(root))){
+ if ((root != null)
+ && (FaceletUtil.isFacelet(root,
+ XmlUtil.getTaglibsForNode(root, pageContext)))) {
addNode(root, null, getContentArea());
} else {
addChildren(null, sourceDocument, getContentArea());
@@ -1947,48 +1948,6 @@
}
/**
- * Check this file is facelet
- *
- * @return this if file is facelet, otherwize false
- */
- private boolean isFacelet(Node sourceNode) {
- boolean isFacelet = false;
- String sourcePrefix = sourceNode.getPrefix();
- List<TaglibData> taglibs = XmlUtil.getTaglibsForNode(sourceNode, pageContext);
- TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourcePrefix, taglibs);
- if (null != sourceNodeTaglib) {
- String sourceNodeUri = sourceNodeTaglib.getUri();
- if (VisualDomUtil.FACELETS_URI.equalsIgnoreCase(sourceNodeUri)) {
- isFacelet = true;
- }
- }
-// IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
-// if (iEditorInput instanceof IFileEditorInput) {
-// IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
-//
-// IFile iFile = iFileEditorInput.getFile();
-//
-// IProject project = iFile.getProject();
-// IModelNature nature = EclipseResourceUtil.getModelNature(project);
-// if (nature != null) {
-// XModel model = nature.getModel();
-// XModelObject webXML = WebAppHelper.getWebApp(model);
-// XModelObject param = WebAppHelper.findWebAppContextParam(
-// webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
-// if (param != null) {
-// String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
-//
-// if (value.length() != 0 && iFile.getName().endsWith(value)) {
-// isFacelet = true;
-// }
-// }
-// }
-// }
-
- return isFacelet;
- }
-
- /**
* @return the xulRunnerEditor
*/
public XulRunnerEditor getXulRunnerEditor() {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-07-26
12:06:20 UTC (rev 23722)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/dialog/ExternalizeStringsWizardPage.java 2010-07-26
12:31:23 UTC (rev 23723)
@@ -54,6 +54,7 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
@@ -65,12 +66,18 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.ui.ModelUIImages;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.jsp.editor.IVisualContext;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
+import org.jboss.tools.jst.jsp.jspeditor.SourceEditorPageContext;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.list.WebPromptingProvider;
+import org.jboss.tools.jst.web.tld.TaglibData;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.bundle.BundleMap;
import org.jboss.tools.vpe.editor.bundle.BundleMap.BundleEntry;
+import org.jboss.tools.vpe.editor.template.VpeCreatorUtil;
import org.jboss.tools.vpe.editor.util.Constants;
+import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
@@ -729,16 +736,49 @@
}
}
}
- /*
- * Add bundles from <f:loadBundle> tags
- */
ISourceEditingTextTools sourceEditingTextTools =
(ISourceEditingTextTools) editor
- .getAdapter(ISourceEditingTextTools.class);
+ .getAdapter(ISourceEditingTextTools.class);
IDOMSourceEditingTextTools domSourceEditingTextTools =
(IDOMSourceEditingTextTools) sourceEditingTextTools;
- Document doc = domSourceEditingTextTools.getDOMDocument();
- NodeList list = doc.getElementsByTagName("f:loadBundle"); //$NON-NLS-1$
+ Document documentWithBundles = domSourceEditingTextTools.getDOMDocument();
+
+ /*
+ * When facelets are used -- get bundles from the template file
+ */
+ if (editor instanceof JSPTextEditor) {
+ IVisualContext context = ((JSPTextEditor) editor).getPageContext();
+ List<TaglibData> taglibs = null;
+ if (context instanceof SourceEditorPageContext) {
+ SourceEditorPageContext sourcePageContext = (SourceEditorPageContext) context;
+ taglibs = sourcePageContext.getTagLibs();
+ }
+ if (null == taglibs) {
+ VpePlugin.getDefault().logError(
+ VpeUIMessages.CANNOT_LOAD_TAGLIBS_FROM_PAGE_CONTEXT);
+ } else {
+ Element root =
FaceletUtil.findComponentElement(documentWithBundles.getDocumentElement());
+ if ((root != null) && FaceletUtil.isFacelet(root, taglibs)
+ && root.hasAttribute("template")) {
+ String filePath= root.getAttributeNode("template").getNodeValue();
+ if (((JSPTextEditor) editor).getEditorInput() instanceof FileEditorInput) {
+ FileEditorInput fei = (FileEditorInput) ((JSPTextEditor) editor).getEditorInput();
+ IFile templateFile = (IFile)
fei.getFile().getProject().getFolder("WebContent").findMember(filePath);
+ Document document = VpeCreatorUtil.getDocumentForRead(templateFile);
+ if (null != document) {
+ /*
+ * Change the document where to look bundles
+ */
+ documentWithBundles = document;
+ }
+ }
+ }
+ }
+ }
+ /*
+ * Add bundles from <f:loadBundle> tags on the current page
+ */
+ NodeList list = documentWithBundles.getElementsByTagName("f:loadBundle");
//$NON-NLS-1$
for (int i = 0; i < list.getLength(); i++) {
Element node = (Element) list.item(i);
uri = node.getAttribute("basename"); //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java 2010-07-26
12:06:20 UTC (rev 23722)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java 2010-07-26
12:31:23 UTC (rev 23723)
@@ -12,7 +12,11 @@
package org.jboss.tools.vpe.editor.util;
import java.util.HashSet;
+import java.util.List;
+import org.jboss.tools.jst.web.kb.PageContextFactory;
+import org.jboss.tools.jst.web.tld.TaglibData;
+import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -81,4 +85,48 @@
}
+
+ /**
+ * Checks if this node is facelet tag
+ *
+ * @param sourceNode the node
+ * @param taglibs specified taglibs
+ * @return <code>true</code> if this node is facelet tag
+ */
+ public static boolean isFacelet(Node sourceNode, List<TaglibData> taglibs) {
+ boolean isFacelet = false;
+ String sourcePrefix = sourceNode.getPrefix();
+ TaglibData sourceNodeTaglib = XmlUtil.getTaglibForPrefix(sourcePrefix, taglibs);
+ if (null != sourceNodeTaglib) {
+ String sourceNodeUri = sourceNodeTaglib.getUri();
+ if (VisualDomUtil.FACELETS_URI.equalsIgnoreCase(sourceNodeUri)) {
+ isFacelet = true;
+ }
+ }
+// IEditorInput iEditorInput = pageContext.getEditPart().getEditorInput();
+// if (iEditorInput instanceof IFileEditorInput) {
+// IFileEditorInput iFileEditorInput = (IFileEditorInput) iEditorInput;
+//
+// IFile iFile = iFileEditorInput.getFile();
+//
+// IProject project = iFile.getProject();
+// IModelNature nature = EclipseResourceUtil.getModelNature(project);
+// if (nature != null) {
+// XModel model = nature.getModel();
+// XModelObject webXML = WebAppHelper.getWebApp(model);
+// XModelObject param = WebAppHelper.findWebAppContextParam(
+// webXML, "javax.faces.DEFAULT_SUFFIX"); //$NON-NLS-1$
+// if (param != null) {
+// String value = param.getAttributeValue("param-value"); //$NON-NLS-1$
+//
+// if (value.length() != 0 && iFile.getName().endsWith(value)) {
+// isFacelet = true;
+// }
+// }
+// }
+// }
+
+ return isFacelet;
+ }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2010-07-26
12:06:20 UTC (rev 23722)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2010-07-26
12:31:23 UTC (rev 23723)
@@ -67,10 +67,12 @@
public static final String TAG_H6 = "h6"; //$NON-NLS-1$
public static final String TAG_FORM = "form"; //$NON-NLS-1$
- /**Use this class if you want to wrap a text node in a span that
- * must not affect visual representation of the text node.
- * <p/>
- * See also EditorOverride.css .*/
+ /*
+ * Use this class if you want to wrap a text node in a span that
+ * must not affect visual representation of the text node.
+ *
+ * See also EditorOverride.css .
+ */
public static final String CLASS_VPE_TEXT = "vpe-text"; //$NON-NLS-1$
public static final String ATTR_ID = "id"; //$NON-NLS-1$
@@ -111,10 +113,12 @@
public static final String ATTR_BACKGROUND = "background"; //$NON-NLS-1$
public static final String ATTR_BGCOLOR = "bgcolor"; //$NON-NLS-1$
- /**Use this constant if you have to span a column to entire row.*/
- /* While in HTML 4.01 standard "colspan='0'" should be used for this
purpose,
+ /*
+ * Use this constant if you have to span a column to entire row.
+ * While in HTML 4.01 standard "colspan='0'" should be used for this
purpose,
* it will not work with documents without DOCTYPE. It is the reason
- * why the value '100' is used.*/
+ * why the value '100' is used.
+ */
public static final String VALUE_COLSPAN_ALL = "100"; //$NON-NLS-1$
public static final String VALUE_ALIGN_TOP = "top"; //$NON-NLS-1$