use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class EntityPart method createFigure.
//******************* Layout related methods *********************/
/**
* Creates a figure which represents the table
*/
@Override
protected EntityFigure createFigure() {
final EntityFigure figure = new EntityFigure(getTable());
final EntityDiagram diagram = ((DiagramPart) getParent()).getDiagram();
Rectangle bounds = diagram.getInitBounds(getTable());
if (bounds != null) {
figure.setLocation(bounds.getLocation());
}
return figure;
}
use of org.jkiss.dbeaver.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class ERDEditorPart method createGraphicalViewer.
/**
* Creates a new <code>GraphicalViewer</code>, configures, registers and
* initializes it.
*
* @param parent the parent composite
*/
@Override
protected void createGraphicalViewer(Composite parent) {
GraphicalViewer viewer = createViewer(parent);
// hook the viewer into the EditDomain
setGraphicalViewer(viewer);
configureGraphicalViewer();
hookGraphicalViewer();
initializeGraphicalViewer();
// Set initial (empty) contents
viewer.setContents(new EntityDiagram(null, "empty"));
// Set context menu
ContextMenuProvider provider = new ERDEditorContextMenuProvider(this);
viewer.setContextMenu(provider);
getSite().registerContextMenu(ERDEditorPart.class.getName() + ".EditorContext", provider, viewer);
}
use of org.jkiss.dbeaver.ext.erd.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);
}
}
use of org.jkiss.dbeaver.ext.erd.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.ext.erd.model.EntityDiagram in project dbeaver by serge-rider.
the class ERDResourceHandler method createDiagram.
public static IFile createDiagram(final EntityDiagram copyFrom, final String title, IFolder folder, DBRProgressMonitor monitor) throws DBException {
if (folder == null) {
try {
folder = getDiagramsFolder(DBeaverCore.getInstance().getProjectRegistry().getActiveProject(), true);
} catch (CoreException e) {
throw new DBException("Can't obtain folder for diagram", e);
}
}
if (folder == null) {
throw new DBException("Can't detect folder for diagram");
}
final IFile file = ContentUtils.getUniqueFile(folder, CommonUtils.escapeFileName(title), ERD_EXT);
try {
DBRRunnableWithProgress runnable = new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
EntityDiagram newDiagram = copyFrom == null ? new EntityDiagram(null, "<Diagram>") : copyFrom.copy();
newDiagram.setName(title);
newDiagram.setLayoutManualAllowed(true);
newDiagram.setLayoutManualDesired(true);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DiagramLoader.save(monitor, null, newDiagram, false, buffer);
InputStream data = new ByteArrayInputStream(buffer.toByteArray());
file.create(data, true, RuntimeUtils.getNestedMonitor(monitor));
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
};
if (monitor == null) {
DBeaverUI.runInProgressService(runnable);
} else {
runnable.run(monitor);
}
} catch (InvocationTargetException e) {
throw new DBException("Error creating diagram", e.getTargetException());
} catch (InterruptedException e) {
// interrupted
}
return file;
}
Aggregations