org-netbeans-modules-autoupdate-ui

erFactory.getDefault().getUpdateUnitProviders(true).iterator(); ((Iterator)localObject).hasNext();)
    {
      UpdateUnitProvider localUpdateUnitProvider = (UpdateUnitProvider)((Iterator)localObject).next();
      Utilities.showProviderNotification(localUpdateUnitProvider);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler.7
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import org.netbeans.modules.autoupdate.ui.PluginManagerUI;
import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard;
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor.Message;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;

final class AutoupdateCheckScheduler$8
  implements ActionListener
{
  AutoupdateCheckScheduler$8(Collection paramCollection, OperationWizardModel.OperationType paramOperationType) {}
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    boolean bool = false;
    RequestProcessor.Task localTask = PluginManagerUI.getRunningTask();
    if ((localTask != null) && (!localTask.isFinished()))
    {
      DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_InstallInProgress"), 2));
      
      return;
    }
    try
    {
      bool = new InstallUnitWizard().invokeLazyWizard(val$units, val$type, false);
    }
    finally
    {
      PluginManagerUI localPluginManagerUI1;
      if (bool)
      {
        PluginManagerUI localPluginManagerUI2 = PluginManagerAction.getPluginManagerUI();
        if (localPluginManagerUI2 != null) {
          localPluginManagerUI2.updateUnitsChanged();
        }
        RequestProcessor.getDefault().post(AutoupdateCheckScheduler.access$300());
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler.8
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actions;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import org.netbeans.api.autoupdate.OperationContainer;
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
import org.netbeans.api.autoupdate.UpdateElement;
import org.netbeans.api.autoupdate.UpdateManager;
import org.netbeans.api.autoupdate.UpdateUnit;
import org.netbeans.api.autoupdate.UpdateUnitProvider;
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.netbeans.modules.autoupdate.ui.PluginManagerUI;
import org.netbeans.modules.autoupdate.ui.Unit;
import org.netbeans.modules.autoupdate.ui.Unit.Available;
import org.netbeans.modules.autoupdate.ui.Unit.InternalUpdate;
import org.netbeans.modules.autoupdate.ui.Unit.Update;
import org.netbeans.modules.autoupdate.ui.UnitCategory;
import org.netbeans.modules.autoupdate.ui.Utilities;
import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard;
import org.netbeans.modules.autoupdate.ui.wizards.LazyInstallUnitWizardIterator.LazyUnit;
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor.Message;
import org.openide.awt.Notification;
import org.openide.awt.NotificationDisplayer;
import org.openide.awt.NotificationDisplayer.Priority;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.Task;
import org.openide.util.TaskListener;
import org.openide.windows.WindowManager;

public class AutoupdateCheckScheduler
{
  private static RequestProcessor.Task regularlyCheck = null;
  private static final RequestProcessor REGULARLY_CHECK_TIMER = new RequestProcessor("auto-checker-reqularly-timer", 1, true);
  private static final Logger err = Logger.getLogger(AutoupdateCheckScheduler.class.getName());
  private static boolean wasRealCheckUpdateCenters = false;
  private static Notification updatesNotification = null;
  
  public static void signOn()
  {
    
    if (timeToCheck()) {
      WindowManager.getDefault().invokeWhenUIReady(new Runnable()
      {
        public void run()
        {
          RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheck, 5000);
        }
      });
    } else {
      WindowManager.getDefault().invokeWhenUIReady(new Runnable()
      {
        public void run()
        {
          RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheckLazyUpdates, 11000);
        }
      });
    }
  }
  
  private static void scheduleRefreshProviders()
  {
    refreshUpdateCenters(null);
    
    long l = System.currentTimeMillis();
    RequestProcessor.Task localTask = RequestProcessor.getDefault().post(doCheckAvailableUpdates, 500);
    localTask.addTaskListener(new TaskListener()
    {
      public void taskFinished(Task paramAnonymousTask)
      {
        paramAnonymousTask.removeTaskListener(this);
        long l = (System.currentTimeMillis() - val$startTime - 500L) / 1000L;
        if (l > 0L) {
          Utilities.putTimeOfInitialization(l);
        }
      }
    });
  }
  
  private static Runnable getRefresher(UpdateUnitProvider paramUpdateUnitProvider, final Collection<String> paramCollection, final ProgressHandle paramProgressHandle)
  {
    new Runnable()
    {
      public void run()
      {
        try
        {
          AutoupdateCheckScheduler.err.log(Level.FINE, "Start refresh " + val$p.getName() + "[" + val$p.getDisplayName() + "]");
          val$p.refresh(paramProgressHandle, true);
          PluginManagerUI localPluginManagerUI = PluginManagerAction.getPluginManagerUI();
          if ((localPluginManagerUI != null) && 
            (initTask.isFinished())) {
            localPluginManagerUI.updateUnitsChanged();
          }
          Utilities.showProviderNotification(val$p);
        }
        catch (IOException localIOException)
        {
          AutoupdateCheckScheduler.err.log(Level.INFO, localIOException.getMessage(), localIOException);
          if (paramCollection != null) {
            paramCollection.add(localIOException.getLocalizedMessage());
          }
        }
        finally
        {
          AutoupdateCheckScheduler.err.log(Level.FINEST, "Refresh of " + val$p.getName() + "[" + val$p.getDisplayName() + "]" + " is finish.");
        }
      }
    };
  }
  
  private static Runnable doCheckAvailableUpdates = new Runnable()
  {
    public void run()
    {
      if (SwingUtilities.isEventDispatchThread())
      {
        RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheckAvailableUpdates);
        return;
      }
      int i = 0;
      if (Utilities.shouldCheckAvailableUpdates())
      {
        Collection localCollection = AutoupdateCheckScheduler.checkUpdateElements(OperationWizardModel.OperationType.UPDATE, false);
        i = (localCollection != null) && (!localCollection.isEmpty()) ? 1 : 0;
        LazyInstallUnitWizardIterator.LazyUnit.storeUpdateElements(OperationWizardModel.OperationType.UPDATE, localCollection);
      }
      if ((i == 0) && (Utilities.shouldCheckAvailableNewPlugins())) {
        LazyInstallUnitWizardIterator.LazyUnit.storeUpdateElements(OperationWizardModel.OperationType.INSTALL, AutoupdateCheckScheduler.checkUpdateElements(OperationWizardModel.OperationType.INSTALL, false));
      }
      RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheckLazyUpdates, 500);
    }
  };
  
  public static void runCheckAvailableUpdates(int paramInt)
  {
    RequestProcessor.getDefault().post(doCheckAvailableUpdates, paramInt);
  }
  
  public static Collection<UpdateElement> checkUpdateElements(OperationWizardModel.OperationType paramOperationType, boolean paramBoolean)
  {
    return checkUpdateElements(paramOperationType, null, paramBoolean);
  }
  
  public static Collection<UpdateElement> checkUpdateElements(OperationWizardModel.OperationType paramOperationType, Collection<String> paramCollection, boolean paramBoolean)
  {
    err.log(Level.FINEST, "Check UpdateElements for " + paramOperationType);
    if (paramBoolean)
    {
      localObject1 = refreshUpdateCenters(ProgressHandleFactory.createHandle("dummy-check-for-updates"));
      if ((paramCollection != null) && (localObject1 != null)) {
        paramCollection.addAll((Collection)localObject1);
      }
    }
    Object localObject1 = UpdateManager.getDefault().getUpdateUnits(Utilities.getUnitTypes());
    int i = OperationWizardModel.OperationType.UPDATE == paramOperationType ? 1 : 0;
    List localList = i != 0 ? Utilities.makeUpdateCategories((List)localObject1, false) : Utilities.makeAvailableCategories((List)localObject1, false);
    if ((localList == null) || (localList.isEmpty()))
    {
      err.log(Level.FINE, "findUpdateElements(" + paramOperationType + ") doesn't find any elements.");
      return null;
    }
    Object localObject2 = new HashSet();
    int j = 0;
    int k = 0;
    OperationContainer localOperationContainer = i != 0 ? OperationContainer.createForUpdate() : OperationContainer.createForInstall();
    
    ArrayList localArrayList = new ArrayList();
    for (Iterator localIterator = localList.iterator(); localIterator.hasNext();)
    {
      localObject3 = (UnitCategory)localIterator.next();
      for (localObject4 = ((UnitCategory)localObject3).getUnits().iterator(); ((Iterator)localObject4).hasNext();)
      {
        localObject5 = (Unit)((Iterator)localObject4).next();
        if ((localObject5 instanceof Unit.Available)) {
          localArrayList.add(((Unit.Available)localObject5).getRelevantElement());
        } else if ((localObject5 instanceof Unit.InternalUpdate)) {
          for (localObject6 = ((Unit.InternalUpdate)localObject5).getUpdateUnits().iterator(); ((Iterator)localObject6).hasNext();)
          {
            localObject7 = (UpdateUnit)((Iterator)localObject6).next();
            localArrayList.add(((UpdateUnit)localObject7).getAvailableUpdates().get(0));
          }
        } else if ((localObject5 instanceof Unit.Update)) {
          localArrayList.add(((Unit.Update)localObject5).getRelevantElement());
        }
      }
    }
    Object localObject3;
    Object localObject4;
    Object localObject5;
    Object localObject6;
    Object localObject7;
    for (localIterator = localArrayList.iterator(); localIterator.hasNext();)
    {
      localObject3 = (UpdateElement)localIterator.next();
      if ((j == 0) && 
        (localOperationContainer.canBeAdded(((UpdateElement)localObject3).getUpdateUnit(), (UpdateElement)localObject3)))
      {
        localObject4 = localOperationContainer.add((UpdateElement)localObject3);
        if (localObject4 == null)
        {
          ((Collection)localObject2).add(localObject3);
        }
        else
        {
          localObject5 = new HashSet(((OperationContainer.OperationInfo)localObject4).getRequiredElements());
          localObject6 = ((OperationContainer.OperationInfo)localObject4).getBrokenDependencies();
          if (!((Collection)localObject6).isEmpty())
          {
            err.log(Level.WARNING, "Plugin " + localObject4 + " cannot be installed because some dependencies cannot be satisfied: " + localObject6);
            
            k = 1;
            break;
          }
          for (localObject7 = ((Collection)localObject5).iterator(); ((Iterator)localObject7).hasNext();)
          {
            localObject8 = (UpdateElement)((Iterator)localObject7).next();
            if (((UpdateElement)localObject8).getUpdateUnit().isPending())
            {
              err.log(Level.WARNING, "Plugin " + ((OperationContainer.OperationInfo)localObject4).getUpdateElement() + " depends on " + localObject8 + " in pending state.");
              
              j = 1;
              localObject2 = Collections.emptySet();
              break;
            }
          }
          if (j == 0)
          {
            localOperationContainer.add((Collection)localObject5);
            ((Collection)localObject2).add(localObject3);
          }
        }
      }
    }
    Object localObject8;
    if ((j == 0) && (!localOperationContainer.listInvalid().isEmpty())) {
      err.log(Level.WARNING, "Plugins " + localObject2 + " cannot be installed, Install Container contains invalid elements " + localOperationContainer.listInvalid());
    }
    if ((j == 0) && (k != 0))
    {
      localObject2 = new HashSet();
      for (localIterator = localArrayList.iterator(); localIterator.hasNext();)
      {
        localObject3 = (UpdateElement)localIterator.next();
        localObject4 = i != 0 ? OperationContainer.createForUpdate() : OperationContainer.createForInstall();
        
        localObject5 = ((UpdateElement)localObject3).getUpdateUnit();
        if (((OperationContainer)localObject4).canBeAdded((UpdateUnit)localObject5, (UpdateElement)localObject3))
        {
          localObject6 = ((OperationContainer)localObject4).add((UpdateElement)localObject3);
          if (localObject6 == null)
          {
            ((Collection)localObject2).add(localObject3);
          }
          else
          {
            int m = 0;
            localObject8 = new HashSet(((OperationContainer.OperationInfo)localObject6).getRequiredElements());
            for (Object localObject9 = ((Collection)localObject8).iterator(); ((Iterator)localObject9).hasNext();)
            {
              localObject10 = (UpdateElement)((Iterator)localObject9).next();
              if (((UpdateElement)localObject10).getUpdateUnit().isPending())
              {
                err.log(Level.WARNING, "Plugin " + localObject3 + " depends on " + localObject10 + " in pending state.");
                
                m = 1;
              }
            }
            Object localObject10;
            if (m == 0)
            {
              ((OperationContainer)localObject4).add((Collection)localObject8);
              localObject9 = new HashSet();
              for (localObject10 = ((OperationContainer)localObject4).listAll().iterator(); ((Iterator)localObject10).hasNext();)
              {
                OperationContainer.OperationInfo localOperationInfo = (OperationContainer.OperationInfo)((Iterator)localObject10).next();
                ((Collection)localObject9).addAll(localOperationInfo.getBrokenDependencies());
              }
              if ((((Collection)localObject9).isEmpty()) && (((OperationContainer)localObject4).listInvalid().isEmpty()))
              {
                ((Collection)localObject2).add(localObject3);
              }
              else
              {
                ((OperationContainer)localObject4).removeAll();
                if (!((Collection)localObject9).isEmpty()) {
                  err.log(Level.WARNING, "Plugin " + localObject3 + " cannot be installed because some dependencies cannot be satisfied: " + localObject9);
                } else {
                  err.log(Level.WARNING, "Plugin " + localObject3 + " cannot be installed, Install Container contains invalid elements " + ((OperationContainer)localObject4).listInvalid());
                }
              }
            }
          }
        }
      }
    }
    err.log(Level.FINE, "findUpdateElements(" + paramOperationType + ") returns " + ((Collection)localObject2).size() + " elements.");
    return (Collection<UpdateElement>)localObject2;
  }
  
  private static Collection<String> refreshUpdateCenters(ProgressHandle paramProgressHandle)
  {
    long l1 = System.currentTimeMillis();
    HashSet localHashSet1 = new HashSet();
    assert (!SwingUtilities.isEventDispatchThread()) : "Cannot run refreshProviders in EQ!";
    HashSet localHashSet2 = new HashSet();
    List localList = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true);
    RequestProcessor localRequestProcessor = new RequestProcessor("autoupdate-refresh-providers", localList.size(), false);
    for (Iterator localIterator = localList.iterator(); localIterator.hasNext();)
    {
      localObject = (UpdateUnitProvider)localIterator.next();
      RequestProcessor.Task localTask = localRequestProcessor.post(getRefresher((UpdateUnitProvider)localObject, localHashSet1, paramProgressHandle));
      localHashSet2.add(localTask);
    }
    Object localObject;
    err.log(Level.FINEST, "Waiting for all refreshTasks...");
    for (localIterator = localHashSet2.iterator(); localIterator.hasNext();)
    {
      localObject = (RequestProcessor.Task)localIterator.next();
      ((RequestProcessor.Task)localObject).waitFinished();
    }
    err.log(Level.FINEST, "Waiting for all refreshTasks is done.");
    long l2 = (System.currentTimeMillis() - l1) / 1000L;
    if (l2 > 0L) {
      Utilities.putTimeOfRefreshUpdateCenters(l2);
    }
    return localHashSet1;
  }
  
  private static boolean timeToCheck()
  {
    if (getReqularlyTimerTask() != null) {
      if ((getReqularlyTimerTask().getDelay() <= 0) && (getWaitPeriod() > 0)) {
        return true;
      }
    }
    if (AutoupdateSettings.getLastCheck() == null) {
      return true;
    }
    switch (AutoupdateSettings.getPeriod())
    {
    case 0: 
      return true;
    case 5: 
      return false;
    case 6: 
      return AutoupdateSettings.getLastCheck().getTime() + AutoupdateSettings.getCheckInterval() < new Date().getTime();
    }
    Date localDate = AutoupdateSettings.getLastCheck();
    GregorianCalendar localGregorianCalendar = new GregorianCalendar();
    localGregorianCalendar.setTime(localDate);
    
    localGregorianCalendar.set(10, 0);
    localGregorianCalendar.set(9, 0);
    localGregorianCalendar.set(12, 0);
    localGregorianCalendar.set(13, 0);
    localGregorianCalendar.set(14, 0);
    switch (AutoupdateSettings.getPeriod())
    {
    case 1: 
      localGregorianCalendar.add(5, 1);
      break;
    case 2: 
      localGregorianCalendar.add(3, 1);
      break;
    case 3: 
      localGregorianCalendar.add(3, 2);
      break;
    case 4: 
      localGregorianCalendar.add(2, 1);
    }
    return localGregorianCalendar.getTime().before(new Date());
  }
  
  private static RequestProcessor.Task getReqularlyTimerTask()
  {
    if (regularlyCheck == null) {
      if (getWaitPeriod() > 0)
      {
        int i = getWaitPeriod();
        int j = i;
        if (AutoupdateSettings.getLastCheck() != null) {
          j = i - (int)(System.currentTimeMillis() - AutoupdateSettings.getLastCheck().getTime());
        }
        if (j <= 0) {
          j = i;
        }
        regularlyCheck = REGULARLY_CHECK_TIMER.post(doCheck, j, 1);
      }
    }
    return regularlyCheck;
  }
  
  private static Runnable doCheck = new Runnable()
  {
    public void run()
    {
      if (SwingUtilities.isEventDispatchThread())
      {
        RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheck);
        return;
      }
      if (AutoupdateCheckScheduler.access$400())
      {
        AutoupdateCheckScheduler.access$500();
        AutoupdateCheckScheduler.access$602(true);
        if ((AutoupdateCheckScheduler.access$700() > 0) && (AutoupdateCheckScheduler.regularlyCheck != null) && (AutoupdateCheckScheduler.regularlyCheck.getDelay() <= 0)) {
          AutoupdateCheckScheduler.access$802(AutoupdateCheckScheduler.REGULARLY_CHECK_TIMER.post(AutoupdateCheckScheduler.doCheck, AutoupdateCheckScheduler.access$700(), 1));
        }
      }
    }
  };
  private static Runnable doCheckLazyUpdates = new Runnable()
  {
    public void run()
    {
      if (SwingUtilities.isEventDispatchThread())
      {
        RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheckLazyUpdates);
        return;
      }
      Collection localCollection = LazyInstallUnitWizardIterator.LazyUnit.loadLazyUnits(OperationWizardModel.OperationType.UPDATE);
      int i = (localCollection != null) && (!localCollection.isEmpty()) ? 1 : 0;
      AutoupdateCheckScheduler.notifyAvailable(localCollection, OperationWizardModel.OperationType.UPDATE);
      if (i == 0)
      {
        localObject = LazyInstallUnitWizardIterator.LazyUnit.loadLazyUnits(OperationWizardModel.OperationType.INSTALL);
        AutoupdateCheckScheduler.notifyAvailable((Collection)localObject, OperationWizardModel.OperationType.INSTALL);
      }
      for (Object localObject = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true).iterator(); ((Iterator)localObject).hasNext();)
      {
        UpdateUnitProvider localUpdateUnitProvider = (UpdateUnitProvider)((Iterator)localObject).next();
        Utilities.showProviderNotification(localUpdateUnitProvider);
      }
    }
  };
  
  private static int getWaitPeriod()
  {
    switch ()
    {
    case 5: 
      return 0;
    case 0: 
      return 0;
    case 1: 
      return 86400000;
    case 2: 
      return 604800000;
    case 3: 
      return 1209600000;
    case 4: 
      return Integer.MAX_VALUE;
    case 6: 
      return AutoupdateSettings.getCheckInterval();
    }
    return 0;
  }
  
  public static void notifyAvailable(Collection<LazyInstallUnitWizardIterator.LazyUnit> paramCollection, final OperationWizardModel.OperationType paramOperationType)
  {
    if ((paramCollection == null) || (paramCollection.isEmpty())) {
      return;
    }
    ActionListener local8 = new ActionListener()
    {
      public void actionPerformed(ActionEvent paramAnonymousActionEvent)
      {
        boolean bool = false;
        RequestProcessor.Task localTask = PluginManagerUI.getRunningTask();
        if ((localTask != null) && (!localTask.isFinished()))
        {
          DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_InstallInProgress"), 2));
          
          return;
        }
        try
        {
          bool = new InstallUnitWizard().invokeLazyWizard(val$units, paramOperationType, false);
        }
        finally
        {
          PluginManagerUI localPluginManagerUI1;
          if (bool)
          {
            PluginManagerUI localPluginManagerUI2 = PluginManagerAction.getPluginManagerUI();
            if (localPluginManagerUI2 != null) {
              localPluginManagerUI2.updateUnitsChanged();
            }
            RequestProcessor.getDefault().post(AutoupdateCheckScheduler.doCheckAvailableUpdates);
          }
        }
      }
    };
    int i = paramCollection.size();
    String str = i == 1 ? NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdateFound_ToolTip", Integer.valueOf(i)) : NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdatesFound_ToolTip", Integer.valueOf(i));
    synchronized (AutoupdateCheckScheduler.class)
    {
      if (updatesNotification != null)
      {
        updatesNotification.clear();
        updatesNotification = null;
      }
      updatesNotification = NotificationDisplayer.getDefault().notify(str, ImageUtilities.loadImageIcon("org/netbeans/modules/autoupdate/ui/resources/newUpdates.png", false), NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_UpdateFound_Hint"), local8, NotificationDisplayer.Priority.HIGH);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actions;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import org.netbeans.modules.autoupdate.ui.Utilities;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbPreferences;

public class AutoupdateSettings
{
  private static String tempIdeIdentity = null;
  private static final Logger err = Logger.getLogger(AutoupdateSettings.class.getName());
  private static final String PROP_IDE_IDENTITY = "ideIdentity";
  private static final String PROP_SUPER_IDENTITY = "superId";
  private static final String PROP_QUALIFIED_IDENTITY = "qualifiedId";
  private static final String PROP_PERIOD = "period";
  private static final String PROP_LAST_CHECK = "lastCheckTime";
  private static final String DEFAULT_NETBEANS_DIR = ".netbeans";
  private static final String SUPER_IDENTITY_FILE_NAME = ".superId";
  private static final char IDE_ID_DELIMETER = '0';
  private static final char QUALIFIED_ID_DELIMETER = '_';
  public static final int EVERY_STARTUP = 0;
  public static final int EVERY_DAY = 1;
  public static final int EVERY_WEEK = 2;
  public static final int EVERY_2WEEKS = 3;
  public static final int EVERY_MONTH = 4;
  public static final int NEVER = 5;
  public static final int CUSTOM_CHECK_INTERVAL = 6;
  private static final String EXPIRATION_RECORD = "expiration";
  private static final String IMPORTED = "imported";
  private static final String[] VERSIONS_FOR_IMPORT = new String[0];
  private static final String[][] KNOWN = { { "EVERY_STARTUP", "0" }, { "EVERY_DAY", "1" }, { "EVERY_WEEK", "2" }, { "EVERY_2WEEKS", "3" }, { "EVERY_MONTH", "4" }, { "NEVER", "5" } };
  private static int checkInterval = 0;
  private static String superId;
  
  public static void generateIdentity()
  {
    
    if ((tempIdeIdentity instanceof String)) {
      return;
    }
    String str1 = getPreferences().get("ideIdentity", null);
    String str2 = null;
    if (str1 == null) {
      str2 = modifyIdeIdentityIfNeeded('0' + generateNewId());
    } else {
      str2 = modifyIdeIdentityIfNeeded((String)str1);
    }
    tempIdeIdentity = str2;
    if ((!str2.equals(str1)) || (!existsSuperIdentity()) || (getPreferences().get("qualifiedId", null) == null))
    {
      err.log(Level.FINE, "Put new value of PROP_IDE_IDENTITY to " + str2);
      
      assert (!str2.startsWith("-n+")) : ("Generated identity (" + str2 + ") is of wrong format. " + "Old identity was [" + str1 + "].");
      
      getPreferences().put("ideIdentity", str2);
      String str3 = getSuperIdentity();
      if (str3 != null) {
        getPreferences().put("superId", str3);
      }
      getPreferences().put("qualifiedId", getQualifiedIdentity(str2));
    }
  }
  
  public static int getPeriod()
  {
    int i = getPreferences().get("period", null) == null ? 1 : 0;
    Integer localInteger = null;
    if (i != 0) {
      localInteger = parse(Utilities.getCustomCheckIntervalInMinutes());
    }
    if (localInteger == null) {
      localInteger = Integer.valueOf(2);
    }
    err.log(Level.FINEST, "getPeriod () returns " + getPreferences().getInt("period", localInteger.intValue()));
    return getPreferences().getInt("period", localInteger.intValue());
  }
  
  public static int getCheckInterval()
  {
    err.log(Level.FINEST, "getCheckInterval () returns " + checkInterval + "ms");
    return checkInterval;
  }
  
  public static void setPeriod(int paramInt)
  {
    err.log(Level.FINEST, "Called setPeriod (" + paramInt + ")");
    getPreferences().putInt("period", paramInt);
  }
  
  public static Date getLastCheck()
  {
    long l = getPreferences().getLong("lastCheckTime", -1L);
    return l > 0L ? new Date(l) : null;
  }
  
  public static void setLastCheck(Date paramDate)
  {
    err.log(Level.FINER, "Set the last check to " + paramDate);
    if (paramDate != null) {
      getPreferences().putLong("lastCheckTime", paramDate.getTime());
    } else {
      getPreferences().remove("lastCheckTime");
    }
  }
  
  private static Preferences getPreferences()
  {
    return NbPreferences.root().node("/org/netbeans/modules/autoupdate");
  }
  
  private static String modifyIdeIdentityIfNeeded(String paramString)
  {
    int i = paramString.indexOf('0');
    String[] arrayOfString = paramString.split("\\d");
    String str1 = null;
    String str2 = null;
    if ((arrayOfString.length == 0) || (i == 0))
    {
      str1 = paramString;
      str2 = "";
    }
    else if ((i != -1) && (paramString.substring(arrayOfString[0].length()).startsWith(48)))
    {
      str2 = paramString.substring(0, i);
      str1 = paramString.substring(str2.length());
    }
    else
    {
      str2 = arrayOfString[0];
      str1 = paramString.substring(str2.length());
    }
    err.log(Level.FINER, "Old IDE Identity Prefix: " + str2);
    err.log(Level.FINER, "Old IDE Identity ID: " + str1);
    String str3 = "";
    try
    {
      FileObject localFileObject = FileUtil.getConfigFile("productid");
      if (localFileObject != null)
      {
        InputStream localInputStream = localFileObject.getInputStream();
        try
        {
          BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localInputStream));
          str3 = localBufferedReader.readLine().trim();
          if (str3.length() > 128) {
            str3 = str3.substring(0, 128);
          }
        }
        finally
        {
          localInputStream.close();
        }
      }
    }
    catch (IOException localIOException)
    {
      err.log(Level.FINER, localIOException.getMessage(), localIOException);
    }
    if (!str3.equals(str2)) {
      err.log(Level.FINER, "New IDE Identity Prefix: " + str3);
    } else {
      err.log(Level.FINER, "No new prefix.");
    }
    assert (!(str3 + str1).startsWith("-n+")) : ("Product Indentity is of wrong format, prefix=" + str3 + ", id=" + str1 + ", oldPrefix=" + str2 + ",oldIdeIdentity=" + paramString);
    
    return str3 + str1;
  }
  
  private static String generateNewId()
  {
    return UUID.randomUUID().toString();
  }
  
  private static Integer parse(String paramString)
  {
    if ((paramString == null) || (paramString.trim().length() == 0)) {
      return null;
    }
    Integer localInteger = null;
    for (String[] arrayOfString1 : KNOWN) {
      if (arrayOfString1[0].equalsIgnoreCase(paramString)) {
        try
        {
          localInteger = Integer.valueOf(Integer.parseInt(arrayOfString1[1]));
        }
        catch (NumberFormatException localNumberFormatException2)
        {
          if (!$assertionsDisabled) {
            throw new AssertionError("Invalid value " + arrayOfString1 + " throws " + localNumberFormatException2);
          }
        }
      }
    }
    if (localInteger == null) {
      try
      {
        checkInterval = Long.parseLong(paramString) * 1000L * 60L > 2147483647L ? Integer.MAX_VALUE : Integer.parseInt(paramString) * 1000 * 60;
        localInteger = Integer.valueOf(6);
        err.log(Level.FINE, "Custom value of " + Utilities.PLUGIN_MANAGER_CHECK_INTERVAL + " is " + paramString + " minutes.");
      }
      catch (NumberFormatException localNumberFormatException1)
      {
        err.log(Level.FINE, "Invalid value " + paramString + " of " + Utilities.PLUGIN_MANAGER_CHECK_INTERVAL + " throws " + localNumberFormatException1);
      }
    } else {
      err.log(Level.FINE, "Custom value of " + Utilities.PLUGIN_MANAGER_CHECK_INTERVAL + " is " + paramString);
    }
    return localInteger;
  }
  
  private static void expirationCheck()
  {
    Preferences localPreferences = getPreferences();
    String str1 = localPreferences.get("expiration", null);
    HashSet localHashSet = new HashSet(Arrays.asList(VERSIONS_FOR_IMPORT));
    String str2 = new File(System.getProperty("netbeans.user")).getName();
    localHashSet.add(str2);
    if ((str1 != null) && (!localHashSet.contains(str1))) {
      try
      {
        int i = getPeriod();
        boolean bool = Utilities.isGlobalInstallation();
        localPreferences.removeNode();
        getPreferences().put("imported", Boolean.toString(true));
        getPreferences().putInt("period", i);
        if (bool)
        {
          List localList = Utilities.sharedDirs();
          if (!localList.isEmpty())
          {
            for (File localFile : localList) {
              if ((localFile.exists()) && (localFile.isDirectory()) && (!Utilities.canWriteInCluster(localFile)))
              {
                bool = false;
                break;
              }
            }
            if (bool) {
              Utilities.setGlobalInstallation(bool);
            }
          }
        }
        err.log(Level.FINE, "Don't read preferences from userdir " + str1);
      }
      catch (BackingStoreException localBackingStoreException)
      {
        err.log(Level.INFO, localBackingStoreException.getLocalizedMessage(), localBackingStoreException);
      }
    } else if (str1 == null) {
      err.log(Level.FINEST, "No preferences imported from previous versoin.");
    } else {
      err.log(Level.FINEST, "Read preferences from userdir " + str1);
    }
    err.log(Level.FINEST, "Store current version " + str2 + " for future import.");
    getPreferences().put("expiration", str2);
  }
  
  private static boolean existsSuperIdentity()
  {
    File localFile = getSuperFile();
    if (localFile == null) {
      return true;
    }
    err.log(Level.FINE, "Does " + localFile + " exist? " + localFile.exists());
    return localFile.exists();
  }
  
  private static File getSuperFile()
  {
    String str = System.getProperty("user.home");
    if ("memory".equals(str))
    {
      err.log(Level.INFO, "IDE launched as JNLP");
      return null;
    }
    File localFile = new File(str, ".netbeans");
    localFile.mkdirs();
    return new File(localFile, ".superId");
  }
  
  private static String getSuperIdentity()
  {
    if (superId != null) {
      return superId;
    }
    File localFile = getSuperFile();
    if (localFile == null) {
      err.log(Level.FINE, "superFile is returns null.");
    }
    if (localFile.exists())
    {
      localObject1 = null;
      try
      {
        localObject1 = new FileInputStream(localFile);
        BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader((InputStream)localObject1));
        superId = localBufferedReader.readLine().trim();
        err.log(Level.FINE, "Read Super Id: " + superId);
      }
      catch (IOException localIOException2)
      {
        err.log(Level.FINER, null, localIOException2);
      }
      finally
      {
        try
        {
          if (localObject1 != null) {
            ((InputStream)localObject1).close();
          }
        }
        catch (IOException localIOException7)
        {
          err.log(Level.FINER, null, localIOException7);
        }
      }
    }
    Object localObject1 = null;
    try
    {
      localObject1 = new BufferedWriter(new FileWriter(localFile));
      String str = generateNewId();
      ((Writer)localObject1).write(str);
      superId = str;
      err.log(Level.FINE, "Wrote Super Id: " + superId);
      try
      {
        if (localObject1 != null) {
          ((Writer)localObject1).close();
        }
      }
      catch (IOException localIOException4)
      {
        err.log(Level.FINER, null, localIOException4);
      }
      if (superId == null) {
        break label393;
      }
    }
    catch (IOException localIOException5)
    {
      err.log(Level.FINER, null, localIOException5);
    }
    finally
    {
      try
      {
        if (localObject1 != null) {
          ((Writer)localObject1).close();
        }
      }
      catch (IOException localIOException8)
      {
        err.log(Level.FINER, null, localIOException8);
      }
    }
    err.log(Level.FINE, "Returns Super Id: " + superId);
    return superId;
    label393:
    err.log(Level.FINE, "Was problem while handling Super Id. Returns null");
    return null;
  }
  
  private static String getQualifiedIdentity(String paramString)
  {
    if (getSuperIdentity() != null)
    {
      err.log(Level.FINE, "Returns Qualified Id: " + paramString + '_' + getSuperIdentity());
      return paramString + '_' + getSuperIdentity();
    }
    err.log(Level.FINE, "Was problem while handling Qualified Id. Returns only original Id: " + paramString);
    return paramString;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.AutoupdateSettings
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actions;

import java.util.Collection;
import org.netbeans.modules.autoupdate.ui.PluginManagerUI;
import org.netbeans.modules.autoupdate.ui.wizards.InstallUnitWizard;
import org.netbeans.modules.autoupdate.ui.wizards.LazyInstallUnitWizardIterator.LazyUnit;
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor.Message;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.actions.CallableSystemAction;

public final class CheckForUpdatesAction
  extends CallableSystemAction
{
  public void performAction()
  {
    boolean bool = false;
    RequestProcessor.Task localTask = PluginManagerUI.getRunningTask();
    if ((localTask != null) && (!localTask.isFinished()))
    {
      DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(NbBundle.getMessage(AutoupdateCheckScheduler.class, "AutoupdateCheckScheduler_InstallInProgress"), 2));
      
      return;
    }
    Collection localCollection = LazyInstallUnitWizardIterator.LazyUnit.loadLazyUnits(OperationWizardModel.OperationType.UPDATE);
    try
    {
      bool = new InstallUnitWizard().invokeLazyWizard(localCollection, OperationWizardModel.OperationType.UPDATE, true);
    }
    finally
    {
      PluginManagerUI localPluginManagerUI1;
      if (bool)
      {
        PluginManagerUI localPluginManagerUI2 = PluginManagerAction.getPluginManagerUI();
        if (localPluginManagerUI2 != null) {
          localPluginManagerUI2.updateUnitsChanged();
        }
      }
    }
  }
  
  public String getName()
  {
    return NbBundle.getMessage(CheckForUpdatesAction.class, "CTL_CheckForUpdatesAction");
  }
  
  protected void initialize()
  {
    super.initialize();
    
    putValue("noIconInMenu", Boolean.TRUE);
  }
  
  public HelpCtx getHelpCtx()
  {
    return HelpCtx.DEFAULT_HELP;
  }
  
  protected boolean asynchronous()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.CheckForUpdatesAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actions;

import org.openide.modules.ModuleInstall;

public class Installer
  extends ModuleInstall
{
  public void restored()
  {
    if ((Boolean.getBoolean("netbeans.full.hack")) || (Boolean.getBoolean("netbeans.close"))) {
      return;
    }
    AutoupdateCheckScheduler.signOn();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.autoupdate.ui.actions.Installer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.autoupdate.ui.actio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

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-2017. Infinite Loop Ltd