/*
setup_priority_buttons

Called by todo.get_items. Sets up the three traffic-light buttons used to select a priority level when creating a new item.
436462
function(){
      $('#priority_buttons').html('');
      var _i, pb, all_pbs = [ ];
      for (_i = 3; _i > 0; _i --){
        pb = new todo.priority_button(_i);
        $('#priority_buttons').append(pb.button);
        all_pbs.push(pb);
        if (_i == 3){
          pb.select(); // Select lower priority by default
        }
      }
      todo.all_pbs = all_pbs;
    }
677491
public void setupKeys()
    {
        KeyAreaInfo keyArea = null;
        keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY);
        keyArea.addKeyField(ID, Constants.ASCENDING);
        keyArea = new KeyAreaInfo(this, Constants.NOT_UNIQUE, SCREEN_IN_PROG_NAME_KEY);
        keyArea.addKeyField(SCREEN_IN_PROG_NAME, Constants.ASCENDING);
        keyArea.addKeyField(SCREEN_ITEM_NUMBER, Constants.ASCENDING);
    }
1076177
function setupHelpButton() {
    var command = commandRegistry.get(mindmaps.HelpCommand);
    command.setHandler(showHelp);

    var notifications = [];
    function showHelp() {
      // true if atleast one notifications is still on screen
      var displaying = notifications.some(function(noti) {
        return noti.isVisible();
      });

      // hide notifications if visible
      if (displaying) {
        notifications.forEach(function(noti) {
          noti.close();
        });
        notifications.length = 0;
        return;
      }

      // show notifications
      var helpRoot = new mindmaps.Notification(
          ".node-caption.root",
          {
            position : "bottomLeft",
            closeButton : true,
            maxWidth : 350,
            title : "This is your main idea",
            content : "Double click an idea to edit its text. Move the mouse over "
                + "an idea and drag the red circle to create a new idea."
          });

      var helpNavigator = new mindmaps.Notification(
          "#navigator",
          {
            position : "leftTop",
            closeButton : true,
            maxWidth : 350,
            padding : 20,
            title : "This is the navigator",
            content : "Use this panel to get an overview of your map. "
                + "You can navigate around by dragging the red rectangle or change the zoom by clicking on the magnifier buttons."
          });

      var helpInspector = new mindmaps.Notification(
          "#inspector",
          {
            position : "leftTop",
            closeButton : true,
            maxWidth : 350,
            padding : 20,
            title : "This is the inspector",
            content : "Use these controls to change the appearance of your ideas. "
                + "Try clicking the icon in the upper right corner to minimize this panel."
          });

      var helpToolbar = new mindmaps.Notification(
          "#toolbar .buttons-left",
          {
            position : "bottomLeft",
            closeButton : true,
            maxWidth : 350,
            title : "This is your toolbar",
            content : "Those buttons do what they say. You can use them or work with keyboard shortcuts. "
                + "Hover over the buttons for the key combinations."
          });

      notifications.push(helpRoot, helpNavigator, helpInspector,
          helpToolbar);
    }
  }
229819
function _addListeners() {
        if (_automaticSort && _currentSort && _currentSort.getEvents()) {
            MainViewManager
                .on(_currentSort.getEvents(), function () {
                    _currentSort.sort();
                })
                .on("_workingSetDisableAutoSort.sort", function () {
                    setAutomatic(false);
                });
        }
    }
214172
function(items, settings) {
            // Param mapping
            if (typeof settings === 'undefined' && $.isPlainObject(items)) {
                // (settings)
                settings = items;
                items = null;
            }

            settings = $.extend({}, Garnish.Drag.defaults, settings);
            this.base(items, settings);
        }
909825
function (settings) {
        var self = this;

        settings.autohide = true;
        settings.constrainToViewport = true;

        if (typeof settings.items === 'function') {
          settings.itemsFactory = settings.items;
          settings.items = [];
        }

        if (settings.itemDefaults) {
          var items = settings.items, i = items.length;

          while (i--) {
            items[i] = Tools.extend({}, settings.itemDefaults, items[i]);
          }
        }

        self._super(settings);
        self.classes.add('menu');
      }
1165948
function () {
            var selected = [];
            var items = this._data.items;
            for (var i = 0; i < items.length; i++) {
                if (!items[i].initiallyDisabled) {
                    selected.push(items[i].value);
                }
            }
            this.setSelectedValues(selected);
            if (this._data) {
                this.json.setValue(this._data, "focusIndex", 0);
            }
        }
37053
function _setupGoLiveButton() {
        if (!_$btnGoLive) {
            _$btnGoLive = $("#toolbar-go-live");
            _$btnGoLive.click(function onGoLive() {
                _handleGoLiveCommand();
            });
        }
        LiveDevImpl.on("statusChange", function statusChange(event, status, reason) {
            // status starts at -1 (error), so add one when looking up name and style
            // See the comments at the top of LiveDevelopment.js for details on the
            // various status codes.
            _setLabel(_$btnGoLive, null, _status[status + 1].style, _status[status + 1].tooltip);
            _showStatusChangeReason(reason);
            if (config.autoconnect) {
                window.sessionStorage.setItem("live.enabled", status === 3);
            }
        });

        // Initialize tooltip for 'not connected' state
        _setLabel(_$btnGoLive, null, _status[1].style, _status[1].tooltip);
    }
1116407
function (items, options) {
            options = options || {};

            this.$items = [];
            this.$itemEventMap = {};

            this.callBase(options);

            if (items) {
                this.add(items);
            }

            var self = this;

            function updateLength() {
                self.length = self.size();
            }

            // TODO: allow array here to give multiple event hin
            this.bind('add', updateLength);
            this.bind('remove', updateLength);
            this.bind('reset', updateLength);

            this.length = this.size();
        }
1184404
def enqueue item, priority=0
      raise RangeError.new("priority #{priority} is greater than queue size") if priority > self.size
      @array.push PQNode.new(item, priority)
      @array.sort! { |a, b| a.priority <=> b.priority }
    end
540043
function priorityFill( callback ) {
	var queue, prioritizedQueue;

	queue = config.queue.slice( priorityFill.pos );
	prioritizedQueue = config.queue.slice( 0, -config.queue.length + priorityFill.pos );

	queue.unshift( callback );
	queue.unshift.apply( queue, prioritizedQueue );

	config.queue = queue;

	priorityFill.pos += 1;
}
649928
function setSelectable(item) {
            if (item.children) {
                item.children.forEach(setSelectable);
            }
            if (item.submenu) {
                item.selectable = !!item.selectable;
            }
        }
83406
function buildButtonList() {
		var buttons=[];
		// var i = 0;
/*
		buttons.push({
			id:id_prefix + 'markers_off',
			title:'Turn off all markers',
			type:'context',
			events: { 'click': setMarkerSet },
			panel: 'marker_panel'
		});
		buttons.push({
			id:id_prefix + 'markers_dimension',
			title:'Dimension',
			type:'context',
			events: { 'click': setMarkerSet },
			panel: 'marker_panel'
		});
		buttons.push({
			id:id_prefix + 'markers_label',
			title:'Label',
			type:'context',
			events: { 'click': setMarkerSet },
			panel: 'marker_panel'
		});
*/
		$.each(mtypes, function (k, pos) {
			var listname = pos + "_marker_list";
			var def = true;
			$.each(marker_types, function (id, v) {
				var title = getTitle('en', id);
				buttons.push({
					id: id_prefix + pos + '_' + id,
					svgicon: id,
					title: title,
					type: 'context',
					events: {'click': setArrowFromButton},
					panel: 'marker_panel',
					list: listname,
					isDefault: def
				});
				def = false;
			});
		});
		return buttons;
	}
1220090
private void setupComponents() {
		cancelButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				dispose();
			}
		});

		finishButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(getContentPane(), "Wizard finished!");
				dispose();
			}
		});

		cancelButton.setMnemonic(KeyEvent.VK_C);
		previousButton.setMnemonic(KeyEvent.VK_P);
		nextButton.setMnemonic(KeyEvent.VK_N);
		finishButton.setMnemonic(KeyEvent.VK_F);

		wizardPageContainer.addContainerListener(new MinimumSizeAdjuster());
	}
146776
def add_priority(self, name, **attrs):
        
        return Priorities(self.requester).create(self.id, name, **attrs)
1266535
public void setSelectedMenuItems(final List<? extends MenuItemSelectable> selectedItems) {
		MenuModel model = getOrCreateComponentModel();
		if (selectedItems == null || selectedItems.isEmpty()) {
			model.selectedMenuItems = null;
		} else {
			List<MenuItemSelectable> items = new ArrayList<>();
			for (MenuItemSelectable item : selectedItems) {
				if (item.isSelectAllowed()) {
					items.add(item);
				}
			}
			if (items.isEmpty()) {
				model.selectedMenuItems = null;
			} else {
				model.selectedMenuItems = items;
			}
		}
	}
369616
public void setButtons(java.util.Collection<Button> buttons) {
        if (buttons == null) {
            this.buttons = null;
            return;
        }

        this.buttons = new java.util.ArrayList<Button>(buttons);
    }