Sets the state of a checkbox
@param page
@param ph
@param {Array} selectorAndState index 0 - {string} selector
index 1 - {boolean} state
@param {pageCallback} callback
552322
function setCheckboxState(page, ph, selectorAndState, callback) {
    page.evaluate(function (selectorAndState) {
        try {
            var selector = selectorAndState[0];
            var state = selectorAndState[1];
            var element = document.querySelector(selector);
            element.checked = state;

            // event is needed because listeners to the change do not react to
            // programmatic changes
            var event = document.createEvent('Event');
            event.initEvent('change', true, false);
            element.dispatchEvent(event);
            return null;
        } catch (error) {
            return error;
        }
    }, function (error) {
        // do this because if there is no error, the error is still something so we can't simply do callback(error, page, ph);
        if (error) {
            callback(error, page, ph);
            return;
        }
        callback(null, page, ph);
    }, selectorAndState);
}
292756
public void setState(CmsListState listState) {

        if (!m_metadata.isSelfManaged()) {
            m_filteredItems = null;
        }
        synchronized (this) {
            if (m_visibleItems != null) {
                m_visibleItems.clear();
            }
        }
        setSearchFilter(listState.getFilter());
        setSortedColumn(listState.getColumn());
        if (listState.getOrder() == CmsListOrderEnum.ORDER_DESCENDING) {
            setSortedColumn(listState.getColumn());
        }
        if (listState.getPage() > 0) {
            if (listState.getPage() <= getNumberOfPages()) {
                setCurrentPage(listState.getPage());
            } else {
                setCurrentPage(1);
            }
        }
    }
414079
public void setPage(int page) {

        if (m_collectorParameter != null) {
            int pos = m_collectorParameter.indexOf(I_CmsListResourceCollector.PARAM_PAGE);
            if (pos >= 0) {
                String params = "";
                int endPos = m_collectorParameter.indexOf(I_CmsListResourceCollector.SEP_PARAM, pos);
                if (pos > 0) {
                    pos -= I_CmsListResourceCollector.SEP_PARAM.length(); // remove also the SEP_PARAM
                    params += m_collectorParameter.substring(0, pos);
                }
                if (endPos >= 0) {
                    if (pos == 0) {
                        endPos += I_CmsListResourceCollector.SEP_PARAM.length(); // remove also the SEP_PARAM
                    }
                    params += m_collectorParameter.substring(endPos, m_collectorParameter.length());
                }
                m_collectorParameter = params;
            }
        }
        if (m_collectorParameter == null) {
            m_collectorParameter = "";
        } else if (m_collectorParameter.length() > 0) {
            m_collectorParameter += I_CmsListResourceCollector.SEP_PARAM;
        }
        m_collectorParameter += I_CmsListResourceCollector.PARAM_PAGE + I_CmsListResourceCollector.SEP_KEYVAL + page;
        synchronized (this) {
            m_resources = null;
        }
    }
1158009
function setOPBrowserState (event) {
    var key = 'anvil.connect.op.state'
    var current = localStorage[key]
    var update = event.data

    if (current !== update) {
      document.cookie = 'anvil.connect.op.state=' + update
      localStorage['anvil.connect.op.state'] = update
    }
  }
177353
function Node(page, startPosition, endPosition) {
        this.parentNode = null;
        this.page = page;
        this.startPosition = startPosition;
        this.endPosition = endPosition;
        this.nodeName = null;
        this.previousSibling = null;
        this.nextSibling = null;
    }
1206252
public static void checkState(boolean b, String errorMessageTemplate, double p) {
        if (!b) {
            throw new IllegalStateException(format(errorMessageTemplate, p));
        }
    }
663376
protected void updatePageStatus() {
		if (this.status.isOK()) {
			setMessage(null, IMessageProvider.NONE);
		} else {
			switch (this.status.getSeverity()) {
			case IStatus.ERROR:
				setMessage(this.status.getMessage(), IMessageProvider.ERROR);
				break;
			case IStatus.INFO:
				setMessage(this.status.getMessage(), IMessageProvider.INFORMATION);
				break;
			case IStatus.WARNING:
				setMessage(this.status.getMessage(), IMessageProvider.WARNING);
				break;
			default:
				break;
			}
		}
		setPageComplete(this.status.isOK() || this.status.getSeverity() == IStatus.INFO);
	}
242075
public static void setStateParam(String name, String value, HttpServletRequest req, HttpServletResponse res) {
		setStateParam(name, value, req, res, false);
	}
1215788
function pageHasChanged(page, oldUrl, callback) {
    var elapsed = 0;

    var newUrl;
    var urlHasChanged = false;
    var documentReady = false;
    var waitTimeOver = false;

    async.until(
        function () {
            waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
            return waitTimeOver || documentReady;
        },

        function (callback) {
            // polls the page at an interval
            setTimeout(function () {
                elapsed += constants.POLL_INTERVAL;

                async.waterfall([
                    function (callback) {
                        // checks the url
                        page.get('url', function (url) {
                            newUrl = url;
                            urlHasChanged = newUrl !== oldUrl;

                            callback();
                        })
                    },
                    function (callback) {
                        if (!urlHasChanged) {
                            callback();
                            return;
                        }

                        // checks the document.readyState
                        page.evaluate(function () {
                            return (document.readyState === 'interactive') || (document.readyState === 'complete');
                        }, function (domReady) {
                            documentReady = domReady;
                            callback();
                        });
                    }
                ], function (error) {
                    // no error is triggered
                    callback();
                });
            }, constants.POLL_INTERVAL);
        },

        function (error) {
            if (waitTimeOver) {
                // todo Go back to previous url?
                callback('Timeout while navigating to ' + url);
                return;
            }

            callback();
        }
    );
}
408382
function (pageIndex, options, callback) {

            if (pageIndex < 0) {
                throw "pageIndex must be >= 0";
            }

            var page = this.$pageCache[pageIndex];
            if (!page) {
                page = this.$pageCache[pageIndex] = new Page(null, this, pageIndex);
            }

            var self = this;
            options = _.extend(this.$, options);
            page.fetch(options, function (err, page) {
                // insert data into items if not already inserted
                if (!err && !page.itemsInsertedIntoCollection) {
                    page.itemsInsertedIntoCollection = true;

                    // add items to collection
                    self.add(page.$items, {
                        index: (pageIndex || 0) * self.$.pageSize
                    });
                }

                if (callback) {
                    callback(err, page, options);
                }
            });
        }
1317801
private synchronized void setState(int state) {
        mState = state;

        // Give the new state to the Handler so the UI Activity can update
        mHandler.obtainMessage(ISOBlueDemo.MESSAGE_STATE_CHANGE, state, -1)
                .sendToTarget();
    }
260016
public void checkReloadState(final AsyncCallback<Boolean> callback) {

        // :read-attribute(name=process-type)
        final ModelNode operation = new ModelNode();
        operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
        operation.get(NAME).set("server-state");
        operation.get(ADDRESS).setEmptyList();

        dispatcher.execute(new DMRAction(operation), new SimpleCallback<DMRResponse>() {

            @Override
            public void onSuccess(DMRResponse result) {

                ModelNode response = result.get();
                System.out.println(response);

                if(response.isFailure()) {
                    callback.onFailure(new RuntimeException("Failed to poll server state"));
                }
                else
                {
                    // TODO: only works when this response changes the reload state
                    String outcome = response.get(RESULT).asString();
                    boolean keepRunning = !outcome.equalsIgnoreCase("running");//reloadState.isStaleModel();

                    if(!keepRunning)
                    {

                        // clear state
                        reloadState.reset();

                        Console.info(Console.MESSAGES.successful("Reload Server"));
                        getView().setReloadRequired(reloadState);
                        getEventBus().fireEvent(new ReloadEvent());
                    }

                    callback.onSuccess(keepRunning);
                }
            }
        });
    }
77236
function (e) {
        if (!this.all || (e && e.prevValue === e.newValue)) {
            return;
        }

        this.all.value = e.newValue;
        if (this.all.selected) {
            this.paginator.set('rowsPerPage',e.newValue);
        }
    }
766411
@SuppressWarnings({"unchecked", "unused"})
	public void setViewState(MvpViewState<View> viewState) {
		mViewStateAsView = (View) viewState;
		mViewState = (MvpViewState) viewState;
	}
1222180
protected void setActiveCheckBox(CheckBox box) {

        m_selected = box;
        if (m_listener != null) {
            m_listener.onSelect(box);
        }
    }
1266464
function(state) {
            this.setState({
                panels: this.state.panels.map(function(panel) {
                    panel.checked = state.index === panel.index
                    return panel
                })
            })
        }
1186301
function checkbox(bind, el, param, value) {
  var attr = {type: 'checkbox', name: param.signal};
  if (value) attr.checked = true;
  var node = element('input', attr);

  el.appendChild(node);

  node.addEventListener('change', function() {
    bind.update(node.checked);
  });

  bind.elements = [node];
  bind.set = function(value) { node.checked = !!value || null; }
}