Author: dazarov
Date: 2011-09-14 16:30:47 -0400 (Wed, 14 Sep 2011)
New Revision: 34745
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java
Log:
"Show All Generic Configuration Points", "Show CDI Events" and
"Show CDI Observer Methods" dialogs should look like "Open
Implementation" in JDT
https://issues.jboss.org/browse/JBIDE-9673
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java 2011-09-14
20:18:48 UTC (rev 34744)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/InformationControlManager.java 2011-09-14
20:30:47 UTC (rev 34745)
@@ -21,12 +21,21 @@
import org.jboss.tools.cdi.text.ext.hyperlink.xpl.InformationPresenter;
public class InformationControlManager {
- public static void showHyperlinks(String title, ITextViewer viewer, IHyperlink[]
hyperlinks){
+ public static IInformationControl showHyperlinks(String title, ITextViewer viewer,
IHyperlink[] hyperlinks){
+ return showHyperlinks(title, viewer, hyperlinks, false);
+ }
+
+ public static IInformationControl showHyperlinks(String title, ITextViewer viewer,
IHyperlink[] hyperlinks, boolean test){
InformationPresenter presenter= new InformationPresenter(viewer,
getHierarchyPresenterControlCreator(title, hyperlinks));
presenter.setAnchor(AbstractInformationControlManager.ANCHOR_GLOBAL);
presenter.setSizeConstraints(60, 10, true, false);
presenter.install(viewer.getTextWidget());
- presenter.showInformation();
+ if(test){
+ return presenter.showInformationForTest();
+ } else {
+ presenter.showInformation();
+ return null;
+ }
}
private static IInformationControlCreator getHierarchyPresenterControlCreator(final
String title, final IHyperlink[] hyperlinks) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java 2011-09-14
20:18:48 UTC (rev 34744)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.text.ext/src/org/jboss/tools/cdi/text/ext/hyperlink/xpl/InformationPresenter.java 2011-09-14
20:30:47 UTC (rev 34745)
@@ -41,6 +41,10 @@
@Override
public void showInformation() {
+ showInformation_internal(false);
+ }
+
+ private IInformationControl showInformation_internal(boolean test){
IInformationControl iControl = getInformationControl();
Point sizeConstraints= computeSizeConstraints(viwer.getTextWidget(), null, iControl);
iControl.setSizeConstraints(sizeConstraints.x, sizeConstraints.y);
@@ -58,8 +62,16 @@
size= Geometry.max(size, sizeConstraints);
iControl.setSize(size.x, size.y);
+ if(test){
+ ((HierarchyInformationControl)iControl).setBlockOnOpen(false);
+ }
iControl.setVisible(true);
+ return iControl;
}
+
+ public IInformationControl showInformationForTest(){
+ return showInformation_internal(true);
+ }
@Override
protected void computeInformation() {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java 2011-09-14
20:18:48 UTC (rev 34744)
+++
trunk/cdi/tests/org.jboss.tools.cdi.text.ext.test/src/org/jboss/tools/cdi/text/ext/test/InjectedPointHyperlinkDetectorTest.java 2011-09-14
20:30:47 UTC (rev 34745)
@@ -4,17 +4,52 @@
import java.util.Set;
import org.eclipse.core.resources.IFile;
+import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.test.tck.TCKTest;
import org.jboss.tools.cdi.text.ext.CDIExtensionsMessages;
import org.jboss.tools.cdi.text.ext.hyperlink.AssignableBeansHyperlink;
+import org.jboss.tools.cdi.text.ext.hyperlink.InformationControlManager;
import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlink;
import org.jboss.tools.cdi.text.ext.hyperlink.InjectedPointHyperlinkDetector;
+import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestHyperlink;
import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestRegion;
import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.cdi.text.ext.test.CDIHyperlinkTestUtil.TestHyperlink;
public class InjectedPointHyperlinkDetectorTest extends TCKTest {
+
+ public void testShowHyperlinksDialog() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/lookup/injectionpoint/BasicLogger.java");
+
+ assertTrue("File must be exist", file.exists());
+
+ IEditorPart part = CDIHyperlinkTestUtil.openFileInEditor(file);
+ if(part instanceof JavaEditor){
+ IDocument document = ((JavaEditor)part).getViewer().getDocument();
+
+ assertNotNull("Document not found", document);
+
+ IBean[] beans = cdiProject.getBeans();
+ IHyperlink[] hyperlinks = new IHyperlink[beans.length];
+ int index = 0;
+ for(IBean b : beans){
+ hyperlinks[index++] = new InjectedPointHyperlink(new Region(1,1), b, document);
+ }
+
+ IInformationControl informationControl =
InformationControlManager.showHyperlinks("Title",
((JavaEditor)part).getViewer(), hyperlinks, true);
+
+ assertNotNull("InformationControl not found", informationControl);
+ informationControl.setVisible(false);
+ }else{
+ fail("Editor part must be instance of JavaEditor, was - "+part.getClass());
+ }
+ }
public void testInjectedPointHyperlinkDetector() throws Exception {
Set<IBean> beans =
cdiProject.getBeans("/tck/JavaSource/org/jboss/jsr299/tck/tests/lookup/injectionpoint/BasicLogger.java", true);