@Test public void testSingleSelection() { Assume.assumeFalse("Cannot run in headless", GraphicsEnvironment.isHeadless()); ContextGlobalExtender globalExtender = Utilities.actionsGlobalContext().lookup(ContextGlobalExtender.class); DefaultSelectionSupport<ProductSceneView> selectionChangeSupport = new DefaultSelectionSupport<>(ProductSceneView.class); MySelectionChangeHandler changeListener = new MySelectionChangeHandler(); selectionChangeSupport.addHandler(changeListener); ProductSceneView sceneView1 = Mockito.mock(ProductSceneView.class); globalExtender.put("view", sceneView1); assertEquals(1, changeListener.count); globalExtender.remove("view"); assertEquals(0, changeListener.count); }
@Override public void addHandler(Handler<T> handler) { if (handlerList.isEmpty() && theWeakListener == null) { theWeakListener = WeakListeners.create(LookupListener.class, lookupListener, itemResult); itemResult.addLookupListener(theWeakListener); } handlerList.add(handler); }
DefaultSelectionSupport implements SelectionSupport<T> { @Override public void addHandler(Handler<T> handler) { if (handlerList.isEmpty() && theWeakListener == null) { theWeakListener = WeakListeners.create(LookupListener.class, lookupListener, itemResult); itemResult.addLookupListener(theWeakListener); } handlerList.add(handler); } }
DefaultSelectionSupport implements SelectionSupport<T> { @Override public void addHandler(Handler<T> handler) { if (handlerList.isEmpty() && theWeakListener == null) { theWeakListener = WeakListeners.create(LookupListener.class, lookupListener, itemResult); itemResult.addLookupListener(theWeakListener); } handlerList.add(handler); } DefaultSelectionSupport(Class<T> type); }
DefaultSelectionSupport implements SelectionSupport<T> { @Override public void addHandler(Handler<T> handler) { if (handlerList.isEmpty() && theWeakListener == null) { theWeakListener = WeakListeners.create(LookupListener.class, lookupListener, itemResult); itemResult.addLookupListener(theWeakListener); } handlerList.add(handler); } DefaultSelectionSupport(Class<T> type); @Override void addHandler(Handler<T> handler); @Override void removeHandler(Handler<T> handler); }
DefaultSelectionSupport implements SelectionSupport<T> { @Override public void addHandler(Handler<T> handler) { if (handlerList.isEmpty() && theWeakListener == null) { theWeakListener = WeakListeners.create(LookupListener.class, lookupListener, itemResult); itemResult.addLookupListener(theWeakListener); } handlerList.add(handler); } DefaultSelectionSupport(Class<T> type); @Override void addHandler(Handler<T> handler); @Override void removeHandler(Handler<T> handler);  }