Author: dazarov
Date: 2007-07-26 07:15:48 -0400 (Thu, 26 Jul 2007)
New Revision: 2672
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
10:55:00 UTC (rev 2671)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/ModelElement.java 2007-07-26
11:15:48 UTC (rev 2672)
@@ -63,6 +63,26 @@
return null;
}
+ public ExpandeableShape getExtendeableShape(){
+ ModelElement element = this;
+ while(true){
+ if(element.getParent() == null)break;
+ if(element.getParent() instanceof ExpandeableShape) return
(ExpandeableShape)element.getParent();
+ element = element.getParent();
+ }
+ return null;
+ }
+
+ public OrmShape getOrmShape(){
+ ModelElement element = this;
+ while(true){
+ if(element.getParent() == null)break;
+ if(element.getParent() instanceof OrmShape) return (OrmShape)element.getParent();
+ element = element.getParent();
+ }
+ return null;
+ }
+
class OList extends ArrayList{
public OList(){
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
10:55:00 UTC (rev 2671)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/parts/ExpandeableShapeEditPart.java 2007-07-26
11:15:48 UTC (rev 2672)
@@ -14,6 +14,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
@@ -69,7 +70,6 @@
((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());
((TitleLabel)getFigure()).setHidden(!((ExpandeableShape)getCastedModel()).isReferenceVisible());
@@ -137,13 +137,16 @@
private void setLinksVisible(OrmEditPart editPart, boolean flag){
ConnectionEditPart link;
OrmEditPart child;
+
for(int i=0;i<editPart.getSourceConnections().size();i++){
link = (ConnectionEditPart)editPart.getSourceConnections().get(i);
- link.getFigure().setVisible(flag);
+ if(isLinkCanBeVisible(link, flag))
+ link.getFigure().setVisible(flag);
}
for(int i=0;i<editPart.getTargetConnections().size();i++){
link = (ConnectionEditPart)editPart.getTargetConnections().get(i);
- link.getFigure().setVisible(flag);
+ if(isLinkCanBeVisible(link, flag))
+ link.getFigure().setVisible(flag);
}
for(int i=0;i<editPart.getChildren().size();i++){
child = (OrmEditPart)editPart.getChildren().get(i);
@@ -151,6 +154,32 @@
}
}
+ private boolean isLinkCanBeVisible(ConnectionEditPart link, boolean visible){
+ if(!visible) return true;
+ if(!((OrmEditPart)link.getSource()).getFigure().isVisible()) return false;
+ if(!((OrmEditPart)link.getTarget()).getFigure().isVisible()) return false;
+ if(!validateShape((Shape)((OrmEditPart)link.getSource()).getModel())) return false;
+ if(!validateShape((Shape)((OrmEditPart)link.getTarget()).getModel())) return false;
+ return true;
+ }
+
+ private boolean validateShape(Shape shape){
+ if(!shape.getClass().equals(OrmShape.class)){
+ OrmShape ormShape = shape.getOrmShape();
+ if(ormShape != null){
+ if(ormShape.isHiden()) return false;
+ }
+ }
+ ExpandeableShape expanableShape = shape.getExtendeableShape();
+ if(expanableShape != null && !shape.equals(expanableShape) &&
!expanableShape.getClass().equals(OrmShape.class)){
+ if(!expanableShape.isReferenceVisible()) return false;
+ }
+
+
+ return true;
+ }
+
+
protected List getModelChildren() {
return ((ExpandeableShape)getModel()).getChildren();
}