code: void toggleOnlineOffline() {
  
          CmsObject cms = A_CmsUI.getCmsObject();
          CmsProject targetProject = null;
          if (cms.getRequestContext().getCurrentProject().isOnlineProject()) {
              targetProject = A_CmsUI.get().getLastOfflineProject();
              if (targetProject == null) {
                  CmsUserSettings userSettings = new CmsUserSettings(cms);
                  try {
                      CmsProject project = cms.readProject(userSettings.getStartProject());
                      if (!project.isOnlineProject()
                          && OpenCms.getOrgUnitManager().getAllAccessibleProjects(
                              cms,
                              project.getOuFqn(),
                              false).contains(project)) {
                          targetProject = project;
                      }
                  } catch (CmsException e) {
                      LOG.debug("Error reading user start project.", e);
                  }
                  if (targetProject == null) {
                      List<CmsProject> availableProjects = CmsVaadinUtils.getAvailableProjects(cms);
                      for (CmsProject project : availableProjects) {
                          if (!project.isOnlineProject()) {
                              targetProject = project;
                              break;
                          }
                      }
                  }
              }
          } else {
              try {
                  targetProject = cms.readProject(CmsProject.ONLINE_PROJECT_ID);
              } catch (CmsException e) {
                  LOG.debug("Error reading online project.", e);
              }
          }
          if (targetProject != null) {
              A_CmsUI.get().changeProject(targetProject);
              onSiteOrProjectChange(targetProject, null);
              Notification.show(
                  CmsVaadinUtils.getMessageText(Messages.GUI_SWITCHED_TO_PROJECT_1, targetProject.getName()));
          }
      }
docs: Toggles between the online and the offline project.<p>