From 75445f3c7aacbea0fb8c18b2f54c06d6d7707843 Mon Sep 17 00:00:00 2001 From: jurgen Date: Thu, 20 Aug 2015 22:03:33 +0000 Subject: [PATCH] GraphML format support --- .../ext/erd/editor/ERDExportGraphML.java | 24 +++++++++---------- .../ext/erd/figures/AttributeListFigure.java | 13 ++++++++++ .../dbeaver/ext/erd/figures/EntityFigure.java | 4 ++++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDExportGraphML.java b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDExportGraphML.java index cf1d801cc5..3ae2566488 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDExportGraphML.java +++ b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/editor/ERDExportGraphML.java @@ -20,7 +20,6 @@ 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; import org.jkiss.dbeaver.Log; import org.jkiss.dbeaver.ext.erd.figures.AttributeListFigure; import org.jkiss.dbeaver.ext.erd.figures.EntityFigure; @@ -101,9 +100,9 @@ public class ERDExportGraphML { // Generic node - EntityPart part = diagramPart.getEntityPart(entity); - EntityFigure figure = (EntityFigure) part.getFigure(); - Rectangle partBounds = part.getBounds(); + EntityPart entityPart = diagramPart.getEntityPart(entity); + EntityFigure entityFigure = (EntityFigure) entityPart.getFigure(); + Rectangle partBounds = entityPart.getBounds(); xml.startElement("y:GenericNode"); xml.addAttribute("configuration", "com.yworks.entityRelationship.big_entity"); @@ -117,21 +116,21 @@ public class ERDExportGraphML // Fill xml.startElement("y:Fill"); - xml.addAttribute("color", getHtmlColor(figure.getBackgroundColor())); + xml.addAttribute("color", getHtmlColor(entityFigure.getBackgroundColor())); //xml.addAttribute("color2", partBounds.width); xml.addAttribute("transparent", "false"); xml.endElement(); // Border xml.startElement("y:BorderStyle"); - xml.addAttribute("color", getHtmlColor(figure.getForegroundColor())); + xml.addAttribute("color", getHtmlColor(entityFigure.getForegroundColor())); xml.addAttribute("type", "line"); xml.addAttribute("width", "1.0"); xml.endElement(); { // Entity Name - Rectangle nameBounds = figure.getNameLabel().getBounds(); + Rectangle nameBounds = entityFigure.getNameLabel().getBounds(); xml.startElement("y:NodeLabel"); xml.addAttribute("alignment", "center"); @@ -143,8 +142,8 @@ public class ERDExportGraphML xml.addAttribute("hasLineColor", "false"); xml.addAttribute("modelName", "internal"); xml.addAttribute("modelPosition", "t"); - xml.addAttribute("backgroundColor", getHtmlColor(figure.getNameLabel().getBackgroundColor())); - xml.addAttribute("textColor", getHtmlColor(figure.getNameLabel().getForegroundColor())); + xml.addAttribute("backgroundColor", getHtmlColor(entityFigure.getNameLabel().getBackgroundColor())); + xml.addAttribute("textColor", getHtmlColor(entityFigure.getNameLabel().getForegroundColor())); xml.addAttribute("visible", "true"); xml.addAttribute("height", nameBounds.height()); @@ -159,9 +158,8 @@ public class ERDExportGraphML { // Attributes - AttributeListFigure columnsFigure = figure.getColumnsFigure(); + AttributeListFigure columnsFigure = entityFigure.getColumnsFigure(); Rectangle attrsBounds = columnsFigure.getBounds(); - FontData attrsFont = columnsFigure.getFont().getFontData()[0]; xml.startElement("y:NodeLabel"); xml.addAttribute("alignment", "left"); @@ -173,8 +171,8 @@ public class ERDExportGraphML xml.addAttribute("hasLineColor", "false"); xml.addAttribute("modelName", "custom"); xml.addAttribute("modelPosition", "t"); - xml.addAttribute("backgroundColor", getHtmlColor(figure.getNameLabel().getBackgroundColor())); - xml.addAttribute("textColor", getHtmlColor(figure.getNameLabel().getForegroundColor())); + xml.addAttribute("backgroundColor", getHtmlColor(columnsFigure.getBackgroundColor())); + xml.addAttribute("textColor", getHtmlColor(columnsFigure.getForegroundColor())); xml.addAttribute("visible", "true"); xml.addAttribute("height", attrsBounds.height()); diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/AttributeListFigure.java b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/AttributeListFigure.java index 539f6020cf..d8c22de5f0 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/AttributeListFigure.java +++ b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/AttributeListFigure.java @@ -27,6 +27,9 @@ import org.eclipse.ui.PlatformUI; import org.jkiss.dbeaver.ext.erd.ERDConstants; import org.jkiss.dbeaver.ext.erd.model.ERDEntity; +import java.util.ArrayList; +import java.util.List; + /** * Figure used to hold the column labels * @author Serge Rieder @@ -54,6 +57,16 @@ public class AttributeListFigure extends Figure setOpaque(true); } + public List getAttributes() { + List result = new ArrayList(); + for (Object child : getChildren()) { + if (child instanceof AttributeItemFigure) { + result.add((AttributeItemFigure) child); + } + } + return result; + } + class ColumnFigureBorder extends AbstractBorder { diff --git a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java index 76d967ae10..6b806bfcd9 100644 --- a/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java +++ b/plugins/org.jkiss.dbeaver.ext.erd/src/org/jkiss/dbeaver/ext/erd/figures/EntityFigure.java @@ -105,6 +105,10 @@ public class EntityFigure extends Figure { return nameLabel; } + public AttributeListFigure getKeyFigure() { + return keyFigure; + } + /** * @return the figure containing the column lables */ -- GitLab