// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IMechanicService.java
// public interface IMechanicService {
// 
//   /**
//    * Causes the scannning service to start as soon as possible.
//    */
//   void start();
// 
//   /**
//    * Causes the scanning service to stop scanning.
//    */
//   void stop();
// 
//   /**
//    * Return true if the mechanic service is not running.
//    */
//   boolean isStopped();
// 
//   /**
//    * Adds the supplied listener to status change events for the Mechanic (not the
//    * Job). UI components can use this facility to get notifications announcing
//    * changes in the mechanic service.
//    *
//    * <p>Callers of this method should note that Mechanic Service will
//    * immediately send a notification to the supplied listener when this method
//    * is called. Also, callers should remember to unsubscribe listeners when
//    * they are disposed (or otherwise reach the end of their life).
//    */
//   void addTaskStatusChangeListener(IStatusChangeListener statusChangeListener);
// 
//   /**
//    * Removes supplied listener from our set of listeners if it is contained
//    * therein, else does nothing.
//    *
//    * @param statusChangeListener listener to receive status update notifications.
//    */
//   void removeTaskStatusChangeListener(IStatusChangeListener statusChangeListener);
// 
//   /**
//    * Returns a {@link RepairManager} capable of fixing broken Tasks. The
//    * returned {@link RepairManager} will use the supplied
//    * {@link RepairDecisionProvider} to collect user input needed to determine
//    * what actions to take for each failing Task.
//    */
//   RepairManager getRepairManager(RepairDecisionProvider rdp);
// 
//   /**
//    * Returns an immutable set of all the currently known tasks, passing or not.
//    */
//   Collection<Task> getAllKnownTasks();
// 
//   /**
//    * A temporary solution allowing the trim widget to display the number
//    * of failing items to the user.
//    */
//   int getFailingItemCount();
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IStatusChangeListener.java
// public interface IStatusChangeListener {
// 
//   void statusChanged(StatusChangedEvent event);
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/MechanicStatus.java
// public enum MechanicStatus {
// 
//   /* there are no failing tasks */
//   PASSED,
// 
//   /* there are failing tasks */
//   FAILED,
// 
//   /* mechanic service is updating its set of tasks */
//   UPDATING,
// 
//   /* mechanic service is not running */
//   STOPPED
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/StatusChangedEvent.java
// public class StatusChangedEvent {
// 
//   private final MechanicStatus status;
// 
//   public StatusChangedEvent(MechanicStatus status) {
//     this.status = status;
//   }
// 
//   public MechanicStatus getStatus() {
//     return status;
//   }
// }


import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import com.google.common.base.Preconditions;
import com.google.eclipse.mechanic.IMechanicService;
import com.google.eclipse.mechanic.IStatusChangeListener;
import com.google.eclipse.mechanic.MechanicStatus;
import com.google.eclipse.mechanic.StatusChangedEvent;
/*******************************************************************************
 * Copyright (C) 2011, Google Inc.
 *
 * 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
 *******************************************************************************/
package com.google.eclipse.mechanic.internal;



/**
 * A {@link IUriContentProvider} that clears its cache when the Mechanic starts a
 * scanning session.
 */
public final class StateSensitiveCache implements IUriContentProvider {
  private final IMechanicService service;
  private final IStatusChangeListener statusChangeListener;
  private final IUriContentProvider delegate;

  public StateSensitiveCache(IMechanicService service, IUriContentProvider delegate) {
    this.service = Preconditions.checkNotNull(service);
    this.delegate = Preconditions.checkNotNull(delegate);
    this.statusChangeListener = new IStatusChangeListener() {
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IMechanicService.java
// public interface IMechanicService {
// 
//   /**
//    * Causes the scannning service to start as soon as possible.
//    */
//   void start();
// 
//   /**
//    * Causes the scanning service to stop scanning.
//    */
//   void stop();
// 
//   /**
//    * Return true if the mechanic service is not running.
//    */
//   boolean isStopped();
// 
//   /**
//    * Adds the supplied listener to status change events for the Mechanic (not the
//    * Job). UI components can use this facility to get notifications announcing
//    * changes in the mechanic service.
//    *
//    * <p>Callers of this method should note that Mechanic Service will
//    * immediately send a notification to the supplied listener when this method
//    * is called. Also, callers should remember to unsubscribe listeners when
//    * they are disposed (or otherwise reach the end of their life).
//    */
//   void addTaskStatusChangeListener(IStatusChangeListener statusChangeListener);
// 
//   /**
//    * Removes supplied listener from our set of listeners if it is contained
//    * therein, else does nothing.
//    *
//    * @param statusChangeListener listener to receive status update notifications.
//    */
//   void removeTaskStatusChangeListener(IStatusChangeListener statusChangeListener);
// 
//   /**
//    * Returns a {@link RepairManager} capable of fixing broken Tasks. The
//    * returned {@link RepairManager} will use the supplied
//    * {@link RepairDecisionProvider} to collect user input needed to determine
//    * what actions to take for each failing Task.
//    */
//   RepairManager getRepairManager(RepairDecisionProvider rdp);
// 
//   /**
//    * Returns an immutable set of all the currently known tasks, passing or not.
//    */
//   Collection<Task> getAllKnownTasks();
// 
//   /**
//    * A temporary solution allowing the trim widget to display the number
//    * of failing items to the user.
//    */
//   int getFailingItemCount();
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/IStatusChangeListener.java
// public interface IStatusChangeListener {
// 
//   void statusChanged(StatusChangedEvent event);
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/MechanicStatus.java
// public enum MechanicStatus {
// 
//   /* there are no failing tasks */
//   PASSED,
// 
//   /* there are failing tasks */
//   FAILED,
// 
//   /* mechanic service is updating its set of tasks */
//   UPDATING,
// 
//   /* mechanic service is not running */
//   STOPPED
// 
// }
// 
// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/StatusChangedEvent.java
// public class StatusChangedEvent {
// 
//   private final MechanicStatus status;
// 
//   public StatusChangedEvent(MechanicStatus status) {
//     this.status = status;
//   }
// 
//   public MechanicStatus getStatus() {
//     return status;
//   }
// }


// Path: parent/bundles/com.google.eclipse.mechanic/src/com/google/eclipse/mechanic/internal/StateSensitiveCache.java
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import com.google.common.base.Preconditions;
import com.google.eclipse.mechanic.IMechanicService;
import com.google.eclipse.mechanic.IStatusChangeListener;
import com.google.eclipse.mechanic.MechanicStatus;
import com.google.eclipse.mechanic.StatusChangedEvent;

/*******************************************************************************
 * Copyright (C) 2011, Google Inc.
 *
 * 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
 *******************************************************************************/
package com.google.eclipse.mechanic.internal;



/**
 * A {@link IUriContentProvider} that clears its cache when the Mechanic starts a
 * scanning session.
 */
public final class StateSensitiveCache implements IUriContentProvider {
  private final IMechanicService service;
  private final IStatusChangeListener statusChangeListener;
  private final IUriContentProvider delegate;

  public StateSensitiveCache(IMechanicService service, IUriContentProvider delegate) {
    this.service = Preconditions.checkNotNull(service);
    this.delegate = Preconditions.checkNotNull(delegate);
    this.statusChangeListener = new IStatusChangeListener() {
      public void statusChanged(StatusChangedEvent event) {