Community
Participate
Working Groups
I'd like to define the label/image of my AbstractDiffExtension within their generated ItemProvider, but it seems it is impossible. Here is a possible workaround: Generated AbstractDiffExtension subclasses should return null on call to getText() getImage() (manual change in the generated code) and the ModelStructureLabelProvider of ModelStructureMergeViewer should be changed to : @Override public Image getImage(Object object) { Image image = null; if (object instanceof AbstractDiffExtension) { image = (Image)((AbstractDiffExtension)object).getImage(); } else if (object instanceof IFile) { image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FILE); } // fallback to ItemProvider if (image == null) { image = adapterProvider.getImage(object); } return image; } @Override public String getText(Object object) { String text = null; if (object instanceof AbstractDiffExtension) { text = ((AbstractDiffExtension)object).getText(); } else if (object instanceof IFile) { text = ((IFile)object).getName(); } else if (object instanceof Resource) { text = ((Resource)object).getURI().lastSegment(); } // fallback to ItemProvider if (text == null || "".equals(text)) { //$NON-NLS-1$ text = adapterProvider.getText(object); } return text; } It does not change the behavior of existing code, it just change the logic to fallback to the ItemProvider instead of returning <null>.
Changing the generated code can not be done as it simply is what EMF does (you generate the code of a "derived" reference, you have to manually code it; by default it throws an UnsupportedOperationException.) and changing it now would break the contract of this API. As for the rest, the ModelStructureMergeViewer now properly falls back to the adapter factory.