Author: mdryakhlenkov
Date: 2007-07-05 08:01:03 -0400 (Thu, 05 Jul 2007)
New Revision: 2311
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/ComponentFigure.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundLineBorder.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundPolylineConnection.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleFigure.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleLabel.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TopLineBorder.java
Log:
JBIDE-559: Hibernate diagram editor cleanup
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/ComponentFigure.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/ComponentFigure.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/ComponentFigure.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import java.util.List;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+
+public class ComponentFigure extends Figure {
+
+ private boolean childsHiden = false;
+
+ public void add(IFigure figure, Object constraint, int index) {
+ if(index != -1){
+ if(index == -2)
+ index = 0;
+ else
+ index++;
+ }
+ super.add(figure, constraint, index);
+ }
+
+ public List getChildren() {
+ if (childsHiden)
+ return super.getChildren().subList(0,1);
+ else
+ return super.getChildren();
+
+ }
+
+ public void setChildsHiden(boolean childsHiden) {
+ this.childsHiden = childsHiden;
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundLineBorder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundLineBorder.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundLineBorder.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.draw2d.geometry.Insets;
+
+public class RoundLineBorder extends LineBorder {
+ public void paint(IFigure figure, Graphics graphics, Insets insets) {
+ tempRect.setBounds(getPaintRectangle(figure, insets).resize(-1,-1));
+ if (getColor() != null)
+ graphics.setForegroundColor(getColor());
+ graphics.drawRoundRectangle(tempRect, 2, 2);
+ }
+}
\ No newline at end of file
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundPolylineConnection.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundPolylineConnection.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/RoundPolylineConnection.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+
+public class RoundPolylineConnection extends PolylineConnection {
+ protected void outlineShape(Graphics g) {
+ PointList points = getPoints();
+ Point point = points.getPoint(0);
+ Point beg = new Point();
+ Point end = new Point();
+ Point eCorner = new Point();
+ Point bCorner = new Point();
+ boolean horiz;
+ beg.x = point.x;
+ beg.y = point.y;
+
+ if (points.getFirstPoint().y == points.getLastPoint().y) {
+ super.outlineShape(g);
+ return;
+ }
+
+ for (int i = 1; i < points.size(); i++) {
+ point = points.getPoint(i);
+ end.x = point.x;
+ end.y = point.y;
+
+ if (beg.y == end.y)
+ horiz = true;
+ else
+ horiz = false;
+
+ eCorner.x = 0;
+ if (i != 1) {
+ if (horiz) {
+ if (end.x > beg.x) {
+ beg.x += 2;
+ } else {
+ beg.x -= 2;
+ }
+ } else {
+ if (end.y > beg.y) {
+ beg.y += 2;
+ } else {
+ beg.y -= 2;
+ }
+ }
+ eCorner.x = beg.x;
+ eCorner.y = beg.y;
+ }
+
+ if (bCorner.x != 0 && eCorner.x != 0)
+ g.drawLine(bCorner, eCorner);
+ bCorner.x = 0;
+
+ if (i != points.size() - 1) {
+ if (horiz) {
+ if (end.x > beg.x) {
+ end.x -= 2;
+ } else {
+ end.x += 2;
+ }
+ } else {
+ if (end.y > beg.y) {
+ end.y -= 2;
+ } else {
+ end.y += 2;
+ }
+ }
+ bCorner.x = end.x;
+ bCorner.y = end.y;
+ }
+
+ g.drawLine(beg, end);
+ point = points.getPoint(i);
+ beg.x = point.x;
+ beg.y = point.y;
+ }
+ }
+}
\ No newline at end of file
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleFigure.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleFigure.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleFigure.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import java.util.List;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+
+public class TitleFigure extends Figure {
+
+ private boolean hiden = false;
+
+ public void add(IFigure figure, Object constraint, int index) {
+ if(index != -1){
+ if(index == -2)
+ index = 0;
+ else
+ index++;
+ }
+ super.add(figure, constraint, index);
+ }
+
+ public List getChildren() {
+ if (hiden)
+ return super.getChildren().subList(0,1);
+ else
+ return super.getChildren();
+
+ }
+
+ public void setHiden(boolean hiden) {
+ this.hiden = hiden;
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleLabel.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleLabel.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TitleLabel.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.hibernate.ui.view.ViewPlugin;
+
+
+public class TitleLabel extends Label {
+
+ static Image shevronUp =
ViewPlugin.getImageDescriptor(ViewPlugin.BUNDLE_IMAGE.getString("VisualMapping.shevronUp")).createImage();
+ static Image shevronDown =
ViewPlugin.getImageDescriptor(ViewPlugin.BUNDLE_IMAGE.getString("VisualMapping.shevronDown")).createImage();
+
+ protected boolean hiden = false;
+
+
+ protected Dimension calculateLabelSize(Dimension txtSize) {
+ Dimension p = super.calculateLabelSize(txtSize).getCopy();
+ p.width+=40;
+ return p;
+ }
+
+ protected void paintFigure(Graphics graphics) {
+ super.paintFigure(graphics);
+ if(hiden)
+ graphics.drawImage(shevronDown, getBounds().x+getBounds().width-20, getBounds().y);
+ else
+ graphics.drawImage(shevronUp, getBounds().x+getBounds().width-20, getBounds().y);
+ }
+
+ public void setHiden(boolean hiden) {
+ this.hiden = hiden;
+ }
+}
Added:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TopLineBorder.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TopLineBorder.java
(rev 0)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/figures/TopLineBorder.java 2007-07-05
12:01:03 UTC (rev 2311)
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.hibernate.ui.veditor.editors.figures;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+
+public class TopLineBorder extends MarginBorder {
+
+ private Color color;
+
+ public Color getColor() {
+ return color;
+ }
+
+ public void setColor(Color color) {
+ this.color = color;
+ }
+
+ public TopLineBorder(int t, int l, int b, int r) {
+ super(t+1, l, b, r);
+ }
+
+ public void paint(IFigure figure, Graphics graphics, Insets insets) {
+ Rectangle r = getPaintRectangle(figure, insets);
+ if (getColor() != null)
+ graphics.setForegroundColor(getColor());
+ graphics.drawLine(r.x, r.y, r.right(), r.y);
+ }
+
+}