Hi,
I want to block “movable” feature of the swimLane element. SwimLane is inside element Pool.
The user can move only the Pool.
I have strange behavior. View image below.
This is code:
var swimLanesGroupTemplate =
GoLib(go.Group, “Spot”, swimLanesStyle(),
{
name: “Lane”,
contextMenu: laneEventMenu,
minLocation: new go.Point(NaN, -Infinity), // only allow vertical movement
maxLocation: new go.Point(NaN, Infinity),
selectionObjectName: “SHAPE”, // selecting a lane causes the body of the lane to be highlit, not the label
resizable: true, resizeObjectName: “SHAPE”, // the custom resizeAdornmentTemplate only permits two kinds of resizing
layout: GoLib(go.LayeredDigraphLayout, // automatically lay out the lane’s subgraph
{
isInitial: false, // don’t even do initial layout
isOngoing: false, // don’t invalidate layout when nodes or links are added or removed
direction: 0,
columnSpacing: 10,
layeringOption: go.LayeredDigraphLayout.LayerLongestPathSource
}),
computesBoundsAfterDrag: true, // needed to prevent recomputing Group.placeholder bounds too soon
computesBoundsIncludingLinks: false, // to reduce occurrences of links going briefly outside the lane
computesBoundsIncludingLocation: true, // to support empty space at top-left corner of lane
handlesDragDropForMembers: true, // don’t need to define handlers on member Nodes and Links
mouseDrop: function (e, grp) { // dropping a copy of some Nodes and Links onto this Group adds them to this Group
// don't allow drag-and-dropping a mix of regular Nodes and Groups
if (!e.diagram.selection.any(function (n) { return (n instanceof go.Group && n.category !== "subprocess") || n.category === "privateProcess"; })) {
var ok = grp.addMembers(grp.diagram.selection, true);
if (ok) {
updateCrossLaneLinks(grp);
relayoutDiagram();
} else {
grp.diagram.currentTool.doCancel();
}
}
},
subGraphExpandedChanged: function (grp) {
var shp = grp.resizeObject;
if (grp.diagram.undoManager.isUndoingRedoing) return;
if (grp.isSubGraphExpanded) {
shp.height = grp._savedBreadth;
} else {
grp._savedBreadth = shp.height;
shp.height = NaN;
}
updateCrossLaneLinks(grp);
}
},
GoLib(go.Shape, "Rectangle", // this is the resized object
{name: "SHAPE", fill: "transparent", /*stroke: null */
stroke: "black"
}, // need stroke null here or you gray out some of pool border.
new go.Binding("fill", "color"),
new go.Binding("desiredSize", "size", go.Size.parse).makeTwoWay(go.Size.stringify)),
// the lane header consisting of a Shape and a TextBlock
GoLib(go.Panel, "Horizontal",
{
name: "HEADER",
angle: 270, // maybe rotate the header to read sideways going up
alignment: go.Spot.LeftCenter, alignmentFocus: go.Spot.LeftCenter
},
GoLib(go.TextBlock, // the lane label
{editable: true, margin: new go.Margin(2, 0, 0, 8) },
new go.Binding("visible", "isSubGraphExpanded").ofObject(),
new go.Binding("text", "text").makeTwoWay()),
GoLib("SubGraphExpanderButton", { margin: 4, angle: -270 }) // but this remains always visible!
), // end Horizontal Panel
GoLib(go.Placeholder,
{ padding: 12, alignment: go.Spot.TopLeft, alignmentFocus: go.Spot.TopLeft }),
GoLib(go.Panel, "Horizontal", { alignment: go.Spot.TopLeft, alignmentFocus: go.Spot.TopLeft },
GoLib(go.TextBlock, // this TextBlock is only seen when the swimlane is collapsed
{
name: "LABEL",
editable: true, visible: false,
angle: 0, margin: new go.Margin(6, 0, 0, 20)
},
new go.Binding("visible", "isSubGraphExpanded", function (e) { return !e; }).ofObject(),
new go.Binding("text", "text").makeTwoWay())
)
); // end swimLanesGroupTemplate
function swimLanesStyle() { // common settings for both Lane
return [
{
layerName: "Background", // all pools and lanes are always behind all nodes and links
background: "transparent", // can grab anywhere in bounds
movable: false, // allows users to re-order by dragging
copyable: false, // can't copy lanes or pools
avoidable: false // don't impede AvoidsNodes routed Links
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify)
];
}
var poolGroupTemplate =
GoLib(go.Group, "Auto", groupStyle(),
{ // use a simple layout that ignores links to stack the "lane" Groups on top of each other
layout: GoLib(PoolLayout, { spacing: new go.Size(0, 0) }) // no space between lanes
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
GoLib(go.Shape,
{ fill: "transparent" },
new go.Binding("fill", "color")),
GoLib(go.Panel, "Table",
{ defaultColumnSeparatorStroke: "black" },
GoLib(go.Panel, "Horizontal",
{ column: 0, angle: 270 },
GoLib(go.TextBlock,
{ editable: true, margin: new go.Margin(5, 0, 5, 0) }, // margin matches private process (black box pool)
new go.Binding("text").makeTwoWay())
),
GoLib(go.Placeholder,
{ background: "transparent", column: 1 })
)
); // end poolGroupTemplate
function groupStyle() { // common settings for both Lane and Pool Groups
return [
{
layerName: "Background", // all pools and lanes are always behind all nodes and links
background: "transparent", // can grab anywhere in bounds
movable: true, // allows users to re-order by dragging
copyable: false, // can't copy lanes or pools
avoidable: false // don't impede AvoidsNodes routed Links
},
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify)
];
}