use of org.eclipse.ui.IMarkerResolution2 in project eclipse.platform.text by eclipse.
the class MarkerInformationControl method setInput.
@SuppressWarnings("unchecked")
@Override
public void setInput(Object input) {
this.composites.values().forEach(Composite::dispose);
this.markers = (List<IMarker>) input;
for (IMarker marker : this.markers) {
Composite markerComposite = new Composite(parent, SWT.NONE);
this.composites.put(marker, markerComposite);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.verticalSpacing = 0;
gridLayout.horizontalSpacing = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
markerComposite.setLayout(gridLayout);
Composite markerLine = new Composite(markerComposite, SWT.NONE);
RowLayout rowLayout = new RowLayout();
rowLayout.marginTop = 0;
rowLayout.marginBottom = 0;
rowLayout.marginLeft = 0;
rowLayout.marginRight = 0;
markerLine.setLayout(rowLayout);
IMarkerResolution[] resolutions = IDE.getMarkerHelpRegistry().getResolutions(marker);
if (resolutions.length > 0) {
Label markerImage = new Label(markerLine, SWT.NONE);
markerImage.setImage(getImage(marker));
}
Label markerLabel = new Label(markerLine, SWT.NONE);
// $NON-NLS-1$
markerLabel.setText(marker.getAttribute(IMarker.MESSAGE, "missing message"));
for (IMarkerResolution resolution : resolutions) {
Composite resolutionComposite = new Composite(markerComposite, SWT.NONE);
GridData layoutData = new GridData();
layoutData.horizontalIndent = 10;
resolutionComposite.setLayoutData(layoutData);
RowLayout resolutionRowLayout = new RowLayout();
resolutionRowLayout.marginBottom = 0;
resolutionComposite.setLayout(resolutionRowLayout);
Label resolutionImage = new Label(resolutionComposite, SWT.NONE);
// TODO: try to retrieve icon from QuickFix command
Image resolutionPic = null;
if (resolution instanceof IMarkerResolution2) {
resolutionPic = ((IMarkerResolution2) resolution).getImage();
}
if (resolutionPic == null) {
resolutionPic = PlatformUI.getWorkbench().getSharedImages().getImage(SharedImages.IMG_OPEN_MARKER);
}
resolutionImage.setImage(resolutionPic);
Link resolutionLink = new Link(resolutionComposite, SWT.NONE);
// $NON-NLS-1$ //$NON-NLS-2$
resolutionLink.setText("<A>" + resolution.getLabel() + "</a>");
resolutionLink.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Job resolutionJob = new // $NON-NLS-1$
Job(// $NON-NLS-1$
"apply resolution - " + resolution.getLabel()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
resolution.run(marker);
return Status.OK_STATUS;
}
};
resolutionJob.setUser(true);
resolutionJob.setSystem(true);
resolutionJob.setPriority(Job.INTERACTIVE);
resolutionJob.schedule();
getShell().dispose();
}
});
}
}
parent.layout(true);
}
Aggregations