region > newPostal (programmatic)
777258
@Programmatic
    public PostalAddress newPostal(
            final Object owner,
            final String addressLine1,
            final String addressLine2,
            final String addressLine3,
            final String addressLine4,
            final String postalCode,
            final String country,
            final String purpose,
            final String notes) {

        final PostalAddress pa = factoryService.instantiate(PostalAddress.class);
        pa.setType(CommunicationChannelType.POSTAL_ADDRESS);
        owner(pa).setOwner(owner);
        pa.setPurpose(purpose);
        pa.setAddressLine1(addressLine1);
        pa.setAddressLine2(addressLine2);
        pa.setAddressLine3(addressLine3);
        pa.setAddressLine4(addressLine4);
        pa.setPostalCode(postalCode);
        pa.setNotes(notes);
        pa.setCountry(country);

        repositoryService.persist(pa);
        return pa;
    }
1185427
public SetAnyLocationsResponse postAnyLocations(String region, SettingsData data) throws ApiException {
        ApiResponse<SetAnyLocationsResponse> resp = postAnyLocationsWithHttpInfo(region, data);
        return resp.getData();
    }
954375
function newPutOne(endpoint, options) {
    // for backwards-compatibility <= 0.11.1
    if (_.isArray(options)) options = { allowable: options };
    else options = options || {};
    options.method = "put";
    return newPostOne(endpoint, options);
}
953255
public ButtonTemplateBuilder addPostbackButton(String title, String payload) {
		Button button = ButtonFactory.createPostbackButton(title, payload);
		this.payload.addButton(button);
		return this;
	}
30900
function postForm({ url, payload, useBearer }) {
  return ajax({
    url,
    body: makeFormData( payload ),
    method: 'post',
    useBearer
  })
}
1348371
private Node newParameter(JSType type) {
    Node paramNode = Node.newString(Token.NAME, "");
    paramNode.setJSType(type);
    root.addChildToBack(paramNode);
    return paramNode;
  }
566888
function(posType) {
    posType = posType || "current";

    var root = this.graph.getNode(this.root),
        config = this.config,
        size = this.canvas.getSize(),
        width = size.width,
        height = size.height,
        offset = config.offset,
        levelsToShow = config.constrained ? config.levelsToShow : Number.MAX_VALUE;

    this.controller.onBeforeCompute(root);

    Graph.Util.computeLevels(this.graph, root.id, 0, "ignore");

    var treeDepth = 0;

    Graph.Util.eachLevel(root, 0, false, function (n, d) { if(d > treeDepth) treeDepth = d; });

    var startNode = this.graph.getNode(this.clickedNode && this.clickedNode.id || root.id);
    var maxDepth = Math.min(treeDepth, levelsToShow-1);
    var initialDepth = startNode._depth;
    if(this.layout.horizontal()) {
      this.computeSubtree(startNode, -width/2, -height/2, width/(maxDepth+1), height, initialDepth, maxDepth, posType);
    } else {
      this.computeSubtree(startNode, -width/2, -height/2, width, height/(maxDepth+1), initialDepth, maxDepth, posType);
    }
  }
1158558
protected function insertNewPost( $post_type, $p, $html, $chapter_parent, $post_status ) {

		$new_post = [
			'post_title' => wp_strip_all_tags( $p['post_title'] ),
			'post_name' => $p['post_name'],
			'post_type' => $post_type,
			'post_status' => ( 'part' === $post_type ) ? 'publish' : $post_status,
			'post_content' => $html,
		];

		if ( 'chapter' === $post_type ) {
			$new_post['post_parent'] = $chapter_parent;
		}

		$pid = wp_insert_post( add_magic_quotes( $new_post ) );

		return $pid;
	}
965128
public function newPartialAction()
    {
        $postParams = $this->params()->fromPost();
        $parentName = $postParams['parent_name'];
        $childName  = $postParams['child_name'];
        $parent     = $postParams['parent'];

        $parent = $this->getService($parentName)->find($parent);
        $child  = $this->getService($childName)->getModel();

        $child->setParent($parent);

        $partial  = $this->dash($childName);
        $viewVars = array(lcfirst($this->camel($childName)) => $child);
        return $this->partialView($partial, $viewVars);
    }
339741
private void addPostParams(final Request request) {
        if (identity != null) {
            request.addPostParam("Identity", identity);
        }

        if (bindingType != null) {
            request.addPostParam("BindingType", bindingType.toString());
        }

        if (address != null) {
            request.addPostParam("Address", address);
        }

        if (tag != null) {
            for (String prop : tag) {
                request.addPostParam("Tag", prop);
            }
        }

        if (notificationProtocolVersion != null) {
            request.addPostParam("NotificationProtocolVersion", notificationProtocolVersion);
        }

        if (credentialSid != null) {
            request.addPostParam("CredentialSid", credentialSid);
        }

        if (endpoint != null) {
            request.addPostParam("Endpoint", endpoint);
        }
    }
802522
public GenericTemplateElementBuilder addPostbackButton(String title,
			String payload) {
		Button button = ButtonFactory.createPostbackButton(title, payload);
		this.element.addButton(button);
		return this;
	}
373947
function(newContent, type) {
		mfp.content = newContent;

		if(newContent) {
			if(mfp.st.showCloseBtn && mfp.st.closeBtnInside &&
				mfp.currTemplate[type] === true) {
				// if there is no markup, we just append close button element inside
				if(!mfp.content.find('.mfp-close').length) {
					mfp.content.append(_getCloseBtn());
				}
			} else {
				mfp.content = newContent;
			}
		} else {
			mfp.content = '';
		}

		_mfpTrigger(BEFORE_APPEND_EVENT);
		mfp.container.addClass('mfp-'+type+'-holder');

		mfp.contentContainer.append(mfp.content);
	}
1362477
public void createAndEditNewElement(
        final org.opencms.ade.containerpage.client.ui.CmsContainerPageElementPanel element,
        final boolean inline) {

        if (!element.isNew()) {
            return;
        }

        final CmsContainer container = m_containers.get(element.getParentTarget().getContainerId());

        m_handler.showPageOverlay();
        CmsRpcAction<CmsCreateElementData> action = new CmsRpcAction<CmsCreateElementData>() {

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
             */
            @Override
            public void execute() {

                getContainerpageService().checkCreateNewElement(
                    CmsCoreProvider.get().getStructureId(),
                    element.getId(),
                    element.getNewType(),
                    container,
                    getLocale(),
                    this);

            }

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
             */
            @Override
            protected void onResponse(CmsCreateElementData result) {

                if (result.needsModelSelection()) {
                    getHandler().openModelResourceSelect(element, result.getModelResources());
                } else {
                    openEditorForNewElement(element, result.getCreatedElement(), inline);
                }
            }
        };
        action.execute();
    }
1350495
private Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> createCell(
            Paragraph<PS, SEG, S> paragraph,
            BiConsumer<TextFlow, PS> applyParagraphStyle,
            Function<StyledSegment<SEG, S>, Node> nodeFactory) {

        ParagraphBox<PS, SEG, S> box = new ParagraphBox<>(paragraph, applyParagraphStyle, nodeFactory);

        box.highlightTextFillProperty().bind(highlightTextFill);
        box.wrapTextProperty().bind(wrapTextProperty());
        box.graphicFactoryProperty().bind(paragraphGraphicFactoryProperty());
        box.graphicOffset.bind(virtualFlow.breadthOffsetProperty());

        EventStream<Integer> boxIndexValues = box.indexProperty().values().filter(i -> i != -1);

        Subscription firstParPseudoClass = boxIndexValues.subscribe(idx -> box.pseudoClassStateChanged(FIRST_PAR, idx == 0));
        Subscription lastParPseudoClass = EventStreams.combine(
                boxIndexValues,
                getParagraphs().sizeProperty().values()
        ).subscribe(in -> in.exec((i, n) -> box.pseudoClassStateChanged(LAST_PAR, i == n-1)));

        // set up caret
        Function<CaretNode, Subscription> subscribeToCaret = caret -> {
            EventStream<Integer> caretIndexStream = EventStreams.nonNullValuesOf(caret.paragraphIndexProperty());

            // a new event stream needs to be created for each caret added, so that it will immediately
            // fire the box's current index value as an event, thereby running the code in the subscribe block
            // Reusing boxIndexValues will not fire its most recent event, leading to a caret not being added
            // Thus, we'll call the new event stream "fresh" box index values
            EventStream<Integer> freshBoxIndexValues = box.indexProperty().values().filter(i -> i != -1);

            return EventStreams.combine(caretIndexStream, freshBoxIndexValues)
                    .subscribe(t -> {
                        int caretParagraphIndex = t.get1();
                        int boxIndex = t.get2();
                        if (caretParagraphIndex == boxIndex) {
                            box.caretsProperty().add(caret);
                        } else {
                            box.caretsProperty().remove(caret);
                        }
                    });
        };
        Subscription caretSubscription = caretSet.addSubscriber(subscribeToCaret);

        // TODO: how should 'hasCaret' be handled now?
        Subscription hasCaretPseudoClass = EventStreams
                .combine(boxIndexValues, Val.wrap(currentParagraphProperty()).values())
                // box index (t1) == caret paragraph index (t2)
                .map(t -> t.get1().equals(t.get2()))
                .subscribe(value -> box.pseudoClassStateChanged(HAS_CARET, value));

        Function<Selection<PS, SEG, S>, Subscription> subscribeToSelection = selection -> {
            EventStream<Integer> startParagraphValues = EventStreams.nonNullValuesOf(selection.startParagraphIndexProperty());
            EventStream<Integer> endParagraphValues = EventStreams.nonNullValuesOf(selection.endParagraphIndexProperty());

            // see comment in caret section about why a new box index EventStream is needed
            EventStream<Integer> freshBoxIndexValues = box.indexProperty().values().filter(i -> i != -1);
            return EventStreams.combine(startParagraphValues, endParagraphValues, freshBoxIndexValues)
                    .subscribe(t -> {
                        int startPar = t.get1();
                        int endPar = t.get2();
                        int boxIndex = t.get3();
                        if (startPar <= boxIndex && boxIndex <= endPar) {
                            //   So that we don't add multiple paths for the same selection,
                            //   which leads to not removing the additional paths when selection is removed,
                            // this is a `Map#putIfAbsent(Key, Value)` implementation that creates the path lazily
                            SelectionPath p = box.selectionsProperty().get(selection);
                            if (p == null) {
                                // create & configure path
                                Val<IndexRange> range = Val.create(
                                        () -> boxIndex != -1
                                                ? getParagraphSelection(selection, boxIndex)
                                                : EMPTY_RANGE,
                                        selection.rangeProperty()
                                );
                                SelectionPath path = new SelectionPath(range);
                                selection.configureSelectionPath(path);

                                box.selectionsProperty().put(selection, path);
                            }
                        } else {
                            box.selectionsProperty().remove(selection);
                        }
                    });
        };
        Subscription selectionSubscription = selectionSet.addSubscriber(subscribeToSelection);

        return new Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>>() {
            @Override
            public ParagraphBox<PS, SEG, S> getNode() {
                return box;
            }

            @Override
            public void updateIndex(int index) {
                box.setIndex(index);
            }

            @Override
            public void dispose() {
                box.highlightTextFillProperty().unbind();
                box.wrapTextProperty().unbind();
                box.graphicFactoryProperty().unbind();
                box.graphicOffset.unbind();
                box.dispose();

                firstParPseudoClass.unsubscribe();
                lastParPseudoClass.unsubscribe();

                caretSubscription.unsubscribe();
                hasCaretPseudoClass.unsubscribe();

                selectionSubscription.unsubscribe();
            }
        };
    }
975306
public static void setPosTags(Token token, JCas jcas, String... posTags) {

        FSArray slots = new FSArray(jcas, posTags.length);
        for (int i = 0; i < posTags.length; i++) {
            POSTag posTag = new POSTag(jcas);
            posTag.setValue(posTags[i]);
            posTag.addToIndexes();
            slots.set(i, posTag);
        }
        token.setPosTag(slots);
    }
158187
public function createAction()
	{
		$this->isPostRequest();

		$type = $this->getRequestParameter('type');

		$page = null;

		switch ($type) {
			case Entity::APPLICATION_DISCR:
				$page = new ApplicationPage(
						$this->getRequestParameter('application_id')
				);
				break;
			case Entity::PAGE_DISCR:
				$page = new Page();
				break;
			default:
				throw new \InvalidArgumentException(sprintf('Unknown page type [%s]', $type));
		}

		$localeId = $this->getCurrentLocale()->getId();

		$localization = Localization::factory($page, $localeId);
		/* @var $localization PageLocalization */

		if (! $localization instanceof PageLocalization) {
			throw new \UnexpectedValueException(sprintf(
					'Expecting created localization to be instance of PageLocalization, [%s] received.',
					get_class($localization)
			));
		}

		$templateId = $this->getRequestParameter('template');
		
		$template = $this->getEntityManager()
				->find(Template::CN(), $templateId);
		/* @var $template Template */

		if ($template === null) {
			throw new CmsException(null, 'Template not specified or found.');
		}

		$templateLocalization = $template->getLocalization($localeId);

		if ($templateLocalization === null) {
			throw new \InvalidArgumentException(
					"Specified template has no localization for [{$localeId}] locale."
			);
		}

		$localization->setTemplate($template);

		// copy values from template
		$localization->setIncludedInSearch($templateLocalization->isIncludedInSearch());
		$localization->setVisibleInMenu($templateLocalization->isVisibleInMenu());
		$localization->setVisibleInSitemap($templateLocalization->isVisibleInSitemap());

		$title = trim($this->getRequestParameter('title', ''));

		if (empty($title)) {
			throw new CmsException(null, 'Page title cannot be empty.');
		}
		
		$localization->setTitle($title);

		$parentLocalization = $pathPart
				= null;

		$parentLocalizationId = $this->getRequestParameter('parent_id');
		
		if (! empty($parentLocalizationId)) {

			$parentLocalization = $this->getEntityManager()
					->find(Localization::CN(), $parentLocalizationId);

			if ($parentLocalization === null) {
				throw new CmsException(null, sprintf(
						'Specified parent page [%s] not found.',
						$parentLocalizationId
				));
			}

			$pathPart = trim($this->getRequestParameter('path'));

			// path part cannot be empty for non-root pages.
			if (empty($pathPart)) {
				throw new CmsException(null, 'Page path can not be empty.');
			}
		}

		if ($parentLocalization && $pathPart) {
			$localization->setPathPart($pathPart);
		} else {
			$rootPath = $localization->getPathEntity();
			$rootPath->setPath('');
			$localization->setPathPart('');
		}

		$entityManager = $this->getEntityManager();

		$entityManager->transactional(function (EntityManager $entityManager) use ($page, $localization, $parentLocalization) {

			$this->lockNestedSet($page);

			$entityManager->persist($page);
			$entityManager->persist($localization);

			if ($parentLocalization) {
				$page->moveAsLastChildOf($parentLocalization->getMaster());
			}

			$this->unlockNestedSet($page);
		});

		return new SupraJsonResponse($this->loadNodeMainData($localization));
	}
1306967
def new(self, event):
        """"""

        # Grid table handles interaction to code_array

        self.grid.actions.clear(event.shape)

        _grid_table = GridTable(self.grid, self.grid.code_array)
        self.grid.SetTable(_grid_table, True)

        # Update toolbars
        self.grid.update_entry_line()
        self.grid.update_attribute_toolbar()