@Override public void addPostSelectionListener(String partId, ISelectionListener listener) { Set<ISelectionListener> listeners = targetedPostSelectionListeners.get(partId); if (listeners == null) { listeners = new HashSet<>(); targetedPostSelectionListeners.put(partId, listeners); } if (listeners.isEmpty() && selectionService != null) { selectionService.addPostSelectionListener(partId, targetedPostListener); } listeners.add(listener); }
@Inject void setSelectionService(@Optional ESelectionService selectionService) { if (this.selectionService != null) { this.selectionService.removeSelectionListener(listener); for (String partId : targetedListeners.keySet()) { this.selectionService.removeSelectionListener(partId, targetedListener); } this.selectionService.removePostSelectionListener(postListener); for (String partId : targetedPostSelectionListeners.keySet()) { this.selectionService.removePostSelectionListener(partId, targetedPostListener); } } if (selectionService != null) { selectionService.addSelectionListener(listener); for (String partId : targetedListeners.keySet()) { selectionService.addSelectionListener(partId, targetedListener); } selectionService.addPostSelectionListener(postListener); for (String partId : targetedPostSelectionListeners.keySet()) { selectionService.addPostSelectionListener(partId, targetedPostListener); } this.selectionService = selectionService; } }