Author: dazarov
Date: 2007-07-27 05:41:56 -0400 (Fri, 27 Jul 2007)
New Revision: 2695
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ModelElement.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java
Log:
http://jira.jboss.com/jira/browse/EXIN-365
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ModelElement.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ModelElement.java 2007-07-26
22:52:48 UTC (rev 2694)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ModelElement.java 2007-07-27
09:41:56 UTC (rev 2695)
@@ -56,8 +56,8 @@
public OrmDiagram getOrmDiagram(){
ModelElement element = this;
while(true){
+ if(element instanceof OrmDiagram) return (OrmDiagram)element;
if(element.getParent() == null)break;
- if(element.getParent() instanceof OrmDiagram) return (OrmDiagram)element.getParent();
element = element.getParent();
}
return null;
@@ -66,6 +66,7 @@
public ExpandeableShape getExtendeableShape(){
ModelElement element = this;
while(true){
+ if(element instanceof ExpandeableShape) return (ExpandeableShape)element;
if(element.getParent() == null)break;
if(element.getParent() instanceof ExpandeableShape) return
(ExpandeableShape)element.getParent();
element = element.getParent();
@@ -76,8 +77,8 @@
public OrmShape getOrmShape(){
ModelElement element = this;
while(true){
+ if(element instanceof OrmShape) return (OrmShape)element;
if(element.getParent() == null)break;
- if(element.getParent() instanceof OrmShape) return (OrmShape)element.getParent();
element = element.getParent();
}
return null;
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java 2007-07-26
22:52:48 UTC (rev 2694)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java 2007-07-27
09:41:56 UTC (rev 2695)
@@ -28,6 +28,7 @@
import org.jboss.tools.hibernate.ui.veditor.editors.figures.TitleLabel;
import org.jboss.tools.hibernate.ui.veditor.editors.figures.TopLineBorder;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ComponentShape;
+import org.jboss.tools.hibernate.ui.veditor.editors.model.Connection;
import org.jboss.tools.hibernate.ui.veditor.editors.model.ExpandeableShape;
import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmDiagram;
import org.jboss.tools.hibernate.ui.veditor.editors.model.OrmShape;
@@ -70,8 +71,9 @@
((IFigure)getFigure().getChildren().get(0)).setForegroundColor(ResourceManager.getInstance().getColor(new
RGB(0,0,0)));
}
}else if (ExpandeableShape.SHOW_REFERENCES.equals(prop)) {
- referenceList.add((OrmShape)getCastedModel().getParent());
- refreshReference((ExpandeableShape)getCastedModel(),
((ExpandeableShape)getCastedModel()).isReferenceVisible());
+ //referenceList.add((OrmShape)getCastedModel().getParent());
+ //refreshReference((ExpandeableShape)getCastedModel(),
((ExpandeableShape)getCastedModel()).isReferenceVisible());
+ refreshReferences((Shape)getCastedModel(),
((ExpandeableShape)getCastedModel()).isReferenceVisible());
((TitleLabel)getFigure()).setHidden(!((ExpandeableShape)getCastedModel()).isReferenceVisible());
// ((IFigure)getFigure().getChildren().get(0)).setBackgroundColor(getSelectionColor());
// ((IFigure)getFigure().getChildren().get(0)).setForegroundColor(ResourceManager.getInstance().getColor(new
RGB(255,255,255)));
@@ -116,6 +118,39 @@
shape.getOrmDiagram().update();
}
+ protected void refreshReferences(Shape shape, boolean visible){
+ Connection link;
+ OrmShape refShape;
+
+ OrmEditPart shapePart = (OrmEditPart)getViewer().getEditPartRegistry().get(shape);
+
+ for(int i=0;i<shape.getSourceConnections().size();i++){
+ link = (Connection)shape.getSourceConnections().get(i);
+ refShape = (OrmShape)link.getTarget().getOrmShape();
+ if(refShape == null) continue;
+ if(!isReferencesCorrect(refShape)) continue;
+
+ OrmEditPart refPart = (OrmEditPart)getViewer().getEditPartRegistry().get(refShape);
+ if(refPart != null){
+ if(isShapeCanBeInvisible(shapePart, refPart, visible)){
+ refPart.getFigure().setVisible(visible);
+ setLinksVisible(refPart, visible);
+ }
+ }
+ referenceList.add(shape.getOrmShape());
+ refreshReferences(refShape, visible);
+ referenceList.remove(shape.getOrmShape());
+ }
+
+ referenceList.add(shape.getOrmShape());
+
+ for(int i=0;i<shape.getChildren().size();i++){
+ refreshReferences((Shape)shape.getChildren().get(i), visible);
+ }
+ referenceList.remove(shape.getOrmShape());
+ shape.getOrmDiagram().update();
+ }
+
private boolean isTableCanBeInvisible(OrmEditPart tablePart, boolean visible){
if(visible) return true;
ConnectionEditPart link;
@@ -126,6 +161,16 @@
return true;
}
+ private boolean isShapeCanBeInvisible(OrmEditPart source, OrmEditPart target, boolean
visible){
+ if(visible) return true;
+ ConnectionEditPart link;
+ for(int i=0;i<target.getTargetConnections().size();i++){
+ link = (ConnectionEditPart)target.getTargetConnections().get(i);
+ if(link.getFigure().isVisible() && link.getSource() != source) return false;
+ }
+ return true;
+ }
+
private boolean isReferencesCorrect(OrmShape shape){
if(shape == null) return false;
for(int i=0;i < referenceList.size();i++){