private void addActionsForSelection(IMenuManager menuManager) { IStructuredSelection selection = (IStructuredSelection) getViewer().getSelection(); if (selection.size() == 1) { Object element = selection.getFirstElement(); if (!(element instanceof IMarker)) { return; } final IMarker marker = (IMarker) element; IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker); for (final IMarkerResolution resolution : resolutions) { Action action = new Action(escapeSpecialChars(resolution.getLabel())) { @Override public void run() { resolution.run(marker); } }; if (resolution instanceof IMarkerResolution2) { IMarkerResolution2 resolution2 = (IMarkerResolution2) resolution; Image image = resolution2.getImage(); if (image != null) { action.setImageDescriptor(ImageDescriptor.createFromImage(image)); } } menuManager.add(action); } } }
@Override public Image getImage() { if (fResolution instanceof AbstractPDEMarkerResolution) { switch (((AbstractPDEMarkerResolution) fResolution).getType()) { case AbstractPDEMarkerResolution.CREATE_TYPE: return fCreateImage; case AbstractPDEMarkerResolution.REMOVE_TYPE: return fRemoveImage; case AbstractPDEMarkerResolution.RENAME_TYPE: return fRenameImage; } } if (fResolution instanceof IMarkerResolution2) { IMarkerResolution2 resolution = (IMarkerResolution2) fResolution; return resolution.getImage(); } return null; }