提交 d7d614ef 编写于 作者: J jurgen

GraphML format support

上级 8b5929e7
......@@ -17,6 +17,7 @@
*/
package org.jkiss.dbeaver.ext.erd.editor;
import org.eclipse.draw2d.Bendpoint;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.FontData;
......@@ -27,6 +28,7 @@ import org.jkiss.dbeaver.ext.erd.model.ERDAssociation;
import org.jkiss.dbeaver.ext.erd.model.ERDEntity;
import org.jkiss.dbeaver.ext.erd.model.ERDEntityAttribute;
import org.jkiss.dbeaver.ext.erd.model.EntityDiagram;
import org.jkiss.dbeaver.ext.erd.part.AssociationPart;
import org.jkiss.dbeaver.ext.erd.part.DiagramPart;
import org.jkiss.dbeaver.ext.erd.part.EntityPart;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
......@@ -72,6 +74,12 @@ public class ERDExportGraphML
xml.addAttribute("yfiles.type", "nodegraphics");
xml.endElement();
xml.startElement("key");
xml.addAttribute("for", "edge");
xml.addAttribute("id", "edgegraph");
xml.addAttribute("yfiles.type", "edgegraphics");
xml.endElement();
xml.startElement("graph");
xml.addAttribute("edgedefault", "directed");
xml.addAttribute("id", "G");
......@@ -90,6 +98,7 @@ public class ERDExportGraphML
// Graph data
xml.startElement("data");
xml.addAttribute("key", "nodegraph");
{
// Generic node
EntityPart part = diagramPart.getEntityPart(entity);
......@@ -194,17 +203,6 @@ public class ERDExportGraphML
xml.endElement();
xml.endElement();
// <y:NodeLabel alignment="left" autoSizePolicy="content" configuration="com.yworks.entityRelationship.label.attributes" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="48.103515625" modelName="custom" textColor="#000000" visible="true" width="57.3671875" x="2.0" y="30.701171875">attribute 1
// attribute 2
// attribute 3<y:LabelModel>
// <y:ErdAttributesNodeLabelModel/>
// </y:LabelModel>
// <y:ModelParameter>
// <y:ErdAttributesNodeLabelModelParameter/>
// </y:ModelParameter>
// </y:NodeLabel>
}
xml.endElement();
......@@ -218,7 +216,14 @@ public class ERDExportGraphML
int edgeNum = 0;
for (ERDEntity entity : diagram.getEntities()) {
EntityPart entityPart = diagramPart.getEntityPart(entity);
for (ERDAssociation association : entity.getForeignKeyRelationships()) {
AssociationPart associationPart = entityPart.getConnectionPart(association, true);
if (associationPart == null) {
log.debug("Association part not found");
continue;
}
edgeNum++;
String edgeId = "e" + edgeNum;
......@@ -226,6 +231,35 @@ public class ERDExportGraphML
xml.addAttribute("id", edgeId);
xml.addAttribute("source", entityMap.get(entity));
xml.addAttribute("target", entityMap.get(association.getPrimaryKeyEntity()));
xml.startElement("data");
xml.addAttribute("key", "edgegraph");
xml.startElement("y:PolyLineEdge");
xml.startElement("y:Path");// sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
for (Bendpoint bp : associationPart.getBendpoints()) {
xml.startElement("y:Point");
xml.addAttribute("x", bp.getLocation().x);
xml.addAttribute("y", bp.getLocation().x);
xml.endElement();
}
xml.endElement();
xml.startElement("y:LineStyle");
xml.addAttribute("color", "#000000");
xml.addAttribute("type", !association.isIdentifying() || association.isLogical() ? "dashed" : "line");
xml.addAttribute("width", "1.0");
xml.endElement();
xml.startElement("y:Arrows");
String sourceStyle = !association.isIdentifying() ? "white_diamond" : "none";
xml.addAttribute("source", sourceStyle);
xml.addAttribute("target", "circle");
xml.endElement();
xml.startElement("y:BendStyle");
xml.addAttribute("smoothed", "false");
xml.endElement();
xml.endElement();
xml.endElement();
xml.endElement();
}
}
......
......@@ -22,6 +22,9 @@ package org.jkiss.dbeaver.ext.erd.model;
import org.eclipse.draw2d.geometry.Point;
import org.jkiss.code.NotNull;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSEntityAssociation;
import java.util.List;
......@@ -37,6 +40,7 @@ public class ERDAssociation extends ERDObject<DBSEntityAssociation>
private ERDEntity primaryKeyEntity;
private ERDEntity foreignKeyEntity;
private List<Point> initBends;
private Boolean identifying;
/**
* Constructor for logical association
......@@ -117,6 +121,18 @@ public class ERDAssociation extends ERDObject<DBSEntityAssociation>
this.initBends = bends;
}
public boolean isIdentifying() {
if (identifying == null) {
identifying = false;
try {
identifying = DBUtils.isIdentifyingAssociation(VoidProgressMonitor.INSTANCE, getObject());
} catch (DBException e) {
log.debug(e);
}
}
return identifying;
}
@Override
public String toString()
{
......
......@@ -20,7 +20,6 @@
*/
package org.jkiss.dbeaver.ext.erd.part;
import org.jkiss.dbeaver.Log;
import org.eclipse.draw2d.*;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
......@@ -31,17 +30,16 @@ import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.ext.erd.model.ERDAssociation;
import org.jkiss.dbeaver.ext.erd.policy.AssociationBendEditPolicy;
import org.jkiss.dbeaver.ext.erd.policy.AssociationEditPolicy;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.model.DBUtils;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.struct.DBSEntityAssociation;
import org.jkiss.dbeaver.model.struct.DBSEntityAttribute;
import org.jkiss.dbeaver.model.struct.DBSEntityConstraintType;
import org.jkiss.dbeaver.model.struct.DBSEntityReferrer;
import org.jkiss.dbeaver.model.runtime.VoidProgressMonitor;
import org.jkiss.dbeaver.model.DBIcon;
import org.jkiss.dbeaver.ui.DBeaverIcons;
import org.jkiss.utils.CommonUtils;
......@@ -53,7 +51,6 @@ import java.util.*;
* @author Serge Rieder
*/
public class AssociationPart extends PropertyAwareConnectionPart {
static final Log log = Log.getLog(AssociationPart.class);
public AssociationPart()
{
......@@ -88,13 +85,6 @@ public class AssociationPart extends PropertyAwareConnectionPart {
protected IFigure createFigure() {
ERDAssociation association = (ERDAssociation) getModel();
boolean identifying = false;
try {
identifying = DBUtils.isIdentifyingAssociation(VoidProgressMonitor.INSTANCE, association.getObject());
} catch (DBException e) {
log.debug(e);
}
PolylineConnection conn = (PolylineConnection) super.createFigure();
//conn.setLineJoin(SWT.JOIN_ROUND);
//conn.setConnectionRouter(new BendpointConnectionRouter());
......@@ -115,7 +105,7 @@ public class AssociationPart extends PropertyAwareConnectionPart {
targetDecor.setBackgroundColor(getParent().getViewer().getControl().getForeground());
//dec.setBackgroundColor(getParent().getViewer().getControl().getBackground());
conn.setTargetDecoration(targetDecor);
if (!identifying) {
if (!association.isIdentifying()) {
final RhombusDecoration sourceDecor = new RhombusDecoration();
sourceDecor.setBackgroundColor(getParent().getViewer().getControl().getBackground());
//dec.setBackgroundColor(getParent().getViewer().getControl().getBackground());
......@@ -123,7 +113,7 @@ public class AssociationPart extends PropertyAwareConnectionPart {
}
}
if (!identifying || association.isLogical()) {
if (!association.isIdentifying() || association.isLogical()) {
conn.setLineStyle(SWT.LINE_CUSTOM);
conn.setLineDash(new float[] {5} );
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册