Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-10-18 12:28:31 -0400
committerChristopher Frost2012-10-18 12:28:31 -0400
commit6772e3a093b2eaed369f7b704e41e91c73e8b386 (patch)
treeaff12db30cf6e5c6bac5fa78ee430dadbb0561fb
parent2c3d81c3a6216da96f830e0a2f3242de2f7a0606 (diff)
downloadorg.eclipse.virgo.kernel-6772e3a093b2eaed369f7b704e41e91c73e8b386.tar.gz
org.eclipse.virgo.kernel-6772e3a093b2eaed369f7b704e41e91c73e8b386.tar.xz
org.eclipse.virgo.kernel-6772e3a093b2eaed369f7b704e41e91c73e8b386.zip
392316 Wiring diagrams should centre both top and bottom rows of bundles
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js54
1 files changed, 45 insertions, 9 deletions
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js b/org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js
index 87c16c93..21357c4e 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js
@@ -98,14 +98,13 @@ var LayoutManager = function(bundleCanvas, width, height, dataSource){
$.each(bundle.rawBundle.RequiredWires, function(index, wire){
topRowBundleIds[wire.ProviderBundleId] = wire;
});
- var topWidth = self.renderBundleRow(topRowBundleIds, -239, 'top', bundle);
+ var topRowRenderResult = self.renderBundleRow(topRowBundleIds, -239, 'top', bundle);
var bottomRowBundleIds = {};
$.each(bundle.rawBundle.ProvidedWires, function(index, wire){
bottomRowBundleIds[wire.RequirerBundleId] = wire;
});
- var bottomWidth = self.renderBundleRow(bottomRowBundleIds, 239, 'bottom', bundle);
- var newWidth = topWidth < bottomWidth ? bottomWidth : topWidth;
- newWidth < self.minimumWidth ? self.paper.setSize(self.minimumWidth, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
+ var bottomRowRenderResult = self.renderBundleRow(bottomRowBundleIds, 239, 'bottom', bundle);
+ self.centerBundles(topRowRenderResult, bottomRowRenderResult);
};
self.renderServices = function(bundle){
@@ -113,26 +112,27 @@ var LayoutManager = function(bundleCanvas, width, height, dataSource){
$.each(bundle.rawBundle.ServicesInUse, function(index, service){
topRowBundleIds[service.BundleIdentifier] = {'service': service, 'consumerId': bundle.rawBundle.Identifier};
});
- var topWidth = self.renderBundleRow(topRowBundleIds, -239, 'top', bundle);
+ var topRowRenderResult = self.renderBundleRow(topRowBundleIds, -239, 'top', bundle);
var bottomRowBundleIds = {};
$.each(bundle.rawBundle.RegisteredServices, function(index, service){
$.each(service.UsingBundles, function(index, bundleId){
bottomRowBundleIds[bundleId] = {'service': service, 'consumerId': bundleId};
});
});
- var bottomWidth = self.renderBundleRow(bottomRowBundleIds, 239, 'bottom', bundle);
- var newWidth = topWidth < bottomWidth ? bottomWidth : topWidth;
- newWidth < self.minimumWidth ? self.paper.setSize(self.minimumWidth, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
+ var bottomRowRenderResult = self.renderBundleRow(bottomRowBundleIds, 239, 'bottom', bundle);
+ self.centerBundles(topRowRenderResult, bottomRowRenderResult);
};
self.renderBundleRow = function(bundleIds, offset, position, focusedBundle){
var yPos = (self.paper.height/2) + offset;
var xPos = this.bundleSpacing;
var focusedBundleId = focusedBundle.rawBundle.Identifier;
+ var renderedBundleIds = new Array();
$.each(bundleIds, function(bundleId, relationshipInfoData){
if(!self.bundles[bundleId]){
var bundle = new Bundle(self.paper, self.dataSource.bundles[bundleId], xPos, yPos, self.displayBundle, position, self.relationshipType, focusedBundle);
bundle.increaseCount(relationshipInfoData);
+ renderedBundleIds.push(bundleId);
self.bundles[bundleId] = bundle;
xPos = xPos + bundle.boxWidth + self.bundleSpacing;
}else if(focusedBundleId == bundleId){
@@ -148,11 +148,34 @@ var LayoutManager = function(bundleCanvas, width, height, dataSource){
}else{//bundle.state == 'hidden'
bundle.reset(xPos, yPos, position, self.relationshipType, focusedBundle);
bundle.increaseCount(relationshipInfoData);
+ renderedBundleIds.push(bundleId);
xPos = xPos + bundle.boxWidth + self.bundleSpacing;
}
}
});
- return xPos;
+ return {bundleIds: renderedBundleIds, width: xPos};
+ };
+
+ self.centerBundles = function(topRowRenderResult, bottomRowRenderResult){
+ var newWidth = topRowRenderResult.width < bottomRowRenderResult.width ? bottomRowRenderResult.width : topRowRenderResult.width;
+ if(newWidth < self.minimumWidth){
+ self.paper.setSize(self.minimumWidth, self.paper.height);
+ newWidth = self.minimumWidth;
+ }else{
+ self.paper.setSize(newWidth, self.paper.height);
+ }
+ if(topRowRenderResult.width < newWidth){
+ self.moveRow(topRowRenderResult.bundleIds, Math.round((newWidth-topRowRenderResult.width)/2));
+ }
+ if(bottomRowRenderResult.width < newWidth){
+ self.moveRow(bottomRowRenderResult.bundleIds, Math.round((newWidth-bottomRowRenderResult.width)/2));
+ }
+ };
+
+ self.moveRow = function(bundleIds, horizontalAdjustment){
+ $.each(bundleIds, function(index, bundleId){
+ self.bundles[bundleId].moveHorizontaly(horizontalAdjustment);
+ });
};
self.hideAll = function(){
@@ -280,6 +303,19 @@ var Bundle = function(paper, rawBundle, x, y, dblClickCallback, position, type,
self.state = 'waiting';
};
+ self.moveHorizontaly = function(horizontalAdjustment){
+ self.x = self.x + horizontalAdjustment;
+ self.text.attr({
+ 'x' : self.x + self.bundleMargin,
+ });
+ self.box.attr({
+ 'x' : self.x,
+ });
+ self.info.attr({
+ 'x' : self.x + (self.boxWidth - 1.5*self.bundleMargin),
+ });
+ };
+
self.increaseCount = function(relationshipInfoData) {
self.relationship.increaseCount(relationshipInfoData);
};

Back to the top