/*******************************************************************************
 * Copyright 2009 Google Inc. All Rights Reserved.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package com.google.gdt.eclipse.suite.update.builders;

import com.google.gdt.eclipse.suite.update.GdtExtPlugin;
import com.google.gwt.eclipse.core.nature.GWTNature;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.compiler.CompilationParticipant;

/**
 * A compilation participant that is used to trigger an update check of the GWT Plugin's feature
 * whenever a Java build is triggered on a GWT project.
 */
public class UpdateTriggerCompilationParticipant extends CompilationParticipant {

  @Override
  public boolean isActive(IJavaProject project) {
    if (!project.exists()) {
      return false;
    }

    if (GWTNature.isGWTProject(project.getProject())) {
      GdtExtPlugin.getFeatureUpdateManager().checkForUpdates();
      GdtExtPlugin.getAnalyticsPingManager().sendCompilationPing();
      return true;
    } else {
      return false;
    }
  }
}

@@ -946,16 +946,189 @@
 ature;%0A%0A
+import org.eclipse.core.runtime.IProgressMonitor;%0Aimport org.eclipse.core.runtime.IStatus;%0Aimport org.eclipse.core.runtime.Status;%0Aimport org.eclipse.core.runtime.jobs.Job;%0A
 import o
@@ -1651,194 +1651,1037 @@
     
-GdtExtPlugin.getFeatureUpdateManager().checkForUpdates();%0A      GdtExtPlugin.getAnalyticsPingManager().sendCompilationPing();%0A      return true;%0A    %7D else %7B%0A      return false
+runProcesses();%0A      return true;%0A    %7D else %7B%0A      return false;%0A    %7D%0A  %7D%0A%0A  /**%0A   * TODO add preferences to disable%0A   */%0A  private void runProcesses() %7B%0A    checkUpdates();%0A    pingAnalytics();%0A  %7D%0A%0A  private void checkUpdates() %7B%0A    Job job = new Job(%22Check Update%22) %7B%0A      @Override%0A      protected IStatus run(IProgressMonitor monitor) %7B%0A        try %7B%0A          GdtExtPlugin.getFeatureUpdateManager().checkForUpdates();%0A        %7D catch (Exception e) %7B%0A          // No need to catch network issues.%0A        %7D%0A        System.out.println(%22check updates%22);%0A        return Status.OK_STATUS;%0A      %7D%0A    %7D;%0A    job.schedule();%0A  %7D%0A%0A  public void pingAnalytics() %7B%0A    Job job = new Job(%22Analytics Ping%22) %7B%0A      @Override%0A      protected IStatus run(IProgressMonitor monitor) %7B%0A        try %7B%0A          GdtExtPlugin.getAnalyticsPingManager().sendCompilationPing();%0A        %7D catch (Exception e) %7B%0A          // No need to catch neetowrk issues%0A        %7D%0A        return Status.OK_STATUS
 ;%0A    
+  
 %7D%0A  
+ 
-%7D
+ %7D;%0A    job.schedule();%0A  %7D%0A
 %0A%7D%0A

Fix offline use with threading network connection.