Beispiel #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;
  }
Beispiel #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();
  }
Beispiel #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;
  }
Beispiel #4
0
 private void notifyServerExited() {
   observerLord.notifyObservers(
       new ObserverLord.ObserverNotification<O>() {
         public void notify(ServerObserver observer) {
           observer.serverExited();
         }
       });
 }
Beispiel #5
0
 private void notifySettingsChanged() {
   settingsObserverLord.notifyObservers(
       new ObserverLord.ObserverNotification<SettingsObserver>() {
         public void notify(SettingsObserver observer) {
           observer.settingsChanged();
         }
       });
 }
Beispiel #6
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);
          }
        });
  }
Beispiel #7
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());
           }
         }
       });
 }
Beispiel #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());
           }
         }
       });
 }
Beispiel #9
0
 public void removeServerObserver(O observer) {
   observerLord.removeObserver(observer);
 }
Beispiel #10
0
 public void addServerObserver(O observer, boolean inEventQueue) {
   observerLord.addObserver(observer, inEventQueue);
 }
Beispiel #11
0
 public void removeCommandLineArgumentAlteringListener(
     CommandLineArgumentAlteringListener listener) {
   commandLineArgumentObserverLord.removeObserver(listener);
 }
Beispiel #12
0
 /**
  * This allows you to add a listener that can add additional command line arguments whenever
  * gradle is executed. This is useful if you've customized your gradle build and need to specify,
  * for example, an init script.
  *
  * <p>param listener the listener that modifies the command line arguments.
  */
 public void addCommandLineArgumentAlteringListener(CommandLineArgumentAlteringListener listener) {
   commandLineArgumentObserverLord.addObserver(listener, false);
 }
Beispiel #13
0
 /**
  * Adds an observer for various events. See PluginObserver.
  *
  * @param observer your observer
  * @param inEventQueue true if you want to be notified in the Event Dispatch Thread.
  */
 public void addGeneralPluginObserver(GeneralPluginObserver observer, boolean inEventQueue) {
   generalObserverLord.addObserver(observer, inEventQueue);
 }
Beispiel #14
0
 public void removeGeneralPluginObserver(GeneralPluginObserver observer) {
   generalObserverLord.removeObserver(observer);
 }
Beispiel #15
0
 public void addRequestObserver(RequestObserver observer, boolean inEventQueue) {
   requestObserverLord.addObserver(observer, inEventQueue);
 }
Beispiel #16
0
 public void removeSettingsObserver(SettingsObserver observer) {
   settingsObserverLord.removeObserver(observer);
 }
Beispiel #17
0
 public void addSettingsObserver(SettingsObserver observer, boolean inEventQueue) {
   settingsObserverLord.addObserver(observer, inEventQueue);
 }
Beispiel #18
0
 public void removeRequestObserver(RequestObserver observer) {
   requestObserverLord.removeObserver(observer);
 }