Creates a new editor for the parent based on the plugin parameters.
        
        :param      parent | <QWidget>
        
        :return     <QWidget> || None
546499
def createEditor(self, parent, column, op, value):
        
        try:
            cls = self._operatorMap[nativestring(op)].cls
        except KeyError, AttributeError:
            return None
        
        # create the new editor
        if cls:
            widget = cls(parent)
            widget.setAttribute(Qt.WA_DeleteOnClose)
            projexui.setWidgetValue(widget, value)
            return widget
        
        return None
244032
def set_parent_on_new(self, parentrefobj):
        
        refobjinter = self.get_refobjinter()
        # to make sure we only get the new one
        # we get all current unwrapped first
        old = self.get_unwrapped(self.get_root(), refobjinter)
        yield
        new = self.get_unwrapped(self.get_root(), refobjinter) - old
        for refobj in new:
            if refobjinter.get_parent(refobj) is None:
                refobjinter.set_parent(refobj, parentrefobj)
110165
def setup_editorstack(self, parent, layout):
        """"""
        layout.setSpacing(1)

        self.fname_label = QLabel()
        self.fname_label.setStyleSheet(
            "QLabel {margin: 0px; padding: 3px;}")
        layout.addWidget(self.fname_label)

        menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'),
                                     tip=_('Options'))
        # Don't show menu arrow and remove padding
        if is_dark_interface():
            menu_btn.setStyleSheet(
                ("QToolButton::menu-indicator{image: none;}\n"
                 "QToolButton{margin: 1px; padding: 3px;}"))
        else:
            menu_btn.setStyleSheet(
                "QToolButton::menu-indicator{image: none;}")
        self.menu = QMenu(self)
        menu_btn.setMenu(self.menu)
        menu_btn.setPopupMode(menu_btn.InstantPopup)
        self.menu.aboutToShow.connect(self.__setup_menu)

        corner_widgets = {Qt.TopRightCorner: [menu_btn]}
        self.tabs = BaseTabs(self, menu=self.menu, menu_use_tooltips=True,
                             corner_widgets=corner_widgets)
        self.tabs.tabBar().setObjectName('plugin-tab')
        self.tabs.set_close_function(self.close_file)
        self.tabs.tabBar().tabMoved.connect(self.move_editorstack_data)
        self.tabs.setMovable(True)

        self.stack_history.refresh()

        if hasattr(self.tabs, 'setDocumentMode') \
           and not sys.platform == 'darwin':
            # Don't set document mode to true on OSX because it generates
            # a crash when the editor is detached from the main window
            # Fixes Issue 561
            self.tabs.setDocumentMode(True)
        self.tabs.currentChanged.connect(self.current_changed)

        if sys.platform == 'darwin':
            tab_container = QWidget()
            tab_container.setObjectName('tab-container')
            tab_layout = QHBoxLayout(tab_container)
            tab_layout.setContentsMargins(0, 0, 0, 0)
            tab_layout.addWidget(self.tabs)
            layout.addWidget(tab_container)
        else:
            layout.addWidget(self.tabs)
793572
def set_editor(self, editor, refresh=True):
        
        self.editor = editor
        # Note: This is necessary to test widgets/editor.py
        # in Qt builds that don't have web widgets
        try:
            from qtpy.QtWebEngineWidgets import QWebEngineView
        except ImportError:
            QWebEngineView = type(None)
        self.words_button.setVisible(not isinstance(editor, QWebEngineView))
        self.re_button.setVisible(not isinstance(editor, QWebEngineView))
        from spyder.plugins.editor.widgets.codeeditor import CodeEditor
        self.is_code_editor = isinstance(editor, CodeEditor)
        self.highlight_button.setVisible(self.is_code_editor)
        if refresh:
            self.refresh()
        if self.isHidden() and editor is not None:
            self.clear_matches()
1020450
def create_widget(self):
        
        d = self.declaration
        self.widget = LinearLayout(self.get_context(), None, d.style)
1340623
function (parent) {

            var renderer = this.renderer,
              parentWrapper = parent || renderer,
              parentNode = parentWrapper.element || renderer.box,
              childNodes,
              element = this.element,
              zIndex = this.zIndex,
              otherElement,
              otherZIndex,
              i,
              inserted;

            if (parent) {
                this.parentGroup = parent;
            }

            // mark as inverted
            this.parentInverted = parent && parent.inverted;

            // build formatted text
            if (this.textStr !== undefined) {
                renderer.buildText(this);
            }

            // mark the container as having z indexed children
            if (zIndex) {
                parentWrapper.handleZ = true;
                zIndex = pInt(zIndex);
            }

            // insert according to this and other elements' zIndex
            if (parentWrapper.handleZ) { // this element or any of its siblings has a z index
                childNodes = parentNode.childNodes;
                for (i = 0; i < childNodes.length; i++) {
                    otherElement = childNodes[i];
                    otherZIndex = attr(otherElement, 'zIndex');
                    if (otherElement !== element && (
                          // insert before the first element with a higher zIndex
                        pInt(otherZIndex) > zIndex ||
                            // if no zIndex given, insert before the first element with a zIndex
                        (!defined(zIndex) && defined(otherZIndex))

                      )) {
                        parentNode.insertBefore(element, otherElement);
                        inserted = true;
                        break;
                    }
                }
            }

            // default: append at the end
            if (!inserted) {
                parentNode.appendChild(element);
            }

            // mark as added
            this.added = true;

            // fire an event for internal hooks
            if (this.onAdd) {
                this.onAdd();
            }

            return this;
        }
864216
def create_widget(self):
        
        d = self.declaration
        self.widget = TabLayout(self.get_context(), None, d.style)
1268372
def create_toolbutton(entries, parent=None):
    
    btn = QtGui.QToolButton(parent)
    menu = QtGui.QMenu()
    actions = []

    for label, slot in entries:
        action = add_menu_action(menu, label, slot)
        actions.append(action)

    btn.setPopupMode(QtGui.QToolButton.MenuButtonPopup)
    btn.setDefaultAction(actions[0])
    btn.setMenu(menu)
    return btn, actions
50334
def create_widget(self):
        
        d = self.declaration
        self.widget = EditText(self.get_context(), None,
                               d.style or "@attr/editTextStyle")
665663
def updateEditor( self ):
        
        
        # assignt the rule operators to the choice list
        rule        = self.currentRule()
        operator    = self.currentOperator()
        widget      = self.uiWidgetAREA.widget()
        editorType  = None
        text        = ''
        
        if ( rule ):
            editorType = rule.editorType(operator)
        
        # no change in types
        if ( widget and editorType and type(widget) == editorType ):
            return
            
        elif ( widget ):
            if ( type(widget) != QWidget ):
                text = widget.text()
            
            widget.setParent(None)
            widget.deleteLater()
        
        self.uiWidgetAREA.setWidget(None)
        
        # create the new editor
        if ( editorType ):
            widget = editorType(self)
            
            if ( isinstance(widget, QLineEdit) ):
                terms  = rule.completionTerms()
                if ( not terms ):
                    qwidget = self.queryBuilderWidget()
                    if ( qwidget ):
                        terms = qwidget.completionTerms()
                
                if ( terms ):
                    widget.setCompleter(XQueryCompleter(terms, widget))
            
            self.uiWidgetAREA.setWidget(widget)
            
            if ( type(widget) != QWidget ):
                widget.setText(text)
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);
    };
  }
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
370425
def createOpenAsMenu(self, parent=None):
        
        openAsMenu = QtWidgets.QMenu(parent=parent)
        openAsMenu.setTitle("Open Item As")

        registry = globalRtiRegistry()
        for rtiRegItem in registry.items:
            #rtiRegItem.tryImportClass()
            def createTrigger():
                """Function to create a closure with the regItem"""
                _rtiRegItem = rtiRegItem # keep reference in closure
                return lambda: self.reloadFileOfCurrentItem(_rtiRegItem)

            action = QtWidgets.QAction("{}".format(rtiRegItem.name), self,
                enabled=bool(rtiRegItem.successfullyImported is not False),
                triggered=createTrigger())
            openAsMenu.addAction(action)

        return openAsMenu
507307
public static void resizeAncestor(Widget parent) {

        while (parent != null) {
            if (parent instanceof I_CmsDescendantResizeHandler) {
                ((I_CmsDescendantResizeHandler)parent).onResizeDescendant();
                return;
            } else {
                parent = parent.getParent();
            }
        }
    }
896557
def edit(cls, record, parent=None, autoCommit=True, title=''):
        
        dlg = cls.getDialog('edit', parent)
        
        # update the title
        try:
            name = record.schema().displayName()
        except AttributeError:
            name = record.__class__.__name__
        
        if not title:
            title = 'Edit {0}'.format(name)
        dlg.setWindowTitle(title)
        
        widget = dlg._mainwidget
        widget.setRecord(record)
        widget.setAutoCommitOnSave(autoCommit)
        
        result = dlg.exec_()
        
        return result == 1
1325839
def parent(self, parent):
        
        self._parent = parent
        self.graph.add(
            (self.asNode(), RDF_NAMESPACES.CAPITAINS.parent, parent.asNode())
        )
        parent._add_member(self)
120332
def get_editor_widget(self, request, plugins, plugin):
        
        cancel_url_name = self.get_admin_url_name('delete_on_cancel')
        cancel_url = reverse('admin:%s' % cancel_url_name)

        render_plugin_url_name = self.get_admin_url_name('render_plugin')
        render_plugin_url = reverse('admin:%s' % render_plugin_url_name)

        action_token = self.get_action_token(request, plugin)

        # should we delete the text plugin when
        # the user cancels?
        delete_text_on_cancel = (
            'delete-on-cancel' in request.GET and  # noqa
            not plugin.get_plugin_instance()[0]
        )

        widget = TextEditorWidget(
            installed_plugins=plugins, pk=plugin.pk,
            placeholder=plugin.placeholder,
            plugin_language=plugin.language,
            configuration=self.ckeditor_configuration,
            render_plugin_url=render_plugin_url,
            cancel_url=cancel_url,
            action_token=action_token,
            delete_on_cancel=delete_text_on_cancel,
        )
        return widget