/** * Converts the viewer update to use java elements. * * @param update * the viewer update to convert * @return <code>true</code> if any elements have been converted, * <code>false</code> otherwise */ private boolean convertToJavaElements(final PipelinedViewerUpdate update) { final Set<IJavaElement> result= new HashSet<IJavaElement>(); for (final Iterator<IAdaptable> iterator= update.getRefreshTargets().iterator(); iterator.hasNext();) { final Object element= iterator.next(); if (element instanceof IProject) { final IJavaElement project= asJavaProject((IProject) element); if (project != null) { iterator.remove(); result.add(project); } } } update.getRefreshTargets().addAll(result); return !result.isEmpty(); }
/** * Test if intercepting an object that does not have a parent works. */ public void testInterceptRefresh() throws Exception { PythonNature nature = createNature(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot/source/python"); project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC + "projroot"), nature); provider = new PythonModelProvider(); PipelinedViewerUpdate update = new PipelinedViewerUpdate(); Set<Object> refreshTargets = update.getRefreshTargets(); refreshTargets.add(project); refreshTargets.add(null); refreshTargets.add("string"); provider.interceptRefresh(update); assertEquals(2, refreshTargets.size()); for (Object wrappedResource : refreshTargets) { assertTrue(wrappedResource == project || wrappedResource.equals("string")); } }
@Override public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) { if (DEBUG) { System.out.println("interceptRefresh"); } return convertToPythonElementsUpdateOrRefresh(refreshSynchronization.getRefreshTargets()); }
@Override public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) { if (DEBUG) { debug("Before interceptUpdate", updateSynchronization); } boolean ret = convertToPythonElementsUpdateOrRefresh(updateSynchronization.getRefreshTargets()); if (DEBUG) { debug("After interceptUpdate", updateSynchronization); } return ret; }
/** * Helper for debugging the things we have in an update */ private void debug(String desc, PipelinedViewerUpdate updateSynchronization) { System.out.println("\nDesc:" + desc); System.out.println("Refresh targets:"); for (Object o : updateSynchronization.getRefreshTargets()) { System.out.println(o); } }
@Override public boolean interceptRefresh(final PipelinedViewerUpdate aRefreshSynchronization) { return true; }
@Override public boolean interceptUpdate(final PipelinedViewerUpdate anUpdateSynchronization) { return true; }
@Override public boolean interceptRefresh( PipelinedViewerUpdate paramPipelinedViewerUpdate) { return false; }
@Override public boolean interceptUpdate( PipelinedViewerUpdate paramPipelinedViewerUpdate) { return false; }
/** * {@inheritDoc} */ public boolean interceptRefresh(final PipelinedViewerUpdate update) { return convertToJavaElements(update); }
/** * {@inheritDoc} */ public boolean interceptUpdate(final PipelinedViewerUpdate anUpdateSynchronization) { return convertToJavaElements(anUpdateSynchronization); }
public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) { return convertToJavaElements(updateSynchronization.getRefreshTargets()); }
public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) { return convertToJavaElements(refreshSynchronization.getRefreshTargets()); }