Adds a State to the selected state

    :param state: the state which is inserted
    :param as_template: If a state is a library state can be insert as template
    :return: boolean: success of the insertion
420339
def insert_state_into_selected_state(state, as_template=False):
    
    smm_m = rafcon.gui.singleton.state_machine_manager_model

    if not isinstance(state, State):
        logger.warning("A state is needed to be insert not {0}".format(state))
        return False

    if not smm_m.selected_state_machine_id:
        logger.warning("Please select a container state within a state machine first")
        return False

    selection = smm_m.state_machines[smm_m.selected_state_machine_id].selection
    if len(selection.states) > 1:
        logger.warning("Please select exactly one state for the insertion")
        return False

    if len(selection.states) == 0:
        logger.warning("Please select a state for the insertion")
        return False

    if is_selection_inside_of_library_state(selected_elements=[selection.get_selected_state()]):
        logger.warning("State is not insert because target state is inside of a library state.")
        return False

    gui_helper_state.insert_state_as(selection.get_selected_state(), state, as_template)

    return True
442838
def _add_sink_state(self, states):
        
        cleared = []
        for i in range(0, 128):
            cleared.append(-1)
        states.append(cleared)
812869
def create_output_dictionary_for_state(state):
        
        from rafcon.core.states.library_state import LibraryState
        result_dict = {}
        for key, data_port in state.output_data_ports.items():
            if isinstance(state, LibraryState) and state.use_runtime_value_output_data_ports[key]:
                result_dict[data_port.name] = copy.copy(state.output_data_port_runtime_values[key])
            else:
                result_dict[data_port.name] = copy.copy(data_port.default_value)
        return result_dict
1320653
public void setState(S state){
		Integer id = definition.getStateId(state);
		currentStateId.set(id);
	}
926683
function() {
			this.states.add([
				new wp.media.controller.Library({
					id: 'insert',
					title: this.options.title,
					selection: this.options.selection,
					priority: 20,
					toolbar: 'main-insert',
					filterable: this.options.filterable,
					searchable: this.options.searchable,
					library: wp.media.query( this.options.query ),
					multiple: this.options.multiple,
					editable: this.options.editable,
					displaySettings: this.options.displaySettings,
					displayUserSettings: this.options.displayUserSettings
				}),

				new wp.media.controller.EditImage({ model: this.options.editImage })
			]);
		}
290738
def _push_new_state(self):
        
        try:
            base = self._states[-1]
        except IndexError:
            graph = DirectedGraph()
            graph.add(None)     # Sentinel as root dependencies' parent.
            state = State(mapping={}, graph=graph)
        else:
            state = State(
                mapping=base.mapping.copy(),
                graph=base.graph.copy(),
            )
        self._states.append(state)
397604
def insert(self, state, token):
        """"""
        if token == EndSymbol():
            return self[state][EndSymbol()]
        from pydsl.check import check
        symbol_list = [x for x in self[state] if isinstance(x, TerminalSymbol) and check(x.gd, [token])]
        if not symbol_list:
            return {"action":"Fail"}
        if len(symbol_list) > 1:
            raise Exception("Multiple symbols matches input")
        symbol = symbol_list[0]
        return self[state][symbol]
340654
def add_state(node, user, params)
      # => Create a Node-State Object
      (n = {}) && (n[:name] = node)
      n[:created] = DateTime.now
      n[:creator] = user
      n[:type] = params['type'] if params['type']
      # => Build the Updated State
      update_state(n)
      # => Return the Added Node
      find_state(node)
    end
614047
def move(self, state):
        
        if state == tuple([ BEGIN ] * self.state_size):
            choices = self.begin_choices
            cumdist = self.begin_cumdist
        else:
            choices, weights = zip(*self.model[state].items())
            cumdist = list(accumulate(weights))
        r = random.random() * cumdist[-1]
        selection = choices[bisect.bisect(cumdist, r)]
        return selection
1369203
def add_state(self):
        """"""
        sid = len(self.states)
        self.states.append(SFAState(sid))
234123
public void setEditingState(String state) {
		if ("idle".equalsIgnoreCase(state)) {
			delegate.setEditingState(GeometryEditState.IDLE);
		} else if ("dragging".equalsIgnoreCase(state)) {
			delegate.setEditingState(GeometryEditState.DRAGGING);
		} else if ("inserting".equalsIgnoreCase(state)) {
			delegate.setEditingState(GeometryEditState.INSERTING);
		}
	}
91872
protected function addState()
    {
        if (!$this->isError()) {
            $state_id = $this->state->add($this->getSubmitted());
            if (empty($state_id)) {
                $this->errorAndExit($this->text('Unexpected result'));
            }
            $this->line($state_id);
        }
    }
1208208
def render(self, name, value, attrs=None, *args, **kwargs):
        
        if isinstance(value, base.StateWrapper):
            state_name = value.state.name
        elif isinstance(value, base.State):
            state_name = value.name
        else:
            state_name = str(value)
        return super(StateSelect, self).render(name, state_name, attrs, *args, **kwargs)
554855
function State(template, easyButton){

  this.title = template.title;
  this.stateName = template.stateName ? template.stateName : 'unnamed-state';

  // build the wrapper
  this.icon = L.DomUtil.create('span', '');

  L.DomUtil.addClass(this.icon, 'button-state state-' + this.stateName.replace(/(^\s*|\s*$)/g,''));
  this.icon.innerHTML = buildIcon(template.icon);
  this.onClick = L.Util.bind(template.onClick?template.onClick:function(){}, easyButton);
}
816281
function statefulSelectors(
  states: Array<InteractionState>,
  template: Function,
  stateMap?: Array<InteractionState>,
): string {
  if (!template) throw new PolishedError(67)
  if (states.length === 0) return generateSelectors(template, null)
  let selectors = []
  for (let i = 0; i < states.length; i += 1) {
    if (stateMap && stateMap.indexOf(states[i]) < 0) {
      throw new PolishedError(68)
    }
    selectors.push(generateSelectors(template, states[i]))
  }
  selectors = selectors.join(',')
  return selectors
}
156206
def set_state(self, state):
        

        # Sanity check
        if REGION_MAPPING not in state.options:
            # add REGION_MAPPING into state.options
            l.warning('Option "REGION_MAPPING" must be enabled when using SimAbstractMemory as the memory model. '
                      'The option is added to state options as a courtesy.'
                      )
            state.options.add(REGION_MAPPING)

        SimMemory.set_state(self, state)

        for _,v in self._regions.items():
            v.set_state(state)

        # Delayed initialization of backer argument from __init__
        if self._temp_backer is not None:
            for region, backer_dict in self._temp_backer.items():
                self._regions[region] = MemoryRegion(region, self.state,
                                                     init_memory=True,
                                                     backer_dict=backer_dict,
                                                     endness=self.endness
                                                     )
            self._temp_backer = None
614160
def _create_states(self, states_num):
        
        states = []
        for i in range(0, states_num):
            states.append(i)
        return states