Source:
public boolean provides(IOperation operation) { Boolean provides = false; if (operation instanceof ContributeToPaletteOperation) { ContributeToPaletteOperation o = (ContributeToPaletteOperation) operation; IEditorPart part = o.getEditor(); if (part instanceof DiagramEditorWithFlyOutPalette) { String diagramName = getDiagram().getName(); if (null != diagramName) { Diagram diagramPalette = ((DiagramEditorWithFlyOutPalette) part).getDiagram(); String implementationID = getDiagram().getImplementationID(); PapyrusDiagramStyle papyrusDiagramStyle = org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPapyrusDiagramStyle(diagramPalette); boolean match = false; if (null != papyrusDiagramStyle) { ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); PapyrusDiagram repKind = (PapyrusDiagram) manager.getRepresentationKindById(papyrusDiagramStyle.getDiagramKindId()); if (repKind != null) match = diagramName.equals(repKind.getName()); } else if (null != implementationID) { match = null != diagramPalette && implementationID.equals(diagramPalette.getType()); } if (match && !isHidden(o)) { ModelSet modelSet = null; try { modelSet = ServiceUtils.getInstance().getModelSet(part.getAdapter(ServicesRegistry.class)); List<?> collect = new ArchitectureDescriptionUtils(modelSet).getArchitectureViewpoints().stream() .flatMap(p -> p.getRepresentationKinds().stream()) .filter(PapyrusDiagram.class::isInstance).map(PapyrusDiagram.class::cast) .filter(p -> getDiagram().getQualifiedName().equals(p.getQualifiedName())) .flatMap(p -> p.getPalettes().stream()).distinct() .collect(Collectors.toList()); provides = !collect.isEmpty(); } catch (ServiceException e) { Activator.log.error("Can't get model set", e); } } } } } return provides; }

Target:
public boolean provides(IOperation operation) { Boolean provides = false; if (operation instanceof ContributeToPaletteOperation) { ContributeToPaletteOperation o = (ContributeToPaletteOperation) operation; IEditorPart part = o.getEditor(); if (part instanceof DiagramEditorWithFlyOutPalette) { String diagramName = getDiagram().getName(); if (null != diagramName) { Diagram diagramPalette = ((DiagramEditorWithFlyOutPalette) part).getDiagram(); String implementationID = getDiagram().getImplementationID(); PapyrusDiagramStyle papyrusDiagramStyle = org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils.getPapyrusDiagramStyle(diagramPalette); boolean match = false; if (null != papyrusDiagramStyle) { ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); PapyrusDiagram repKind = (PapyrusDiagram) manager.getRepresentationKindById(papyrusDiagramStyle.getDiagramKindId()); if (repKind != null) { match = diagramName.equals(repKind.getName()); } } else if (null != implementationID) { match = null != diagramPalette && implementationID.equals(diagramPalette.getType()); } if (match && !isHidden(o)) { ModelSet modelSet = null; try { modelSet = ServiceUtils.getInstance().getModelSet(part.getAdapter(ServicesRegistry.class)); List<?> collect = new ArchitectureDescriptionUtils(modelSet).getArchitectureViewpoints().stream() .flatMap(p -> p.getRepresentationKinds().stream()) .filter(PapyrusDiagram.class::isInstance).map(PapyrusDiagram.class::cast) .filter(p -> getDiagram().getQualifiedName().equals(p.getQualifiedName())) .flatMap(p -> p.getPalettes().stream()).distinct() .collect(Collectors.toList()); provides = !collect.isEmpty(); } catch (ServiceException e) { Activator.log.error("Can't get model set", e); } } } } } return provides; }