Triggered when shortcut keys for adding a new state are pressed, or Menu Bar "Edit, Add State" is clicked.

        Adds a new state only if the the state machine tree is in focus.
11257
def _add_new_state(self, *event, **kwargs):
        
        if react_to_event(self.view, self.view['state_machine_tree_view'], event):
            state_type = StateType.EXECUTION if 'state_type' not in kwargs else kwargs['state_type']
            gui_helper_state_machine.add_new_state(self._selected_sm_model, state_type)
            return True
667950
def on_toggle_sticky_clicked(self, event, state_m):
        
        [page, state_identifier] = self.find_page_of_state_m(state_m)
        if not page:
            return
        self.tabs[state_identifier]['is_sticky'] = not self.tabs[state_identifier]['is_sticky']
        page.sticky_button.set_active(self.tabs[state_identifier]['is_sticky'])
89869
def on_close_shortcut(self, *args):
        """"""
        state_machine_m = self.model.get_selected_state_machine_model()
        if state_machine_m is None:
            return
        self.on_close_clicked(None, state_machine_m, None, force=False)
960039
def on_state_changed(self, state):
        
        super(GoToDefinitionMode, self).on_state_changed(state)
        if state:
            self.editor.mouse_moved.connect(self._on_mouse_moved)
            self.editor.mouse_released.connect(self._on_mouse_released)
            self.editor.add_action(self.action_goto, sub_menu='COBOL')
            self.editor.mouse_double_clicked.connect(
                self._timer.cancel_requests)
        else:
            self.editor.mouse_moved.disconnect(self._on_mouse_moved)
            self.editor.mouse_released.disconnect(self._on_mouse_released)
            self.editor.remove_action(self.action_goto, sub_menu='Python')
            self.editor.mouse_double_clicked.disconnect(
                self._timer.cancel_requests)
202800
function( key ){
		var fields = this.state.fields;
		if( fields[ key ] && fields[ key ].settings.focus === true ){
			fields = assign({}, fields);
			fields[key].settings.focus = false;
			this.setState( {fields: fields} );
		}
	}
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);
        }
    }
1235349
function( state ) {
			if ( this._.state == state )
				return false;

			this._.state = state;

			var element = CKEDITOR.document.getById( this._.id );

			if ( element ) {
				element.setState( state, 'cke_button' );

				state == CKEDITOR.TRISTATE_DISABLED ?
					element.setAttribute( 'aria-disabled', true ) :
					element.removeAttribute( 'aria-disabled' );

				if ( !this.hasArrow ) {
					// Note: aria-pressed attribute should not be added to menuButton instances. (#11331)
					state == CKEDITOR.TRISTATE_ON ?
						element.setAttribute( 'aria-pressed', true ) :
						element.removeAttribute( 'aria-pressed' );
				} else {
					var newLabel = state == CKEDITOR.TRISTATE_ON ?
						this._.editor.lang.button.selectedLabel.replace( /%1/g, this.label ) : this.label;
					CKEDITOR.document.getById( this._.id + '_label' ).setText( newLabel );
				}

				return true;
			} else
				return false;
		}
714285
def add_state_editor(self, state_m):
        
        state_identifier = self.get_state_identifier(state_m)

        if state_identifier in self.closed_tabs:
            state_editor_ctrl = self.closed_tabs[state_identifier]['controller']
            state_editor_view = state_editor_ctrl.view
            handler_id = self.closed_tabs[state_identifier]['source_code_changed_handler_id']
            source_code_view_is_dirty = self.closed_tabs[state_identifier]['source_code_view_is_dirty']
            del self.closed_tabs[state_identifier]  # pages not in self.closed_tabs and self.tabs at the same time
        else:
            state_editor_view = StateEditorView()
            if isinstance(state_m, LibraryStateModel):
                state_editor_view['main_notebook_1'].set_current_page(
                    state_editor_view['main_notebook_1'].page_num(state_editor_view.page_dict["Data Linkage"]))
            state_editor_ctrl = StateEditorController(state_m, state_editor_view)
            self.add_controller(state_identifier, state_editor_ctrl)
            if state_editor_ctrl.get_controller('source_ctrl') and state_m.state.get_next_upper_library_root_state() is None:
                # observe changed to set the mark dirty flag
                handler_id = state_editor_view.source_view.get_buffer().connect('changed', self.script_text_changed,
                                                                                state_m)
                self.view.get_top_widget().connect('draw', state_editor_view.source_view.on_draw)
            else:
                handler_id = None
            source_code_view_is_dirty = False

        (tab, inner_label, sticky_button) = create_tab_header('', self.on_tab_close_clicked,
                                                              self.on_toggle_sticky_clicked, state_m)
        set_tab_label_texts(inner_label, state_m, source_code_view_is_dirty)

        state_editor_view.get_top_widget().title_label = inner_label
        state_editor_view.get_top_widget().sticky_button = sticky_button

        page_content = state_editor_view.get_top_widget()
        page_id = self.view.notebook.prepend_page(page_content, tab)
        page = self.view.notebook.get_nth_page(page_id)
        self.view.notebook.set_tab_reorderable(page, True)
        page.show_all()

        self.view.notebook.show()
        self.tabs[state_identifier] = {'page': page, 'state_m': state_m,
                                       'controller': state_editor_ctrl, 'sm_id': self.model.selected_state_machine_id,
                                       'is_sticky': False,
                                       'source_code_view_is_dirty': source_code_view_is_dirty,
                                       'source_code_changed_handler_id': handler_id}
        return page_id
823833
def setEditable( self, state ):
        
        self._editable = state
        
        if not state:
            self.setEditTriggers(QtGui.QTreeWidget.NoEditTriggers)
        else:
            triggers  = QtGui.QTreeWidget.DoubleClicked
            triggers |= QtGui.QTreeWidget.AnyKeyPressed
            triggers |= QtGui.QTreeWidget.EditKeyPressed
            triggers |= QtGui.QTreeWidget.SelectedClicked
            
            self.setEditTriggers(triggers)
207513
public void updateState()
  {
/*
    if( _editor.getCaretPosition() == _iCaretPos )
    {
      if( isOtherPopupShowing() )
      {
        resetSmartHelpState();
      }      
      return;
    }

*/
    resetSmartHelpState();

    if( isOtherPopupShowing() )
    {
      return; //don't clobber existing popups
    }

    //Iterate through all the closest issues within one line of the current cursor and offer to fix the closest one
    final List<IParseIssue> parseIssues = findParseIssuesOrderedByDistanceFromCaret( 1 );
    setMode( SmartFixMode.NONE );
    for( Highlighter.Highlight highlight : _editor.getHighlighter().getHighlights() )
    {
      if( highlight.getPainter() instanceof SmartFixHighlightPainter )
      {
        _editor.getHighlighter().removeHighlight( highlight );
      }
    }
    final Set<String> processed = new HashSet<String>();
//    if (isModeAvailable(SmartFixMode.CONVERT_STRING_TO_DISPLAY_KEY)) {
//      int lineNum = _gosuEditor.getLineNumberAtCaret();
//      Element line = _gosuEditor.getEditor().getDocument().getDefaultRootElement().getElement(lineNum - 1);
//      try {
//        if (_gosuEditor.getEditor().getText(line.getStartOffset(), line.getEndOffset() - line.getStartOffset()).contains("\"")) {
//          IParseTree locationAtCaret = _gosuEditor.getDeepestLocationAtCaret();
//          if (offerToTurnStringLiteralToDisplayKey(locationAtCaret)) {
//            _stringLiteralLocationToReplace = locationAtCaret;
//            return;
//          }
//        }
//      } catch (BadLocationException e) {
//        // ignore
//      }
//    }

    final ITypeUsesMap[] uses = new ITypeUsesMap[]{_gosuEditor.getTypeUsesMapFromMostRecentParse()};

    Runnable runnable = new Runnable()
    {
      @Override
      public void run()
      {
        if( uses[0] == null )
        {
          _gosuEditor.waitForParser();
          uses[0] = _gosuEditor.getTypeUsesMapFromMostRecentParse();
        }
        for( IParseIssue parseIssue : parseIssues )
        {
          IParsedElement source = parseIssue.getSource();
          if( isModeAvailable( SmartFixMode.IMPORT ) && _gosuEditor.acceptsUses() && handlePossibleImportFix( source, uses[0], processed ) )
          {
            setMode( SmartFixMode.IMPORT );
            return;
          }
          else if( isModeAvailable( SmartFixMode.FIX_IMPLICIT_CAST ) && isImplictCoercion( parseIssue ) )
          {
            setMode( SmartFixMode.FIX_IMPLICIT_CAST );
            return;
          }
          else if( isModeAvailable( SmartFixMode.FIX_CTOR_SYNTAX ) && isObsoleteConstructor( parseIssue ) )
          {
            setMode( SmartFixMode.FIX_CTOR_SYNTAX );
            return;
          }
          else if( isModeAvailable( SmartFixMode.FIX_JAVA_STYLE_CAST ) && isJavaStyleCast( parseIssue ) )
          {
            setMode( SmartFixMode.FIX_JAVA_STYLE_CAST );
            return;
          }
//          else if( isModeAvailable(SmartFixMode.CREATE_DISPLAY_KEY) && isPossibleDisplayKey( parseIssue ) )
//          {
//            setMode( SmartFixMode.CREATE_DISPLAY_KEY );
//            return;
//          }
          if( isModeAvailable( SmartFixMode.ADD_MISSING_OVERRIDE ) && isMissingOverride( parseIssue ) )
          {
            setMode( SmartFixMode.ADD_MISSING_OVERRIDE );
            return;
          }
          else if( isModeAvailable( SmartFixMode.FIX_CASE ) && isCaseIssue( parseIssue ) )
          {
            setMode( SmartFixMode.FIX_CASE );
            return;
          }
          else if( isModeAvailable( SmartFixMode.FIX_RETURN_TYPE ) && isVoidReturnTypeIssue( parseIssue ) )
          {
            setMode( SmartFixMode.FIX_RETURN_TYPE );
            return;
//          else if( isModeAvailable( SmartFixMode.IMPL_FUNCTIONS ) && showImplementPopup(parseIssue))
//          {
//            setMode( SmartFixMode.IMPL_FUNCTIONS );
//            return;
          }
          else if( isModeAvailable( SmartFixMode.GENERATE_CONSTRUCTORS ) && isMissingConstructor( parseIssue ) )
          {
            setMode( SmartFixMode.GENERATE_CONSTRUCTORS );
            return;
          }
          else if( isModeAvailable( SmartFixMode.GENERATE_SUPER_CALL ) && isMissingSuperCall( parseIssue ) )
          {
            setMode( SmartFixMode.GENERATE_SUPER_CALL );
            return;
          }
        }
      }
    };

    editor.util.EditorUtilities.doBackgroundOp( runnable );
  }
365576
def add(self, action):
        """"""
        self._state_machine.transition_to_add()
        self._actions.append(action)
262965
def register_actions(self, shortcut_manager):
        
        shortcut_manager.add_callback_for_action('rename', self.rename_selected_state)
        super(StatesEditorController, self).register_actions(shortcut_manager)
641533
function openedChanged(element) {
  if (element.state.autoFocus) {
    if (element.state.opened) {
      // Opened
      if (!element[restoreFocusToElementKey] && document.activeElement !== document.body) {
        // Remember which element had the focus before we were opened.
        element[restoreFocusToElementKey] = document.activeElement;
      }
      // Focus on the element itself (if it's focusable), or the first focusable
      // element inside it.
      // TODO: We'd prefer to require that overlays (like the Overlay base
      // class) make use of delegatesFocus via DelegateFocusMixin, which would
      // let us drop the need for this mixin here to do anything special with
      // focus. However, an initial trial of this revealed an issue in
      // MenuButton, where invoking the menu did not put the focus on the first
      // menu item as expected. Needs more investigation.
      const focusElement = firstFocusableElement(element);
      if (focusElement) {
        focusElement.focus();
      }
    } else {
      // Closed
      if (element[restoreFocusToElementKey]) {
        // Restore focus to the element that had the focus before the overlay was
        // opened.
        element[restoreFocusToElementKey].focus();
        element[restoreFocusToElementKey] = null;
      }
    }
  }
}
1055540
def add_action_callback(self, key_value, modifier_mask, a_dict=False):
        """"""
        if react_to_event(self.view, self.tree_view, event=(key_value, modifier_mask)) and self.active_entry_widget is None:
            self.on_add(None, a_dict)
            return True
566419
def _on_key_pressed(self, event):
        
        if not event.isAccepted():
            if event.key() == Qt.Key_Return or event.key() == Qt.Key_Enter:
                cursor = self.editor.textCursor()
                pre, post = self._get_indent(cursor)
                cursor.beginEditBlock()
                cursor.insertText("%s\n%s" % (pre, post))

                # eats possible whitespaces
                cursor.movePosition(cursor.WordRight, cursor.KeepAnchor)
                txt = cursor.selectedText()
                if txt.startswith(' '):
                    new_txt = txt.replace(" ", '')
                    if len(txt) > len(new_txt):
                        cursor.insertText(new_txt)
                cursor.endEditBlock()
                event.accept()
306177
private void updateState(final TaskStatus.State state) {
    statusUpdater.setState(state);
    // Commit and push a new status
    try {
      statusUpdater.update();
    } catch (InterruptedException e) {
      // TODO: propagate interrupt instead?
      Thread.currentThread().interrupt();
    }
  }
688891
public static void addShortcutToComponent(final JComponent component, final KeyStroke keystroke,
		final String actionCommand, final Action action)
	{
		addShortcutToComponent(component, keystroke, JComponent.WHEN_IN_FOCUSED_WINDOW,
			actionCommand, action);
	}