Commit 1a1ff57f authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

fix(diagram) fix pool resize (#1569)

Closes BS-19297
parent bfd9cd07
......@@ -94,7 +94,6 @@ public class UpdatePoolSizeCommand extends AbstractTransactionalCommand {
setRequest1.setResizeDirection(PositionConstants.NORTH);
setRequest1.setSizeDelta(new Dimension(0,-150));
gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
for(Object o : gep.getChildren()){
if(o instanceof CustomPoolCompartmentEditPart){
for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
......@@ -114,7 +113,6 @@ public class UpdatePoolSizeCommand extends AbstractTransactionalCommand {
setRequest1.setResizeDirection(PositionConstants.SOUTH);
setRequest1.setSizeDelta(new Dimension(0,150));
gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
for(Object o : gep.getChildren()){
if(o instanceof CustomPoolCompartmentEditPart){
for(CustomLaneEditPart lane : ((CustomPoolCompartmentEditPart)o).getPoolLanes()){
......@@ -135,13 +133,11 @@ public class UpdatePoolSizeCommand extends AbstractTransactionalCommand {
epToMove.add(lane);
}
}
}
setRequest1.setEditParts(epToMove);
setRequest1.setResizeDirection(PositionConstants.EAST);
setRequest1.setSizeDelta(new Dimension(-150,0));
if(gep.getFigure().getSize().width > gep.getFigure().getMinimumSize().width ){
if(gep.getFigure().getSize().width - 150 > gep.getFigure().getMinimumSize().width ){
gep.getDiagramEditDomain().getDiagramCommandStack().execute(gep.getCommand(setRequest1));
for(Object o : gep.getChildren()){
if(o instanceof CustomPoolCompartmentEditPart){
......
......@@ -168,12 +168,6 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
hideSelection();
layer = getLayer(LayerConstants.HANDLE_LAYER);
/*
* need to flush in order to have the new correct size of the host
* figure
*/
// poolEditPart.getViewer().flush();
//FIXME
Rectangle ref = sourceFigure.getBounds();
if (ref.x == 0 && ref.y == 0 && ref.height == 0 && ref.width == 0) {
......@@ -205,7 +199,6 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
result = ((AbstractConnectionEditPart) host).getSource();
}
EditPart tempEditPart = result;
/*first search for a CustomLaneEditPart*/
while(!(result instanceof CustomPoolEditPart) && result != null){
result = result.getParent() ;
......@@ -231,7 +224,7 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
Rectangle ref = sourceFigure.getBounds();
IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
f.setSize(20, 20);
f.setLocation(ref.getRight().translate(10, -20));
f.setLocation(ref.getRight().getCopy().translate(10, -20));
f.getBounds().performScale(zoom) ;
f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_RIGHT));
layer.add(f);
......@@ -253,7 +246,7 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
Rectangle ref = sourceFigure.getBounds();
IFigure f = new ImageFigure(Pics.getImage(PicsConstants.plusBlack));
f.setSize(20, 20);
f.setLocation(ref.getBottom().translate(20, 0));
f.setLocation(ref.getBottom().getCopy().translate(20, 0));
f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM));
f.getBounds().performScale(zoom);
layer.add(f);
......@@ -274,7 +267,7 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
Rectangle ref = sourceFigure.getBounds();
IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
f.setSize(20, 20);
f.setLocation(ref.getBottom().translate(20, -20));
f.setLocation(ref.getBottom().getCopy().translate(20, -20));
f.getBounds().performScale(zoom);
f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_BOTTOM));
layer.add(f);
......@@ -298,7 +291,7 @@ public class UpdateSizePoolSelectionEditPolicy extends SelectionEditPolicy imple
Rectangle ref = sourceFigure.getBounds();
IFigure f = new ImageFigure(Pics.getImage(PicsConstants.minusBlack));
f.setSize(20, 20);
f.setLocation(ref.getLeft().translate(-25, -10));
f.setLocation(ref.getLeft().getCopy().translate(-25, -10));
f.addMouseListener(new MouseListenerForSpan(UpdateSizePoolSelectionEditPolicy.REMOVE_RIGHT));
f.getBounds().performScale(zoom);
......
......@@ -81,9 +81,7 @@ public class CustomLaneEditPart extends LaneEditPart {
@Override
protected NodeFigure createNodePlate() {
final NodeFigure figure = new DefaultSizeNodeFigure(getMapMode().DPtoLP(975), getMapMode().DPtoLP(100));
figure.setMinimumSize(new Dimension(975, 100));
return figure;
return new DefaultSizeNodeFigure(getMapMode().DPtoLP(975), getMapMode().DPtoLP(100));
}
@Override
......@@ -202,7 +200,7 @@ public class CustomLaneEditPart extends LaneEditPart {
}
final CustomPoolEditPart parent = (CustomPoolEditPart) getParent().getParent();
int width = parent.getFigure().getSize().width;
int width = parent.getCurrentSize().width;
int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue();
if (height == -1) {
......@@ -345,7 +343,7 @@ public class CustomLaneEditPart extends LaneEditPart {
setBackgroundColor(THIS_BACK);
this.setPreferredSize(new Dimension(getMapMode().DPtoLP(975),
getMapMode().DPtoLP(100)));
setMinimumSize(new Dimension(getMapMode().DPtoLP(975),
setMinimumSize(new Dimension(-1,
getMapMode().DPtoLP(100)));
createContents();
}
......
......@@ -35,6 +35,8 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx;
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.swt.graphics.Color;
......@@ -71,8 +73,10 @@ public class CustomPoolEditPart extends PoolEditPart {
* @return the defaultWidth
*/
public int getDefaultWidth() {
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() != null) {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getClientArea().width - CONSTANT_RIGHT_MARGIN;
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
&& PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell() != null) {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getClientArea().width
- CONSTANT_RIGHT_MARGIN;
} else {
return MIN_POOL_WIDTH;
}
......@@ -189,6 +193,13 @@ public class CustomPoolEditPart extends PoolEditPart {
return primaryShape = figure;
}
@Override
protected NodeFigure createNodePlate() {
NodeFigure nodeFigure = new DefaultSizeNodeFigure(new Dimension(-1, 100));
nodeFigure.setMinimumSize(new Dimension(-1, 100));
return nodeFigure;
}
public class CustomPoolFigure extends PoolFigure {
/**
......@@ -205,7 +216,6 @@ public class CustomPoolEditPart extends PoolEditPart {
* @generated
*/
public CustomPoolFigure() {
final GridLayout layoutThis = new GridLayout();
layoutThis.numColumns = 2;
layoutThis.makeColumnsEqualWidth = false;
......@@ -222,7 +232,7 @@ public class CustomPoolEditPart extends PoolEditPart {
getMapMode().DPtoLP(getDefaultHeight()));
this.setSize(defaultSize);
this.setPreferredSize(defaultSize);
setMinimumSize(new Dimension(getMapMode().DPtoLP(MIN_POOL_WIDTH), getMapMode().DPtoLP(100)));
setMinimumSize(new Dimension(MIN_POOL_WIDTH, getMapMode().DPtoLP(100)));
currentSize = new Dimension(defaultSize);
setLocation(new Point(20, 20));
createContents();
......@@ -422,7 +432,8 @@ public class CustomPoolEditPart extends PoolEditPart {
super.setFont(fontData);
if (fontData != null && ((Element) resolveSemanticElement()).getName() != null) {
final Font font = new Font(Display.getCurrent(), fontData);
final int height = FigureUtilities.getStringExtents(((Element) resolveSemanticElement()).getName(), font).height;
final int height = FigureUtilities.getStringExtents(((Element) resolveSemanticElement()).getName(),
font).height;
font.dispose();
((CustomPoolFigure) getContentPane()).getLabelGridData().widthHint = height + 2;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment