use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class ERDEditorStandalone method loadContentFromFile.
private EntityDiagram loadContentFromFile(DBRProgressMonitor progressMonitor) throws DBException {
final IFile file = getEditorFile();
final DiagramPart diagramPart = getDiagramPart();
EntityDiagram entityDiagram = new EntityDiagram(null, file.getName());
entityDiagram.clear();
entityDiagram.setLayoutManualAllowed(true);
entityDiagram.setLayoutManualDesired(true);
diagramPart.setModel(entityDiagram);
try (final InputStream fileContent = file.getContents()) {
DiagramLoader.load(progressMonitor, file.getProject(), diagramPart, fileContent);
} catch (Exception e) {
log.error("Error loading ER diagram from '" + file.getName() + "'", e);
}
return entityDiagram;
}
use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class ERDEditorEmbedded method loadFromDatabase.
private EntityDiagram loadFromDatabase(DBRProgressMonitor monitor) throws DBException {
DBSObject dbObject = getRootObject();
if (dbObject == null) {
log.error("Database object must be entity container to render ERD diagram");
return null;
}
EntityDiagram diagram;
if (!dbObject.isPersisted()) {
diagram = new EntityDiagram(dbObject, "New Object");
} else {
diagram = new EntityDiagram(dbObject, dbObject.getName());
diagram.fillTables(monitor, collectDatabaseTables(monitor, dbObject), dbObject);
}
return diagram;
}
use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class DelegatingLayoutManager method layout.
@Override
public void layout(IFigure container) {
EntityDiagram entityDiagram = diagram.getDiagram();
try {
if (entityDiagram.isLayoutManualDesired()) {
if (activeLayoutManager != xyLayoutManager) {
if (entityDiagram.isLayoutManualAllowed() && !entityDiagram.isNeedsAutoLayout()) {
// yes we are okay to start populating the table bounds
setLayoutManager(container, xyLayoutManager);
activeLayoutManager.layout(container);
} else {
// we first have to set the constraint data
if (diagram.setTableFigureBounds(true)) {
//we successfully set bounds for all the existing
// tables so we can start using xyLayout immediately
setLayoutManager(container, xyLayoutManager);
activeLayoutManager.layout(container);
} else {
//we did not - we still need to run autolayout once
// before we can set xyLayout
activeLayoutManager.layout(container);
//run this again so that it will work again next time
setLayoutManager(container, xyLayoutManager);
}
}
} else {
setLayoutManager(container, xyLayoutManager);
activeLayoutManager.layout(container);
}
} else {
setLayoutManager(container, graphLayoutManager);
activeLayoutManager.layout(container);
}
} finally {
if (!diagram.getChildren().isEmpty()) {
entityDiagram.setNeedsAutoLayout(false);
}
}
}
use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class NoteEditPolicy method createDeleteCommand.
@Override
protected Command createDeleteCommand(GroupRequest request) {
NotePart notePart = (NotePart) getHost();
Rectangle bounds = notePart.getFigure().getBounds().getCopy();
EntityDiagram parent = (EntityDiagram) (notePart.getParent().getModel());
return new NoteDeleteCommand(parent, notePart, bounds);
}
use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class EntityEditPolicy method createDeleteCommand.
@Override
protected Command createDeleteCommand(GroupRequest request) {
EntityPart entityPart = (EntityPart) getHost();
Rectangle bounds = entityPart.getFigure().getBounds().getCopy();
EntityDiagram parent = (EntityDiagram) (entityPart.getParent().getModel());
return new EntityDeleteCommand(parent, entityPart, bounds);
}
Aggregations