Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-10-03 13:32:19 -0400
committerChristopher Frost2012-10-03 13:32:19 -0400
commit471e398bd4832662a43e440c382601e0157c38c4 (patch)
tree6b8666f00bd633e9ca9e7e5294cdfe5159575e6b
parent7e8401d5180dc7e40dc9ad5b35e68667f4199477 (diff)
downloadorg.eclipse.virgo.kernel-471e398bd4832662a43e440c382601e0157c38c4.tar.gz
org.eclipse.virgo.kernel-471e398bd4832662a43e440c382601e0157c38c4.tar.xz
org.eclipse.virgo.kernel-471e398bd4832662a43e440c382601e0157c38c4.zip
wip
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/bundlesGui.js458
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/common.js63
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/configurations.js2
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js2
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js146
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js9
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/styles/common.css61
-rw-r--r--org.eclipse.virgo.management.console/src/main/webapp/styles/wirings.css53
-rw-r--r--org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/BundlesGuiJSTests.java17
9 files changed, 437 insertions, 374 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 3dabda2a..9fa7f271 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
@@ -10,7 +10,7 @@
*
*******************************************************************************/
-var LayoutManager = function(bundleCanvas, paper, dataSource){
+var LayoutManager = function(bundleCanvas, width, height, dataSource){
var self = this;
@@ -22,37 +22,31 @@ var LayoutManager = function(bundleCanvas, paper, dataSource){
self.bundles = {};
- self.focused = -1;
+ self.focused = NaN;
self.bundleSpacing = 10; //Pixels to leave between bundles when rendering
- self.bundleCanvas = bundleCanvas;
+ self.bundleCanvas = $('#' + bundleCanvas);
- self.paper = paper;
+ self.paper = Raphael(bundleCanvas, width, height);
+
+ self.minimumWidth = width;
self.setFocusListener = function(listener) {
self.focusListener = listener;
};
self.displayType = function(type){
- self.hideAll();
- if(self.focused != -1){
- self.focused.show();
- }
if(type == 'wires') {
$('#view-wires-button').addClass('button-selected');
$('#view-services-button').removeClass('button-selected');
self.relationshipType = type;
- if(self.focused != -1){
- self.renderWires(self.focused);
- }
+ self.displayBundle(self.focused);
} else if(type == 'services'){
$('#view-services-button').addClass('button-selected');
$('#view-wires-button').removeClass('button-selected');
self.relationshipType = type;
- if(self.focused != -1){
- self.renderServices(self.focused);
- }
+ self.displayBundle(self.focused);
}
};
@@ -60,23 +54,39 @@ var LayoutManager = function(bundleCanvas, paper, dataSource){
if(!isNaN(bundleId)){
self.hideAll();
self.bundleCanvas.addClass('spinner-large');
- self.focused = -1;
- var bundle;
+ self.focused = NaN;
self.dataSource.updateBundle(bundleId, function(){
+ var bundle;
+ var rawBundle = self.dataSource.bundles[bundleId];
+
+ if(self.relationshipType == 'wires'){
+ self.renderWires(rawBundle);
+ }else{
+ self.renderServices(rawBundle);
+ }
+
+ var middleX = Math.round(self.paper.width/2);
+ var middleY = Math.round(self.paper.height/2);
if(self.bundles[bundleId]){
bundle = self.bundles[bundleId];
}else{
- bundle = new Bundle(self.paper, self.dataSource.bundles[bundleId], self.displayBundle);
+ bundle = new Bundle(self.paper, rawBundle, middleX, middleY, self.displayBundle);
self.bundles[bundleId] = bundle;
}
- self.focused = bundle;
- bundle.move(Math.round(self.paper.width/2), Math.round(self.paper.height/2));
+ bundle.move(middleX - (bundle.boxWidth/2), middleY);
+
+ $.each(self.relationships, function(relationshipKey, relationship){
+ if(relationship.fromBundle == undefined){
+ relationship.fromBundle = bundle;
+ }else if(relationship.toBundle == undefined){
+ relationship.toBundle = bundle;
+ }
+ relationship.display();
+ });
+
+ self.focused = bundleId;
bundle.show();
- if(self.relationshipType == 'wires'){
- self.renderWires(bundle);
- }else{
- self.renderServices(bundle);
- }
+ self.bundleCanvas.scrollLeft(middleX - (self.minimumWidth/2));
self.bundleCanvas.removeClass('spinner-large');
});
if(self.focusListener){
@@ -85,78 +95,75 @@ var LayoutManager = function(bundleCanvas, paper, dataSource){
}
};
- self.renderWires = function(bundle){
- var bundleIds = {};
- $.each(bundle.rawBundle.RequiredWires, function(index, wire){
- bundleIds[wire.ProviderBundleId] = new InfoBox().initWithWire(wire);
+ self.renderWires = function(rawBundle){
+ var topRowBundleIds = {};
+ $.each(rawBundle.RequiredWires, function(index, wire){
+ topRowBundleIds[wire.ProviderBundleId] = self.getInfoBoxWithWire(wire);
});
- var topWidth = self.renderBundleRow(bundleIds, -239, bundle, false);
- bundleIds = {};
- $.each(bundle.rawBundle.ProvidedWires, function(index, wire){
- bundleIds[wire.RequirerBundleId] = new InfoBox().initWithWire(wire);
+ var topWidth = self.renderBundleRow(topRowBundleIds, -239, rawBundle, true);
+ var bottomRowBundleIds = {};
+ $.each(rawBundle.ProvidedWires, function(index, wire){
+ bottomRowBundleIds[wire.RequirerBundleId] = self.getInfoBoxWithWire(wire);
});
- var bottomWidth = self.renderBundleRow(bundleIds, 239, bundle, true);
+ var bottomWidth = self.renderBundleRow(bottomRowBundleIds, 239, rawBundle, false);
var newWidth = topWidth < bottomWidth ? bottomWidth : topWidth;
- newWidth < 900 ? self.paper.setSize(900, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
+ newWidth < self.minimumWidth ? self.paper.setSize(self.minimumWidth, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
};
- self.renderServices = function(bundle){
- var bundleIds = {};
- $.each(bundle.rawBundle.ServicesInUse, function(index, service){
- bundleIds[service.BundleIdentifier] = new InfoBox().initWithService(service);
+ self.renderServices = function(rawBundle){
+ var topRowBundleIds = {};
+ $.each(rawBundle.ServicesInUse, function(index, service){
+ topRowBundleIds[service.BundleIdentifier] = self.getInfoBoxWithService(service, service.BundleIdentifier, rawBundle.Identifier);
});
- var topWidth = self.renderBundleRow(bundleIds, -239, bundle, false);
- bundleIds = {};
- $.each(bundle.rawBundle.RegisteredServices, function(index, service){
+ var topWidth = self.renderBundleRow(topRowBundleIds, -239, rawBundle, true);
+ var bottomRowBundleIds = {};
+ $.each(rawBundle.RegisteredServices, function(index, service){
$.each(service.UsingBundles, function(index, bundleId){
- bundleIds[bundleId] = new InfoBox().initWithService(service);
+ bottomRowBundleIds[bundleId] = self.getInfoBoxWithService(service, bundleId, rawBundle.Identifier);
});
});
- var bottomWidth = self.renderBundleRow(bundleIds, 239, bundle, true);
+ var bottomWidth = self.renderBundleRow(bottomRowBundleIds, 239, rawBundle, false);
var newWidth = topWidth < bottomWidth ? bottomWidth : topWidth;
- newWidth < 900 ? self.paper.setSize(900, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
+ newWidth < self.minimumWidth ? self.paper.setSize(self.minimumWidth, self.paper.height) : self.paper.setSize(newWidth, self.paper.height);
};
-
- self.renderBundleRow = function(bundleIds, offset, focused, isFrom){
- var yPos = Math.round(self.paper.height/2) + offset;
+
+ self.renderBundleRow = function(bundleIds, offset, focusedRawBundle, topRow){
+ var yPos = (self.paper.height/2) + offset;
var xPos = this.bundleSpacing;
var bundle;
$.each(bundleIds, function(bundleId, relationshipInfoBox){
if(self.bundles[bundleId]){
bundle = self.bundles[bundleId];
+ bundle.move(xPos, yPos);
}else{
- bundle = new Bundle(self.paper, self.dataSource.bundles[bundleId], self.displayBundle);
+ bundle = new Bundle(self.paper, self.dataSource.bundles[bundleId], xPos, yPos, self.displayBundle);
self.bundles[bundleId] = bundle;
}
- var releationshipKey = self.getRelationshipKey(bundle, focused);
- if(!bundle.isVisible){
+ var releationshipKey = self.getRelationshipKey(bundleId, focusedRawBundle.Identifier);
+ if(!bundle.isVisible || focusedRawBundle.Identifier != bundleId){
var relationship;
- if(isFrom){
- relationship = new Relationship(self.paper, focused, bundle, relationshipInfoBox);
+ if(topRow){
+ relationship = new Relationship(self.paper, bundle, undefined, relationshipInfoBox);
}else{
- relationship = new Relationship(self.paper, bundle, focused, relationshipInfoBox);
+ relationship = new Relationship(self.paper, undefined, bundle, relationshipInfoBox);
}
self.relationships[releationshipKey] = relationship;
- xPos = xPos + bundle.boxWidth/2;
- bundle.move(xPos, yPos);
bundle.show();
- relationship.display();
- xPos = xPos + bundle.boxWidth/2 + self.bundleSpacing;
+ xPos = xPos + bundle.boxWidth + self.bundleSpacing;
} else {
var existingRelationship = self.relationships[releationshipKey];
- if(bundle.rawBundle.Identifier == focused.rawBundle.Identifier){
+ if(bundle.rawBundle.Identifier == focusedRawBundle.Identifier){
if(existingRelationship){
existingRelationship.increaseCount(relationshipInfoBox);
}else{//Handle the first self relationship
var relationship = new Relationship(self.paper, bundle, bundle, relationshipInfoBox);
self.relationships[releationshipKey] = relationship;
- relationship.display();
}
} else {
var existingFromBundle = existingRelationship.fromBundle.rawBundle.Identifier;
- if(isFrom && focused.rawBundle.Identifier == existingFromBundle){// On the bottom row
+ if(topRow && focusedRawBundle.Identifier == existingFromBundle){// On the bottom row
existingRelationship.increaseCount(relationshipInfoBox);
- } else if(!isFrom && bundle.rawBundle.Identifier == existingFromBundle){// On the top row
+ } else if(!topRow && bundle.rawBundle.Identifier == existingFromBundle){// On the top row
existingRelationship.increaseCount(relationshipInfoBox);
} else {
existingRelationship.increaseBackCount(relationshipInfoBox); //On the top row
@@ -167,14 +174,14 @@ var LayoutManager = function(bundleCanvas, paper, dataSource){
return xPos;
};
- self.getRelationshipKey = function(bundle1, bundle2){
- if(bundle1.rawBundle.Identifier == bundle2.rawBundle.Identifier){
- return 'self' + bundle1.rawBundle.Identifier;
+ self.getRelationshipKey = function(bundleId1, bundleId2){
+ if(bundleId1 == bundleId2){
+ return 'self' + bundleId1;
}
- if(bundle1.rawBundle.Identifier < bundle2.rawBundle.Identifier){
- return bundle1.rawBundle.Identifier + '-' + bundle2.rawBundle.Identifier;
+ if(bundleId1 < bundleId2){
+ return bundleId1 + '-' + bundleId2;
}
- return bundle2.rawBundle.Identifier + '-' + bundle1.rawBundle.Identifier;
+ return bundleId2 + '-' + bundleId1;
};
self.hideAll = function(){
@@ -186,30 +193,77 @@ var LayoutManager = function(bundleCanvas, paper, dataSource){
});
self.relationships = {};
};
+
+ self.getInfoBoxWithService = function(service, bundleId1, bundleId2){
+ var name = 'service' + service.Identifier;
+ var title = 'Service(s) between Bundles ' + bundleId1 + ' and ' + bundleId2;
+ var infoBox = $('<ul></ul>');
+ infoBox.append($('<li>Service [' + service.Identifier + '] ' + service.objectClass[0] + (service.objectClass.length > 1 ? '...' : '') + '</li>').addClass('section-title'));
+ infoBox.append($('<li>Published by Bundle ' + service.BundleIdentifier + '</li>'));
+ infoBox.append($('<li>Used by</li>'));
+ $.each(service.UsingBundles, function(index, item){
+ infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
+ });
+ infoBox.append($('<li>ObjectClass</li>'));
+ $.each(service.objectClass, function(index, item){
+ infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
+ });
+ return new InfoBox({name: name, title: title, content: infoBox, closeable: true});
+ };
+
+ self.getInfoBoxWithWire = function(wire){
+ var name = 'wire' + wire.ProviderBundleId + '-' + wire.RequirerBundleId;
+ var title = 'Wire(s) between Bundles ' + wire.ProviderBundleId + ' and ' + wire.RequirerBundleId;
+ var infoBox = $('<ul></ul>');
+ infoBox.append($('<li>"' + wire.BundleRequirement.Namespace + '" provided by Bundle ' + wire.ProviderBundleId + ' to Bundle ' + wire.RequirerBundleId + '</li>').addClass('section-title'));
+ infoBox.append($('<li>Capability</li>'));
+ self.addWireProperties(infoBox, wire.BundleCapability.Attributes, '=', 'Attributes');
+ self.addWireProperties(infoBox, wire.BundleCapability.Directives, ':=', 'Directives');
+ infoBox.append($('<li>Requirement</li>'));
+ self.addWireProperties(infoBox, wire.BundleRequirement.Attributes, '=', 'Attributes');
+ self.addWireProperties(infoBox, wire.BundleRequirement.Directives, ':=', 'Directives');
+ return new InfoBox({name: name, title: title, content: infoBox, closeable: true});
+ };
+
+ self.addWireProperties = function(list, attributes, delimiter, type){
+ var firstItem = $('<li></li>').addClass('indent1');
+ list.append(firstItem);
+ var itemsAdded = false;
+ $.each(attributes, function(key, value){
+ if(!itemsAdded){
+ itemsAdded = true;
+ firstItem.text(type);
+ }
+ list.append($('<li>' + value.Key + delimiter + value.Value + '</li>').addClass('indent2'));
+ });
+ if(!itemsAdded){
+ firstItem.text('No ' + type);
+ }
+ };
+
};
/**
* Bundle
*/
-var Bundle = function(paper, rawBundle, dblClickCallback){
+var Bundle = function(paper, rawBundle, x, y, dblClickCallback){
var self = this;
self.paper = paper;
self.rawBundle = rawBundle;
- self.infoBox = new InfoBox().initWithBundle(rawBundle);
self.dblClickCallback = dblClickCallback;
self.relationships = {};
self.isVisible = false;
-
//Display attributes
self.bundleMargin = 8;
- self.x = 5;
- self.y = 5;
+ self.boxHeight = 28 + (2*self.bundleMargin); // Starter value to get text in the right place
+ self.x = Math.round(x); //Left edge of the box
+ self.y = Math.round(y); //Middle of the box
self.summary = '[' + self.rawBundle.Identifier + '] ' + self.rawBundle.SymbolicName + '\n' + self.rawBundle.Version;
- self.text = self.paper.text(self.x, self.y, self.summary).attr({
+ self.text = self.paper.text(self.x + self.bundleMargin, self.y, self.summary).attr({
'text-anchor' : 'start',
'font' : '12px Arial'
}).hide();
@@ -217,12 +271,12 @@ var Bundle = function(paper, rawBundle, dblClickCallback){
self.boxWidth = Math.round(self.text.getBBox().width) + (3*self.bundleMargin);
self.boxHeight = Math.round(self.text.getBBox().height) + (2*self.bundleMargin);
- self.box = self.paper.rect(self.x, self.y, self.boxWidth, self.boxHeight, self.bundleMargin).attr({
+ self.box = self.paper.rect(self.x, self.y - (self.boxHeight/2), self.boxWidth, self.boxHeight, self.bundleMargin).attr({
'fill' : '#E8F6FF',
'stroke' : '#002F5E'
}).hide();
- self.info = self.paper.text(self.x, self.y, 'i').attr({
+ self.info = self.paper.text(self.x + (self.boxWidth - 1.5*self.bundleMargin), self.y, 'i').attr({
'text-anchor' : 'start',
'font-size' : '17px',
'font-family' : 'serif',
@@ -243,40 +297,88 @@ var Bundle = function(paper, rawBundle, dblClickCallback){
});
self.info.click(function(){
- self.infoBox.go();
+ if(!self.infoBox){
+ self.infoBox = self.getInfoBoxWithBundle(self.rawBundle);
+ }
+ self.infoBox.show();
});
- self.hide = function(){
- self.text.hide();
- self.box.hide();
- self.info.hide();
- self.isVisible = false;
+ self.show = function(){
+ if(!self.isVisible){
+ self.text.show();
+ self.box.show();
+ self.info.show();
+ self.isVisible = true;
+ }
};
- self.show = function(){
- self.text.show();
- self.box.show();
- self.info.show();
- self.isVisible = true;
+ self.hide = function(){
+ if(self.isVisible){
+ self.text.hide();
+ self.box.hide();
+ self.info.hide();
+ self.infoBox = undefined;//Force it to be reloaded as the underlying data may have changed
+ self.isVisible = false;
+ }
};
self.move = function(x, y) {
- self.x = x;
- self.y = y;
- self.box.attr({
- 'x' : Math.round(x - self.boxWidth/2),
- 'y' : Math.round(y - self.boxHeight/2)
- });
+ self.x = Math.round(x);
+ self.y = Math.round(y);
self.text.attr({
- 'x' : Math.round(x - self.boxWidth/2) + self.bundleMargin,
- 'y' : Math.round(y)
+ 'x' : self.x + self.bundleMargin,
+ 'y' : self.y
+ });
+ self.box.attr({
+ 'x' : self.x,
+ 'y' : self.y - (self.boxHeight/2)
});
self.info.attr({
- 'x' : Math.round(x + self.boxWidth/2 - 1.5*self.bundleMargin),
- 'y' : Math.round(y)
+ 'x' : self.x + (self.boxWidth - 1.5*self.bundleMargin),
+ 'y' : self.y
});
};
+
+ self.getInfoBoxWithBundle = function(rawBundle){
+ var name = 'bundle' + rawBundle.Identifier;
+ var title = 'Bundle [' + rawBundle.Identifier + '] ' + rawBundle.SymbolicName + ': ' + rawBundle.Version;
+ var infoBox = $('<ul></ul>');
+ infoBox.append($('<li>State - ' + rawBundle.State + '</li>'));
+ if(rawBundle.StartLevel){
+ infoBox.append($('<li>StartLevel - ' + rawBundle.StartLevel + '</li>'));
+ }
+ infoBox.append($('<li>Region - ' + rawBundle.Region + '</li>'));
+ infoBox.append($('<li>Location - ' + rawBundle.Location + '</li>'));
+ if(rawBundle.LastModified){
+ infoBox.append($('<li>LastModified - ' + rawBundle.LastModified + '</li>'));
+ }
+ infoBox.append($('<li>Is a fragment - ' + rawBundle.Fragment + '</li>'));
+ if(rawBundle.PersistentlyStarted){
+ infoBox.append($('<li>PersistentlyStarted - ' + rawBundle.PersistentlyStarted + '</li>'));
+ }
+ if(rawBundle.ActivationPolicyUsed){
+ infoBox.append($('<li>ActivationPolicyUsed - ' + rawBundle.ActivationPolicyUsed + '</li>'));
+ }
+ infoBox.append($('<li>Required - ' + rawBundle.Required + '</li>'));
+ if(!rawBundle.ExportedPackages || rawBundle.ExportedPackages.length == 0){
+ infoBox.append($('<li>No exported packages</li>'));
+ } else {
+ infoBox.append($('<li>Exported packages</li>'));
+ $.each(rawBundle.ExportedPackages, function(index, item){
+ infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
+ });
+ }
+ if(!rawBundle.ImportedPackages || rawBundle.ImportedPackages.length == 0){
+ infoBox.append($('<li>No imported packages</li>'));
+ } else {
+ infoBox.append($('<li>Imported packages</li>'));
+ $.each(rawBundle.ImportedPackages, function(index, item){
+ infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
+ });
+ }
+ return new InfoBox({name: name, title: title, content: infoBox, closeable: true});
+ };
};
@@ -288,26 +390,25 @@ var Relationship = function(paper, fromBundle, toBundle, infoBox) {
self.fromBundle = fromBundle;
self.toBundle = toBundle;
self.infoBox = infoBox;
- self.tooltip = 'From bundle ' + fromBundle.summary + '\n To bundle ' + toBundle.summary;
self.doubleEnded = false;
self.count = 1;
- self.controlPointOffset = 100;
-
+ self.controlPointOffset = 90;
+
self.setCoordinates = function(){
if(self.fromBundle.rawBundle.Identifier == self.toBundle.rawBundle.Identifier){
- var xOffSet = Math.round(fromBundle.x + toBundle.boxWidth/2);
- self.startPoint = {'x' : xOffSet - 20, 'y' : Math.round(fromBundle.y - fromBundle.boxHeight/2)};
- self.endPoint = {'x' : xOffSet - 20, 'y' : Math.round(toBundle.y + toBundle.boxHeight/2)};
+ var xOffSet = self.fromBundle.x + self.toBundle.boxWidth;
+ self.startPoint = {'x' : xOffSet - 20, 'y' : self.fromBundle.y - (self.fromBundle.boxHeight/2)};
+ self.endPoint = {'x' : xOffSet - 20, 'y' : Math.round(self.toBundle.y + (self.toBundle.boxHeight/2))};
self.startPointControl = {'x' : self.startPoint.x + self.controlPointOffset, 'y' : self.startPoint.y - self.controlPointOffset};
self.endPointControl = {'x' : self.endPoint.x + self.controlPointOffset, 'y' : self.endPoint.y + self.controlPointOffset};
- self.midPoint = {'x' : xOffSet + 54, 'y' : fromBundle.y};
+ self.midPoint = {'x' : xOffSet + 47, 'y' : self.fromBundle.y};
}else{
- self.startPoint = {'x' : fromBundle.x, 'y' : Math.round(fromBundle.y + fromBundle.boxHeight/2)};
- self.endPoint = {'x' : toBundle.x, 'y' : Math.round(toBundle.y - toBundle.boxHeight/2)};
+ self.startPoint = {'x' : Math.round(self.fromBundle.x + self.fromBundle.boxWidth/2), 'y' : self.fromBundle.y + (self.fromBundle.boxHeight/2)};
+ self.endPoint = {'x' : Math.round(self.toBundle.x + self.toBundle.boxWidth/2), 'y' : self.toBundle.y - (self.fromBundle.boxHeight/2)};
self.startPointControl = {'x' : self.startPoint.x, 'y' : self.startPoint.y + self.controlPointOffset};
self.endPointControl = {'x' : self.endPoint.x, 'y' : self.endPoint.y - self.controlPointOffset};
- self.midPoint = self.calculateMidpoint(this.startPoint.x, self.startPoint.y, self.endPoint.x, self.endPoint.y);
+ self.midPoint = self.calculateMidpoint(self.startPoint.x, self.startPoint.y, self.endPoint.x, self.endPoint.y);
}
};
@@ -327,16 +428,9 @@ var Relationship = function(paper, fromBundle, toBundle, infoBox) {
};
self.display = function() {
- if(self.visual){
- self.visual.remove();
- }
- if(self.infoPoint){
- self.infoPoint.remove();
- }
- if(self.infoPointText){
- self.infoPointText.remove();
- }
+ self.remove();
self.setCoordinates();
+ self.tooltip = 'From bundle ' + self.fromBundle.summary + '\n To bundle ' + self.toBundle.summary;
self.visual = self.paper.path('M' + self.startPoint.x + ',' + self.startPoint.y +
'C' + self.startPointControl.x + ',' + self.startPointControl.y +
',' + self.endPointControl.x + ',' + self.endPointControl.y +
@@ -366,12 +460,14 @@ var Relationship = function(paper, fromBundle, toBundle, infoBox) {
};
self.displayInfoBox = function() {
- infoBox.go();
+ self.infoBox.show();
};
self.increaseCount = function(relationshipInfoBox) {
self.count = self.count + 1;
- self.infoPointText.attr({'text': self.count});
+ if(self.infoPointText){
+ self.infoPointText.attr({'text': self.count});
+ }
self.infoBox.addInfoBox(relationshipInfoBox);
};
@@ -384,129 +480,15 @@ var Relationship = function(paper, fromBundle, toBundle, infoBox) {
};
self.remove = function() {
- self.visual.remove();
- self.infoPoint.remove();
- self.infoPointText.remove();
- };
-
-};
-
-var InfoBox = function(){
-
- var self = this;
-
- self.title = "Not Defined";
- self.dialogBox = $('<div />');
-
- self.initWithBundle = function(rawBundle){
- self.title = 'Bundle [' + rawBundle.Identifier + '] ' + rawBundle.SymbolicName + ': ' + rawBundle.Version;
- var infoBox = $('<ul></ul>');
- infoBox.append($('<li>State - ' + rawBundle.State + '</li>'));
- if(rawBundle.StartLevel){
- infoBox.append($('<li>StartLevel - ' + rawBundle.StartLevel + '</li>'));
- }
- infoBox.append($('<li>Region - ' + rawBundle.Region + '</li>'));
- infoBox.append($('<li>Location - ' + rawBundle.Location + '</li>'));
- if(rawBundle.LastModified){
- infoBox.append($('<li>LastModified - ' + rawBundle.LastModified + '</li>'));
- }
- infoBox.append($('<li>Is a fragment - ' + rawBundle.Fragment + '</li>'));
- if(rawBundle.PersistentlyStarted){
- infoBox.append($('<li>PersistentlyStarted - ' + rawBundle.PersistentlyStarted + '</li>'));
- }
- if(rawBundle.ActivationPolicyUsed){
- infoBox.append($('<li>ActivationPolicyUsed - ' + rawBundle.ActivationPolicyUsed + '</li>'));
- }
- infoBox.append($('<li>Required - ' + rawBundle.Required + '</li>'));
- if(!rawBundle.ExportedPackages || rawBundle.ExportedPackages.length == 0){
- infoBox.append($('<li>No exported packages</li>'));
- } else {
- infoBox.append($('<li>Exported packages</li>'));
- $.each(rawBundle.ExportedPackages, function(index, item){
- infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
- });
+ if(self.visual){
+ self.visual.remove();
}
- if(!rawBundle.ImportedPackages || rawBundle.ImportedPackages.length == 0){
- infoBox.append($('<li>No imported packages</li>'));
- } else {
- infoBox.append($('<li>Imported packages</li>'));
- $.each(rawBundle.ImportedPackages, function(index, item){
- infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
- });
+ if(self.infoPoint){
+ self.infoPoint.remove();
}
- self.dialogBox.append(infoBox);
- return self;
- };
-
- self.initWithService = function(service){
- self.title = 'Service(s)' ;
- var infoBox = $('<ul></ul>');
- infoBox.append($('<li>Service [' + service.Identifier + '] ' + service.objectClass[0] + (service.objectClass.length > 1 ? '...' : '') + '</li>').addClass('section-title'));
-
- infoBox.append($('<li>Published by Bundle ' + service.BundleIdentifier + '</li>'));
- infoBox.append($('<li>Used by</li>'));
- $.each(service.UsingBundles, function(index, item){
- infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
- });
- infoBox.append($('<li>ObjectClass</li>'));
- $.each(service.objectClass, function(index, item){
- infoBox.append($('<li>' + item + '</li>').addClass('indent1'));
- });
- self.dialogBox.append(infoBox);
- return self;
- };
-
- self.initWithWire = function(wire){
- self.title = 'Wire(s) between Bundle ' + wire.ProviderBundleId + ' and Bundle ' + wire.RequirerBundleId;
- var infoBox = $('<ul></ul>');
- infoBox.append($('<li>"' + wire.BundleRequirement.Namespace + '" provided by Bundle ' + wire.ProviderBundleId + ' to Bundle ' + wire.RequirerBundleId + '</li>').addClass('section-title'));
- infoBox.append($('<li>Capability</li>'));
- self.addWireProperties(infoBox, wire.BundleCapability.Attributes, '=', 'Attributes');
- self.addWireProperties(infoBox, wire.BundleCapability.Directives, ':=', 'Directives');
- infoBox.append($('<li>Requirement</li>'));
- self.addWireProperties(infoBox, wire.BundleRequirement.Attributes, '=', 'Attributes');
- self.addWireProperties(infoBox, wire.BundleRequirement.Directives, ':=', 'Directives');
- self.dialogBox.append(infoBox);
- return self;
- };
-
- self.addWireProperties = function(list, attributes, delimiter, type){
- var firstItem = $('<li></li>').addClass('indent1');
- list.append(firstItem);
- var itemsAdded = false;
- $.each(attributes, function(key, value){
- if(!itemsAdded){
- itemsAdded = true;
- firstItem.text(type);
- }
- list.append($('<li>' + value.Key + delimiter + value.Value + '</li>').addClass('indent2'));
- });
- if(!itemsAdded){
- firstItem.text('No ' + type);
+ if(self.infoPointText){
+ self.infoPointText.remove();
}
};
-
- self.addInfoBox = function(newInfoBox){
- $.each(newInfoBox.dialogBox.children(), function(index, item){
- self.dialogBox.append(item);
- });
- };
-
- self.go = function(){
- var newDialogBox = self.dialogBox.clone();
- $("li", newDialogBox).removeClass('li-odd');
- $("li:odd", newDialogBox).addClass('li-odd');
- newDialogBox.dialog({
- modal : true,
- dialogClass: 'info-box',
- resizable: false,
- width : 600,
- title : self.title,
- close : function(a,b){
- $(this).parent().remove();
- return false;
- }
- });
- };
-
+
};
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/common.js b/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
index 97f834b0..47479ad5 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/common.js
@@ -237,6 +237,9 @@ var Util = function(){
var cell = $('*:nth-child(' + (index+1) + ')', tr);
return $(cell).text();
};
+ console.log(getText(tr1));
+ console.log(getText(tr2));
+ console.log(getText(tr1) - getText(tr2));
return getText(tr1) - getText(tr2);
};
@@ -338,12 +341,62 @@ var Util = function(){
return newTable;
};
+
+};
- /**
- * Create a new div element of the given class.
- */
- self.makeDiv = function(clazz) {
- return $('<div />', {'class' : clazz});
+/**
+ *
+ */
+var InfoBox = function(properties){
+
+ var self = this;
+
+ self.isVisible = false;
+
+ self.dialogBox = $('<div />').addClass(properties.name).addClass('info-box');
+
+ self.title = $('<div />', {'class': 'box-title'}).text(properties.title);
+ self.dialogBox.append(self.title);
+
+ self.content = $('<div />', {'class': 'box-content'}).append(properties.content);
+ self.dialogBox.append(self.content);
+
+ var position = $('#content').position();
+ self.dialogBox.css({top: position.top + 80, left: position.left + 80});
+
+ if(properties.modal){
+
+ }
+ if(properties.closeable){
+ self.title.append($('<div />', {'class': 'box-title-close'}).append('x').click(function(){
+ self.hide();
+ }));
+ }
+
+ self.dialogBox.draggable({ scroll: false, stack: '.info-box'});
+
+ self.addInfoBox = function(newInfoBox){
+ $.each(newInfoBox.content.children(), function(index, item){
+ self.content.append(item);
+ });
+ };
+
+ self.show = function(){
+ if(!self.isVisible){
+ $("li", self.dialogBox).removeClass('li-odd');
+ $("li:odd", self.dialogBox).addClass('li-odd');
+ $('body').append(self.dialogBox);
+ self.dialogBox.show();
+ self.isVisible = true;
+ }
+ };
+
+ self.hide = function(){
+ if(self.isVisible){
+ self.dialogBox.detach();
+ self.dialogBox.hide();
+ self.isVisible = false;
+ }
};
};
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/configurations.js b/org.eclipse.virgo.management.console/src/main/webapp/js/configurations.js
index fa7d0187..41443640 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/configurations.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/configurations.js
@@ -101,7 +101,7 @@ var Configuration = function(pid, location, regionName, label){
var propertiesTable = util.makeTable({
clazz: "config-table",
- headers: ['Key', 'Value'],
+ headers: [{title: 'Property'}, {title: 'Value'}],
rows: tableRows
});
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js b/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
index 6234258b..e7be6a4b 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/dumps.js
@@ -172,7 +172,7 @@ var DumpViewer = function(){
}else{
bundleToDisplay = bundles[0].identifier;
}
- new LayoutManager(bundleCanvas, Raphael('bundle-canvas', width, height), dataSource).displayBundle(bundleToDisplay);
+ new LayoutManager('bundle-canvas', width, height, dataSource).displayBundle(bundleToDisplay);
});
});
};
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js b/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
index bfc7bebe..aaac68d6 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/repositories.js
@@ -27,85 +27,89 @@ function pageinit() {
};
Repositories = {
-
-renderRepositoryMBeans: function(mbeanNames){
- var getNameAttribute = function(mbeanName){
- return util.readObjectName(mbeanName).get('name');
- };
-
- $.each(mbeanNames, function(i, mbeanName){
- var button = util.makeDiv('button').append(util.makeDiv('button-cap-left-blue'), util.makeDiv('button-text').text(getNameAttribute(mbeanName)),
- util.makeDiv('button-cap-right-blue'));
- $('#repository-controls').append(button);
- button.mbeanName = mbeanName;
- button.click(button, Repositories.display);
- if(i == 0){
- button.click();
- }
-
- });
-},
-
-display: function(clickEvent){
- var button = clickEvent.data;
+ renderRepositoryMBeans: function(mbeanNames){
+ var getNameAttribute = function(mbeanName){
+ return util.readObjectName(mbeanName).get('name');
+ };
+
+ $.each(mbeanNames, function(i, mbeanName){
+ var button = $('<div />', {'class' : 'button'}).append(
+ $('<div />', {'class' : 'button-cap-left-blue'}),
+ $('<div />', {'class' : 'button-text'}).text(getNameAttribute(mbeanName)),
+ $('<div />', {'class' : 'button-cap-right-blue'})
+ );
+ $('#repository-controls').append(button);
+ button.mbeanName = mbeanName;
+ button.click(button, Repositories.display);
+ if(i == 0){
+ button.click();
+ }
- $('.button-selected').removeClass('button-selected');
- button.addClass('button-selected');
+ });
+
+ },
- $.ajax({
- url: util.getCurrentHost() + '/jolokia/read/' + button.mbeanName,
- dataType: 'json',
- success: function (response) {
- Repositories.renderArtifactDescriptorSummaries(response.value.AllArtifactDescriptorSummaries);
- }
- });
-
-},
-
-renderArtifactDescriptorSummaries: function(artifactDescriptorSummaries){
+ display: function(clickEvent){
+ var button = clickEvent.data;
+
+ $('.button-selected').removeClass('button-selected');
+ button.addClass('button-selected');
+
+ $.ajax({
+ url: util.getCurrentHost() + '/jolokia/read/' + button.mbeanName,
+ dataType: 'json',
+ success: function (response) {
+ Repositories.renderArtifactDescriptorSummaries(response.value.AllArtifactDescriptorSummaries);
+ }
+ });
- var rows = [];
+ },
- $.each(artifactDescriptorSummaries, function(i, summary){
- rows.push([summary.type,
- summary.name,
- summary.version,
- $('<td />', {'class' : 'repository-deploy', 'onClick': 'Repositories.deploy("repository:' + summary.type + '/' + summary.name + '")'}).text('deploy')]);
- });
+ renderArtifactDescriptorSummaries: function(artifactDescriptorSummaries){
+
+ var rows = [];
+
+ $.each(artifactDescriptorSummaries, function(i, summary){
+ var deployButton = $('<td />', {'class' : 'repository-deploy', 'onClick': 'Repositories.deploy("repository:' + summary.type + '/' + summary.name + '")'}).text('deploy');
+ rows.push([summary.type,
+ summary.name,
+ summary.version,
+ deployButton]);
+ });
+
+ var descriptorTable = util.makeTable({
+ clazz: 'repository-table table-selectable',
+ headers: [{title: 'Type'}, {title: 'Name'}, {title: 'Version', type: 'numeric'}],
+ rows: rows,
+ selectable: true,
+ sortable: true,
+ sortIndex: 1
+ });
+
+
+ var panel = $('#repository-panel');
+ panel.empty();
+ panel.append(descriptorTable);
- var descriptorTable = util.makeTable({
- clazz: 'repository-table table-selectable',
- headers: [{title: 'Type'}, {title: 'Name'}, {title: 'Version'}],
- rows: rows,
- selectable: true,
- sortable: true,
- sortIndex: 1
- });
+ },
+ deploy: function(artifact){
- var panel = $('#repository-panel');
- panel.empty();
- panel.append(descriptorTable);
-
-},
-
-deploy: function(artifact){
-
- var request = [{
- "type":"EXEC",
- "mbean":"org.eclipse.virgo.kernel:category=Control,type=Deployer",
- "operation":"deploy(java.lang.String)",
- "arguments":[artifact]
- }];
+ var request = [{
+ "type":"EXEC",
+ "mbean":"org.eclipse.virgo.kernel:category=Control,type=Deployer",
+ "operation":"deploy(java.lang.String)",
+ "arguments":[artifact]
+ }];
+
+ util.doBulkQuery(request, function(response){
+ alert('Deployed artifact of type:' + response[0].value.type + ', name: ' + response[0].value.symbolicName + ', version: ' + response[0].value.version + '. If the version doesn\'t match, then that version was found in the configured repository chain.');
+ }, function(xmlHttpRequest, textStatus, errorThrown){
+ console.log(xmlHttpRequest, textStatus, errorThrown);
+ alert('Deployment failed \'' + textStatus + '\': ' + xmlHttpRequest + ' ' + errorThrown);
+ });
- util.doBulkQuery(request, function(response){
- alert('Deployed artifact of type:' + response[0].value.type + ', name: ' + response[0].value.symbolicName + ', version: ' + response[0].value.version + '. If the version doesn\'t match, then that version was found in the configured repository chain.');
- }, function(xmlHttpRequest, textStatus, errorThrown){
- console.log(xmlHttpRequest, textStatus, errorThrown);
- alert('Deployment failed \'' + textStatus + '\': ' + xmlHttpRequest + ' ' + errorThrown);
- });
-
-}
+ }
}; \ No newline at end of file
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js b/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
index 3148511c..59df1266 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
+++ b/org.eclipse.virgo.management.console/src/main/webapp/js/wirings.js
@@ -17,12 +17,11 @@ function pageinit() {
var width = 900;
var height = 551;
- var bundleCanvas = $('#bundle-canvas');
- bundleCanvas.css({'width' : width, 'height' : height + 18});
+ $('#bundle-canvas').css({'width' : width, 'height' : height + 18});
var dataSource = new GeminiDataSource();
dataSource.updateData(function(){
- layoutManager = new LayoutManager(bundleCanvas, Raphael('bundle-canvas', width, height), dataSource);
+ layoutManager = new LayoutManager('bundle-canvas', width, height, dataSource);
new SideBar(layoutManager, dataSource).init();
if(util.pageLocation && util.pageLocation.length > 0){
layoutManager.displayBundle(util.pageLocation);
@@ -54,7 +53,9 @@ var SideBar = function(layoutManager, dataSource){
var rowIds = $('td:first-child', self.bundlesTable);
$.each(rowIds, function(index, rowId){
if($(rowId).text() == bundleId){
- rowId.scrollIntoView(true);
+ //rowId.scrollIntoView(true);
+ $('#side-bar').scrollTop($(rowId).position().top);
+
$('.table-tr-selected', self.bundlesTable).removeClass('table-tr-selected');
$(rowId).parent().addClass('table-tr-selected');
}
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/styles/common.css b/org.eclipse.virgo.management.console/src/main/webapp/styles/common.css
index 04d52a76..5e00795c 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/styles/common.css
+++ b/org.eclipse.virgo.management.console/src/main/webapp/styles/common.css
@@ -459,3 +459,64 @@ td {
color: #999;
text-decoration: none;
}
+
+/*
+ * INFO BOX
+ */
+
+
+.info-box {
+ background: #FFFFFF;
+ border: 3px solid #002F5E;
+ -moz-border-radius: 8px;
+ -webkit-border-radius: 8px;
+ -khtml-border-radius: 8px;
+ border-radius: 8px;
+ z-index: 1500;
+ position:absolute;
+}
+
+.info-box .box-title-close {
+ float: right;
+ cursor: pointer;
+}
+
+.info-box .box-title {
+ font-weight: bold;
+ text-align: center;
+ color: #002F5E;
+ padding: 5px;
+ border-bottom: 1px solid #B6D9ED;
+}
+
+.info-box .box-content {
+ margin: 5px 0;
+ max-height: 300px;
+ overflow: auto;
+ padding: 0 5px;
+ min-width: 500px;
+}
+
+.info-box .section-title {
+ padding: 5px;
+ font-weight: bold;
+}
+
+.info-box .indent1 {
+ padding-left: 20px;
+}
+.info-box .indent2 {
+ padding-left: 40px;
+}
+
+.info-box .li-odd {
+ background: #E8F6FF;
+}
+
+.info-box li {
+ padding: 3px;
+}
+
+.info-box li:hover {
+ background: #BAD9EC;
+}
diff --git a/org.eclipse.virgo.management.console/src/main/webapp/styles/wirings.css b/org.eclipse.virgo.management.console/src/main/webapp/styles/wirings.css
index 5a116708..6ea8bf67 100644
--- a/org.eclipse.virgo.management.console/src/main/webapp/styles/wirings.css
+++ b/org.eclipse.virgo.management.console/src/main/webapp/styles/wirings.css
@@ -37,56 +37,3 @@ svg:not(:root) {
margin-right: auto;
overflow-x: auto;
}
-
-.info-box {
- background: #FFFFFF;
- border: 3px solid #002F5E;
- -moz-border-radius: 8px;
- -webkit-border-radius: 8px;
- -khtml-border-radius: 8px;
- border-radius: 8px;
-}
-
-.info-box .ui-dialog-titlebar {
- border-bottom: 1px solid #002F5E;
- -moz-border-radius: 5px 5px 0px 0px;
- -webkit-border-radius: 5px 5px 0px 0px;
- -khtml-border-radius: 5px 5px 0px 0px;
- border-radius: 5px 5px 0px 0px;
- background: #E8F6FF;
- padding: 5px;
-}
-
-.info-box .ui-dialog-titlebar-close {
- float: right;
-}
-
-.info-box .ui-dialog-content {
- padding: 5px;
- overflow-x: auto;
-}
-
-.info-box .ui-dialog-content .section-title {
- font-weight: bold;
- text-align: center;
- color: #002F5E;
-}
-
-.info-box .indent1 {
- padding-left: 20px;
-}
-.info-box .indent2 {
- padding-left: 40px;
-}
-
-.info-box .li-odd {
- background: #E8F6FF;
-}
-
-.info-box li {
- padding: 3px;
-}
-
-.info-box li:hover {
- background: #BAD9EC;
-} \ No newline at end of file
diff --git a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/BundlesGuiJSTests.java b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/BundlesGuiJSTests.java
index 525eb71b..f48cdf8d 100644
--- a/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/BundlesGuiJSTests.java
+++ b/org.eclipse.virgo.management.console/src/test/java/org/eclipse/virgo/management/console/BundlesGuiJSTests.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.virgo.management.console;
+import static org.junit.Assert.assertEquals;
+
import java.io.IOException;
import javax.script.ScriptException;
@@ -18,7 +20,9 @@ import org.junit.Test;
import sun.org.mozilla.javascript.internal.Context;
import sun.org.mozilla.javascript.internal.Function;
+import sun.org.mozilla.javascript.internal.FunctionObject;
import sun.org.mozilla.javascript.internal.Scriptable;
+import sun.org.mozilla.javascript.internal.ScriptableObject;
/**
*
@@ -29,14 +33,25 @@ public class BundlesGuiJSTests extends AbstractJSTests {
@Test
public void testConstructors() throws ScriptException, IOException, NoSuchMethodException{
addCommonObjects();
+
+ FunctionObject raphaelFunction = new FunctionObject("Raphael", BundlesGuiJSTests.class.getDeclaredMethod("raphael", String.class, int.class, int.class), scope);
+ ScriptableObject.putProperty(scope, "Raphael", raphaelFunction);
+
readFile("src/main/webapp/js/bundlesGui.js");
- ((Function) scope.get("LayoutManager", scope)).construct(context, scope, new Object[]{null, null, null});
+ ((Function) scope.get("LayoutManager", scope)).construct(context, scope, new Object[]{"DrawOnMe", 500, 600, null});
((Function) scope.get("Bundle", scope)).construct(context, scope, new Object[]{getTestPaper(), getTestRawBundle(), null});
((Function) scope.get("Relationship", scope)).construct(context, scope, new Object[]{getTestPaper(), getTestRawBundle(), getTestRawBundle(), null});
((Function) scope.get("InfoBox", scope)).construct(context, scope, new Object[]{});
}
+
+ public static Object raphael(String element, int width, int height){
+ assertEquals("DrawOnMe", element);
+ assertEquals(500, width);
+ assertEquals(600, height);
+ return null;
+ }
private Scriptable getTestRawBundle() throws IOException{
readString( "var TestRawBundle = function() {" +

Back to the top