Creates a new editor for the given parent and operator.
        
        :param      parent      | <QWidget>
                    operator    | <str>
                    value       | <variant>
432926
def createEditor(self, parent, column, operator, value):
        
        editor = super(NumericPlugin, self).createEditor(parent,
                                                         column,
                                                         operator,
                                                         value)
        
        if isinstance(editor, QLineEdit):
            validator = QRegExpValidator(QRegExp('^-?\d+\.?\d*'), editor)
            editor.setValidator(validator)
            if value is None:
                value = 0
            editor.setText(nativestring(value))
        return editor
1353231
def createEditor(self, delegate, parent, option):
        
        return UntypedCtiEditor(self, delegate, parent=parent)
368576
def _set_parent(self, parent=None):
        
        if parent is not None:
            if not isinstance(parent, Parentable):
                raise ValueError('Parent object must implement Parentable interface.')
            if parent is self or parent._contains(self):
                raise ValueError('Self references are not allowed.')
        self._parent = parent if parent is not None else None
670481
def dockWidget(self, widget, title, area):
        
        assert widget.parent() is None, "Widget already has a parent"

        dockWidget = QtWidgets.QDockWidget(title, parent=self)
        dockWidget.setObjectName("dock_" + string_to_identifier(title))
        dockWidget.setWidget(widget)

        # Prevent parent context menu (with e.g. 'set inspector" option) to be displayed.
        dockWidget.setContextMenuPolicy(Qt.PreventContextMenu)

        self.addDockWidget(area, dockWidget)
        self.viewMenu.addAction(dockWidget.toggleViewAction())
        return dockWidget
764237
protected void createLaunchOptionEditor(Composite parent, String text) {
		final Group group = SWTFactory.createGroup(parent, text, 1, 1, GridData.FILL_HORIZONTAL);
		this.enableAssertionsInRunModeButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_2);
		this.enableAssertionsInRunModeButton.addSelectionListener(this.defaultListener);
		this.enableAssertionsInDebugModeButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_1);
		this.enableAssertionsInDebugModeButton.addSelectionListener(this.defaultListener);
		this.runInEclipseButton = createCheckButton(group, Messages.SARLMainLaunchConfigurationTab_0);
		this.runInEclipseButton.addSelectionListener(this.defaultListener);
	}
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
388425
public void init(Object parent, Object record)
    {
    	super.init(parent, record);
    	
        this.setOpaque(false);
        this.setBorder(new EtchedBorder());
        
        this.setLayout(new BorderLayout());
        this.add(m_helpView = new JHelpView(this, null), BorderLayout.CENTER);
        this.add(m_iconArea = new JBaseToolbar(this, null)
	        {
	            private static final long serialVersionUID = 1L;
	            /**
	             * Add the buttons to this window.
	             * Override this to include buttons other than the default buttons.
	             */
	            public void addButtons()
	            {
	               //super.addButtons();
	               //addButton(ThinMenuConstants.HOME);
	               JButton button = addButton(null, ThinMenuConstants.CLOSE, ThinMenuConstants.CLOSE);
	               button.setOpaque(false);
	               button.setBorder(new LineBorder(Color.black, 1));
	             }
	        }, BorderLayout.NORTH);
        m_iconArea.setOpaque(false);
        
        m_helpView.getHtmlEditor().setHelpPane(this);
    }
1235074
def editorValue(self, editor):
        
        if isinstance(editor, QLineEdit):
            try:
                return eval(nativestring(editor.text()))
            except:
                return 0
        else:
            return super(NumericPlugin, self).editorValue(editor)
1128706
def createEditor(self, parent, column, operator, value):
        
        if type(value) == datetime.timedelta:
            editor = XTimeDeltaEdit(parent)
            editor.setAttribute(Qt.WA_DeleteOnClose)
            editor.setDelta(value)
            return editor
        
        else:
            editor = super(DateTimePlugin, self).createEditor(parent,
                                                              column,
                                                              operator,
                                                              value)
        
            if isinstance(editor, XDateTimeEdit) or \
               isinstance(editor, XDateEdit):
                editor.setCalendarPopup(True)
            
            return editor
296623
protected void visit(Object value, BioPAXElement parent,
			Model newModel, PropertyEditor editor)
	{
			if(editor != null && editor.isUnknown(value)) {
				return;
			}

			String parentType = parent.getModelInterface().getSimpleName();
			BioPAXElement newParent = null;
			Object newValue = value;
			String newProp = propsmap.getProperty(editor.getProperty());

			// special case (PATHWAY-COMPONENTS maps to pathwayComponent or pathwayOrder)
			if(parent instanceof pathway && value instanceof pathwayStep
					&& editor.getProperty().equals("PATHWAY-COMPONENTS")) {
				newProp = "pathwayOrder";
			}

			// for pEPs, getting the corresponding simple PE or Complex is different
			if(parent instanceof physicalEntityParticipant) {
				newParent = getMappedPE((physicalEntityParticipant) parent, newModel);
			} else {
				newParent = newModel.getByID(parent.getUri());
			}

			// bug check!
			if(newParent == null) {
				throw new IllegalAccessError("Of " + value +
					", parent " + parentType + " : " + parent +
					" is not yet in the new model: ");
			}

			PropertyEditor newEditor =
				SimpleEditorMap.L3.getEditorForProperty(newProp, newParent.getModelInterface());

			if(value instanceof Level2Element)
			// not a String, Enum, or primitive type
			{
				// when pEP, create/add stoichiometry!
				if(value instanceof physicalEntityParticipant)
				{
					physicalEntityParticipant pep = (physicalEntityParticipant) value;
					newValue = getMappedPE(pep, newModel);

					float coeff = (float) pep.getSTOICHIOMETRIC_COEFFICIENT();
					if (coeff > 1 ) { //!= BioPAXElement.UNKNOWN_DOUBLE) {
					  if(parent instanceof conversion || parent instanceof complex) {
						PhysicalEntity pe3 = (PhysicalEntity) newValue;
						Stoichiometry stoichiometry = factory
							.create(Stoichiometry.class,
                                    pe3.getUri() + "-stoichiometry" + Math.random());
						stoichiometry.setStoichiometricCoefficient(coeff);
						stoichiometry.setPhysicalEntity(pe3);
						//System.out.println("parent=" + parent + "; phy.ent.=" + pep + "; coeff=" + coeff);
						if (parent instanceof conversion) {
							// (pep) value participates in the conversion interaction
							Conversion conv = (Conversion) newModel
								.getByID(parent.getUri());
							conv.addParticipantStoichiometry(stoichiometry);	
						} else {
							// this (pep) value is component of the complex
							Complex cplx = (Complex) newModel.getByID(parent.getUri());
							cplx.addComponentStoichiometry(stoichiometry);
						} 
						
						newModel.add(stoichiometry);
						
					  } else {
						if (log.isDebugEnabled())
							log.debug(pep + " STOICHIOMETRIC_COEFFICIENT is "
								+ coeff	+ ", but the pEP's parent is not a conversion or complex - " + parent);
					  }
					}
					
					traverse(pep, newModel);
				}
				else if(value instanceof openControlledVocabulary) 
				{
					// create the proper type ControlledVocabulary instance	
					newValue = convertAndAddVocabulary((openControlledVocabulary)value, 
						(Level2Element)parent, newModel, newEditor);
				}
				else
				{
					String id = ((Level2Element) value).getUri();
					newValue = newModel.getByID(id);
				}
			}
			else if (value.getClass().isEnum())
			{
				newValue = getMatchingEnum(value);
			}
			else
			{
				// relationshipXref.RELATIONSHIP-TYPE range changed (String -> RelationshipTypeVocabulaty)
				if(parent instanceof relationshipXref && editor.getProperty().equals("RELATIONSHIP-TYPE")) {
					String id = URLEncoder.encode(value.toString());
					if(!newModel.containsID(id)) {
						RelationshipTypeVocabulary cv = (RelationshipTypeVocabulary) 
							newModel.addNew(newEditor.getRange(), id);
						cv.addTerm(value.toString().toLowerCase());
						newValue = cv;
					} else {
						newValue = newModel.getByID(id);
					}
				}
			}
			
			if(newValue == null) {
				log.debug("Skipped for  " + parent + "." + editor.getProperty()
					+ "=" + value + " ==> " + newParent.getUri() + "." + newProp	+ " = NULL");
				return;
			}
			
			if (newProp != null) {
				if (newEditor != null){
					setNewProperty(newParent, newValue, newEditor);
				} else if(parent instanceof physicalEntity) {
					// Special mapping for 'AVAILABILITY' and 'DATA-SOURCE'
					// find parent pEP(s)
					Set<physicalEntityParticipant> ppeps = ((physicalEntity)parent).isPHYSICAL_ENTITYof();
					// if several pEPs use the same phy.entity, we get this property/value cloned...
					for(physicalEntityParticipant pep: ppeps) {
						//find proper L3 physical entity
						newParent = getMappedPE(pep, newModel);
						if(newParent != null) {
							newEditor = SimpleEditorMap.L3.getEditorForProperty(newProp, newParent.getModelInterface());
							setNewProperty(newParent, newValue, newEditor);
						} else { // bug!
							log.error("Cannot find converted PE to map the property " 
								+ editor.getProperty() + " of physicalEntity " + parent + " (" + parentType + ")");
						}
					}
				} else {
					log.debug("Skipped property " + editor.getProperty() + " in " + parentType + " to " +
						newParent.getModelInterface().getSimpleName() + " conversion (" + parent + ")");
				}
			} else {
				log.warn("No mapping defined for property: " + parentType + "." + editor.getProperty());
			} 
		}
1061623
def createEditor(self, parent, column, operator, value):
        
        editor = super(EnumPlugin, self).createEditor(parent,
                                                      column,
                                                      operator,
                                                      value)
        
        editor.setEnum(column.enum())
        if operator in ('contains', 'does not contain'):
            editor.setCheckable(True)
        
        editor.setCurrentValue(value)
        return editor
653266
def createEditor(self, parent, option, index):
        """"""
        if index.column() < 3:
            return None
        if self.show_warning(index):
            answer = QMessageBox.warning(self.parent(), _("Warning"),
                                      _("Opening this variable can be slow\n\n"
                                        "Do you want to continue anyway?"),
                                      QMessageBox.Yes | QMessageBox.No)
            if answer == QMessageBox.No:
                return None
        try:
            value = self.get_value(index)
            if value is None:
                return None
        except Exception as msg:
            QMessageBox.critical(self.parent(), _("Error"),
                                 _("Spyder was unable to retrieve the value of "
                                   "this variable from the console.<br><br>"
                                   "The error mesage was:<br>"
                                   "<i>%s</i>"
                                   ) % to_text_string(msg))
            return
        key = index.model().get_key(index)
        readonly = (isinstance(value, (tuple, set)) or self.parent().readonly
                    or not is_known_type(value))
        # CollectionsEditor for a list, tuple, dict, etc.
        if isinstance(value, (list, set, tuple, dict)):
            editor = CollectionsEditor(parent=parent)
            editor.setup(value, key, icon=self.parent().windowIcon(),
                         readonly=readonly)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # ArrayEditor for a Numpy array
        elif isinstance(value, (ndarray, MaskedArray)) \
          and ndarray is not FakeObject:
            editor = ArrayEditor(parent=parent)
            if not editor.setup_and_check(value, title=key, readonly=readonly):
                return
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # ArrayEditor for an images
        elif isinstance(value, Image) and ndarray is not FakeObject \
          and Image is not FakeObject:
            arr = array(value)
            editor = ArrayEditor(parent=parent)
            if not editor.setup_and_check(arr, title=key, readonly=readonly):
                return
            conv_func = lambda arr: Image.fromarray(arr, mode=value.mode)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly,
                                            conv=conv_func))
            return None
        # DataFrameEditor for a pandas dataframe, series or index
        elif isinstance(value, (DataFrame, Index, Series)) \
          and DataFrame is not FakeObject:
            editor = DataFrameEditor(parent=parent)
            if not editor.setup_and_check(value, title=key):
                return
            editor.dataModel.set_format(index.model().dataframe_format)
            editor.sig_option_changed.connect(self.change_option)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
        # QDateEdit and QDateTimeEdit for a dates or datetime respectively
        elif isinstance(value, datetime.date):
            if readonly:
                return None
            else:
                if isinstance(value, datetime.datetime):
                    editor = QDateTimeEdit(value, parent=parent)
                else:
                    editor = QDateEdit(value, parent=parent)
                editor.setCalendarPopup(True)
                editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
                return editor
        # TextEditor for a long string
        elif is_text_string(value) and len(value) > 40:
            te = TextEditor(None, parent=parent)
            if te.setup_and_check(value):
                editor = TextEditor(value, key,
                                    readonly=readonly, parent=parent)
                self.create_dialog(editor, dict(model=index.model(),
                                                editor=editor, key=key,
                                                readonly=readonly))
            return None
        # QLineEdit for an individual value (int, float, short string, etc)
        elif is_editable_type(value):
            if readonly:
                return None
            else:
                editor = QLineEdit(parent=parent)
                editor.setFont(get_font(font_size_delta=DEFAULT_SMALL_DELTA))
                editor.setAlignment(Qt.AlignLeft)
                # This is making Spyder crash because the QLineEdit that it's
                # been modified is removed and a new one is created after
                # evaluation. So the object on which this method is trying to
                # act doesn't exist anymore.
                # editor.returnPressed.connect(self.commitAndCloseEditor)
                return editor
        # CollectionsEditor for an arbitrary Python object
        else:
            editor = CollectionsEditor(parent=parent)
            editor.setup(value, key, icon=self.parent().windowIcon(),
                         readonly=readonly)
            self.create_dialog(editor, dict(model=index.model(), editor=editor,
                                            key=key, readonly=readonly))
            return None
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()
906856
def wrap(self, value):
        
        return self._parent.new_query().get_query().get_grammar().wrap(value)
652854
def createEditor(self, delegate, parent, option):
        
        return IntCtiEditor(self, delegate, parent=parent)
1175144
def addBinding(self, node, value):
        
        # assert value.source in (node, node.parent):
        for scope in self.scopeStack[::-1]:
            if value.name in scope:
                break
        existing = scope.get(value.name)

        if (existing and not isinstance(existing, Builtin) and
                not self.differentForks(node, existing.source)):

            parent_stmt = self.getParent(value.source)
            if isinstance(existing, Importation) and isinstance(parent_stmt, FOR_TYPES):
                self.report(messages.ImportShadowedByLoopVar,
                            node, value.name, existing.source)

            elif scope is self.scope:
                if (isinstance(parent_stmt, ast.comprehension) and
                        not isinstance(self.getParent(existing.source),
                                       (FOR_TYPES, ast.comprehension))):
                    self.report(messages.RedefinedInListComp,
                                node, value.name, existing.source)
                elif not existing.used and value.redefines(existing):
                    if value.name != '_' or isinstance(existing, Importation):
                        if not is_typing_overload(existing, self.scopeStack):
                            self.report(messages.RedefinedWhileUnused,
                                        node, value.name, existing.source)

            elif isinstance(existing, Importation) and value.redefines(existing):
                existing.redefined.append(node)

        if value.name in self.scope:
            # then assume the rebound name is used as a global or within a loop
            value.used = self.scope[value.name].used

        self.scope[value.name] = value
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);
    };
  }