use of org.jkiss.dbeaver.erd.ui.model.EntityDiagram in project dbeaver by dbeaver.
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", getContentProvider(), getDecorator());
} else {
diagram = new EntityDiagram(dbObject, dbObject.getName(), getContentProvider(), getDecorator());
// Fill from database even if we loaded from state (something could change since last view)
diagram.fillEntities(monitor, ERDUtils.collectDatabaseTables(monitor, dbObject, diagram, ERDUIActivator.getDefault().getPreferenceStore().getBoolean(ERDUIConstants.PREF_DIAGRAM_SHOW_VIEWS), ERDUIActivator.getDefault().getPreferenceStore().getBoolean(ERDUIConstants.PREF_DIAGRAM_SHOW_PARTITIONS)), dbObject);
boolean hasPersistedState = false;
try {
// Load persisted state
DBVObject vObject = this.getVirtualObject();
if (vObject != null) {
Map<String, Object> diagramState = vObject.getProperty(PROP_DIAGRAM_STATE);
if (diagramState != null) {
String serializedDiagram = (String) diagramState.get(PROPS_DIAGRAM_SERIALIZED);
if (!CommonUtils.isEmpty(serializedDiagram)) {
Document xmlDocument = XMLUtils.parseDocument(new StringReader(serializedDiagram));
DiagramLoader.loadDiagram(monitor, xmlDocument, dbObject.getDataSource().getContainer().getProject(), diagram);
hasPersistedState = true;
}
}
}
} catch (Exception e) {
log.error("Error loading ER diagram from saved state", e);
}
diagram.setLayoutManualAllowed(true);
diagram.setNeedsAutoLayout(!hasPersistedState);
}
return diagram;
}
use of org.jkiss.dbeaver.erd.ui.model.EntityDiagram in project dbeaver by dbeaver.
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.erd.ui.model.EntityDiagram in project dbeaver by dbeaver.
the class EntityPart method createFigure.
// ******************* Layout related methods *********************/
/**
* Creates a figure which represents the table
*/
@Override
protected EntityFigure createFigure() {
final EntityDiagram diagram = getDiagram();
final EntityFigure figure = createFigureImpl();
EntityDiagram.NodeVisualInfo visualInfo = diagram.getVisualInfo(getEntity().getObject());
if (visualInfo != null) {
if (visualInfo.initBounds != null) {
figure.setLocation(visualInfo.initBounds.getLocation());
}
if (visualInfo.bgColor != null) {
figure.setBackgroundColor(visualInfo.bgColor);
}
if (getEntity().getAttributeVisibility() == null && visualInfo.attributeVisibility != null) {
getEntity().setAttributeVisibility(visualInfo.attributeVisibility);
}
}
return figure;
}
use of org.jkiss.dbeaver.erd.ui.model.EntityDiagram in project dbeaver by serge-rider.
the class FlyoutChangeLayoutAction method isChecked.
/**
* @see org.eclipse.jface.action.IAction#isChecked()
*/
public boolean isChecked(IEditorPart editor) {
if (editor instanceof ERDEditorPart) {
ERDEditorPart schemaEditor = (ERDEditorPart) editor;
EntityDiagram entityDiagram = schemaEditor.getDiagram();
boolean checkTrue = entityDiagram.isLayoutManualDesired();
return (!checkTrue);
} else {
return false;
}
}
use of org.jkiss.dbeaver.erd.ui.model.EntityDiagram in project dbeaver by serge-rider.
the class FlyoutChangeLayoutAction method run.
@Override
public void run() {
if (editor instanceof ERDEditorPart) {
ERDEditorPart erdEditor = (ERDEditorPart) editor;
EntityDiagram entityDiagram = erdEditor.getDiagram();
boolean isManual = entityDiagram.isLayoutManualDesired();
entityDiagram.setLayoutManualDesired(!isManual);
erdEditor.getDiagramPart().changeLayout();
checked = !isManual;
setChecked(checked);
}
}
Aggregations