// Refresh when a Resource has been renamed, if it exists in the active package
  public void onResourceRenamed(@Observes final ResourceRenamedEvent event) {
    if (!getView().isVisible()) {
      return;
    }
    final Path sourcePath = event.getPath();
    final Path destinationPath = event.getDestinationPath();

    boolean refresh = false;
    if (Utils.isInFolderItem(activeFolderItem, sourcePath)) {
      refresh = true;
    } else if (Utils.isInFolderItem(activeFolderItem, destinationPath)) {
      refresh = true;
    }

    if (refresh) {
      explorerService
          .call(
              new RemoteCallback<FolderListing>() {
                @Override
                public void callback(final FolderListing folderListing) {
                  getView().setItems(folderListing);
                }
              },
              new DefaultErrorCallback())
          .getFolderListing(
              activeOrganizationalUnit,
              activeRepository,
              activeProject,
              activeFolderItem,
              getActiveOptions());
    }
  }
  // Refresh when a Resource has been copied, if it exists in the active package
  public void onResourceCopied(@Observes final ResourceCopiedEvent event) {
    if (!getView().isVisible()) {
      return;
    }
    final Path resource = event.getDestinationPath();
    if (resource == null) {
      return;
    }
    if (!Utils.isInFolderItem(activeFolderItem, resource)) {
      return;
    }

    explorerService
        .call(
            new RemoteCallback<FolderListing>() {
              @Override
              public void callback(final FolderListing folderListing) {
                getView().setItems(folderListing);
              }
            },
            new DefaultErrorCallback())
        .getFolderListing(
            activeOrganizationalUnit,
            activeRepository,
            activeProject,
            activeFolderItem,
            getActiveOptions());
  }
 @Override
 public void projectSelected(final Project project) {
   if (Utils.hasProjectChanged(project, activeProject)) {
     getView().getExplorer().clear();
     initialiseViewForActiveContext(activeOrganizationalUnit, activeRepository, project);
   }
 }
 @Override
 public void organizationalUnitSelected(final OrganizationalUnit organizationalUnit) {
   if (Utils.hasOrganizationalUnitChanged(organizationalUnit, activeOrganizationalUnit)) {
     getView().getExplorer().clear();
     initialiseViewForActiveContext(organizationalUnit);
   }
 }
 @Override
 public void repositorySelected(final Repository repository) {
   if (Utils.hasRepositoryChanged(repository, activeRepository)) {
     getView().getExplorer().clear();
     initialiseViewForActiveContext(activeOrganizationalUnit, repository);
   }
 }
 boolean setupActiveRepository(final ProjectExplorerContent content) {
   if (Utils.hasRepositoryChanged(content.getRepository(), activeRepository)) {
     setActiveRepository(content.getRepository());
     return true;
   } else {
     return false;
   }
 }
 boolean setupActiveProject(final ProjectExplorerContent content) {
   if (Utils.hasProjectChanged(content.getProject(), activeProject)) {
     setActiveProject(content.getProject());
     return true;
   } else {
     return false;
   }
 }
  boolean setupActiveOrganizationalUnit(final ProjectExplorerContent content) {

    if (Utils.hasOrganizationalUnitChanged(
        content.getOrganizationalUnit(), activeOrganizationalUnit)) {
      setActiveOrganizationalUnit(content.getOrganizationalUnit());
      return true;
    } else {
      return false;
    }
  }
 public void onProjectRename(@Observes final RenameProjectEvent event) {
   if (!getView().isVisible()) {
     return;
   }
   if (!Utils.isInRepository(activeRepository, event.getOldProject())) {
     return;
   }
   if (authorizationManager.authorize(event.getOldProject(), identity)) {
     doInitialiseViewForActiveContext(
         activeOrganizationalUnit, activeRepository, event.getNewProject(), null, null, true);
   }
 }
  public void onPackageAdded(@Observes final NewPackageEvent event) {
    if (!getView().isVisible()) {
      return;
    }
    final Package pkg = event.getPackage();
    if (pkg == null) {
      return;
    }
    if (!Utils.isInProject(activeProject, pkg)) {
      return;
    }

    refresh(false);
  }
 public void onProjectDelete(@Observes final DeleteProjectEvent event) {
   if (!getView().isVisible()) {
     return;
   }
   if (!Utils.isInRepository(activeRepository, event.getProject())) {
     return;
   }
   if (authorizationManager.authorize(event.getProject(), identity)) {
     if (activeProject != null && activeProject.equals(event.getProject())) {
       activeProject = null;
     }
     doInitialiseViewForActiveContext(
         activeOrganizationalUnit, activeRepository, null, null, null, true);
   }
 }
 public void onProjectAdded(@Observes final NewProjectEvent event) {
   if (!getView().isVisible()) {
     return;
   }
   final Project project = event.getProject();
   if (project == null) {
     return;
   }
   if (!Utils.isInRepository(activeRepository, project)) {
     return;
   }
   if (authorizationManager.authorize(project, identity)) {
     doInitialiseViewForActiveContext(
         activeOrganizationalUnit, activeRepository, project, null, null, false);
   }
 }
  boolean setupActiveFolderAndPackage(final ProjectExplorerContent content) {
    if (Utils.hasFolderItemChanged(content.getFolderListing().getItem(), activeFolderItem)) {
      setActiveFolderItem(content.getFolderListing().getItem());
      if (activeFolderItem != null
          && activeFolderItem.getItem() != null
          && activeFolderItem.getItem() instanceof Package) {
        setActivePackage((Package) activeFolderItem.getItem());
      } else if (activeFolderItem == null || activeFolderItem.getItem() == null) {
        setActivePackage(null);
      }

      return true;
    } else {
      return false;
    }
  }
  private IsWidget makeItemNavLink(
      final ClientResourceType resourceType, final FolderItem folderItem) {
    String fileName = folderItem.getFileName();
    if (!(resourceType instanceof AnyResourceType)) {
      fileName = Utils.getBaseFileName(fileName);
    }
    fileName = fileName.replaceAll(" ", "\u00a0");
    final NavLink navLink = new NavLink(fileName);
    navLink.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            Window.alert("click en el boton del resurso");
            presenter.itemSelected(folderItem);
          }
        });
    return navLink;
  }
  @Override
  public void activeFolderItemSelected(final FolderItem item) {
    if (Utils.hasFolderItemChanged(item, activeFolderItem)) {
      activeFolderItem = item;
      fireContextChangeEvent();

      // Show busy popup. Once Items are loaded it is closed
      getView().showBusyIndicator(CommonConstants.INSTANCE.Loading());
      explorerService
          .call(
              new RemoteCallback<FolderListing>() {
                @Override
                public void callback(final FolderListing folderListing) {
                  loadContent(folderListing);
                  getView().setItems(folderListing);
                  getView().hideBusyIndicator();
                }
              },
              new HasBusyIndicatorDefaultErrorCallback(getView()))
          .getFolderListing(
              activeOrganizationalUnit, activeRepository, activeProject, item, getActiveOptions());
    }
  }