oldVertexList = new ArrayList<Vertex>(vertexList);
}
final Set<BlockDevInfo> blockDevInfos = host.getBrowser().getSortedBlockDevInfos();
if (oldVertexList != null) {
for (final Vertex vertex : oldVertexList) {
final BlockDevInfo bdi = (BlockDevInfo) getInfo(vertex);
if (bdi == null) {
continue;
}
if (!blockDevInfos.contains(bdi)) {
/* removing */
final Vertex bdv = bdiToVertexMap.get(bdi);
final VolumeInfo dvi = bdi.getDrbdVolumeInfo();
if (dvi != null) {
removeDrbdVolume(dvi);
dvi.getDrbdResourceInfo().removeDrbdVolumeFromHashes(dvi);
}
application.invokeLater(new Runnable() {
@Override
public void run() {
lockGraph();
getGraph().removeVertex(bdv);
unlockGraph();
}
});
removeInfo(bdv);
removeVertex(bdi);
getVertexToMenus().remove(bdv);
bdiToVertexMap.remove(bdi);
blockDeviceToVertexMap.remove(bdi.getBlockDevice());
vertexToHostMap.remove(bdv);
vertexList.remove(bdv);
somethingChanged();
}
}
}
BlockDevInfo prevBdi = null;
for (final BlockDevInfo bdi : blockDevInfos) {
stopAnimation(bdi);
Vertex bdv = null;
if (!blockDeviceToVertexMap.containsKey(bdi.getBlockDevice())) {
bdv = new Vertex();
somethingChanged();
bdiToVertexMap.put(bdi, bdv);
blockDeviceToVertexMap.put(bdi.getBlockDevice(), bdv);
putVertexToInfo(bdv, bdi);
putInfoToVertex(bdi, bdv);
vertexToHostMap.put(bdv, hostDrbdInfo);
vertexList.add(bdv);
// TODO: get saved position is disabled at the moment,
// because it does more harm than good at the moment.
}
if (bdv == null) {
bdv = blockDeviceToVertexMap.get(bdi.getBlockDevice());
}
if (prevBdi != null
&& bdi.getBlockDevice().isVolumeGroupOnPhysicalVolume()
&& bdi.getBlockDevice().getVgOnPhysicalVolume().equals(
prevBdi.getBlockDevice().getVgOnPhysicalVolume())) {
devYPos -= 8;
} else if (prevBdi != null
&& (!bdi.getBlockDevice().isDrbd() || !prevBdi.getBlockDevice().isDrbd())) {
devYPos -= 4;
} else if (prevBdi != null
&& bdi.getBlockDevice().isDrbd()
&& prevBdi.getBlockDevice().isDrbd()
&& bdi.getDrbdVolumeInfo().getDrbdResourceInfo()
== prevBdi.getDrbdVolumeInfo().getDrbdResourceInfo()) {
devYPos -= 6;
}
final Point2D pos = new Point2D.Double(hostXPos + BD_X_OFFSET + VERTEX_SIZE_BD / 2, devYPos);
devYPos += BD_STEP_Y;
getVertexLocations().put(bdv, pos);