Source:
<code>public EditingTarget addTab(SourceDocument doc, Integer position, int mode) { final String defaultNamePrefix = editingTargetSource_.getDefaultNamePrefix(doc); final EditingTarget target = editingTargetSource_.getEditingTarget( doc, fileContext_, () -> getNextDefaultName(defaultNamePrefix)); final Widget widget = createWidget(target); if (position == null) { editors_.add(target); } else { editors_.add(position, target); for (int i = 0; i < tabOrder_.size(); i++) { int pos = tabOrder_.get(i); if (pos >= position) tabOrder_.set(i, pos + 1); } tabOrder_.add(position, position); } display_.addTab(widget, target.getIcon(), target.getId(), target.getName().getValue(), target.getTabTooltip(), position, true); fireDocTabsChanged(); target.getName().addValueChangeHandler(event -> { display_.renameTab(widget, target.getIcon(), event.getValue(), target.getPath()); fireDocTabsChanged(); }); display_.setDirty(widget, target.dirtyState().getValue()); target.dirtyState().addValueChangeHandler(event -> { display_.setDirty(widget, event.getValue()); manageCommands(false); }); <START> target.addEnsureVisibleHandler(new EnsureVisibleHandler() <END> { @Override public void onEnsureVisible(EnsureVisibleEvent event) { display_.selectTab(widget); } }); target.addCloseHandler(voidCloseEvent -> closeTab(widget, false)); events_.fireEvent(new SourceDocAddedEvent(doc, mode, getName())); if (target instanceof TextEditingTarget && doc.isReadOnly()) { ((TextEditingTarget) target).setIntendedAsReadOnly( JsUtil.toList(doc.getReadOnlyAlternatives())); } if (editors_.size() == 2) manageMultiTabCommands(); if (doc.getCollabParams() != null) target.beginCollabSession(doc.getCollabParams()); return target; }</code><technical_language>nit: lambda</technical_language>

Target:
public EditingTarget addTab(SourceDocument doc, Integer position, int mode) { final String defaultNamePrefix = editingTargetSource_.getDefaultNamePrefix(doc); final EditingTarget target = editingTargetSource_.getEditingTarget( doc, fileContext_, () -> getNextDefaultName(defaultNamePrefix)); final Widget widget = createWidget(target); if (position == null) { editors_.add(target); } else { editors_.add(position, target); for (int i = 0; i < tabOrder_.size(); i++) { int pos = tabOrder_.get(i); if (pos >= position) tabOrder_.set(i, pos + 1); } tabOrder_.add(position, position); } display_.addTab(widget, target.getIcon(), target.getId(), target.getName().getValue(), target.getTabTooltip(), position, true); fireDocTabsChanged(); target.getName().addValueChangeHandler(event -> { display_.renameTab(widget, target.getIcon(), event.getValue(), target.getPath()); fireDocTabsChanged(); }); display_.setDirty(widget, target.dirtyState().getValue()); target.dirtyState().addValueChangeHandler(event -> { display_.setDirty(widget, event.getValue()); manageCommands(false); }); target.addEnsureVisibleHandler(event -> display_.selectTab(widget)); target.addCloseHandler(voidCloseEvent -> closeTab(widget, false)); events_.fireEvent(new SourceDocAddedEvent(doc, mode, getName())); if (target instanceof TextEditingTarget && doc.isReadOnly()) { ((TextEditingTarget) target).setIntendedAsReadOnly( JsUtil.toList(doc.getReadOnlyAlternatives())); } if (editors_.size() == 2) manageMultiTabCommands(); if (doc.getCollabParams() != null) target.beginCollabSession(doc.getCollabParams()); return target; }