Author: akazakov
Date: 2010-09-09 20:10:15 -0400 (Thu, 09 Sep 2010)
New Revision: 24850
Added:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/BeansXmlHyperLinkTest.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.xml.ui/src/org/jboss/tools/cdi/xml/ui/CDIXMLUiPlugin.java
trunk/cdi/plugins/org.jboss.tools.cdi.xml/src/org/jboss/tools/cdi/xml/CDIXMLPlugin.java
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/HyperlinkDetectorTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7025 beans.xml openons
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml 2010-09-09 19:23:16 UTC (rev
24849)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/plugin.xml 2010-09-10 00:10:15 UTC (rev
24850)
@@ -31,5 +31,35 @@
targetId="org.eclipse.jdt.ui.javaCode">
</hyperlinkDetector>
</extension>
-
-</plugin>
+
+ <extension
+ point="org.jboss.tools.common.text.ext.hyperlinkPartitioner"
+ id="org.jboss.tools.cdi.text.ext.hyperlinkPartitioner"
+ name="org.jboss.tools.cdi.text.ext.hyperlinkPartitioner">
+ <hyperlinkPartitioner
+
id="org.jboss.tools.cdi.text.ext.hyperlink.TypeNameHyperlinkPartitioner"
+
class="org.jboss.tools.common.text.ext.hyperlink.xml.XMLClassHyperlinkPartitioner">
+ <contentType id="org.jboss.tools.common.model.ui.xml">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ROOT">
+ <axis path="/beans/*/class/" />
+ </partitionType>
+ </contentType>
+ <contentType id="org.eclipse.core.runtime.xml">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ROOT">
+ <axis path="/beans/*/class/" />
+ </partitionType>
+ </contentType>
+ <contentType id="org.jboss.tools.common.model.ui.xml">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ROOT">
+ <axis path="/beans/alternatives/stereotype/" />
+ </partitionType>
+ </contentType>
+ <contentType id="org.eclipse.core.runtime.xml">
+ <partitionType
id="org.jboss.tools.common.text.ext.xml.XML_ROOT">
+ <axis path="/beans/alternatives/stereotype/" />
+ </partitionType>
+ </contentType>
+ </hyperlinkPartitioner>
+ </extension>
+
+</plugin>
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.xml/src/org/jboss/tools/cdi/xml/CDIXMLPlugin.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.xml/src/org/jboss/tools/cdi/xml/CDIXMLPlugin.java 2010-09-09
19:23:16 UTC (rev 24849)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.xml/src/org/jboss/tools/cdi/xml/CDIXMLPlugin.java 2010-09-10
00:10:15 UTC (rev 24850)
@@ -17,7 +17,7 @@
/**
*/
public class CDIXMLPlugin extends AbstractUIPlugin {
- public static final String PLUGIN_ID = "org.jboss.tools.seam.xml";
//$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.jboss.tools.cdi.xml";
//$NON-NLS-1$
public CDIXMLPlugin() {
super();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.xml.ui/src/org/jboss/tools/cdi/xml/ui/CDIXMLUiPlugin.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.xml.ui/src/org/jboss/tools/cdi/xml/ui/CDIXMLUiPlugin.java 2010-09-09
19:23:16 UTC (rev 24849)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.xml.ui/src/org/jboss/tools/cdi/xml/ui/CDIXMLUiPlugin.java 2010-09-10
00:10:15 UTC (rev 24850)
@@ -17,7 +17,7 @@
import org.osgi.framework.BundleContext;
public class CDIXMLUiPlugin extends AbstractUIPlugin {
- public static String PLUGIN_ID = "org.jboss.tools.seam.xml.ui"; //$NON-NLS-1$
+ public static String PLUGIN_ID = "org.jboss.tools.cdi.xml.ui"; //$NON-NLS-1$
static CDIXMLUiPlugin INSTANCE = null;
public CDIXMLUiPlugin() {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/META-INF/MANIFEST.MF 2010-09-09
19:23:16 UTC (rev 24849)
+++ trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/META-INF/MANIFEST.MF 2010-09-10
00:10:15 UTC (rev 24850)
@@ -13,7 +13,9 @@
org.eclipse.jdt.ui;bundle-version="3.5.0",
org.eclipse.core.commands;bundle-version="3.5.0",
org.jboss.tools.cdi.core.test;bundle-version="1.0.0",
- org.eclipse.jdt.core;bundle-version="3.5.0"
+ org.eclipse.jdt.core;bundle-version="3.5.0",
+ org.eclipse.wst.xml.ui,
+ org.eclipse.jface;bundle-version="3.6.0"
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Bundle-Vendor.0
Export-Package: org.jboss.tools.cdi.text.ext.test
Added:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/BeansXmlHyperLinkTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/BeansXmlHyperLinkTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/BeansXmlHyperLinkTest.java 2010-09-10
00:10:15 UTC (rev 24850)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.text.ext.test;
+
+
+/**
+ * beans.xml OpenOns test
+ *
+ * @author Alexey Kazakov
+ */
+public class BeansXmlHyperLinkTest extends HyperlinkDetectorTest {
+
+ public void testAlternativesClassOpenOns() throws Exception {
+ checkHyperLinkInXml("WebContent/WEB-INF/beans.xml", 73,
"org.jboss.tools.common.text.ext.hyperlink.ClassHyperlink");
+ }
+
+ public void testAlternativesStereotypeOpenOns() throws Exception {
+ checkHyperLinkInXml("WebContent/WEB-INF/beans.xml", 395,
"org.jboss.tools.common.text.ext.hyperlink.ClassHyperlink");
+ }
+
+ public void testDecoratorClassOpenOns() throws Exception {
+ checkHyperLinkInXml("WebContent/WEB-INF/beans.xml", 1159,
"org.jboss.tools.common.text.ext.hyperlink.ClassHyperlink");
+ }
+
+ public void testInterceptorClassOpenOns() throws Exception {
+ checkHyperLinkInXml("WebContent/WEB-INF/beans.xml", 1761,
"org.jboss.tools.common.text.ext.hyperlink.ClassHyperlink");
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/BeansXmlHyperLinkTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java 2010-09-09
19:23:16 UTC (rev 24849)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/CdiTextExtAllTests.java 2010-09-10
00:10:15 UTC (rev 24850)
@@ -1,21 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.cdi.text.ext.test;
+import junit.framework.Test;
+import junit.framework.TestSuite;
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.jboss.tools.cdi.core.test.CDICoreTestSetup;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
public class CdiTextExtAllTests {
public static Test suite() {
// it could be done here because it is not needed to be enabled back
JavaModelManager.getIndexManager().disable();
-
- TestSuite suite = new TestSuite(CdiTextExtAllTests.class.getName());
- suite.addTest(new CDICoreTestSetup(new
TestSuite(InjectedPointHyperlinkDetectorTest.class)));
- suite.addTest(new CDICoreTestSetup(new
TestSuite(ProducerDisposerHyperlinkDetectorTest.class)));
- suite.addTest(new CDICoreTestSetup(new
TestSuite(EventAndObserverMethodHyperlinkDetectorTest.class)));
- return suite;
+
+ TestSuite suiteAll = new TestSuite("CDI Core Tests");
+
+ TestSuite suite = new TestSuite("CDI OpenOns Tests");
+ suite.addTestSuite(InjectedPointHyperlinkDetectorTest.class);
+ suite.addTestSuite(ProducerDisposerHyperlinkDetectorTest.class);
+ suite.addTestSuite(EventAndObserverMethodHyperlinkDetectorTest.class);
+ suite.addTestSuite(BeansXmlHyperLinkTest.class);
+ suiteAll.addTest(new CDICoreTestSetup(suite));
+
+ return suiteAll;
}
-}
+}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/HyperlinkDetectorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/HyperlinkDetectorTest.java 2010-09-09
19:23:16 UTC (rev 24849)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/HyperlinkDetectorTest.java 2010-09-10
00:10:15 UTC (rev 24850)
@@ -1,12 +1,11 @@
package org.jboss.tools.cdi.text.ext.test;
-import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.text.JavaWordFinder;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
@@ -25,18 +24,21 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+import org.eclipse.wst.xml.ui.internal.tabletree.XMLMultiPageEditorPart;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.common.text.ext.hyperlink.HyperlinkDetector;
import org.jboss.tools.common.text.ext.hyperlink.IHyperlinkRegion;
import org.jboss.tools.common.text.ext.util.AxisUtil;
public class HyperlinkDetectorTest extends TCKTest {
- protected void checkRegions(String fileName, ArrayList<Region> regionList,
AbstractHyperlinkDetector elPartitioner) throws Exception {
- IFile javaFile = tckProject.getFile(fileName);
+ protected void checkRegions(String fileName, List<Region> regionList,
AbstractHyperlinkDetector elPartitioner) throws Exception {
+ IFile file = tckProject.getFile(fileName);
- TCKTest.assertTrue("The file \"" + fileName + "\" is not
found", (javaFile != null));
- TCKTest.assertTrue("The file \"" + fileName + "\" is not
found", (javaFile.exists()));
+ assertNotNull("The file \"" + fileName + "\" is not
found", file);
+ assertTrue("The file \"" + fileName + "\" is not found",
file.isAccessible());
- FileEditorInput editorInput = new FileEditorInput(javaFile);
+ FileEditorInput editorInput = new FileEditorInput(file);
IDocumentProvider documentProvider = null;
try {
@@ -63,13 +65,13 @@
for(Region region : regionList)
expected += region.getLength()+1;
- IEditorPart part = openFileInEditor(javaFile);
+ IEditorPart part = openFileInEditor(file);
ISourceViewer viewer = null;
if(part instanceof JavaEditor){
viewer = ((JavaEditor)part).getViewer();
}
- elPartitioner.setContext(new TestContext((ITextEditor)part));
+ elPartitioner.setContext(new TestContext((ITextEditor)part));
int counter = 0;
for (int i = 0; i < document.getLength(); i++) {
@@ -98,8 +100,36 @@
documentProvider.disconnect(editorInput);
}
-
- protected boolean findOffsetInRegions(int offset, ArrayList<Region> regionList){
+ protected void checkHyperLinkInXml(String fileName, int offset, String
hyperlinkClassName) throws Exception {
+ Region region = new Region(offset, 0);
+ IFile file = tckProject.getFile(fileName);
+
+ assertNotNull("The file \"" + fileName + "\" is not
found", file);
+ assertTrue("The file \"" + fileName + "\" is not found",
file.isAccessible());
+
+ FileEditorInput editorInput = new FileEditorInput(file);
+
+ IEditorPart part = openFileInEditor(file);
+ ISourceViewer viewer = null;
+ if (part instanceof XMLMultiPageEditorPart) {
+ IEditorPart[] parts = ((XMLMultiPageEditorPart)part).findEditors(editorInput);
+ if(parts.length>0) {
+ viewer = ((StructuredTextEditor)parts[0]).getTextViewer();
+ }
+ }
+
+ IHyperlink[] links = HyperlinkDetector.getInstance().detectHyperlinks(viewer, region,
true);
+ if(links!=null) {
+ for (IHyperlink hyperlink : links) {
+ if(hyperlink.getClass().getName().equals(hyperlinkClassName)) {
+ return;
+ }
+ }
+ }
+ fail("Can't find HyperLink");
+ }
+
+ protected boolean findOffsetInRegions(int offset, List<Region> regionList){
for(Region region : regionList){
if(offset >= region.getOffset() && offset <=
region.getOffset()+region.getLength())
return true;
@@ -108,11 +138,21 @@
}
protected IEditorPart openFileInEditor(IFile input) {
+ return openFileInEditor(input, null);
+ }
+
+ protected IEditorPart openFileInEditor(IFile input, String id) {
if (input != null && input.exists()) {
try {
- IWorkbenchPage page = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- return IDE.openEditor(page, input, true);
+ if(id==null) {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ return IDE.openEditor(page, input, true);
+ } else {
+ IWorkbenchPage page = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage();
+ return IDE.openEditor(page, input, id, true);
+ }
} catch (PartInitException pie) {
pie.printStackTrace();
fail(pie.getMessage());
@@ -148,7 +188,7 @@
x.printStackTrace();
fail(x.getMessage());
}
-
+
return region;
}
@@ -217,4 +257,4 @@
return null;
}
}
-}
+}
\ No newline at end of file