コード例 #1
0
 public boolean connect() {
   try {
     ConnectJob connectJob = new ConnectJob();
     WizardUtils.runInWizard(
         connectJob, new DelegatingProgressMonitor(), getContainer(), getDatabindingContext());
     boolean connected = JobUtils.isOk(connectJob.getConnectionStatus());
     if (connected) {
       boolean result = pageModel.saveConnection();
       if (result) {
         SecureStoreException e = pageModel.getRecentSecureStoreException();
         if (e != null && e.getCause() instanceof StorageException) {
           result = false;
           Display.getDefault()
               .asyncExec(
                   new Runnable() {
                     @Override
                     public void run() {
                       String message =
                           "Connection is successful, but access to secure storage is denied.\n"
                               + "Please change save password/token settings and try again.\n"
                               + "Be aware, that if you select 'Cancel' at this point, you will "
                               + "be prompted for secure storage at each request for resources.";
                       MessageDialog.openWarning(
                           getWizard().getContainer().getShell(), "Warning", message);
                     }
                   });
         }
       }
       return result;
     } else {
       return false;
     }
   } catch (InterruptedException e) {
     OpenShiftCommonUIActivator.log(
         NLS.bind("Failed to authenticate user on server at {1}", pageModel.getHost()), e);
     return false;
   } catch (InvocationTargetException e) {
     OpenShiftCommonUIActivator.log(
         NLS.bind("Failed to authenticate user on server at {1}", pageModel.getHost()), e);
     return false;
   }
 }
コード例 #2
0
  private boolean importProject() {
    try {
      final DelegatingProgressMonitor delegatingMonitor = new DelegatingProgressMonitor();
      ImportJob importJob =
          new ImportJob(model.getGitUrl(), model.getCloneDestination(), delegatingMonitor)
              .setGitRef(model.getGitRef());

      String gitContextDir = model.getGitContextDir();
      if (!StringUtils.isEmptyOrNull(gitContextDir)) {
        importJob.setFilters(Collections.singleton(gitContextDir));
      }
      IStatus jobResult = WizardUtils.runInWizard(importJob, delegatingMonitor, getContainer());
      return JobUtils.isOk(jobResult);
    } catch (Exception e) {
      ErrorDialog.openError(
          getShell(),
          "Error",
          "Could not create local git repository.",
          OpenShiftUIActivator.statusFactory()
              .errorStatus("An exception occurred while creating local git repository.", e));
      return false;
    }
  }