Source:
private void updatePaletteForDiagramWithLayer(DiagramDescription description, Session session, DDiagram dDiagram) { HashSet<Layer> layersInActivatedViewpoints = new HashSet<Layer>(new DiagramComponentizationManager().getAllLayers(session.getSelectedViewpoints(false), description)); Set<Layer> activatedLayers = Sets.newHashSet(new DDiagramQuery(dDiagram).getAllActivatedLayers()); final List<Layer> activatedLayersOfSelectedViewpoints = Lists.newArrayList(Sets.intersection(layersInActivatedViewpoints, activatedLayers)); final List<Layer> deactivatedLayersAndAllLayersOfDeselectedViewpoints = Lists.newArrayList(Sets.symmetricDifference(layersInActivatedViewpoints, activatedLayers)); for (final ToolSection section : new DiagramComponentizationManager().getRootPaletteSections(session.getSelectedViewpoints(false), description)) { updateFilters(session, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); } for (final ToolSection section : new DiagramComponentizationManager().getRootPaletteSections(session.getSelectedViewpoints(false), description)) { Option<SectionPaletteDrawer> paletteEntry = getPaletteEntry(paletteRoot, MessageTranslator.INSTANCE.getMessage(section, new IdentifiedElementQuery(section).getLabel()), SectionPaletteDrawer.class); if (!paletteEntry.some()) { final PaletteContainer container = PaletteManagerImpl.createPaletteDrawner(section); updateContainer(session, dDiagram, container, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); paletteRoot.add(container); } else { updateContainer(session, dDiagram, paletteEntry.get(), new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); } } for (final Layer layer : Lists.newArrayList(deactivatedLayersAndAllLayersOfDeselectedViewpoints)) { setLayerVisibility(layer, false); } for (final Layer layer : Lists.newArrayList(activatedLayersOfSelectedViewpoints)) { setLayerVisibility(layer, true); } }

Target:
private void updatePaletteForDiagramWithLayer(DiagramDescription description, Session session, DDiagram dDiagram) { HashSet<Layer> layersInActivatedViewpoints = new HashSet<Layer>(new DiagramComponentizationManager().getAllLayers(session.getSelectedViewpoints(false), description)); Set<Layer> activatedLayers = new HashSet<Layer>(new DDiagramQuery(dDiagram).getAllActivatedLayers()); final List<Layer> activatedLayersOfSelectedViewpoints = Lists.newArrayList(Sets.intersection(layersInActivatedViewpoints, activatedLayers)); final List<Layer> deactivatedLayersAndAllLayersOfDeselectedViewpoints = Lists.newArrayList(Sets.symmetricDifference(layersInActivatedViewpoints, activatedLayers)); for (final ToolSection section : new DiagramComponentizationManager().getRootPaletteSections(session.getSelectedViewpoints(false), description)) { updateFilters(session, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); } for (final ToolSection section : new DiagramComponentizationManager().getRootPaletteSections(session.getSelectedViewpoints(false), description)) { Option<SectionPaletteDrawer> paletteEntry = getPaletteEntry(paletteRoot, MessageTranslator.INSTANCE.getMessage(section, new IdentifiedElementQuery(section).getLabel()), SectionPaletteDrawer.class); if (!paletteEntry.some()) { final PaletteContainer container = PaletteManagerImpl.createPaletteDrawner(section); updateContainer(session, dDiagram, container, new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); paletteRoot.add(container); } else { updateContainer(session, dDiagram, paletteEntry.get(), new DiagramComponentizationManager().getAllToolEntries(session.getSelectedViewpoints(false), section)); } } for (final Layer layer : Lists.newArrayList(deactivatedLayersAndAllLayersOfDeselectedViewpoints)) { setLayerVisibility(layer, false); } for (final Layer layer : Lists.newArrayList(activatedLayersOfSelectedViewpoints)) { setLayerVisibility(layer, true); } }