Creates a new editor for the given parent and operator.
        
        :param      parent      | <QWidget>
                    operator    | <str>
                    value       | <variant>
427880
def createEditor(self, parent, column, operator, value):
        
        editor = super(ForeignKeyPlugin, self).createEditor(parent,
                                                            column,
                                                            operator,
                                                            value)
        
        if editor is not None:
            editor.setRequired(column.required())
            editor.setMinimumWidth(150)
            
            model = column.referenceModel()
            if model:
                text = model.schema().displayName().lower()
                editor.setHint('any {0}'.format(text))
                
                editor.setRecords(model.select())
                if operator in ('is in', 'is not in'):
                    editor.setCheckable(True)
        
        return editor
909824
def add_parent(self, parent):
        
        parent.add_child(self)
        self.parent = parent
        return parent
465417
def __createInspectorActionGroup(self, parent):
        
        actionGroup = QtWidgets.QActionGroup(parent)
        actionGroup.setExclusive(True)

        sortedItems = sorted(self.argosApplication.inspectorRegistry.items,
                             key=lambda item: item.identifier)
        shortCutNr = 1
        for item in sortedItems:
            logger.debug("item: {}".format(item.identifier))
            setAndDrawFn = partial(self.setAndDrawInspectorById, item.identifier)
            action = QtWidgets.QAction(item.name, self, triggered=setAndDrawFn, checkable=True)
            action.setData(item.identifier)
            if shortCutNr <= 9 and "debug" not in item.identifier: # TODO: make configurable by the user
                action.setShortcut(QtGui.QKeySequence("Ctrl+{}".format(shortCutNr)))
                shortCutNr += 1

            actionGroup.addAction(action)

        return actionGroup
243725
function (parent, child) {

/*Line 17 - 'AtomFormLayout.js' */                var isChildField = false;

/*Line 19 - 'AtomFormLayout.js' */                var amap = AtomUI.attributeMap(child, /^(atom\-(init|type|label|required|regex|data\-type|is\-valid|field\-(value|visible|class)|error))$/i);

/*Line 21 - 'AtomFormLayout.js' */                var at = amap["atom-type"];
/*Line 22 - 'AtomFormLayout.js' */                if (at) {
/*Line 23 - 'AtomFormLayout.js' */                    amap["atom-type"] = null;
/*Line 24 - 'AtomFormLayout.js' */                    switch (at.value) {
/*Line 25 - 'AtomFormLayout.js' */                        case "AtomFormField":
/*Line 26 - 'AtomFormLayout.js' */                            isChildField = true;
/*Line 27 - 'AtomFormLayout.js' */                            break;
/*Line 28 - 'AtomFormLayout.js' */                        case "AtomFormGridLayout":
/*Line 29 - 'AtomFormLayout.js' */                        case "AtomFormTab":
/*Line 30 - 'AtomFormLayout.js' */                            parent.appendChild(child);
/*Line 31 - 'AtomFormLayout.js' */                            var a = AtomUI.createControl(child, at.value);
/*Line 32 - 'AtomFormLayout.js' */                            return a;
/*Line 33 - 'AtomFormLayout.js' */                            break;
/*Line 34 - 'AtomFormLayout.js' */                    }
/*Line 35 - 'AtomFormLayout.js' */                }


/*Line 38 - 'AtomFormLayout.js' */                var field = AtomUI.cloneNode(this._fieldTemplate);

/*Line 40 - 'AtomFormLayout.js' */                var cp = AtomUI.findPresenter(field);
/*Line 41 - 'AtomFormLayout.js' */                if (cp) {
/*Line 42 - 'AtomFormLayout.js' */                    if (isChildField) {
/*Line 43 - 'AtomFormLayout.js' */                        var ce = new ChildEnumerator(child);
/*Line 44 - 'AtomFormLayout.js' */                        while (ce.next()) {
/*Line 45 - 'AtomFormLayout.js' */                            cp.appendChild(ce.current());
/*Line 46 - 'AtomFormLayout.js' */                        }
/*Line 47 - 'AtomFormLayout.js' */                    } else {
/*Line 48 - 'AtomFormLayout.js' */                        cp.appendChild(child);
/*Line 49 - 'AtomFormLayout.js' */                    }
/*Line 50 - 'AtomFormLayout.js' */                    AtomUI.removeAttr(cp, "atom-presenter");
/*Line 51 - 'AtomFormLayout.js' */                } else {
/*Line 52 - 'AtomFormLayout.js' */                    field.contentElement = child;
/*Line 53 - 'AtomFormLayout.js' */                }

/*Line 55 - 'AtomFormLayout.js' */                parent.appendChild(field);

/*Line 57 - 'AtomFormLayout.js' */                for (var k in amap) {
/*Line 58 - 'AtomFormLayout.js' */                    var v = amap[k];
/*Line 59 - 'AtomFormLayout.js' */                    if (!v)
/*Line 60 - 'AtomFormLayout.js' */                        continue;
/*Line 61 - 'AtomFormLayout.js' */                    child.removeAttributeNode(v.node);
/*Line 62 - 'AtomFormLayout.js' */                    field.setAttributeNode(v.node);
/*Line 63 - 'AtomFormLayout.js' */                }

/*Line 65 - 'AtomFormLayout.js' */                amap = AtomUI.attributeMap(field, /^atom\-(field\-value|is\-valid)$/i);

/*Line 67 - 'AtomFormLayout.js' */                if (!(amap["atom-field-value"] || amap["atom-is-valid"])) {
/*Line 68 - 'AtomFormLayout.js' */                    var v = AtomUI.attr(child, "atom-value");
/*Line 69 - 'AtomFormLayout.js' */                    if (v && /^\$\[/gi.test(v)) {
/*Line 70 - 'AtomFormLayout.js' */                        // must be a two way binding..
/*Line 71 - 'AtomFormLayout.js' */                        v = v.substr(2);
/*Line 72 - 'AtomFormLayout.js' */                        if (!/^\$/gi.test(v)) {
/*Line 73 - 'AtomFormLayout.js' */                            v = "$" + v;
/*Line 74 - 'AtomFormLayout.js' */                        }
/*Line 75 - 'AtomFormLayout.js' */                        v = "[" + v;
/*Line 76 - 'AtomFormLayout.js' */                        var ind = v.indexOf(']');
/*Line 77 - 'AtomFormLayout.js' */                        v = v.substr(0, ind + 1);
/*Line 78 - 'AtomFormLayout.js' */                        AtomUI.attr(field, "atom-field-value", v);
/*Line 79 - 'AtomFormLayout.js' */                    }
/*Line 80 - 'AtomFormLayout.js' */                }

/*Line 82 - 'AtomFormLayout.js' */                return AtomUI.createControl(field, WebAtoms.AtomFieldType);
/*Line 83 - 'AtomFormLayout.js' */            }
347183
def parent(self, parent):
        
        self._parent = parent
        if parent:
            pctx = dict((x, getattr(parent, x)) for x in parent.context_keys)
            self.inject_context(pctx)
            self.depth = parent.depth + 1
            for command in self.subcommands.values():
                command.parent = self  # bump.
        else:
            self.depth = 0
757361
def duplicate(self, parent):
        
        # only return a single singleton instance
        if self.isViewSingleton():
            return self
            
        output = type(self).createInstance(parent, self.viewWidget())
        
        # save/restore the current settings
        xdata = ElementTree.Element('data')
        self.saveXml(xdata)
        new_name = output.objectName()
        output.setObjectName(self.objectName())
        output.restoreXml(xdata)
        output.setObjectName(new_name)
        
        return output
365065
function(result, value, parent) {
	var i;
	result = result != null ? result : _.object([parent], [0]);
		
	if (_.isNumber(value)) {
		result[parent] += value;
	}
	
	else if (_.isObject(value)) {
		if (_.isArray(value)) {
			for (i = 0; i < value.length; i += 1) {
				_formatRow(result, value[i], parent);
			}
		} else {
			for (i in value) {
				if (value.hasOwnProperty(i)) {
					_formatRow(result, value[i], parent);
				}
			}
		}
		return result;
	}
	return result;
}
1176929
def editor(self, value):
        

        if value is not None:
            assert type(value) is Editor, "'{0}' attribute: '{1}' type is not 'Editor'!".format("editor", value)
        self.__editor = value
159321
def parent_widget(self):
        
        parent = self.parent()
        if parent is not None and isinstance(parent, QtGraphicsItem):
            return parent.widget
1208294
def replace_parent(self, parent_simples):
        
        assert parent_simples

        ancestors = parent_simples[:-1]
        parent = parent_simples[-1]

        did_replace = False
        new_tokens = []
        for token in self.tokens:
            if not did_replace and token in ('&', 'self'):
                did_replace = True
                new_tokens.extend(parent.tokens)
                if token == 'self':
                    warn(FutureWarning(
                        "The xCSS 'self' selector is deprecated and will be "
                        "removed in 2.0.  Use & instead.  ({0!r})"
                        .format(self)
                    ))
            else:
                new_tokens.append(token)

        if not did_replace:
            # This simple selector doesn't contain a parent reference so just
            # stick it on the end
            return parent_simples + (self,)

        # This simple selector was merged into the direct parent.
        merged_self = type(self)(parent.combinator, new_tokens)
        selector = ancestors + (merged_self,)
        # Our combinator goes on the first ancestor, i.e., substituting "foo
        # bar baz" into "+ &.quux" produces "+ foo bar baz.quux".  This means a
        # potential conflict with the first ancestor's combinator!
        root = selector[0]
        if not _is_combinator_subset_of(self.combinator, root.combinator):
            raise ValueError(
                "Can't sub parent {0!r} into {1!r}: "
                "combinators {2!r} and {3!r} conflict!"
                .format(
                    parent_simples, self, self.combinator, root.combinator))

        root = type(self)(self.combinator, root.tokens)
        selector = (root,) + selector[1:]
        return tuple(selector)
652854
def createEditor(self, delegate, parent, option):
        
        return IntCtiEditor(self, delegate, parent=parent)
231174
function(self, options) {

    self.options = options;
    self.editorName = self.name + '-widgets-editor';

    // Opens the editor modal of a widget, unless the widget is contextualOnly,
    // in which case we simply save the widget and call the save method
    // Widget can opitonally be set to skipInitialModal which skips the first
    // edit modal but binds future editing interactions

    self.edit = function(data, options, save) {
      if (!data) {
        data = {};
      }
      if (!data._id) {
        _.assign(data, apos.schemas.newInstance(self.schema));
      }

      // Only create a modal editor if the schema is not contextual only
      if (self.options.contextualOnly) {

        return save(checkOrGenerateId(data), function() {});

      } else {

        if (self.options.skipInitialModal && (!data || !data._id)) {
          return save(checkOrGenerateId(data), function() {});

        }

        apos.create(self.editorName, {
          label: self.label,
          action: self.options.action,
          schema: self.options.schema,
          data: data,
          templateOptions: options,
          save: save,
          module: self
        });
      }

      // Checks for an id or assign a generated one
      function checkOrGenerateId (data) {
        data = data || {};
        if (!data._id) {
          data._id = apos.utils.generateId();
        }
        return data;
      }

    };

    // Area editor calls this to determine whether to apply an empty state
    // class for the widget
    self.isEmpty = function($widget) {
      return false;
    };

    var superGetData = self.getData;
    self.getData = function($widget) {
      var data = superGetData($widget);
      // If the field is contextual and its type has a `contextualConvert`
      // function, we need to run that when retrieving the widget's data.
      // Or, if the field has a `contextualIsPresent` method, we can use that
      // to check whether an editor is actually present for it, bypassing the
      // need to restrict this feature solely to fields marked contextual
      // in the schema.
      _.each(self.schema, function(field) {
        var type = apos.schemas.fieldTypes[field.type];
        if (
          (type.contextualIsPresent && type.contextualIsPresent($widget, field) && type.contextualConvert) ||
          (field.contextual && type.contextualConvert)
        ) {
          apos.schemas.fieldTypes[field.type].contextualConvert(data, field.name, $widget, field);
        }
      });
      return data;
    };

    // Start autosaving the area containing the given widget,
    // then invoke the given function. On failure fn is not invoked.
    // Invoked by widgets that are edited contextually on the page,
    // like apostrophe-rich-text, as opposed to widgets edited
    // via a modal.

    self.startAutosavingAreaThen = function($widget, fn) {
      var $area = $widget.closest('[data-apos-area]');
      return $area.data('editor').startAutosavingThen(fn);
    };
  }
245740
def set_parent(self, parent):
        
        if self._parent == parent:
            return
        if self._parent:
            self._parent.remove_child(self)
        self._parent = parent
        if parent:
            parent.add_child(self)
294870
def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
                      toggled=None, triggered=None,
                      autoraise=True, text_beside_icon=False):
    """"""
    button = QToolButton(parent)
    if text is not None:
        button.setText(text)
    if icon is not None:
        if is_text_string(icon):
            icon = get_icon(icon)
        button.setIcon(icon)
    if text is not None or tip is not None:
        button.setToolTip(text if tip is None else tip)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    button.setAutoRaise(autoraise)
    if triggered is not None:
        button.clicked.connect(triggered)
    if toggled is not None:
        button.toggled.connect(toggled)
        button.setCheckable(True)
    if shortcut is not None:
        button.setShortcut(shortcut)
    return button
1052361
def set_parent(self, parent):
        '''
        '''
        if not isinstance(parent, Node):
            raise TypeError("parent must be a Node")
        self.parent = parent
739881
def control(parent, indent)
      # Accept eval or multiline eval syntax and return a new node,
      return unless (structure = accept(:control))
      structure = structure.to_sym

      # Handle each and the other control structures
      condition = accept(:line_feed).strip

      # Process each control structure condition
      if structure == :each
        # Check if arguments provided correctly
        unless condition.match Tokens[:each_pattern]
          Logger.error :parse, @code, @i, @j, :each_arguments
        end

        # Conditions for each iterator
        condition = [
          Regexp.last_match[1].split(' '),
          Regexp.last_match[2].split(/,(.+)$/).map(&:strip).map(&:to_sym)
        ]

        # Array loop as default
        condition[0].unshift '{}' if condition[0].length == 1
      end

      # Else and default structures are not allowed to have any condition
      # set and the other control structures require a condition
      if structure == :else
        unless condition.empty?
          Logger.error :parse, @code, @i, @j, :condition_exists
        end
      else
        if condition.empty?
          Logger.error :parse, @code, @i, @j, :condition_missing
        end
      end

      # Add the condition and create a new child to the control parent.
      # The control parent keeps condition -> children matches for our
      # document's content
      # add_options = proc do |control_parent|
      #   control_parent.value << condition
      #   control_parent.children << []
      #
      #   root control_parent
      # end

      # If the current control structure is a parent which allows multiple
      # branches, such as an if or case, we create an array of conditions
      # which can be matched and an array of children belonging to each
      # conditional branch
      if [:if, :unless].include? structure
        # Create the control structure and get its child nodes
        control_structure = [structure, [condition], {}, [], indent]
        root control_structure, indent

        # Turn children into an array because we allow multiple branches
        control_structure[@children] = [control_structure[@children]]

        # Add it to the parent node
        parent[@children] << control_structure

      elsif structure == :case
        # Create the control structure and get its child nodes
        control_structure = [
          structure,
          [],
          { condition: condition },
          [],
          indent
        ]

        # Add it to the parent node
        parent[@children] << control_structure

      # If the control structure is a child structure, we need to find the
      # node it belongs to amont the current parent. Search from end to
      # beginning until we find the node parent
      elsif control_child structure
        # During the search, we try to find the matching parent type
        unless control_parent(structure).include? parent[@children][-1][@type]
          Logger.error :parse,
                       @code,
                       @i,
                       @j,
                       :control_child,
                       control_parent(structure)
        end

        # Gather child elements for current structure
        control_structure = [structure, [condition], {}, [], indent]
        root control_structure, indent

        # Add the new condition and children to our parent structure
        parent[@children][-1][@value] << condition
        parent[@children][-1][@children] << control_structure[@children]

      # When our control structure isn't a complex composite, we create
      # it the same way as a normal node
      else
        control_structure = [structure, condition, {}, [], indent]
        root control_structure, indent

        parent[@children] << control_structure
      end
    end
1251183
def _assign_parent(self, ctx):
        
        def _assign(cls, _, obj):
            if obj == None:
                return

            if cls.is_produced(obj):
                if isinstance(obj, BaseObj):
                    obj._parent__ = self
            else:
                raise ValueError('Object is not instance of {0} but {1}'.format(cls.__swagger_ref_object__.__name__, obj.__class__.__name__))

        # set self as childrent's parent
        for name, (ct, ctx) in six.iteritems(ctx.__swagger_child__):
            obj = getattr(self, name)
            if obj == None:
                continue

            container_apply(ct, obj, functools.partial(_assign, ctx))