use of org.eclipse.ui.IPathEditorInput in project dbeaver by serge-rider.
the class ImageEditorPart method loadImage.
private void loadImage() {
if (imageViewer == null || imageViewer.isDisposed()) {
return;
}
if (getEditorInput() instanceof IPathEditorInput) {
try {
final IPath absolutePath = ((IPathEditorInput) getEditorInput()).getPath();
File localFile = absolutePath.toFile();
if (localFile.exists()) {
try (InputStream inputStream = new FileInputStream(localFile)) {
contentValid = imageViewer.loadImage(inputStream);
imageViewer.update();
}
}
} catch (Exception e) {
log.error("Can't load image contents", e);
}
}
}
use of org.eclipse.ui.IPathEditorInput in project dbeaver by serge-rider.
the class ImageEditorPart method resourceChanged.
@Override
public void resourceChanged(IResourceChangeEvent event) {
IResourceDelta delta = event.getDelta();
if (delta == null) {
return;
}
IEditorInput input = getEditorInput();
IPath localPath = null;
if (input instanceof IPathEditorInput) {
localPath = ((IPathEditorInput) input).getPath();
}
if (localPath == null) {
return;
}
localPath = ContentUtils.convertPathToWorkspacePath(localPath);
delta = delta.findMember(localPath);
if (delta == null) {
return;
}
if (delta.getKind() == IResourceDelta.CHANGED) {
// Refresh editor
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
loadImage();
}
});
}
}
Aggregations