Skip to content

Commit

Permalink
Display number of objects in a sub-graph
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Mar 15, 2012
1 parent d1e8859 commit 1ab2820
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
5 changes: 5 additions & 0 deletions content/app/objectGraphGenerator.js
Expand Up @@ -26,6 +26,8 @@ ObjectGraphGenerator.prototype =
if (!o)
return null;

this.counter = 0;

var res = {};
this.getObjectGraph(o, o.address, res);
return res;
Expand All @@ -42,6 +44,9 @@ ObjectGraphGenerator.prototype =
obj.name = o.name;
res[this.ensureUniqueName(res, name)] = obj;

// Just counting number of objects in the sub-graph
this.counter++;

for each (var owner in o.owners)
this.getObjectGraph(owner.from, owner.name ? owner.name : "<unknown-owner>", obj);

Expand Down
30 changes: 29 additions & 1 deletion content/tabs/graphTab.js
Expand Up @@ -36,11 +36,33 @@ GraphTab.prototype = Lib.extend(BaseTab.prototype,
noGraph:
SPAN("No graph found"),

infoBarItem:
SPAN({"class": "infoBarItem toolbarButton", title: "Cycle Collector sub-graph info"}),

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Toolbar

getToolbarButtons: function()
{
this.toolbar.noSeparators = true;

var buttons = [];
buttons.push({
id: "infoBar",
tag: this.infoBarItem
});

return buttons.concat(BaseTab.prototype.getToolbarButtons.apply(this, arguments));
},

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Content

onUpdateBody: function(tabView, body)
{
BaseTab.prototype.onUpdateBody.apply(this, arguments);

// Render tab content.
// Render an empty tab content if there is no selection.
var content = body.querySelector(".tabContent");
var selection = tabView.selection;
if (!selection)
Expand All @@ -49,10 +71,16 @@ GraphTab.prototype = Lib.extend(BaseTab.prototype,
return;
}

// Search the whole CC graph for subgraph related to the selected object.
var searchId = this.tabView.analyzer.getSearchId();
var generator = new ObjectGraphGenerator(searchId);
this.graph = generator.findGraph(selection);

// Update infor bar item in the toolbar.
var label = this.toolbar.element.querySelector(".infoBarItem");
var text = "Collected: " + generator.counter + " objects";
label.innerHTML = text;

this.renderGraph(content);
},

Expand Down
14 changes: 13 additions & 1 deletion skin/classic/styles.css
Expand Up @@ -74,8 +74,20 @@ html, body {
/*************************************************************************************************/
/* Graph Tab */

.tabGraphBody .searchBox {
float: right;
}

.tabGraphBody .toolbar {
text-align: right;
clear: both;
padding-bottom: 3px;
}

.tabGraphBody .infoBarItem {
white-space: nowrap;
color: gray;
cursor: text;
margin: 11px 5px 7px 5px;
}

/*************************************************************************************************/
Expand Down

0 comments on commit 1ab2820

Please sign in to comment.