public void testSearchNotRunIfViewDeactivated() throws PartInitException, JavaModelException { view = (ActiveSearchView) JavaPlugin.getActivePage().showView(ActiveSearchView.ID); for (AbstractRelationProvider provider : ContextCorePlugin.getDefault().getRelationProviders()) { assertTrue(provider.getCurrentDegreeOfSeparation() > 0); } IViewPart viewPart = JavaPlugin.getActivePage().showView("org.eclipse.ui.views.ProblemView"); // XXX e4.0 IPerspectiveDescriptor API has changed // IPerspectiveDescriptor perspective = ((WorkbenchPage) // JavaPlugin.getActivePage()).getPerspective(); IViewReference reference = JavaPlugin.getActivePage().findViewReference(ActiveSearchView.ID); assertNotNull(reference); // assertTrue(perspective.canCloseView(view)); // assertTrue(perspective.hideView(reference)); JavaPlugin.getActivePage().hideView(viewPart); for (AbstractRelationProvider provider : ContextCorePlugin.getDefault().getRelationProviders()) { assertFalse(provider.isEnabled()); } JavaPlugin.getActivePage().showView(ActiveSearchView.ID); for (AbstractRelationProvider provider : ContextCorePlugin.getDefault().getRelationProviders()) { assertTrue(provider.isEnabled()); } }
public void testViewRecursion() throws JavaModelException, PartInitException { view = (ActiveSearchView) JavaPlugin.getActivePage().showView(ActiveSearchView.ID); ActiveSearchView.getFromActivePerspective().setSyncExecForTesting(false); for (AbstractRelationProvider provider : ContextCorePlugin.getDefault().getRelationProviders()) { assertTrue(provider.isEnabled()); } assertEquals(0, view.getViewer().getTree().getItemCount()); IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); IMethod m1 = type1.createMethod("void m1() {\n m1(); \n}", null, true, null); StructuredSelection sm1 = new StructuredSelection(m1); monitor.selectionChanged(part, sm1); IInteractionElement node = manager.processInteractionEvent( mockInterestContribution(m1.getHandleIdentifier(), scaling.getLandmark())); assertEquals(1, ContextCore.getContextManager().getActiveLandmarks().size()); assertEquals(1, search(2, node).size()); List<TreeItem> collectedItems = new ArrayList<TreeItem>(); UiTestUtil.collectTreeItemsInView(view.getViewer().getTree().getItems(), collectedItems); // just make sure that the view didn't blow up. assertEquals(1, collectedItems.size()); monitor.selectionChanged(part, sm1); manager.processInteractionEvent( mockInterestContribution(m1.getHandleIdentifier(), -scaling.getLandmark())); }
private static void readBridge(IConfigurationElement element) { try { Object object = element.createExecutableExtension(BridgesExtensionPointReader.ATTR_CLASS); if (!(object instanceof AbstractContextStructureBridge)) { StatusHandler.log( new Status( IStatus.WARNING, ContextCorePlugin.ID_PLUGIN, "Could not load bridge: " + object.getClass().getCanonicalName() + " must implement " //$NON-NLS-1$ //$NON-NLS-2$ + AbstractContextStructureBridge.class.getCanonicalName())); return; } AbstractContextStructureBridge bridge = (AbstractContextStructureBridge) object; if (element.getAttribute(BridgesExtensionPointReader.ATTR_PARENT_CONTENT_TYPE) != null) { String parentContentType = element.getAttribute(BridgesExtensionPointReader.ATTR_PARENT_CONTENT_TYPE); if (parentContentType != null) { bridge.setParentContentType(parentContentType); } } ContextCorePlugin.getDefault().addStructureBridge(bridge); } catch (Throwable e) { StatusHandler.log( new Status( IStatus.WARNING, ContextCorePlugin.ID_PLUGIN, "Could not load bridge extension", e)); //$NON-NLS-1$ } }
public IInteractionElement getElement(String handle, String kind) { IInteractionElement node = context.addEvent(mockSelection(handle, kind, source)); ContextCorePlugin.getContextManager() .processInteractionEvent( mockUserEvent( handle, kind, source, (1 / ContextCore.getCommonContextScaling().getLandmark()) * -2), true); return node; }
private static void readInternalBridge(IConfigurationElement element) { String baseContent = element.getAttribute(ATTR_BASE_CONTENT); String shadowedByContent = element.getAttribute(ATTR_SHADOWED_BY_CONTENT); if (baseContent == null || shadowedByContent == null) { StatusHandler.log( new Status( IStatus.WARNING, ContextCorePlugin.ID_PLUGIN, "Ignoring bridge shadowing because of invalid extension point " //$NON-NLS-1$ + BridgesExtensionPointReader.ELEMENT_STRUCTURE_BRIDGE, new Exception())); } ContextCorePlugin.getDefault().addShadowsContent(baseContent, shadowedByContent); }
private static void readRelationProvider(IConfigurationElement element) { try { String contentType = element.getAttribute(BridgesExtensionPointReader.ATTR_CONTENT_TYPE); AbstractRelationProvider relationProvider = (AbstractRelationProvider) element.createExecutableExtension(BridgesExtensionPointReader.ATTR_CLASS); if (contentType != null) { ContextCorePlugin.getDefault().addRelationProvider(contentType, relationProvider); } } catch (Throwable e) { StatusHandler.log( new Status( IStatus.WARNING, ContextCorePlugin.ID_PLUGIN, "Could not load relation provider", e)); //$NON-NLS-1$ } }
/** For testing * */ private List<IContextContributor> getContextContributor() { return ContextCorePlugin.getDefault().getContextContributor(); }