Esempio n. 1
0
  /**
   * This will refresh the project/task tree. This version allows you to specify additional
   * arguments to be passed to gradle during the refresh (such as -b to specify a build file)
   *
   * @param additionalCommandLineArguments the arguments to add, or null if none.
   * @return the Request that was created. Null if no request created.
   */
  public Request addRefreshRequestToQueue(String additionalCommandLineArguments) {
    if (!isStarted) {
      return null;
    }

    if (hasRequestOfType(RefreshTaskListRequest.TYPE)) {
      return null; // we're already doing a refresh.
    }

    // we'll request a task list since there is no way to do a no op. We're not really interested
    // in what's being executed, just the ability to get the task list (which must be populated as
    // part of executing anything).
    String fullCommandLine = ImplicitTasksConfigurer.TASKS_TASK;

    if (additionalCommandLineArguments != null) {
      fullCommandLine += ' ' + additionalCommandLineArguments;
    }

    // here we'll give the UI a chance to add things to the command line.
    fullCommandLine = alterCommandLine(fullCommandLine);

    final RefreshTaskListRequest request =
        new RefreshTaskListRequest(getNextRequestID(), fullCommandLine, executionQueue, this);
    executionQueue.addRequestToQueue(request);
    // TODO - fix this race condition - request may already have completed
    requestObserverLord.notifyObservers(
        new ObserverLord.ObserverNotification<RequestObserver>() {
          public void notify(RequestObserver observer) {
            observer.refreshRequestAdded(request);
          }
        });
    return request;
  }
Esempio n. 2
0
  /**
   * This is where we notify listeners and give them a chance to add things to the command line.
   *
   * @param fullCommandLine the full command line
   * @return the new command line.
   */
  private String alterCommandLine(String fullCommandLine) {
    CommandLineArgumentAlteringNotification notification =
        new CommandLineArgumentAlteringNotification(fullCommandLine);
    commandLineArgumentObserverLord.notifyObservers(notification);

    return notification.getFullCommandLine();
  }
Esempio n. 3
0
  /**
   * Call this to execute a task in a background thread. This creates or uses an existing
   * OutputPanel to display the results. This version takes text instead of a task object.
   *
   * @param fullCommandLine the full command line to pass to gradle.
   * @param displayName what we show on the tab.
   * @param forceOutputToBeShown overrides the user setting onlyShowOutputOnErrors so that the
   *     output is shown regardless
   */
  public Request addExecutionRequestToQueue(
      String fullCommandLine, String displayName, boolean forceOutputToBeShown) {
    if (!isStarted) {
      return null;
    }

    if (fullCommandLine == null) {
      return null;
    }

    // here we'll give the UI a chance to add things to the command line.
    fullCommandLine = alterCommandLine(fullCommandLine);

    final ExecutionRequest request =
        new ExecutionRequest(
            getNextRequestID(), fullCommandLine, displayName, forceOutputToBeShown, executionQueue);
    requestObserverLord.notifyObservers(
        new ObserverLord.ObserverNotification<RequestObserver>() {
          public void notify(RequestObserver observer) {
            observer.executionRequestAdded(request);
          }
        });
    executionQueue.addRequestToQueue(request);
    return request;
  }
Esempio n. 4
0
 private void notifyServerExited() {
   observerLord.notifyObservers(
       new ObserverLord.ObserverNotification<O>() {
         public void notify(ServerObserver observer) {
           observer.serverExited();
         }
       });
 }
Esempio n. 5
0
 private void notifySettingsChanged() {
   settingsObserverLord.notifyObservers(
       new ObserverLord.ObserverNotification<SettingsObserver>() {
         public void notify(SettingsObserver observer) {
           observer.settingsChanged();
         }
       });
 }
Esempio n. 6
0
 private void notifyAboutToExecuteRequest(final Request request) {
   requestObserverLord.notifyObservers(
       new ObserverLord.ObserverNotification<RequestObserver>() {
         public void notify(RequestObserver observer) {
           try { // wrap this in a try/catch block so exceptions in the observer doesn't stop
                 // everything
             observer.aboutToExecuteRequest(request);
           } catch (Exception e) {
             logger.error("notifying aboutToExecuteCommand() " + e.getMessage());
           }
         }
       });
 }
Esempio n. 7
0
  /**
   * Sets the current projects. This is only supposed to be called by internal gradle classes.
   *
   * @param newProjects
   */
  public void setProjects(final List<ProjectView> newProjects) {
    projects.clear();
    if (newProjects != null) {
      projects.addAll(newProjects);
    }

    generalObserverLord.notifyObservers(
        new ObserverLord.ObserverNotification<GeneralPluginObserver>() {
          public void notify(GeneralPluginObserver observer) {
            observer.projectsAndTasksReloaded(newProjects != null);
          }
        });
  }
Esempio n. 8
0
 private void notifyRequestExecutionComplete(
     final Request request, final int result, final String output) {
   requestObserverLord.notifyObservers(
       new ObserverLord.ObserverNotification<RequestObserver>() {
         public void notify(RequestObserver observer) {
           try { // wrap this in a try/catch block so exceptions in the observer doesn't stop
                 // everything
             observer.requestExecutionComplete(request, result, output);
           } catch (Exception e) {
             logger.error("notifying requestExecutionComplete() " + e.getMessage());
           }
         }
       });
 }