use of org.eclipse.core.resources.IWorkspace in project bndtools by bndtools.
the class BaselineErrorHandler method getResolutions.
@Override
public List<IMarkerResolution> getResolutions(IMarker marker) {
List<IMarkerResolution> result = new LinkedList<IMarkerResolution>();
final String suggestedVersion = marker.getAttribute(PROP_SUGGESTED_VERSION, null);
if (suggestedVersion != null) {
result.add(new IMarkerResolution() {
@Override
public void run(IMarker marker) {
final IFile file = (IFile) marker.getResource();
final IWorkspace workspace = file.getWorkspace();
try {
workspace.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
String input = "version " + suggestedVersion;
ByteArrayInputStream stream = new ByteArrayInputStream(input.getBytes());
file.setContents(stream, false, true, monitor);
}
}, null);
} catch (CoreException e) {
logger.logError("Error applying baseline version quickfix.", e);
}
}
@Override
public String getLabel() {
return "Change package version to " + suggestedVersion;
}
});
}
return result;
}
Aggregations