Changeset 199077 in webkit


Ignore:
Timestamp:
Apr 5, 2016 3:32:03 PM (8 years ago)
Author:
Matt Baker
Message:

Web Inspector: Should not allow selecting no Timelines when editing in Timeline tab
https://bugs.webkit.org/show_bug.cgi?id=156223
<rdar://problem/25552221>

Reviewed by Joseph Pecoraro.

  • UserInterface/Views/TimelineOverview.js:

(WebInspector.TimelineOverview):
(WebInspector.TimelineOverview.prototype._startEditingInstruments):
Register EnabledDidChange event handler for all tree elements.

(WebInspector.TimelineOverview.prototype._stopEditingInstruments):
Unregister event handler for enabled tree elements. The rest are removed
from the tree outline once editing has completed.

(WebInspector.TimelineOverview.prototype._timelineTreeElementEnabledDidChange):
Enable "Done" button if at least one timeline is enabled.

  • UserInterface/Views/TimelineTreeElement.js:

Dispatch a new event, EnabledDidChange, when the checkbox state changes.

(WebInspector.TimelineTreeElement.prototype._showCheckbox):
(WebInspector.TimelineTreeElement.prototype._clickHandler):
(WebInspector.TimelineTreeElement.prototype._dispatchEnabledDidChangeEvent):
(WebInspector.TimelineTreeElement):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r199041 r199077  
     12016-04-05  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Should not allow selecting no Timelines when editing in Timeline tab
     4        https://bugs.webkit.org/show_bug.cgi?id=156223
     5        <rdar://problem/25552221>
     6
     7        Reviewed by Joseph Pecoraro.
     8
     9        * UserInterface/Views/TimelineOverview.js:
     10        (WebInspector.TimelineOverview):
     11        (WebInspector.TimelineOverview.prototype._startEditingInstruments):
     12        Register EnabledDidChange event handler for all tree elements.
     13
     14        (WebInspector.TimelineOverview.prototype._stopEditingInstruments):
     15        Unregister event handler for enabled tree elements. The rest are removed
     16        from the tree outline once editing has completed.
     17
     18        (WebInspector.TimelineOverview.prototype._timelineTreeElementEnabledDidChange):
     19        Enable "Done" button if at least one timeline is enabled.
     20
     21        * UserInterface/Views/TimelineTreeElement.js:
     22        Dispatch a new event, EnabledDidChange, when the checkbox state changes.
     23
     24        (WebInspector.TimelineTreeElement.prototype._showCheckbox):
     25        (WebInspector.TimelineTreeElement.prototype._clickHandler):
     26        (WebInspector.TimelineTreeElement.prototype._dispatchEnabledDidChangeEvent):
     27        (WebInspector.TimelineTreeElement):
     28
    1292016-04-04  Joseph Pecoraro  <pecoraro@apple.com>
    230
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineOverview.js

    r198605 r199077  
    877877
    878878            treeElement.editing = true;
     879            treeElement.addEventListener(WebInspector.TimelineTreeElement.Event.EnabledDidChange, this._timelineTreeElementEnabledDidChange, this);
    879880        }
    880881
     
    893894            if (treeElement.status.checked) {
    894895                treeElement.editing = false;
     896                treeElement.removeEventListener(WebInspector.TimelineTreeElement.Event.EnabledDidChange, this._timelineTreeElementEnabledDidChange, this);
    895897                continue;
    896898            }
     
    944946        let bTimelineIndex = this._instrumentTypes.indexOf(bTimelineType);
    945947        return aTimelineIndex - bTimelineIndex;
     948    }
     949
     950    _timelineTreeElementEnabledDidChange(event)
     951    {
     952        let enabled = this._timelinesTreeOutline.children.some((treeElement) => {
     953            let timelineType = treeElement.representedObject.type;
     954            return this._canShowTimelineType(timelineType) && treeElement.status.checked;
     955        });
     956
     957        this._editInstrumentsButton.enabled = enabled;
    946958    }
    947959};
  • trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTreeElement.js

    r198605 r199077  
    8888
    8989        let button = new WebInspector.TreeElementStatusButton(checkboxElement);
     90        checkboxElement.addEventListener("change", () => { this._dispatchEnabledDidChangeEvent(); });
     91
    9092        this.status = checkboxElement;
    9193    }
     
    105107
    106108        this.status.checked = !this.status.checked;
     109        this._dispatchEnabledDidChangeEvent();
     110    }
     111
     112    _dispatchEnabledDidChangeEvent()
     113    {
     114        this.dispatchEventToListeners(WebInspector.TimelineTreeElement.Event.EnabledDidChange);
    107115    }
    108116};
     117
     118WebInspector.TimelineTreeElement.Event = {
     119    EnabledDidChange: "timeline-tree-element-enabled-did-change"
     120};
Note: See TracChangeset for help on using the changeset viewer.