Takes the newView and restore the state taken as base the provided ViewEntry,
and then move all child components from oldView to newView, to finally obtain
a clean component tree.

@param context
@param newView
@param entry
514034
public void cloneAndRestoreView(FacesContext context, UIViewRoot newView, 
            ViewEntry entry, ViewStructureMetadata metadata)
    {
        UIViewRoot oldView = entry.getViewRoot();
        // retrieveViewRootInitialState(context, oldView)
        Object viewState = metadata.getViewRootState();
        Object newViewState;
        UIComponent metadataFacet = newView.getFacet(UIViewRoot.METADATA_FACET_NAME);
        if (viewState == null)
        {
            // (Optional, it should be always metadata)
            oldView.clearInitialState();
            viewState = oldView.saveState(context);
        }
        Map<String, Object> viewScopeMap = newView.getViewMap(false);
        if (viewScopeMap != null && !viewScopeMap.isEmpty())
        {
            newViewState = newView.saveState(context);
        }
        else
        {
            newViewState = null;
        }
        
        boolean oldProcessingEvents = context.isProcessingEvents();
        context.setProcessingEvents(false);
        try
        {
            if (oldView.getFacetCount() > 0)
            {
                List<String> facetKeys = new ArrayList<String>();
                facetKeys.addAll(oldView.getFacets().keySet());
                for (String facetKey : facetKeys)
                {
                    //context.setProcessingEvents(false);
                    if (metadataFacet != null && UIViewRoot.METADATA_FACET_NAME.equals(facetKey) &&
                        !PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()))
                    {
                        // Metadata facet is special, it is created when ViewHandler.createView(...) is
                        // called, so it shouldn't be taken from the oldView, otherwise the state
                        // will be lost. Instead reuse it and discard the one in oldView.
                        // But on restore view phase, use the old one, because the new one does not
                        // have initial state marked.
                        newView.getFacets().put(facetKey, metadataFacet);
                    }
                    else
                    {
                        UIComponent facet = oldView.getFacets().remove(facetKey);
                        //context.setProcessingEvents(true);
                        newView.getFacets().put(facetKey, facet);
                    }
                }
            }
            if (oldView.getChildCount() > 0)
            {
                for (Iterator<UIComponent> it = oldView.getChildren().iterator(); it.hasNext();)
                {
                    //context.setProcessingEvents(false);
                    UIComponent c = it.next();
                    it.remove();
                    //context.setProcessingEvents(true);
                    newView.getChildren().add(c);
                }
            }
            
            // Restore the newView as saved just before markInitialState() call
            newView.restoreState(context, viewState);
            newView.markInitialState();
            
            if (!PhaseId.RESTORE_VIEW.equals(context.getCurrentPhaseId()))
            {
                // Restore bindings like in restore view phase, because in this case,
                // bindings needs to be set (Application.createComponent is not called!).
                restoreViewSupport.processComponentBinding(context, newView);
                
                // Restore view scope map if necessary
                if (viewScopeMap != null && !viewScopeMap.isEmpty())
                {
                    Map<String, Object> newViewScopeMap = newView.getViewMap(false);
                    if (newViewScopeMap == null)
                    {
                        newView.restoreViewScopeState(context, newViewState);
                    }
                    else
                    {
                        // Should theoretically not happen, because when a pooled static view 
                        // is saved, the view scope map is skipped, otherwise it could be a
                        // leak. Anyway, we let this code here that overrides the values from
                        // the original map.
                        for (Map.Entry<String, Object> entry2 : viewScopeMap.entrySet())
                        {
                            newViewScopeMap.put(entry2.getKey(), entry2.getValue());
                        }
                    }
                }
            }
            
            // Update request view metadata to ensure resource list is restored as when the
            // view was built on the first time. This ensures correct calculation of added 
            // resources by dynamic behavior. 
            RequestViewContext rcv = RequestViewContext.getCurrentInstance(context, newView, false);
            if (rcv != null)
            {
                rcv.setRequestViewMetadata(metadata.getRequestViewMetadata().cloneInstance());
            }
            else
            {
                RequestViewContext.setCurrentInstance(context, newView,
                        RequestViewContext.newInstance(metadata.getRequestViewMetadata().cloneInstance()));
            }
        }
        finally
        {
            context.setProcessingEvents(oldProcessingEvents);
        }
    }
888253
public final void registerView(final View view) {
        mActivity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (null != mRenderableViewGroup && view.getParent() != mRenderableViewGroup) {
                    /* The full screen should be updated otherwise just the children's bounds may be refreshed. */
                    mRenderableViewGroup.setClipChildren(false);
                    mRenderableViewGroup.addView(view);
                }
            }
        });
    }
148443
public void applyAndJournal(Supplier<JournalContext> context, SetAclEntry entry) {
    try {
      applySetAcl(entry);
      context.get().append(JournalEntry.newBuilder().setSetAcl(entry).build());
    } catch (Throwable t) {
      ProcessUtils.fatalError(LOG, t, "Failed to apply %s", entry);
      throw t; // fatalError will usually system.exit
    }
  }
575564
protected Object processEntry(BinaryEntry entry) {
        Binary binCurrent = entry.getBinaryValue();
        if (binCurrent == null && !fAllowInsert) {
            return fReturn ? null : NO_RESULT;
        }

        PofValue pvCurrent = getPofValue(binCurrent);
        PofValue pvNew = getPofValue("newValue");

        Integer versionCurrent = (Integer) get(pvCurrent);
        Integer versionNew = (Integer) get(pvNew);

        if (versionCurrent.equals(versionNew)) {
            set(pvNew, versionNew + 1);
            entry.updateBinaryValue(pvNew.applyChanges());
            return NO_RESULT;
        }

        return fReturn ? pvCurrent.getValue() : NO_RESULT;
    }
76870
public void applyAndJournal(Supplier<JournalContext> context, RenameEntry entry) {
    try {
      applyRename(entry);
      context.get().append(JournalEntry.newBuilder().setRename(entry).build());
    } catch (Throwable t) {
      ProcessUtils.fatalError(LOG, t, "Failed to apply %s", entry);
      throw t; // fatalError will usually system.exit
    }
  }
219109
public void onRestoreInstanceState(Bundle savedInstanceState) {
    String instanceKey = getContext().getString(R.string.navigation_view_instance_state);
    NavigationViewInstanceState navigationViewInstanceState = savedInstanceState.getParcelable(instanceKey);
    recenterBtn.setVisibility(navigationViewInstanceState.getRecenterButtonVisibility());
    wayNameView.setVisibility(navigationViewInstanceState.isWayNameVisible() ? VISIBLE : INVISIBLE);
    wayNameView.updateWayNameText(navigationViewInstanceState.getWayNameText());
    resetBottomSheetState(navigationViewInstanceState.getBottomSheetBehaviorState());
    updateInstructionListState(navigationViewInstanceState.isInstructionViewVisible());
    updateInstructionMutedState(navigationViewInstanceState.isMuted());
    mapInstanceState = savedInstanceState.getParcelable(MAP_INSTANCE_STATE_KEY);
  }
474531
public void createSubEntry(final CmsClientSitemapEntry newEntry, CmsUUID parentId, CmsUUID structureId) {

        if (structureId == null) {
            structureId = m_data.getDefaultNewElementInfo().getCopyResourceId();
        }
        create(newEntry, parentId, m_data.getDefaultNewElementInfo().getId(), structureId, null, false);
    }
68210
private void init(Context context) {
        LayoutInflater.from(context).inflate(R.layout.artist_view, this);
        this.setVisibility(INVISIBLE);
        mAvatar = ((ImageView) findViewById(R.id.artist_view_avatar));
        mArtistName = ((TextView) findViewById(R.id.artist_view_name));
        mTracks = ((TextView) findViewById(R.id.artist_view_track_number));
        mDescription = ((TextView) findViewById(R.id.artist_view_description));
    }
626007
private void putEntry(String key, CacheHeader entry) {
        if (!mEntries.containsKey(key)) {
            mTotalSize += entry.size;
        } else {
            CacheHeader oldEntry = mEntries.get(key);
            mTotalSize += (entry.size - oldEntry.size);
        }
        mEntries.put(key, entry);
    }
339944
@Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ensureContent();
    }
640057
public void viewDocument(DocumentEntry entry)
   {
      InputStream is = null;

      try
      {
         is = new DocumentInputStream(entry);
         byte[] data = new byte[is.available()];
         is.read(data);
         m_model.setData(data);
         updateTables();
      }

      catch (IOException ex)
      {
         throw new RuntimeException(ex);
      }

      finally
      {
         StreamHelper.closeQuietly(is);
      }

   }
112001
public final void setEntryViewFactory(
            Callback<Entry<?>, MonthEntryView> factory) {
        requireNonNull(factory);
        entryViewFactoryProperty().set(factory);
    }
1211581
function(model, componentView, customView) {
      var t = this,
          componentPane = t.$('.nm-cs-component');

      // Remember the model state on entry
      t.model = model;
      t.componentView = componentView;
      t.monitor = model.get('monitor');
      t.originalModel = t.model.toJSON({trim:false});

      // Remove any inner views
      if (t.sourceView) {
        t.sourceView.remove();
      }
      if (t.customView) {
        t.customView.remove();
      }

      // Clean up prior monitorParams
      if (t.monitorParams) {
        t.monitorParams.off('change');
      }

      // Create the custom settings view
      if (customView) {
        t.customView = new customView({
          model: t.model.get('viewOptions'),
          monitor: t.model.get('monitor'),
          pageView: UI.pageView,
          component: t.model,
          componentView: componentView
        });
        t.$('.nm-cs-view-settings').append(t.customView.el);
        t.customView.render();

        // Attach tooltips to anything with a title
        UI.tooltip(t.$('*[title]'));
      }

      // Normal data binding - name to model
      t.modelBinder.bind(t.model, t.$el, t.componentBindings);

      // Bind data-view-option elements to component.viewOptions
      t.viewOptionBinder.bind(
        t.model.get('viewOptions'),
        componentPane,
        Backbone.ModelBinder.createDefaultBindings(componentPane, 'data-view-option')
      );

      // Bind data-monitor-param elements to monitor.initParams.
      // This is a bit more difficult because initParams isnt a Backbone model.
      // Copy into a Backbone model, and bind to that.
      t.monitorParams = new Backbone.Model(t.monitor.get('initParams'));
      t.monitorParamBinder.bind(
        t.monitorParams,
        componentPane,
        Backbone.ModelBinder.createDefaultBindings(componentPane, 'data-monitor-param')
      );
      t.monitorParams.on('change', function() {
        t.monitor.set('initParams', t.monitorParams.toJSON());
      });

      // Instantiate the source view
      t.sourceView = new UI.JsonView({
        model: t.model.toJSON({trim:false})
      });
      t.sourceView.render();
      t.$('.nm-cs-source-view').append(t.sourceView.$el);
    }
1108707
public void addToNavigation(CmsClientSitemapEntry entry) {

        entry.setInNavigation(true);
        CmsSitemapChange change = new CmsSitemapChange(entry.getId(), entry.getSitePath(), ChangeType.modify);
        CmsPropertyModification mod = new CmsPropertyModification(
            entry.getId(),
            CmsClientProperty.PROPERTY_NAVTEXT,
            entry.getTitle(),
            true);
        change.setPropertyChanges(Collections.singletonList(mod));
        change.setPosition(entry.getPosition());
        commitChange(change, null);
    }
745054
public void init(CmsElementView view, boolean useDefault) {

        m_currentView = view;
        if (!view.getId().equals(getViewSelector().getValue())) {
            getViewSelector().setValue(view.getId());
        }
        getVerticalLayout().removeAllComponents();

        List<CmsResourceTypeBean> typeBeans = m_typeHelper.getPrecomputedTypes(view);
        if (view.getId().equals(ID_VIEW_ALL)) {
            typeBeans = m_allTypes;
        }

        if (typeBeans == null) {

            LOG.warn("precomputed type list is null: " + view.getTitle(A_CmsUI.getCmsObject(), Locale.ENGLISH));
            return;
        }
        for (CmsResourceTypeBean type : typeBeans) {
            final String typeName = type.getType();
            String title = typeName;
            String subtitle = getSubtitle(type, useDefault);
            CmsExplorerTypeSettings explorerType = OpenCms.getWorkplaceManager().getExplorerTypeSetting(typeName);

            title = CmsVaadinUtils.getMessageText(explorerType.getKey());
            CmsResourceInfo info = new CmsResourceInfo(
                title,
                subtitle,
                CmsResourceUtil.getBigIconResource(explorerType, null));
            info.setData(type);
            m_resourceInfoMap.put(type, info);
            getVerticalLayout().addComponent(info);
        }
    }
330672
public void updateFromEntry(UpdateInodeEntry entry) {
    if (entry.hasAcl()) {
      setInternalAcl(ProtoUtils.fromProto(entry.getAcl()));
    }
    if (entry.hasCreationTimeMs()) {
      setCreationTimeMs(entry.getCreationTimeMs());
    }
    if (entry.hasGroup()) {
      setGroup(entry.getGroup());
    }
    if (entry.hasLastModificationTimeMs()) {
      setLastModificationTimeMs(entry.getLastModificationTimeMs(),
          entry.getOverwriteModificationTime());
    }
    if (entry.hasMode()) {
      setMode((short) entry.getMode());
    }
    if (entry.hasName()) {
      setName(entry.getName());
    }
    if (entry.hasOwner()) {
      setOwner(entry.getOwner());
    }
    if (entry.hasParentId()) {
      setParentId(entry.getParentId());
    }
    if (entry.hasPersistenceState()) {
      setPersistenceState(PersistenceState.valueOf(entry.getPersistenceState()));
    }
    if (entry.hasPinned()) {
      setPinned(entry.getPinned());
    }
    if (entry.hasTtl()) {
      setTtl(entry.getTtl());
    }
    if (entry.hasTtlAction()) {
      setTtlAction(ProtobufUtils.fromProtobuf(entry.getTtlAction()));
    }
    if (entry.hasUfsFingerprint()) {
      setUfsFingerprint(entry.getUfsFingerprint());
    }
  }
1300605
function Context(view, parentContext) {
  this.view = view || {};
  this.cache = {
    '.': this.view
  };
  this.parent = parentContext;

  // If parent context isn't passed, but the model has parents, build the chain
  this.initialize(view, parentContext);
  if (this.isModel(view)) {
    this.lastModel = view;
  } else if (parentContext) {
    this.lastModel = parentContext.lastModel;
  }
}