Author: mareshkau
Date: 2009-05-25 12:07:41 -0400 (Mon, 25 May 2009)
New Revision: 15492
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/inputName.xhtml
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4373Test.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/META-INF/MANIFEST.MF
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
trunk/vpe/plugins/org.jboss.tools.vpe.html/META-INF/MANIFEST.MF
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
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/VpeSourceDomBuilder.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.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/VpeDefineContainerTemplate.java
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.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/VpeTemplate.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4373
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF 2009-05-25
12:17:38 UTC (rev 15491)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.ajax4jsf/META-INF/MANIFEST.MF 2009-05-25
16:07:41 UTC (rev 15492)
@@ -11,6 +11,7 @@
org.jboss.tools.jst.jsp,
org.mozilla.xpcom,
org.jboss.tools.jsf.vpe.richfaces;bundle-version="2.1.0",
- org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0"
+ org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0",
+ org.eclipse.jface.text;bundle-version="3.5.0"
Eclipse-LazyStart: true
Bundle-Vendor: %Bundle-Vendor.0
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/META-INF/MANIFEST.MF 2009-05-25
12:17:38 UTC (rev 15491)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/META-INF/MANIFEST.MF 2009-05-25
16:07:41 UTC (rev 15492)
@@ -13,7 +13,8 @@
org.jboss.tools.vpe,
org.eclipse.core.resources,
org.jboss.tools.jst.jsp,
- org.mozilla.xpcom
+ org.mozilla.xpcom,
+ org.eclipse.jface.text;bundle-version="3.5.0"
Export-Package: org.jboss.tools.jsf.vpe.facelets,
org.jboss.tools.jsf.vpe.facelets.template
Bundle-Version: 2.1.0
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeCompositionTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -10,14 +10,18 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.facelets.template;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.jsf.vpe.facelets.template.util.Facelets;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -37,12 +41,12 @@
protected VpeCreationData createStub(String fileName, Node sourceElement, nsIDOMDocument
visualDocument) {
nsIDOMElement container = visualDocument.createElement(HTML.TAG_DIV);
- container.setAttribute("style", "border: 1px dashed #2A7F00");
+ container.setAttribute("style", "border: 1px dashed #2A7F00");
//$NON-NLS-1$ //$NON-NLS-2$
VpeVisualDomBuilder.markIncludeElement(container);
nsIDOMElement title = visualDocument.createElement(HTML.TAG_DIV);
nsIDOMElement tag = visualDocument.createElement(HTML.TAG_SPAN);
- tag.setAttribute("class", "__any__tag__caption");
+ tag.setAttribute("class", "__any__tag__caption"); //$NON-NLS-1$
//$NON-NLS-2$
tag.appendChild(visualDocument.createTextNode(sourceElement.getNodeName()));
title.appendChild(tag);
if (fileName != null) {
@@ -52,8 +56,16 @@
return new VpeCreationData(container);
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
@Override
- public boolean recreateAtAttrChange(VpePageContext pageContext, Element sourceElement,
nsIDOMDocument visualDocument,nsIDOMElement visualNode, Object data, String name, String
value) {
- return true;
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+ Element sourceElement = (Element) sourceNode;
+ Node paramAttr = sourceElement.getAttributeNode(Facelets.ATTR_TEMPLATE);
+ return new Region(NodesManagingUtil.getStartOffsetNode(paramAttr),0);
}
+
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.facelets/src/org/jboss/tools/jsf/vpe/facelets/template/VpeDecorateTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -10,10 +10,14 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.facelets.template;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.jsf.vpe.facelets.template.util.Facelets;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -24,4 +28,15 @@
String fileName = ((Element)sourceNode).getAttribute(Facelets.ATTR_TEMPLATE);
return createTemplate(fileName, pageContext, sourceNode, visualDocument);
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+ Element sourceElement = (Element) sourceNode;
+ Node paramAttr = sourceElement.getAttributeNode(Facelets.ATTR_TEMPLATE);
+ return new Region(NodesManagingUtil.getStartOffsetNode(paramAttr),0);
+ }
}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.jstl/src/org/jboss/tools/jsf/vpe/jstl/template/JstlImportTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -10,11 +10,15 @@
******************************************************************************/
package org.jboss.tools.jsf.vpe.jstl.template;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.jsf.vpe.jstl.template.util.Jstl;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -26,4 +30,14 @@
return createTemplate(fileName, pageContext, sourceNode, visualDocument);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+ Element sourceElement = (Element) sourceNode;
+ Node paramAttr = sourceElement.getAttributeNode(Jstl.ATTR_URL);
+ return new Region(NodesManagingUtil.getStartOffsetNode(paramAttr),0);
+ }
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF 2009-05-25
12:17:38 UTC (rev 15491)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.myfaces/META-INF/MANIFEST.MF 2009-05-25
16:07:41 UTC (rev 15492)
@@ -10,7 +10,8 @@
org.jboss.tools.common,
org.jboss.tools.vpe,
org.mozilla.xpcom,
- org.jboss.tools.jst.jsp
+ org.jboss.tools.jst.jsp,
+ org.eclipse.jface.text;bundle-version="3.5.0"
Eclipse-LazyStart: true
Export-Package: org.jboss.tools.jsf.vpe.myfaces,
org.jboss.tools.jsf.vpe.myfaces.template
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/META-INF/MANIFEST.MF 2009-05-25
12:17:38 UTC (rev 15491)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/META-INF/MANIFEST.MF 2009-05-25
16:07:41 UTC (rev 15492)
@@ -14,7 +14,8 @@
org.eclipse.ui.workbench.texteditor,
org.eclipse.ui.ide,
org.mozilla.xpcom,
- org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0"
+ org.jboss.tools.jsf.vpe.jsf;bundle-version="2.1.0",
+ org.eclipse.jface.text;bundle-version="3.5.0"
Bundle-Vendor: %Bundle-Vendor.0
Eclipse-LazyStart: true
Bundle-ClassPath: lib/antlr.jar,
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.seam/src/org/jboss/tools/jsf/vpe/seam/template/SeamDecorateTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -1,13 +1,17 @@
package org.jboss.tools.jsf.vpe.seam.template;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.jsf.vpe.jsf.template.util.ComponentUtil;
import org.jboss.tools.jsf.vpe.seam.template.util.Seam;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
import org.jboss.tools.vpe.editor.template.VpeDefineContainerTemplate;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
+import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -42,5 +46,14 @@
return creationData;
}
-
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+ Element sourceElement = (Element) sourceNode;
+ Node paramAttr = sourceElement.getAttributeNode(Seam.ATTR_TEMPLATE);
+ return new Region(NodesManagingUtil.getStartOffsetNode(paramAttr),0);
+ }
}
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/inputName.xhtml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/inputName.xhtml
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/resources/customFaceletsTestProject/WebContent/pages/inputName.xhtml 2009-05-25
16:07:41 UTC (rev 15492)
@@ -0,0 +1,13 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:c="http://java.sun.com/jstl/core">
+
+ <f:loadBundle basename="resources" var="msg" />
+
+ <ui:composition template="/templates/common.xhtml">
+
+ </ui:composition>
+</html>
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-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/JsfAllTests.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -56,6 +56,7 @@
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3650Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE3734Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4037Test;
+import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE4373Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE675Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE788Test;
import org.jboss.tools.jsf.vpe.jsf.test.jbide.JBIDE924Test;
@@ -138,6 +139,7 @@
suite.addTestSuite(JBIDE3632Test.class);
suite.addTestSuite(JBIDE3650Test.class);
suite.addTestSuite(JBIDE3197Test.class);
+ suite.addTestSuite(JBIDE4373Test.class);
// $JUnit-END$
// added by Max Areshkau
Added:
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4373Test.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4373Test.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.vpe.jsf.test/src/org/jboss/tools/jsf/vpe/jsf/test/jbide/JBIDE4373Test.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.common.model.filesystems.impl.SimpleFileImpl;
+import org.jboss.tools.common.model.impl.CustomizedObjectImpl;
+import org.jboss.tools.jsf.vpe.jsf.test.JsfAllTests;
+import org.jboss.tools.vpe.editor.VpeController;
+import org.jboss.tools.vpe.editor.util.SelectionUtil;
+import org.jboss.tools.vpe.ui.test.TestUtil;
+import org.jboss.tools.vpe.ui.test.VpeTest;
+import org.mozilla.interfaces.nsIDOMNode;
+import org.w3c.dom.Node;
+
+
+/**
+ *
+ * Junit test for JBIDE-4373
+ * @author mareshkau
+ *
+ */
+public class JBIDE4373Test extends VpeTest{
+
+ public JBIDE4373Test(String name) {
+ super(name);
+ }
+
+ /**
+ * OpenOn test for Custom elements
+ */
+
+ public void testCorrectCustomElements() throws CoreException {
+
+ VpeController vpeController = openInVpe(JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT,
"correctCustomTags.xhtml"); //$NON-NLS-1$
+ int position =
TestUtil.getLinePositionOffcet(vpeController.getSourceEditor().getTextViewer(), 13, 8);
+
+ Node sourceNode =
SelectionUtil.getNodeBySourcePosition(vpeController.getSourceEditor(), position);
+ assertEquals("Name of node should be ma:paginator", "ma:paginator",
sourceNode.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
+ nsIDOMNode domNode = vpeController.getDomMapping().getNearVisualNode(sourceNode);
+ vpeController.getSourceBuilder().openOn(domNode);
+ IEditorPart activeEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ assertEquals("facelets.taglib.xml file should be
opened","facelets.taglib.xml", activeEditor.getEditorInput().getName());
//$NON-NLS-1$//$NON-NLS-2$
+ StructuredSelection selection = (StructuredSelection)
activeEditor.getEditorSite().getSelectionProvider().getSelection();
+ CustomizedObjectImpl customizedObjectImpl = (CustomizedObjectImpl)
selection.getFirstElement();
+ //cheak if selection on right line, how?
+ assertEquals("Children lenght should be
","FileSystems/WEB-ROOT/tags/facelets.taglib.xml/paginator",customizedObjectImpl.getLongPath());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ /**
+ * test openOn for undefined template
+ */
+ public void testIncorrectCustomElements() throws CoreException {
+ VpeController vpeController = openInVpe(JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT,
"incorrectCustomTags.xhtml"); //$NON-NLS-1$
+ int position =
TestUtil.getLinePositionOffcet(vpeController.getSourceEditor().getTextViewer(), 9, 6);
+
+ Node sourceNode =
SelectionUtil.getNodeBySourcePosition(vpeController.getSourceEditor(), position);
+ assertEquals("Name of node should be", "ma:test",
sourceNode.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
+ nsIDOMNode domNode = vpeController.getDomMapping().getNearVisualNode(sourceNode);
+ vpeController.getSourceBuilder().openOn(domNode);
+ IEditorPart activeEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ assertEquals("facelets.taglib.xml file should be
opened","facelets.taglib.xml", activeEditor.getEditorInput().getName());
//$NON-NLS-1$//$NON-NLS-2$
+ StructuredSelection selection = (StructuredSelection)
activeEditor.getEditorSite().getSelectionProvider().getSelection();
+ SimpleFileImpl customizedObjectImpl = (SimpleFileImpl) selection.getFirstElement();
+ //cheak if selection on right line, how?
+ assertEquals("Children lenght should
be","FileSystems/WEB-ROOT/tags/facelets.taglib.xml",customizedObjectImpl.getLongPath());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+ /**
+ *
+ * @throws CoreException
+ */
+ public void testOpenOnforFacelets() throws CoreException {
+ VpeController vpeController = openInVpe(JsfAllTests.IMPORT_CUSTOM_FACELETS_PROJECT,
"inputName.xhtml"); //$NON-NLS-1$
+ int position =
TestUtil.getLinePositionOffcet(vpeController.getSourceEditor().getTextViewer(), 10, 38);
+ Node sourceNode =
SelectionUtil.getNodeBySourcePosition(vpeController.getSourceEditor(), position);
+ nsIDOMNode domNode = vpeController.getDomMapping().getNearVisualNode(sourceNode);
+ vpeController.getSourceBuilder().openOn(domNode);
+ IEditorPart activeEditor =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
+ assertEquals("facelets.taglib.xml file should be
opened","common.xhtml", activeEditor.getEditorInput().getName());
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/jspeditor/JSPTextEditor.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -24,6 +24,7 @@
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.formatter.IContentFormatter;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
@@ -164,6 +165,7 @@
super.setSourceViewerConfiguration(new JSPTextViewerConfiguration());
}
+ @Override
protected void setSourceViewerConfiguration(SourceViewerConfiguration config) {
if (config instanceof StructuredTextViewerConfigurationJSP) {
if (!(config instanceof JSPTextViewerConfiguration)) {
@@ -190,7 +192,6 @@
// Added By Max Areshkau
// Fix for JBIDE-788
public IVisualContext getPageContext() {
-
if (pageContext == null) {
pageContext = new SourceEditorPageContext(parentEditor);
}
@@ -1269,5 +1270,13 @@
}
return false;
}
+ /**
+ *
+ * @return HyperLinkDetectors for sourceRegion
+ */
+ public IHyperlinkDetector[] getHyperlinkDetectors() {
+
+ return getSourceViewerConfiguration().getHyperlinkDetectors(getSourceViewer());
+ }
}
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-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -1132,9 +1132,12 @@
}
try {
nsIDOMNode visualNode = VisualDomUtil.getTargetNode(mouseEvent);
+
if (visualNode != null) {
+
if (!sourceBuilder.openBundleEditors(visualNode)) {
- sourceBuilder.openIncludeEditor(visualNode);
+ sourceBuilder.openOn(visualNode);
+// sourceBuilder.openIncludeEditor(visualNode);
}
if (VpeDebug.PRINT_VISUAL_MOUSE_EVENT) {
System.out.println("<<< mouseDblClick visualNode: " +
visualNode.getNodeName() + //$NON-NLS-1$
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeSourceDomBuilder.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -14,8 +14,11 @@
import java.util.List;
import java.util.Set;
+import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Point;
@@ -29,7 +32,8 @@
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
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.common.text.ext.hyperlink.AbstractHyperlink;
+import org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.mapping.VpeElementMapping;
@@ -250,6 +254,39 @@
}
}
+ /**
+ *
+ *This method calls when openOn event occures in
+ *visual part of VPE
+ *
+ * @param visualNode - node on which event has occured
+ *
+ * @author mareshkau
+ */
+
+ public void openOn(nsIDOMNode visualNode) {
+
+ VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
+ this.domMapping, visualNode);
+ if (nodeMapping != null
+ && nodeMapping instanceof VpeElementMapping) {
+
+ VpeElementMapping elementMapping = (VpeElementMapping) nodeMapping;
+ VpeTemplate template = elementMapping.getTemplate();
+ IRegion regionForOpenOn = template.getSourceRegionForOpenOn(this.pageContext,
elementMapping.getSourceNode(), visualNode);
+ IHyperlinkDetector [] hyperlinkDetectors =
((JSPTextEditor)this.sourceEditor).getHyperlinkDetectors();
+ IHyperlink [] hyperLinks = null;
+ for (IHyperlinkDetector iHyperlinkDetector : hyperlinkDetectors) {
+ hyperLinks = iHyperlinkDetector.detectHyperlinks(this.sourceEditor.getTextViewer(),
regionForOpenOn, true);
+ if(hyperLinks!=null && hyperLinks.length>0 && hyperLinks[0]
instanceof AbstractHyperlink) {
+ AbstractHyperlink abstractHyperlink = (AbstractHyperlink) hyperLinks[0];
+ abstractHyperlink.open();
+ return;
+ }
+ }
+ }
+ }
+
boolean openBundleEditors(nsIDOMNode visualNode) {
VpeNodeMapping nodeMapping = NodesManagingUtil.getNodeMapping(
@@ -272,17 +309,17 @@
return false;
}
- boolean openIncludeEditor(nsIDOMNode visualNode) {
- Node sourceNode = domMapping.getNearSourceNode(visualNode);
- if (sourceNode != null && sourceNode.getNodeType() == Node.ELEMENT_NODE) {
- VpeElementMapping elementMapping =
(VpeElementMapping)domMapping.getNodeMapping(sourceNode);
- if (elementMapping != null) {
- VpeTemplate template = elementMapping.getTemplate();
- template.openIncludeEditor(pageContext, (Element)sourceNode,
elementMapping.getData());
- }
- }
- return false;
- }
+// boolean openIncludeEditor(nsIDOMNode visualNode) {
+// Node sourceNode = domMapping.getNearSourceNode(visualNode);
+// if (sourceNode != null && sourceNode.getNodeType() == Node.ELEMENT_NODE) {
+// VpeElementMapping elementMapping =
(VpeElementMapping)domMapping.getNodeMapping(sourceNode);
+// if (elementMapping != null) {
+// VpeTemplate template = elementMapping.getTemplate();
+// template.openIncludeEditor(pageContext, (Element)sourceNode,
elementMapping.getData());
+// }
+// }
+// return false;
+// }
boolean isEmptyDocument() {
if (sourceDocument == null) return true;
@@ -392,7 +429,7 @@
return null;
}
- Point getSelectionRange() {
+ public Point getSelectionRange() {
return sourceEditor.getTextViewer().getSelectedRange();
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mapping/VpeElementMapping.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -65,14 +65,6 @@
return template;
}
-// public Map getXmlnsMap() {
-// return xmlnsMap;
-// }
-//
-// public void setXmlnsMap(Map xmlnsMap) {
-// this.xmlnsMap = xmlnsMap;
-// }
-
/**
* @deprecated - You must use elementData. If VpeElementData has not
* necessary functionality you must extend its
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-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeAbstractTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -1226,16 +1226,16 @@
Element sourceElement, Object data) {
}
- /**
- * Opens editor of source file for include-element.
- *
- * @param sourceElement The current element of the source tree.
- * @param data The arbitrary data, built by a method <code>create</code>
- * @param pageContext Contains the information on edited page.
- */
- public void openIncludeEditor(VpePageContext pageContext,
- Element sourceElement, Object data) {
- }
+// /**
+// * Opens editor of source file for include-element.
+// *
+// * @param sourceElement The current element of the source tree.
+// * @param data The arbitrary data, built by a method <code>create</code>
+// * @param pageContext Contains the information on edited page.
+// */
+// public void openIncludeEditor(VpePageContext pageContext,
+// Element sourceElement, Object data) {
+// }
/**
* The unfilled element of an source tree can be mapped in the visiblis
@@ -1457,5 +1457,19 @@
public void setInvisible(boolean invisible) {
this.invisible = invisible;
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeTemplate#getSourceRegionForOpenOn(org.mozilla.interfaces.nsIDOMNode)
+ *
+ */
+ /**
+ * @author mareshkau
+ */
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext, Node sourceNode
,nsIDOMNode domNode) {
+ int offset = NodesManagingUtil.getStartOffsetNode(sourceNode);
+ //calculate openOnPosition,prefixLengght+>+":"
+ offset+=sourceNode.getPrefix().length()+1+1;
+ return new Region(offset, 0);
+ }
}
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-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeCustomTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -12,18 +12,18 @@
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.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.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.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Attr;
@@ -90,28 +90,10 @@
visualDocument);
creationData.setData(null);
return creationData;
- }
+ }
@Override
- public void openIncludeEditor(VpePageContext pageContext,
- Element sourceElement, Object data) {
-
- IFile file = getFileForOpenOn(pageContext, sourceElement);
-
- if(file!=null && file.exists()) {
- IWorkbenchPage workbenchPage = VpePlugin.getDefault()
- .getWorkbench().getActiveWorkbenchWindow().getActivePage();
- try {
- IDE.openEditor(workbenchPage, file,true);
- } catch (PartInitException e) {
- VpePlugin.reportProblem(e);
- }
- }
- }
-
- @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(
@@ -151,32 +133,6 @@
addedAttrToElExpressions.toArray(new ResourceReference[0]));
return resourceReferences;
}
- /**
- * Looks for file to open on each editor, for open on click
- * @param pageContext
- * @param sourceElement
- * @return file, if file has been founded or null otherwise
- */
- private static IFile getFileForOpenOn(VpePageContext pageContext,
- Element sourceElement) {
- IPath pathToFile = CustomTLDReference
- .getCustomElementPath(sourceElement, pageContext);
-
- IFile file =null;
-
- if(pathToFile!=null) {
- 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().getFile(
- pathToFile);
- }
- return file;
- }
@Override
public void beforeRemove(VpePageContext pageContext, Node sourceNode,
@@ -189,6 +145,21 @@
}
super.beforeRemove(pageContext, sourceNode, visualNode, file);
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeTemplate#getSourceRegionForOpenOn(org.mozilla.interfaces.nsIDOMNode)
+ *
+ */
+ /**
+ * @author mareshkau
+ */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext, Node sourceNode
,nsIDOMNode domNode) {
+ int offset = NodesManagingUtil.getStartOffsetNode(sourceNode);
+ //calculate openOnPosition,prefixLengght+>+":"
+ offset+=sourceNode.getPrefix().length()+1+1;
+ return new Region(offset, 0);
+ }
/**
* Object which used to passing argument throw template event processing,
@@ -222,5 +193,5 @@
public IFile getCustomFile() {
return this.customFile;
}
- };
+ }
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeDefineContainerTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -335,15 +335,15 @@
}
- @Override
- public void openIncludeEditor(VpePageContext pageContext,
- Element sourceElement, Object data) {
+// @Override
+// public void openIncludeEditor(VpePageContext pageContext,
+// Element sourceElement, Object data) {
+//
+// if (data instanceof TemplateFileInfo) {
+// FileUtil.openEditor(((TemplateFileInfo) data).getTemplateFile());
+// }
+// }
- if (data instanceof TemplateFileInfo) {
- FileUtil.openEditor(((TemplateFileInfo) data).getTemplateFile());
- }
- }
-
protected VpeCreationData createStub(String fileName,
Node sourceElement, nsIDOMDocument visualDocument) {
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeHtmlTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -13,6 +13,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
@@ -24,10 +27,12 @@
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionException;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.mozilla.interfaces.nsIDOMText;
+import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -370,36 +375,11 @@
if (model != null) model.releaseFromRead();
}
}
-
-
/**
*
* Deprecated
*/
@Override
- public void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object
data) {
- openIncludeEditor(pageContext, sourceElement, (Map<?,?>) data);
- }
-
- private void openIncludeEditor(VpePageContext pageContext, Element sourceElement,
Map<?,?> visualNodeMap) {
- if (sourceElement != null) {
- String file = null;
- if ("jsp:directive.include".equals(sourceElement.getNodeName())) {
- file = sourceElement.getAttribute("file");
- } else if ("jsp:include".equals(sourceElement.getNodeName())) {
- file = sourceElement.getAttribute("page");
- }
- if (file != null) {
- pageContext.openIncludeFile(file);
- }
- }
- }
-
- /**
- *
- * Deprecated
- */
- @Override
public void setSourceAttributeValue(VpePageContext pageContext, Element sourceElement,
Object data) {
setSourceAttributeValue(pageContext, sourceElement, (Map<?,?>)data);
}
@@ -595,4 +575,28 @@
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
+ /**
+ * @author mareshkau
+ */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+ if(sourceNode != null && sourceNode instanceof Element) {
+ Attr file = null;
+ if ("jsp:directive.include".equals(sourceNode.getNodeName())) {
//$NON-NLS-1$
+ file = ((Element)sourceNode).getAttributeNode("file"); //$NON-NLS-1$
+ } else if ("jsp:include".equals(sourceNode.getNodeName())) {
//$NON-NLS-1$
+ file = ((Element)sourceNode).getAttributeNode("page"); //$NON-NLS-1$
+ }
+
+ if(file!=null) {
+ return new Region(NodesManagingUtil.getStartOffsetNode(file),0);
+ }
+ }
+ return null;
+ }
}
\ No newline at end of file
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-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeIncludeTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -11,10 +11,13 @@
package org.jboss.tools.vpe.editor.template;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
import org.jboss.tools.vpe.VpePlugin;
import org.jboss.tools.vpe.editor.VpeIncludeInfo;
import org.jboss.tools.vpe.editor.VpeVisualDomBuilder;
import org.jboss.tools.vpe.editor.context.VpePageContext;
+import org.jboss.tools.vpe.editor.template.expression.VpeAttributeOperand;
import org.jboss.tools.vpe.editor.template.expression.VpeExpression;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilder;
import org.jboss.tools.vpe.editor.template.expression.VpeExpressionBuilderException;
@@ -23,6 +26,7 @@
import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.editor.util.FileUtil;
import org.jboss.tools.vpe.editor.util.HTML;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
@@ -144,22 +148,40 @@
return new VpeCreationData(visualNewElement);
}
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.jboss.tools.vpe.editor.context.VpePageContext,
org.w3c.dom.Node, org.mozilla.interfaces.nsIDOMNode)
+ */
+ /**
+ * @author mareshkau
+ */
@Override
- public void openIncludeEditor(VpePageContext pageContext, Element sourceElement, Object
data) {
- if (sourceElement != null && fileNameExpression != null) {
- VpeValue vpeValue;
- try {
- vpeValue = fileNameExpression.exec(pageContext, sourceElement);
- if (vpeValue != null && vpeValue.stringValue().length() > 0) {
- pageContext.openIncludeFile(vpeValue.stringValue());
- }
- } catch (VpeExpressionException e) {
-
- VpePlugin.reportProblem(e);
- }
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext,
+ Node sourceNode, nsIDOMNode domNode) {
+
+ if (sourceNode != null && this.fileNameExpression != null &&
this.fileNameExpression instanceof VpeAttributeOperand) {
+ Element sourceElement = (Element) sourceNode;
+ Node paramAttr =
sourceElement.getAttributeNode(((VpeAttributeOperand)this.fileNameExpression).getAttributeName());
+ return new Region(NodesManagingUtil.getStartOffsetNode(paramAttr),0);
}
+ return null;
}
+// @Override
+// public void openIncludeEditor(VpePageContext pageContext, Element sourceElement,
Object data) {
+// if (sourceElement != null && fileNameExpression != null) {
+// VpeValue vpeValue;
+// try {
+// vpeValue = fileNameExpression.exec(pageContext, sourceElement);
+// if (vpeValue != null && vpeValue.stringValue().length() > 0) {
+// pageContext.openIncludeFile(vpeValue.stringValue());
+// }
+// } catch (VpeExpressionException e) {
+//
+// VpePlugin.reportProblem(e);
+// }
+// }
+// }
+
}
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/template/VpeTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.vpe.editor.template;
+import org.eclipse.jface.text.IRegion;
import org.jboss.tools.jst.jsp.editor.ITextFormatter;
import org.jboss.tools.vpe.editor.VpeSourceInnerDragInfo;
import org.jboss.tools.vpe.editor.VpeSourceInnerDropInfo;
@@ -360,18 +361,18 @@
void openBundleEditors(VpePageContext pageContext, Element sourceElement,
Object data);
- /**
- * Opens editor of source file for include-element
- *
- * @param pageContext
- * Contains the information on edited page.
- * @param sourceElement
- * The current element of the source tree.
- * @param data
- * The arbitrary data, built by a method <code>create</code>
- */
- void openIncludeEditor(VpePageContext pageContext, Element sourceElement,
- Object data);
+// /**
+// * Opens editor of source file for include-element
+// *
+// * @param pageContext
+// * Contains the information on edited page.
+// * @param sourceElement
+// * The current element of the source tree.
+// * @param data
+// * The arbitrary data, built by a method <code>create</code>
+// */
+// void openIncludeEditor(VpePageContext pageContext, Element sourceElement,
+// Object data);
/**
* @deprecated
@@ -487,4 +488,13 @@
public boolean isInvisible();
+ /**
+ * Calculates and returns sourceRegion, on which we should
+ * make openOn action
+ * @param sourceNode - source node from element mapping
+ * @param domNode
+ * @return sourceRegion on which we should make openOn action
+ */
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext, Node
sourceNode,nsIDOMNode domNode);
+
}
\ No newline at end of file
Modified: trunk/vpe/plugins/org.jboss.tools.vpe.html/META-INF/MANIFEST.MF
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe.html/META-INF/MANIFEST.MF 2009-05-25 12:17:38
UTC (rev 15491)
+++ trunk/vpe/plugins/org.jboss.tools.vpe.html/META-INF/MANIFEST.MF 2009-05-25 16:07:41
UTC (rev 15492)
@@ -10,7 +10,8 @@
org.jboss.tools.vpe,
org.mozilla.xpcom,
org.jboss.tools.jst.jsp,
- org.jboss.tools.common
+ org.jboss.tools.common,
+ org.eclipse.jface.text;bundle-version="3.5.0"
Eclipse-LazyStart: true
Bundle-Localization: plugin
Export-Package: org.jboss.tools.vpe.html.template
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java
===================================================================
---
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2009-05-25
12:17:38 UTC (rev 15491)
+++
trunk/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlTextTemplate.java 2009-05-25
16:07:41 UTC (rev 15492)
@@ -11,17 +11,22 @@
package org.jboss.tools.vpe.html.template;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.swt.graphics.Point;
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.NodeData;
import org.jboss.tools.vpe.editor.mapping.VpeElementData;
import org.jboss.tools.vpe.editor.template.VpeAbstractTemplate;
import org.jboss.tools.vpe.editor.template.VpeCreationData;
+import org.jboss.tools.vpe.editor.util.NodesManagingUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
import org.mozilla.interfaces.nsIDOMDocument;
import org.mozilla.interfaces.nsIDOMElement;
import org.mozilla.interfaces.nsIDOMNode;
import org.w3c.dom.Node;
+import org.w3c.dom.ranges.RangeException;
/**
* @author mareshkau
@@ -55,4 +60,17 @@
return result;
}
+
+// /* (non-Javadoc)
+// * @see
org.jboss.tools.vpe.editor.template.VpeAbstractTemplate#getSourceRegionForOpenOn(org.w3c.dom.Node,
org.mozilla.interfaces.nsIDOMNode)
+// */
+ @Override
+ public IRegion getSourceRegionForOpenOn(VpePageContext pageContext, Node sourceNode,
nsIDOMNode domNode) {
+
+ Point selection = pageContext.getSourceBuilder().getSelectionRange();
+
+ return new Region(selection.x,0);
+ }
+
+
}