enable and disable the panel toolbar buttons upon selection change

This commit is contained in:
Damien Churchill 2010-04-28 17:46:21 +01:00
parent ce46dcdf7a
commit c45583e8e7
1 changed files with 15 additions and 2 deletions

View File

@ -182,6 +182,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
singleSelect: true, singleSelect: true,
autoExpandColumn: 'name' autoExpandColumn: 'name'
}); });
this.list.on('selectionchange', this.onSelectionChange, this);
this.panel = this.add({ this.panel = this.add({
items: [this.list], items: [this.list],
@ -195,12 +196,14 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
text: _('Edit'), text: _('Edit'),
iconCls: 'icon-edit', iconCls: 'icon-edit',
handler: this.onEditClick, handler: this.onEditClick,
scope: this scope: this,
disabled: true
}, '->', { }, '->', {
text: _('Remove'), text: _('Remove'),
iconCls: 'icon-remove', iconCls: 'icon-remove',
handler: this.onRemoveClick, handler: this.onRemoveClick,
scope: this scope: this,
disabled: true
}] }]
} }
}); });
@ -256,6 +259,16 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, {
}, },
scope: this scope: this
}); });
},
onSelectionChange: function(dv, selections) {
if (selections.length) {
this.panel.getBottomToolbar().items.get(1).enable();
this.panel.getBottomToolbar().items.get(3).enable();
} else {
this.panel.getBottomToolbar().items.get(1).disable();
this.panel.getBottomToolbar().items.get(3).disable();
}
} }
}); });