summaryrefslogtreecommitdiffstats
path: root/WebCore/inspector/front-end/DataGrid.js
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/inspector/front-end/DataGrid.js')
-rw-r--r--WebCore/inspector/front-end/DataGrid.js38
1 files changed, 29 insertions, 9 deletions
diff --git a/WebCore/inspector/front-end/DataGrid.js b/WebCore/inspector/front-end/DataGrid.js
index 7b58c8e..3eca9e4 100644
--- a/WebCore/inspector/front-end/DataGrid.js
+++ b/WebCore/inspector/front-end/DataGrid.js
@@ -39,6 +39,8 @@ WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
this._dataTable.addEventListener("mousedown", this._mouseDownInDataTable.bind(this), true);
this._dataTable.addEventListener("click", this._clickInDataTable.bind(this), true);
+ this._dataTable.addEventListener("contextmenu", this._contextMenuInDataTable.bind(this), true);
+
// FIXME: Add a createCallback which is different from editCallback and has different
// behavior when creating a new node.
if (editCallback) {
@@ -469,10 +471,11 @@ WebInspector.DataGrid.prototype = {
this.children = [];
},
- handleKeyEvent: function(event)
+
+ _keyDown: function(event)
{
if (!this.selectedNode || event.shiftKey || event.metaKey || event.ctrlKey || this._editing)
- return false;
+ return;
var handled = false;
var nextSelectedNode;
@@ -540,8 +543,6 @@ WebInspector.DataGrid.prototype = {
event.preventDefault();
event.stopPropagation();
}
-
- return handled;
},
expand: function()
@@ -572,11 +573,6 @@ WebInspector.DataGrid.prototype = {
return rowElement._dataGridNode;
},
- _keyDown: function(event)
- {
- this.handleKeyEvent(event);
- },
-
_clickInHeaderCell: function(event)
{
var cell = event.target.enclosingNodeOrSelfWithNodeName("th");
@@ -621,6 +617,30 @@ WebInspector.DataGrid.prototype = {
} else
gridNode.select();
},
+
+ _contextMenuInDataTable: function(event)
+ {
+ var gridNode = this.dataGridNodeFromNode(event.target);
+ if (!gridNode || !gridNode.selectable)
+ return;
+
+ if (gridNode.isEventWithinDisclosureTriangle(event))
+ return;
+
+ var contextMenu = new WebInspector.ContextMenu();
+
+ // FIXME: Use the column names for Editing, instead of just "Edit".
+ if (this.dataGrid._editCallback) {
+ if (gridNode === this.creationNode)
+ contextMenu.appendItem(WebInspector.UIString("Add New"), this._startEditing.bind(this, event.target));
+ else
+ contextMenu.appendItem(WebInspector.UIString("Edit"), this._startEditing.bind(this, event.target));
+ }
+ if (this.dataGrid._deleteCallback && gridNode !== this.creationNode)
+ contextMenu.appendItem(WebInspector.UIString("Delete"), this._deleteCallback.bind(this, gridNode));
+
+ contextMenu.show(event);
+ },
_clickInDataTable: function(event)
{