提交 db20773a 编写于 作者: S serge-rider

#9741 Load ERD from external file fix (NPE)

上级 eefddc77
......@@ -43,6 +43,8 @@ import org.jkiss.dbeaver.ui.navigator.NavigatorPreferences;
import org.jkiss.dbeaver.utils.RuntimeUtils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ResourceBundle;
......@@ -175,19 +177,21 @@ public class ERDEditorStandalone extends ERDEditorPart implements IResourceChang
private EntityDiagram loadContentFromFile(DBRProgressMonitor progressMonitor)
throws DBException
{
final IFile file = getEditorFile();
IFile resFile = getEditorFile();
IProject project = resFile == null ? DBWorkbench.getPlatform().getWorkspace().getActiveProject().getEclipseProject() : resFile.getProject();
final File localFile = EditorUtils.getLocalFileFromInput(getEditorInput());
final DiagramPart diagramPart = getDiagramPart();
EntityDiagram entityDiagram = new EntityDiagram(null, file.getName(), getContentProvider(), getDecorator());
EntityDiagram entityDiagram = new EntityDiagram(null, localFile.getName(), getContentProvider(), getDecorator());
entityDiagram.clear();
entityDiagram.setLayoutManualAllowed(true);
entityDiagram.setLayoutManualDesired(true);
diagramPart.setModel(entityDiagram);
try (final InputStream fileContent = file.getContents()) {
DiagramLoader.load(progressMonitor, file.getProject(), diagramPart, fileContent);
try (final InputStream fileContent = new FileInputStream(localFile)) {
DiagramLoader.load(progressMonitor, project, diagramPart, fileContent);
} catch (Exception e) {
log.error("Error loading ER diagram from '" + file.getName() + "'", e);
log.error("Error loading ER diagram from '" + localFile.getName() + "'", e);
}
return entityDiagram;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册