Skip to content

Commit

Permalink
Fix child object x,y set to 0,0 when dragged out of parent onto diagram
Browse files Browse the repository at this point in the history
* If a child object is dragged out of its parent into a new parent we want to ensure a minimum x,y of 0,0
* But we don't want to do this if the parent is the diagram itself
* This is because a diagram cna have negative space
  • Loading branch information
Phillipus committed Jun 11, 2019
1 parent c7b6127 commit 12fdae7
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.archimatetool.editor.diagram.commands.SetConstraintObjectCommand;
import com.archimatetool.editor.diagram.editparts.IConstrainedSizeEditPart;
import com.archimatetool.editor.diagram.editparts.INonResizableEditPart;
import com.archimatetool.model.IDiagramModel;
import com.archimatetool.model.IDiagramModelContainer;
import com.archimatetool.model.IDiagramModelObject;
import com.archimatetool.model.ILockable;
Expand Down Expand Up @@ -111,13 +112,17 @@ protected AddObjectCommand createAddCommand(ChangeBoundsRequest request, EditPar
IDiagramModelContainer parent = (IDiagramModelContainer)getHost().getModel();
IDiagramModelObject child = (IDiagramModelObject)childEditPart.getModel();

// Keep within box
Rectangle bounds = (Rectangle)constraint;
if(bounds.x < 0) {
bounds.x = 0;
}
if(bounds.y < 0) {
bounds.y = 0;

// Keep within the parent box
// Fixed 2019-06-11 to check that the parent is not a diagram model (which can have negative space)
if(!(parent instanceof IDiagramModel)) {
if(bounds.x < 0) {
bounds.x = 0;
}
if(bounds.y < 0) {
bounds.y = 0;
}
}

return new AddObjectCommand(parent, child, bounds);
Expand Down

0 comments on commit 12fdae7

Please sign in to comment.