Esempio n. 1
0
 protected boolean preloadRepositories() {
   hasNoRepos = false;
   RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
   if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0) {
     hasNoRepos = true;
     return false;
   }
   return super.preloadRepositories();
 }
  public void reportLoadFailure(final URI location, ProvisionException e) {
    int code = e.getStatus().getCode();
    // If the user doesn't have a way to manage repositories, then don't report failures.
    if (!ui.getPolicy().getRepositoriesVisible()) {
      super.reportLoadFailure(location, e);
      return;
    }

    // Special handling when the location is bad (not found, etc.) vs. a failure
    // associated with a known repo.
    if (code == ProvisionException.REPOSITORY_NOT_FOUND
        || code == ProvisionException.REPOSITORY_INVALID_LOCATION) {
      if (!hasNotFoundStatusBeenReported(location)) {
        addNotFound(location);
        ProvUI.getDefaultParentShell()
            .getDisplay()
            .asyncExec(
                new Runnable() {
                  public void run() {
                    //						IWorkbench workbench = PlatformUI.getWorkbench();
                    //						if (workbench.isClosing())
                    //							return;
                    Shell shell = ProvUI.getDefaultParentShell();
                    if (MessageDialog.openQuestion(
                        shell,
                        ProvUIMessages.ColocatedRepositoryTracker_SiteNotFoundTitle,
                        NLS.bind(
                            ProvUIMessages.ColocatedRepositoryTracker_PromptForSiteLocationEdit,
                            URIUtil.toUnencodedString(location)))) {
                      RepositoryNameAndLocationDialog dialog =
                          new RepositoryNameAndLocationDialog(shell, ui) {
                            protected String getInitialLocationText() {
                              return URIUtil.toUnencodedString(location);
                            }

                            protected String getInitialNameText() {
                              String nickname =
                                  getMetadataRepositoryManager()
                                      .getRepositoryProperty(location, IRepository.PROP_NICKNAME);
                              return nickname == null ? "" : nickname; // $NON-NLS-1$
                            }
                          };
                      int ret = dialog.open();
                      if (ret == Window.OK) {
                        URI correctedLocation = dialog.getLocation();
                        if (correctedLocation != null) {
                          ui.signalRepositoryOperationStart();
                          try {
                            removeRepositories(new URI[] {location}, ui.getSession());
                            addRepository(correctedLocation, dialog.getName(), ui.getSession());
                          } finally {
                            ui.signalRepositoryOperationComplete(null, true);
                          }
                        }
                      }
                    }
                  }
                });
      }
    } else {
      ProvUI.handleException(e, null, StatusManager.SHOW | StatusManager.LOG);
    }
  }