org.eclipse.team.ui_3.6.101.R37x_v20111109-0800

nable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.ProgressMonitorWrapper;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.ILock;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.SubscriberParticipant;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.progress.IProgressConstants;

public abstract class RefreshParticipantJob
  extends Job
{
  private static final Object FAMILY_ID = new Object();
  private boolean reschedule = false;
  private boolean restartOnCancel = true;
  private static long scheduleDelay;
  private ISynchronizeParticipant participant;
  private String taskName;
  private static List listeners = new ArrayList(1);
  private static final int STARTED = 1;
  private static final int DONE = 2;
  private static final ILock lock = Job.getJobManager().newLock();
  private static final IStatus POSTPONED = new Status(8, "org.eclipse.team.ui", 0, "Scheduled refresh postponed due to conflicting operation", null);
  
  private final class GotoActionWrapper
    extends WorkbenchAction
  {
    private ActionFactory.IWorkbenchAction gotoAction;
    private IStatus status;
    
    GotoActionWrapper(GotoActionWrapper paramGotoActionWrapper)
    {
      this();
    }
    
    public void run()
    {
      if ((status != null) && (!status.isOK())) {
        ErrorDialog.openError(Utils.getShell(null), null, TeamUIMessages.RefreshSubscriberJob_3, status);
      } else if (gotoAction != null) {
        gotoAction.run();
      }
    }
    
    public boolean isEnabled()
    {
      if (gotoAction != null) {
        return gotoAction.isEnabled();
      }
      return true;
    }
    
    public String getText()
    {
      if (gotoAction != null) {
        return gotoAction.getText();
      }
      return null;
    }
    
    public String getToolTipText()
    {
      if ((status != null) && (!status.isOK())) {
        return status.getMessage();
      }
      if (gotoAction != null) {
        return gotoAction.getToolTipText();
      }
      return Utils.shortenText(100, getName());
    }
    
    public void dispose()
    {
      super.dispose();
      if (gotoAction != null) {
        gotoAction.dispose();
      }
    }
    
    public void setGotoAction(ActionFactory.IWorkbenchAction gotoAction)
    {
      this.gotoAction = gotoAction;
      setEnabled(isEnabled());
      setToolTipText(getToolTipText());
      gotoAction.addPropertyChangeListener(new RefreshParticipantJob.1(this));
    }
    
    public void setStatus(IStatus status)
    {
      this.status = status;
    }
    
    private GotoActionWrapper() {}
  }
  
  private abstract class Notification
    implements ISafeRunnable
  {
    private IRefreshSubscriberListener listener;
    
    Notification(Notification paramNotification)
    {
      this();
    }
    
    public void run(IRefreshSubscriberListener listener)
    {
      this.listener = listener;
      SafeRunner.run(this);
    }
    
    public void run()
      throws Exception
    {
      notify(listener);
    }
    
    private Notification() {}
    
    public void handleException(Throwable exception) {}
    
    protected abstract void notify(IRefreshSubscriberListener paramIRefreshSubscriberListener);
  }
  
  private class NonblockingProgressMonitor
    extends ProgressMonitorWrapper
  {
    private final RefreshParticipantJob job;
    private long blockTime;
    private static final int THRESHOLD = 250;
    private boolean wasBlocking = false;
    
    protected NonblockingProgressMonitor(IProgressMonitor monitor, RefreshParticipantJob job)
    {
      super();
      this.job = job;
    }
    
    public boolean isCanceled()
    {
      if (super.isCanceled()) {
        return true;
      }
      if ((job.shouldReschedule()) && (job.isBlocking()))
      {
        if (blockTime == 0L)
        {
          blockTime = System.currentTimeMillis();
        }
        else if (System.currentTimeMillis() - blockTime > 250L)
        {
          wasBlocking = true;
          return true;
        }
      }
      else {
        blockTime = 0L;
      }
      wasBlocking = false;
      return false;
    }
    
    public boolean wasBlocking()
    {
      return wasBlocking;
    }
  }
  
  public RefreshParticipantJob(ISynchronizeParticipant participant, String jobName, String taskName, IRefreshSubscriberListener listener)
  {
    super(jobName);
    Assert.isNotNull(participant);
    this.participant = participant;
    this.taskName = taskName;
    setPriority(50);
    setRefreshInterval(3600L);
    
    addJobChangeListener(new JobChangeAdapter()
    {
      public void done(IJobChangeEvent event)
      {
        if (shouldReschedule())
        {
          IStatus result = event.getResult();
          if ((result.getSeverity() == 8) && (!restartOnCancel)) {
            return;
          }
          long delay = RefreshParticipantJob.scheduleDelay;
          if (result == RefreshParticipantJob.POSTPONED) {
            delay = 5000L;
          }
          schedule(delay);
          restartOnCancel = true;
        }
      }
    });
    if (listener != null) {
      initialize(listener);
    }
  }
  
  public boolean belongsTo(Object family)
  {
    if ((family instanceof SubscriberParticipant)) {
      return family == participant;
    }
    return (family == getFamily()) || (family == ISynchronizeManager.FAMILY_SYNCHRONIZE_OPERATION);
  }
  
  public static Object getFamily()
  {
    return FAMILY_ID;
  }
  
  /* Error */
  public IStatus run(IProgressMonitor monitor)
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 467	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:shouldReschedule	()Z
    //   4: ifeq +27 -> 31
    //   7: aload_0
    //   8: getstatic 408	org/eclipse/core/resources/ResourcesPlugin:FAMILY_AUTO_BUILD	Ljava/lang/Object;
    //   11: invokespecial 472	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:isJobInFamilyRunning	(Ljava/lang/Object;)Z
    //   14: ifne +13 -> 27
    //   17: aload_0
    //   18: getstatic 409	org/eclipse/core/resources/ResourcesPlugin:FAMILY_MANUAL_BUILD	Ljava/lang/Object;
    //   21: invokespecial 472	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:isJobInFamilyRunning	(Ljava/lang/Object;)Z
    //   24: ifeq +7 -> 31
    //   27: getstatic 424	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:POSTPONED	Lorg/eclipse/core/runtime/IStatus;
    //   30: areturn
    //   31: iconst_0
    //   32: istore_2
    //   33: goto +25 -> 58
    //   36: getstatic 425	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:lock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   39: ldc2_w 198
    //   42: invokeinterface 509 3 0
    //   47: istore_2
    //   48: goto +6 -> 54
    //   51: pop
    //   52: iconst_0
    //   53: istore_2
    //   54: aload_1
    //   55: invokestatic 451	org/eclipse/team/internal/ui/Policy:checkCanceled	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   58: iload_2
    //   59: ifeq -23 -> 36
    //   62: aload_0
    //   63: invokevirtual 480	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:createChangeDescription	()Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$IChangeDescription;
    //   66: astore_3
    //   67: new 230	org/eclipse/team/internal/ui/synchronize/RefreshEvent
    //   70: dup
    //   71: aload_0
    //   72: getfield 419	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:reschedule	Z
    //   75: ifeq +7 -> 82
    //   78: iconst_1
    //   79: goto +4 -> 83
    //   82: iconst_2
    //   83: aload_0
    //   84: getfield 426	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:participant	Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;
    //   87: aload_3
    //   88: invokespecial 457	org/eclipse/team/internal/ui/synchronize/RefreshEvent:<init>	(ILorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$IChangeDescription;)V
    //   91: astore 4
    //   93: aconst_null
    //   94: astore 5
    //   96: aconst_null
    //   97: astore 6
    //   99: aload 4
    //   101: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   104: invokevirtual 452	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStartTime	(J)V
    //   107: aload_1
    //   108: invokeinterface 500 1 0
    //   113: ifeq +37 -> 150
    //   116: getstatic 410	org/eclipse/core/runtime/Status:CANCEL_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   119: astore 11
    //   121: aload 4
    //   123: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   126: invokevirtual 453	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStopTime	(J)V
    //   129: iload_2
    //   130: ifeq +11 -> 141
    //   133: getstatic 425	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:lock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   136: invokeinterface 508 1 0
    //   141: aload_1
    //   142: invokeinterface 499 1 0
    //   147: aload 11
    //   149: areturn
    //   150: aload_0
    //   151: iconst_1
    //   152: aload 4
    //   154: invokevirtual 477	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:notifyListeners	(ILorg/eclipse/team/internal/ui/synchronize/IRefreshEvent;)V
    //   157: aload_1
    //   158: aload_0
    //   159: invokevirtual 473	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:getName	()Ljava/lang/String;
    //   162: invokeinterface 501 2 0
    //   167: new 237	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$NonblockingProgressMonitor
    //   170: dup
    //   171: aload_0
    //   172: aload_1
    //   173: aload_0
    //   174: invokespecial 491	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$NonblockingProgressMonitor:<init>	(Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob;Lorg/eclipse/core/runtime/IProgressMonitor;Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob;)V
    //   177: astore 6
    //   179: aload_0
    //   180: aload_3
    //   181: aload 6
    //   183: invokevirtual 483	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:doRefresh	(Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$IChangeDescription;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   186: aload_0
    //   187: getstatic 430	org/eclipse/ui/progress/IProgressConstants:KEEPONE_PROPERTY	Lorg/eclipse/core/runtime/QualifiedName;
    //   190: aload_0
    //   191: invokespecial 465	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:isJobModal	()Z
    //   194: ifeq +7 -> 201
    //   197: iconst_0
    //   198: goto +4 -> 202
    //   201: iconst_1
    //   202: invokestatic 434	java/lang/Boolean:valueOf	(Z)Ljava/lang/Boolean;
    //   205: invokevirtual 482	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:setProperty	(Lorg/eclipse/core/runtime/QualifiedName;Ljava/lang/Object;)V
    //   208: goto +185 -> 393
    //   211: pop
    //   212: aload_1
    //   213: invokeinterface 500 1 0
    //   218: ifeq +11 -> 229
    //   221: getstatic 410	org/eclipse/core/runtime/Status:CANCEL_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   224: astore 5
    //   226: goto +29 -> 255
    //   229: aload 6
    //   231: ifnull +19 -> 250
    //   234: aload 6
    //   236: invokevirtual 490	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$NonblockingProgressMonitor:wasBlocking	()Z
    //   239: ifeq +11 -> 250
    //   242: getstatic 424	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:POSTPONED	Lorg/eclipse/core/runtime/IStatus;
    //   245: astore 5
    //   247: goto +8 -> 255
    //   250: getstatic 410	org/eclipse/core/runtime/Status:CANCEL_STATUS	Lorg/eclipse/core/runtime/IStatus;
    //   253: astore 5
    //   255: aload 4
    //   257: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   260: invokevirtual 453	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStopTime	(J)V
    //   263: goto +138 -> 401
    //   266: astore 7
    //   268: aload 7
    //   270: invokevirtual 444	org/eclipse/core/runtime/CoreException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   273: astore 5
    //   275: aload_0
    //   276: invokevirtual 466	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:isUser	()Z
    //   279: ifne +62 -> 341
    //   282: aload_0
    //   283: getstatic 428	org/eclipse/ui/progress/IProgressConstants:ACTION_PROPERTY	Lorg/eclipse/core/runtime/QualifiedName;
    //   286: invokevirtual 481	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:getProperty	(Lorg/eclipse/core/runtime/QualifiedName;)Ljava/lang/Object;
    //   289: astore 8
    //   291: aload 8
    //   293: instanceof 235
    //   296: ifeq +45 -> 341
    //   299: aload 8
    //   301: checkcast 235	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$GotoActionWrapper
    //   304: astore 9
    //   306: aload 9
    //   308: aload 7
    //   310: invokevirtual 444	org/eclipse/core/runtime/CoreException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   313: invokevirtual 488	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$GotoActionWrapper:setStatus	(Lorg/eclipse/core/runtime/IStatus;)V
    //   316: new 221	org/eclipse/core/runtime/Status
    //   319: dup
    //   320: iconst_0
    //   321: ldc 2
    //   323: iconst_0
    //   324: aload 7
    //   326: invokevirtual 444	org/eclipse/core/runtime/CoreException:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   329: invokeinterface 504 1 0
    //   334: aload 7
    //   336: invokespecial 445	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    //   339: astore 5
    //   341: aload_0
    //   342: invokevirtual 466	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:isUser	()Z
    //   345: ifne +24 -> 369
    //   348: aload 5
    //   350: invokeinterface 503 1 0
    //   355: iconst_4
    //   356: if_icmpne +13 -> 369
    //   359: aload_0
    //   360: getstatic 431	org/eclipse/ui/progress/IProgressConstants:NO_IMMEDIATE_ERROR_PROMPT_PROPERTY	Lorg/eclipse/core/runtime/QualifiedName;
    //   363: getstatic 407	java/lang/Boolean:TRUE	Ljava/lang/Boolean;
    //   366: invokevirtual 482	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:setProperty	(Lorg/eclipse/core/runtime/QualifiedName;Ljava/lang/Object;)V
    //   369: aload 4
    //   371: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   374: invokevirtual 453	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStopTime	(J)V
    //   377: goto +24 -> 401
    //   380: astore 10
    //   382: aload 4
    //   384: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   387: invokevirtual 453	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStopTime	(J)V
    //   390: aload 10
    //   392: athrow
    //   393: aload 4
    //   395: invokestatic 441	java/lang/System:currentTimeMillis	()J
    //   398: invokevirtual 453	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStopTime	(J)V
    //   401: aload 5
    //   403: ifnonnull +11 -> 414
    //   406: aload_0
    //   407: aload 4
    //   409: invokespecial 484	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:calculateStatus	(Lorg/eclipse/team/internal/ui/synchronize/IRefreshEvent;)Lorg/eclipse/core/runtime/IStatus;
    //   412: astore 5
    //   414: aload 4
    //   416: aload 5
    //   418: invokevirtual 455	org/eclipse/team/internal/ui/synchronize/RefreshEvent:setStatus	(Lorg/eclipse/core/runtime/IStatus;)V
    //   421: aload_0
    //   422: iconst_2
    //   423: aload 4
    //   425: invokevirtual 477	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:notifyListeners	(ILorg/eclipse/team/internal/ui/synchronize/IRefreshEvent;)V
    //   428: aload 4
    //   430: invokevirtual 456	org/eclipse/team/internal/ui/synchronize/RefreshEvent:getChangeDescription	()Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$IChangeDescription;
    //   433: invokeinterface 511 1 0
    //   438: ifle +40 -> 478
    //   441: aload_0
    //   442: getfield 426	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:participant	Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;
    //   445: instanceof 239
    //   448: ifeq +30 -> 478
    //   451: aload_0
    //   452: getfield 426	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:participant	Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;
    //   455: checkcast 239	org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant
    //   458: astore 7
    //   460: aload 7
    //   462: aload_0
    //   463: getfield 426	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:participant	Lorg/eclipse/team/ui/synchronize/ISynchronizeParticipant;
    //   466: ldc_w 204
    //   469: aconst_null
    //   470: aload 4
    //   472: invokevirtual 456	org/eclipse/team/internal/ui/synchronize/RefreshEvent:getChangeDescription	()Lorg/eclipse/team/internal/ui/synchronize/RefreshParticipantJob$IChangeDescription;
    //   475: invokevirtual 493	org/eclipse/team/ui/synchronize/AbstractSynchronizeParticipant:firePropertyChange	(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
    //   478: aload 4
    //   480: invokevirtual 454	org/eclipse/team/internal/ui/synchronize/RefreshEvent:getStatus	()Lorg/eclipse/core/runtime/IStatus;
    //   483: astore 13
    //   485: iload_2
    //   486: ifeq +11 -> 497
    //   489: getstatic 425	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:lock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   492: invokeinterface 508 1 0
    //   497: aload_1
    //   498: invokeinterface 499 1 0
    //   503: aload 13
    //   505: areturn
    //   506: astore 12
    //   508: iload_2
    //   509: ifeq +11 -> 520
    //   512: getstatic 425	org/eclipse/team/internal/ui/synchronize/RefreshParticipantJob:lock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   515: invokeinterface 508 1 0
    //   520: aload_1
    //   521: invokeinterface 499 1 0
    //   526: aload 12
    //   528: athrow
    // Line number table:
    //   Java source line #274	-> byte code offset #0
    //   Java source line #275	-> byte code offset #7
    //   Java source line #276	-> byte code offset #17
    //   Java source line #277	-> byte code offset #27
    //   Java source line #284	-> byte code offset #31
    //   Java source line #286	-> byte code offset #33
    //   Java source line #288	-> byte code offset #36
    //   Java source line #289	-> byte code offset #51
    //   Java source line #290	-> byte code offset #52
    //   Java source line #292	-> byte code offset #54
    //   Java source line #286	-> byte code offset #58
    //   Java source line #295	-> byte code offset #62
    //   Java source line #296	-> byte code offset #67
    //   Java source line #297	-> byte code offset #93
    //   Java source line #298	-> byte code offset #96
    //   Java source line #300	-> byte code offset #99
    //   Java source line #301	-> byte code offset #107
    //   Java source line #302	-> byte code offset #116
    //   Java source line #341	-> byte code offset #121
    //   Java source line #358	-> byte code offset #129
    //   Java source line #359	-> byte code offset #141
    //   Java source line #302	-> byte code offset #147
    //   Java source line #305	-> byte code offset #150
    //   Java source line #307	-> byte code offset #157
    //   Java source line #308	-> byte code offset #167
    //   Java source line #309	-> byte code offset #179
    //   Java source line #311	-> byte code offset #186
    //   Java source line #312	-> byte code offset #211
    //   Java source line #313	-> byte code offset #212
    //   Java source line #315	-> byte code offset #221
    //   Java source line #318	-> byte code offset #229
    //   Java source line #319	-> byte code offset #242
    //   Java source line #321	-> byte code offset #250
    //   Java source line #341	-> byte code offset #255
    //   Java source line #324	-> byte code offset #266
    //   Java source line #326	-> byte code offset #268
    //   Java source line #327	-> byte code offset #275
    //   Java source line #329	-> byte code offset #282
    //   Java source line #330	-> byte code offset #291
    //   Java source line #331	-> byte code offset #299
    //   Java source line #332	-> byte code offset #306
    //   Java source line #333	-> byte code offset #316
    //   Java source line #336	-> byte code offset #341
    //   Java source line #338	-> byte code offset #359
    //   Java source line #341	-> byte code offset #369
    //   Java source line #340	-> byte code offset #380
    //   Java source line #341	-> byte code offset #382
    //   Java source line #342	-> byte code offset #390
    //   Java source line #341	-> byte code offset #393
    //   Java source line #345	-> byte code offset #401
    //   Java source line #346	-> byte code offset #406
    //   Java source line #348	-> byte code offset #414
    //   Java source line #349	-> byte code offset #421
    //   Java source line #350	-> byte code offset #428
    //   Java source line #351	-> byte code offset #441
    //   Java source line #352	-> byte code offset #451
    //   Java source line #353	-> byte code offset #460
    //   Java source line #356	-> byte code offset #478
    //   Java source line #358	-> byte code offset #485
    //   Java source line #359	-> byte code offset #497
    //   Java source line #356	-> byte code offset #503
    //   Java source line #357	-> byte code offset #506
    //   Java source line #358	-> byte code offset #508
    //   Java source line #359	-> byte code offset #520
    //   Java source line #360	-> byte code offset #526
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	529	0	this	RefreshParticipantJob
    //   0	529	1	monitor	IProgressMonitor
    //   32	477	2	acquired	boolean
    //   66	22	3	changeDescription	IChangeDescription
    //   150	31	3	changeDescription	IChangeDescription
    //   91	31	4	event	RefreshEvent
    //   150	329	4	event	RefreshEvent
    //   94	3	5	status	IStatus
    //   150	267	5	status	IStatus
    //   97	3	6	wrappedMonitor	NonblockingProgressMonitor
    //   150	85	6	wrappedMonitor	NonblockingProgressMonitor
    //   266	69	7	e	CoreException
    //   458	3	7	asp	org.eclipse.team.ui.synchronize.AbstractSynchronizeParticipant
    //   289	11	8	prop	Object
    //   304	3	9	wrapper	GotoActionWrapper
    //   380	11	10	localObject1	Object
    //   119	29	11	localIStatus1	IStatus
    //   506	21	12	localObject2	Object
    //   483	21	13	localIStatus2	IStatus
    //   51	1	19	localInterruptedException	InterruptedException
    //   211	1	20	localOperationCanceledException	org.eclipse.core.runtime.OperationCanceledException
    // Exception table:
    //   from	to	target	type
    //   36	48	51	java/lang/InterruptedException
    //   99	121	211	org/eclipse/core/runtime/OperationCanceledException
    //   150	208	211	org/eclipse/core/runtime/OperationCanceledException
    //   99	121	266	org/eclipse/core/runtime/CoreException
    //   150	208	266	org/eclipse/core/runtime/CoreException
    //   99	121	380	finally
    //   150	255	380	finally
    //   266	369	380	finally
    //   33	129	506	finally
    //   150	485	506	finally
  }
  
  protected abstract void doRefresh(IChangeDescription paramIChangeDescription, IProgressMonitor paramIProgressMonitor)
    throws CoreException;
  
  protected abstract int getChangeCount();
  
  protected abstract int getIncomingChangeCount();
  
  protected abstract int getOutgoingChangeCount();
  
  private boolean isJobInFamilyRunning(Object family)
  {
    Job[] jobs = Job.getJobManager().find(family);
    if ((jobs != null) && (jobs.length > 0)) {
      for (int i = 0; i < jobs.length; i++)
      {
        Job job = jobs[i];
        if (job.getState() != 0) {
          return true;
        }
      }
    }
    return false;
  }
  
  private IStatus calculateStatus(IRefreshEvent event)
  {
    StringBuffer text = new StringBuffer();
    int code = 0;
    int changeCount = event.getChangeDescription().getChangeCount();
    int numChanges = getChangeCount();
    if (numChanges > 0)
    {
      code = 1;
      
      int incomingChanges = getIncomingChangeCount();
      String numIncomingChanges = incomingChanges == 0 ? "" : 
        NLS.bind(TeamUIMessages.RefreshCompleteDialog_incomingChanges, Integer.toString(incomingChanges));
      
      int outgoingChanges = getOutgoingChangeCount();
      String numOutgoingChanges = outgoingChanges == 0 ? "" : 
        NLS.bind(TeamUIMessages.RefreshCompleteDialog_outgoingChanges, Integer.toString(outgoingChanges));
      
      String sep = (incomingChanges > 0) && (outgoingChanges > 0) ? "; " : "";
      if (changeCount > 0)
      {
        code = 2;
        String numNewChanges = Integer.toString(changeCount);
        if (changeCount == 1) {
          text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_newChangesSingular, new Object[] { getName(), numNewChanges, numIncomingChanges, sep, numOutgoingChanges }));
        } else {
          text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_newChangesPlural, new Object[] { getName(), numNewChanges, numIncomingChanges, sep, numOutgoingChanges }));
        }
      }
      else if (numChanges == 1)
      {
        text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_changesSingular, new Object[] { getName(), new Integer(numChanges), numIncomingChanges, sep, numOutgoingChanges }));
      }
      else
      {
        text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_changesPlural, new Object[] { getName(), new Integer(numChanges), numIncomingChanges, sep, numOutgoingChanges }));
      }
    }
    else
    {
      code = 0;
      text.append(NLS.bind(TeamUIMessages.RefreshCompleteDialog_6, new String[] { getName() }));
    }
    return new Status(0, "org.eclipse.team.ui", code, text.toString(), null);
  }
  
  private void initialize(IRefreshSubscriberListener listener)
  {
    GotoActionWrapper actionWrapper = new GotoActionWrapper(null);
    
    IProgressMonitor group = Job.getJobManager().createProgressGroup();
    group.beginTask(taskName, 100);
    setProgressGroup(group, 80);
    handleProgressGroupSet(group, 20);
    setProperty(IProgressConstants.ICON_PROPERTY, participant.getImageDescriptor());
    setProperty(IProgressConstants.ACTION_PROPERTY, actionWrapper);
    setProperty(IProgressConstants.KEEPONE_PROPERTY, Boolean.valueOf(!isJobModal()));
    
    IRefreshSubscriberListener autoListener = new IRefreshSubscriberListener()
    {
      private final IRefreshSubscriberListener val$listener;
      private final RefreshParticipantJob.GotoActionWrapper val$actionWrapper;
      
      public void refreshStarted(IRefreshEvent event)
      {
        if (val$listener != null) {
          val$listener.refreshStarted(event);
        }
      }
      
      public ActionFactory.IWorkbenchAction refreshDone(IRefreshEvent event)
      {
        if (val$listener != null)
        {
          boolean isModal = RefreshParticipantJob.this.isJobModal();
          event.setIsLink(!isModal);
          ActionFactory.IWorkbenchAction runnable = val$listener.refreshDone(event);
          if (runnable != null) {
            if (isModal)
            {
              if (runnable != null)
              {
                Job update = new RefreshParticipantJob.4(this, "", runnable);
                
                update.setSystem(true);
                update.schedule();
              }
            }
            else {
              val$actionWrapper.setGotoAction(runnable);
            }
          }
          RefreshParticipantJob.removeRefreshListener(this);
        }
        return null;
      }
    };
    if (listener != null) {
      addRefreshListener(autoListener);
    }
  }
  
  protected abstract void handleProgressGroupSet(IProgressMonitor paramIProgressMonitor, int paramInt);
  
  protected abstract IChangeDescription createChangeDescription();
  
  public long getScheduleDelay()
  {
    return scheduleDelay;
  }
  
  protected void start()
  {
    if ((getState() == 0) && 
      (shouldReschedule())) {
      schedule(getScheduleDelay());
    }
  }
  
  public void setRefreshInterval(long seconds)
  {
    boolean restart = false;
    if (getState() == 1)
    {
      restart = true;
      cancel();
    }
    scheduleDelay = seconds * 1000L;
    if (restart) {
      start();
    }
  }
  
  public void setRestartOnCancel(boolean restartOnCancel)
  {
    this.restartOnCancel = restartOnCancel;
  }
  
  public void setReschedule(boolean reschedule)
  {
    this.reschedule = reschedule;
  }
  
  public boolean shouldReschedule()
  {
    return reschedule;
  }
  
  public static void addRefreshListener(IRefreshSubscriberListener listener)
  {
    synchronized (listeners)
    {
      if (!listeners.contains(listener)) {
        listeners.add(listener);
      }
    }
  }
  
  public static void removeRefreshListener(IRefreshSubscriberListener listener)
  {
    synchronized (listeners)
    {
      listeners.remove(listener);
    }
  }
  
  protected void notifyListeners(int state, IRefreshEvent event)
  {
    IRefreshSubscriberListener[] listenerArray;
    synchronized (listeners)
    {
      listenerArray = (IRefreshSubscriberListener[])listeners.toArray(new IRefreshSubscriberListener[listeners.size()]);
    }
    IRefreshSubscriberListener[] listenerArray;
    for (int i = 0; i < listenerArray.length; i++)
    {
      IRefreshSubscriberListener listener = listenerArray[i];
      Notification notification = new Notification(state, event)
      {
        private final int val$state;
        private final IRefreshEvent val$event;
        
        protected void notify(IRefreshSubscriberListener listener)
        {
          switch (val$state)
          {
          case 1: 
            listener.refreshStarted(val$event);
            break;
          case 2: 
            listener.refreshDone(val$event);
            break;
          }
        }
      };
      notification.run(listener);
    }
  }
  
  private boolean isJobModal()
  {
    Boolean isModal = (Boolean)getProperty(IProgressConstants.PROPERTY_IN_DIALOG);
    if (isModal == null) {
      return false;
    }
    return isModal.booleanValue();
  }
  
  public ISynchronizeParticipant getParticipant()
  {
    return participant;
  }
  
  public static abstract interface IChangeDescription
  {
    public abstract int getChangeCount();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.RefreshParticipantJob
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.subscribers.Subscriber;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoTree;
import org.eclipse.team.internal.core.subscribers.SubscriberSyncInfoCollector;
import org.eclipse.team.ui.synchronize.SubscriberParticipant;

public class RefreshSubscriberParticipantJob
  extends RefreshParticipantJob
{
  private final IResource[] resources;
  
  public RefreshSubscriberParticipantJob(SubscriberParticipant participant, String jobName, String taskName, IResource[] resources, IRefreshSubscriberListener listener)
  {
    super(participant, jobName, taskName, listener);
    this.resources = resources;
  }
  
  protected Subscriber getSubscriber()
  {
    return ((SubscriberParticipant)getParticipant()).getSubscriber();
  }
  
  private SubscriberSyncInfoCollector getCollector()
  {
    return ((SubscriberParticipant)getParticipant()).getSubscriberSyncInfoCollector();
  }
  
  protected int getChangeCount()
  {
    int numChanges = 0;
    SubscriberSyncInfoCollector collector = getCollector();
    if (collector != null)
    {
      SyncInfoTree set = collector.getSyncInfoSet();
      for (int i = 0; i < resources.length; i++)
      {
        IResource resource = resources[i];
        SyncInfo[] infos = set.getSyncInfos(resource, 2);
        if ((infos != null) && (infos.length > 0)) {
          numChanges += infos.length;
        }
      }
    }
    return numChanges;
  }
  
  protected int getIncomingChangeCount()
  {
    return getChangesInMode(8);
  }
  
  protected int getOutgoingChangeCount()
  {
    return getChangesInMode(4);
  }
  
  private int getChangesInMode(int kind)
  {
    int numChanges = 0;
    SubscriberSyncInfoCollector collector = getCollector();
    if (collector != null)
    {
      SyncInfoTree set = collector.getSyncInfoSet();
      for (int i = 0; i < resources.length; i++)
      {
        IResource resource = resources[i];
        SyncInfo[] infos = set.getSyncInfos(resource, 2);
        if ((infos != null) && (infos.length > 0)) {
          for (int j = 0; j < infos.length; j++) {
            if ((infos[j].getKind() & kind) > 0) {
              numChanges++;
            }
          }
        }
      }
    }
    return numChanges;
  }
  
  protected RefreshParticipantJob.IChangeDescription createChangeDescription()
  {
    return new RefreshChangeListener(resources, getCollector());
  }
  
  protected void handleProgressGroupSet(IProgressMonitor group, int ticks)
  {
    getCollector().setProgressGroup(group, ticks);
  }
  
  public boolean shouldRun()
  {
    return (getSubscriber() != null) && (getCollector().getSyncInfoSet() != null);
  }
  
  public boolean belongsTo(Object family)
  {
    if ((family instanceof RefreshSubscriberParticipantJob)) {
      return ((RefreshSubscriberParticipantJob)family).getSubscriber() == getSubscriber();
    }
    return super.belongsTo(family);
  }
  
  /* Error */
  protected void doRefresh(RefreshParticipantJob.IChangeDescription changeListener, IProgressMonitor monitor)
    throws org.eclipse.team.core.TeamException
  {
    // Byte code:
    //   0: aload_0
    //   1: invokevirtual 125	org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob:getSubscriber	()Lorg/eclipse/team/core/subscribers/Subscriber;
    //   4: astore_3
    //   5: aload_3
    //   6: ifnull +53 -> 59
    //   9: aload_3
    //   10: aload_1
    //   11: checkcast 64	org/eclipse/team/internal/ui/synchronize/RefreshChangeListener
    //   14: invokevirtual 113	org/eclipse/team/core/subscribers/Subscriber:addListener	(Lorg/eclipse/team/core/subscribers/ISubscriberChangeListener;)V
    //   17: aload_3
    //   18: aload_0
    //   19: getfield 112	org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob:resources	[Lorg/eclipse/core/resources/IResource;
    //   22: iconst_2
    //   23: aload_2
    //   24: invokevirtual 115	org/eclipse/team/core/subscribers/Subscriber:refresh	([Lorg/eclipse/core/resources/IResource;ILorg/eclipse/core/runtime/IProgressMonitor;)V
    //   27: aload_0
    //   28: invokespecial 126	org/eclipse/team/internal/ui/synchronize/RefreshSubscriberParticipantJob:getCollector	()Lorg/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector;
    //   31: aload_2
    //   32: invokevirtual 118	org/eclipse/team/internal/core/subscribers/SubscriberSyncInfoCollector:waitForCollector	(Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   35: goto +16 -> 51
    //   38: astore 4
    //   40: aload_3
    //   41: aload_1
    //   42: checkcast 64	org/eclipse/team/internal/ui/synchronize/RefreshChangeListener
    //   45: invokevirtual 114	org/eclipse/team/core/subscribers/Subscriber:removeListener	(Lorg/eclipse/team/core/subscribers/ISubscriberChangeListener;)V
    //   48: aload 4
    //   50: athrow
    //   51: aload_3
    //   52: aload_1
    //   53: checkcast 64	org/eclipse/team/internal/ui/synchronize/RefreshChangeListener
    //   56: invokevirtual 114	org/eclipse/team/core/subscribers/Subscriber:removeListener	(Lorg/eclipse/team/core/subscribers/ISubscriberChangeListener;)V
    //   59: return
    // Line number table:
    //   Java source line #112	-> byte code offset #0
    //   Java source line #113	-> byte code offset #5
    //   Java source line #115	-> byte code offset #9
    //   Java source line #116	-> byte code offset #17
    //   Java source line #117	-> byte code offset #27
    //   Java source line #118	-> byte code offset #38
    //   Java source line #119	-> byte code offset #40
    //   Java source line #120	-> byte code offset #48
    //   Java source line #119	-> byte code offset #51
    //   Java source line #122	-> byte code offset #59
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	60	0	this	RefreshSubscriberParticipantJob
    //   0	60	1	changeListener	RefreshParticipantJob.IChangeDescription
    //   0	60	2	monitor	IProgressMonitor
    //   4	48	3	subscriber	Subscriber
    //   38	11	4	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   9	38	38	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.RefreshSubscriberParticipantJob
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize;

import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeView;

class RefreshUserNotificationPolicy$1
  implements Runnable
{
  final RefreshUserNotificationPolicy this$0;
  private final IRefreshEvent val$event;
  
  RefreshUserNotificationPolicy$1(RefreshUserNotificationPolicy paramRefreshUserNotificationPolicy, IRefreshEvent paramIRefreshEvent)
  {
    this$0 = paramRefreshUserNotificationPolicy;val$event = paramIRefreshEvent;
  }
  
  public void run()
  {
    if ((val$event.getRefreshType() == 2) && (val$event.getParticipant() == RefreshUserNotificationPolicy.access$0(this$0)))
    {
      ISynchronizeView view = TeamUI.getSynchronizeManager().showSynchronizeViewInActivePage();
      if (view != null) {
        view.display(RefreshUserNotificationPolicy.access$0(this$0));
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.team.internal.ui.synchronize.RefreshUserNotificationPolicy.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.team.internal.ui.synchronize;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ui.TeamUIMessages;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.ui.TeamUI;
import org.eclipse.team.ui.synchronize.ISynchronizeManager;
import org.eclipse.team.ui.synchronize.ISynchronizeParticipant;
import org.eclipse.team.ui.synchronize.ISynchronizeView;

class RefreshUserNotificationPolicy$2
  extends WorkbenchAction
{
  final RefreshUserNotificationPolicy this$0;
  private final IRefreshEvent val$event;
  
  RefreshUserNotificationPolicy$2(RefreshUserNotificationPolicy paramRefreshUserNotificationPolicy, IRefreshEvent paramIRefreshEvent)
  {
    this$0 = paramRefreshUserNotificationPolicy;val$event = paramIRefreshEvent;
  }
  
  public void run()
  {
    boolean prompt = val$event.getStatus().getCode() == 0;
    
    prompt = this$0.handleRefreshDon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd