org.eclipse.equinox.p2.ui.sdk_1.0.200.v20110815-1419

16:44:34.877 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.p2.ui.sdk_1.0.200.v20110815-1419.jar
package org.eclipse.equinox.internal.p2.ui.sdk;

public abstract interface IProvSDKHelpContextIds
{
  public static final String PREFIX = "org.eclipse.equinox.p2.ui.sdk.";
  public static final String PROVISIONING_PREFERENCE_PAGE = "org.eclipse.equinox.p2.ui.sdk.provisioning_preference_page_context";
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.IProvSDKHelpContextIds
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;

public class InstallNewSoftwareHandler
  extends PreloadingRepositoryHandler
{
  protected void doExecute(LoadMetadataRepositoryJob job)
  {
    getProvisioningUI().openInstallWizard(null, null, job);
  }
  
  protected boolean waitForPreload()
  {
    return !getProvisioningUI().getPolicy().getRepositoriesVisible();
  }
  
  protected void setLoadJobProperties(Job loadJob)
  {
    super.setLoadJobProperties(loadJob);
    if (!waitForPreload())
    {
      loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_AUTHENTICATION_JOB_MARKER, Boolean.toString(true));
      loadJob.setProperty(LoadMetadataRepositoryJob.SUPPRESS_REPOSITORY_EVENTS, Boolean.toString(true));
    }
  }
  
  protected String getProgressTaskName()
  {
    return ProvSDKMessages.InstallNewSoftwareHandler_ProgressTaskName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.InstallNewSoftwareHandler
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

class PreloadingRepositoryHandler$1
  implements Runnable
{
  final PreloadingRepositoryHandler this$0;
  
  PreloadingRepositoryHandler$1(PreloadingRepositoryHandler paramPreloadingRepositoryHandler) {}
  
  public void run()
  {
    this$0.doExecuteAndLoad();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.ProvisioningUI;

class PreloadingRepositoryHandler$2
  extends LoadMetadataRepositoryJob
{
  final PreloadingRepositoryHandler this$0;
  
  PreloadingRepositoryHandler$2(PreloadingRepositoryHandler paramPreloadingRepositoryHandler, ProvisioningUI $anonymous0)
  {
    super($anonymous0);
  }
  
  public IStatus runModal(IProgressMonitor monitor)
  {
    SubMonitor sub = SubMonitor.convert(monitor, this$0.getProgressTaskName(), 1000);
    IStatus status = super.runModal(sub.newChild(500));
    if (status.getSeverity() == 8) {
      return status;
    }
    try
    {
      this$0.doPostLoadBackgroundWork(sub.newChild(500));
    }
    catch (OperationCanceledException localOperationCanceledException)
    {
      return Status.CANCEL_STATUS;
    }
    return status;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler.2
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;

class PreloadingRepositoryHandler$3$1
  implements Runnable
{
  final PreloadingRepositoryHandler.3 this$1;
  
  PreloadingRepositoryHandler$3$1(PreloadingRepositoryHandler.3 param3, LoadMetadataRepositoryJob paramLoadMetadataRepositoryJob) {}
  
  public void run()
  {
    PreloadingRepositoryHandler.3.access$0(this$1).doExecute(val$loadJob);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler.3.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;

class PreloadingRepositoryHandler$3
  extends JobChangeAdapter
{
  final PreloadingRepositoryHandler this$0;
  
  PreloadingRepositoryHandler$3(PreloadingRepositoryHandler paramPreloadingRepositoryHandler, LoadMetadataRepositoryJob paramLoadMetadataRepositoryJob) {}
  
  public void done(IJobChangeEvent event)
  {
    if ((PlatformUI.isWorkbenchRunning()) && 
      (event.getResult().isOK())) {
      PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
      {
        public void run()
        {
          this$0.doExecute(val$loadJob);
        }
      });
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler.3
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.IProfile;
import org.eclipse.equinox.p2.engine.IProfileRegistry;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.statushandlers.StatusManager;

abstract class PreloadingRepositoryHandler
  extends AbstractHandler
{
  public Object execute(ExecutionEvent event)
  {
    String profileId = getProvisioningUI().getProfileId();
    IProvisioningAgent agent = getProvisioningUI().getSession().getProvisioningAgent();
    IProfile profile = null;
    if (agent != null)
    {
      IProfileRegistry registry = (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
      if (registry != null) {
        profile = registry.getProfile(profileId);
      }
    }
    if (profile == null)
    {
      MessageDialog.openInformation(null, ProvSDKMessages.Handler_SDKUpdateUIMessageTitle, ProvSDKMessages.Handler_CannotLaunchUI);
      
      StatusManager.getManager().handle(ProvSDKUIActivator.getNoSelfProfileStatus());
    }
    else
    {
      BusyIndicator.showWhile(getShell().getDisplay(), new Runnable()
      {
        public void run()
        {
          doExecuteAndLoad();
        }
      });
    }
    return null;
  }
  
  void doExecuteAndLoad()
  {
    if (preloadRepositories())
    {
      Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
      final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(getProvisioningUI())
      {
        public IStatus runModal(IProgressMonitor monitor)
        {
          SubMonitor sub = SubMonitor.convert(monitor, getProgressTaskName(), 1000);
          IStatus status = super.runModal(sub.newChild(500));
          if (status.getSeverity() == 8) {
            return status;
          }
          try
          {
            doPostLoadBackgroundWork(sub.newChild(500));
          }
          catch (OperationCanceledException localOperationCanceledException)
          {
            return Status.CANCEL_STATUS;
          }
          return status;
        }
      };
      setLoadJobProperties(loadJob);
      if (waitForPreload())
      {
        loadJob.addJobChangeListener(new JobChangeAdapter()
        {
          public void done(IJobChangeEvent event)
          {
            if ((PlatformUI.isWorkbenchRunning()) && 
              (event.getResult().isOK())) {
              PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
              {
                public void run()
                {
                  doExecute(val$loadJob);
                }
              });
            }
          }
        });
        loadJob.setUser(true);
        loadJob.schedule();
      }
      else
      {
        loadJob.setSystem(true);
        loadJob.setUser(false);
        loadJob.schedule();
        doExecute(null);
      }
    }
    else
    {
      doExecute(null);
    }
  }
  
  protected abstract String getProgressTaskName();
  
  protected abstract void doExecute(LoadMetadataRepositoryJob paramLoadMetadataRepositoryJob);
  
  protected boolean preloadRepositories()
  {
    return true;
  }
  
  protected void doPostLoadBackgroundWork(IProgressMonitor monitor)
    throws OperationCanceledException
  {}
  
  protected boolean waitForPreload()
  {
    return true;
  }
  
  protected void setLoadJobProperties(Job loadJob)
  {
    loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
  }
  
  protected ProvisioningUI getProvisioningUI()
  {
    return ProvisioningUI.getDefaultUI();
  }
  
  protected Shell getShell()
  {
    return PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.PreloadingRepositoryHandler
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.osgi.util.NLS;

public class ProvSDKMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.p2.ui.sdk.messages";
  public static String Handler_CannotLaunchUI;
  public static String Handler_SDKUpdateUIMessageTitle;
  public static String InstallNewSoftwareHandler_ProgressTaskName;
  public static String PreferenceInitializer_Error;
  public static String ProvisioningPreferencePage_AlwaysOpenWizard;
  public static String ProvisioningPreferencePage_BrowsingPrefsGroup;
  public static String ProvisioningPreferencePage_ShowLatestVersions;
  public static String ProvisioningPreferencePage_ShowAllVersions;
  public static String ProvisioningPreferencePage_NeverOpenWizard;
  public static String ProvisioningPreferencePage_OpenWizardIfInvalid;
  public static String ProvisioningPreferencePage_PromptToOpenWizard;
  public static String ProvisioningPreferencePage_UninstallUpdateLink;
  public static String ProvSDKUIActivator_ErrorSavingPrefs;
  public static String ProvSDKUIActivator_NoSelfProfile;
  public static String ProvSDKUIActivator_OpenWizardAnyway;
  public static String ProvSDKUIActivator_Question;
  public static String SDKPolicy_PrefPageName;
  public static String UpdateHandler_NoSitesMessage;
  public static String UpdateHandler_NoSitesTitle;
  public static String UpdateHandler_ProgressTaskName;
  
  static
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.p2.ui.sdk.messages", ProvSDKMessages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;

class ProvSDKUIActivator$1
  implements IPropertyChangeListener
{
  final ProvSDKUIActivator this$0;
  
  ProvSDKUIActivator$1(ProvSDKUIActivator paramProvSDKUIActivator) {}
  
  public void propertyChange(PropertyChangeEvent event)
  {
    this$0.updateWithPreferences(this$0.getPolicy());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator.1
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import java.io.IOException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceInitializer;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.ProfileScope;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;

public class ProvSDKUIActivator
  extends AbstractUIPlugin
{
  private static ProvSDKUIActivator plugin;
  private static BundleContext context;
  private ScopedPreferenceStore preferenceStore;
  private IPropertyChangeListener preferenceListener;
  public static final String PLUGIN_ID = "org.eclipse.equinox.p2.ui.sdk";
  
  public static BundleContext getContext()
  {
    return context;
  }
  
  public static ProvSDKUIActivator getDefault()
  {
    return plugin;
  }
  
  public static ImageDescriptor getImageDescriptor(String path)
  {
    return imageDescriptorFromPlugin("org.eclipse.equinox.p2.ui.sdk", path);
  }
  
  public void start(BundleContext bundleContext)
    throws Exception
  {
    super.start(bundleContext);
    plugin = this;
    context = bundleContext;
    PreferenceInitializer.migratePreferences();
    getPreferenceStore().addPropertyChangeListener(getPreferenceListener());
  }
  
  private IPropertyChangeListener getPreferenceListener()
  {
    if (preferenceListener == null) {
      preferenceListener = new IPropertyChangeListener()
      {
        public void propertyChange(PropertyChangeEvent event)
        {
          updateWithPreferences(getPolicy());
        }
      };
    }
    return preferenceListener;
  }
  
  public ProvisioningUI getProvisioningUI()
  {
    return ProvisioningUI.getDefaultUI();
  }
  
  Policy getPolicy()
  {
    return getProvisioningUI().getPolicy();
  }
  
  public IProvisioningAgent getProvisioningAgent()
  {
    return getProvisioningUI().getSession().getProvisioningAgent();
  }
  
  public void stop(BundleContext bundleContext)
    throws Exception
  {
    plugin = null;
    getPreferenceStore().removePropertyChangeListener(preferenceListener);
    super.stop(bundleContext);
  }
  
  static IStatus getNoSelfProfileStatus()
  {
    return new Status(2, "org.eclipse.equinox.p2.ui.sdk", ProvSDKMessages.ProvSDKUIActivator_NoSelfProfile);
  }
  
  void updateWithPreferences(Policy policy)
  {
    policy.setShowLatestVersionsOnly(getPreferenceStore().getBoolean("showLatestVersion"));
  }
  
  public IPreferenceStore getPreferenceStore()
  {
    if (preferenceStore == null)
    {
      IAgentLocation agentLocation = getAgentLocation();
      if (agentLocation == null) {
        return super.getPreferenceStore();
      }
      preferenceStore = new ScopedPreferenceStore(new ProfileScope(agentLocation, "_SELF_"), "org.eclipse.equinox.p2.ui.sdk");
    }
    return preferenceStore;
  }
  
  private IAgentLocation getAgentLocation()
  {
    ServiceReference<?> ref = getContext().getServiceReference(IAgentLocation.SERVICE_NAME);
    if (ref == null) {
      return null;
    }
    IAgentLocation location = (IAgentLocation)getContext().getService(ref);
    getContext().ungetService(ref);
    return location;
  }
  
  public void savePreferences()
  {
    if (preferenceStore != null) {
      try
      {
        preferenceStore.save();
      }
      catch (IOException e)
      {
        StatusManager.getManager().handle(new Status(4, "org.eclipse.equinox.p2.ui.sdk", 0, ProvSDKMessages.ProvSDKUIActivator_ErrorSavingPrefs, e), 3);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.IExecutableExtensionFactory;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.p2.ui.RevertProfilePage;
import org.osgi.framework.Bundle;

public class RevertProfilePageExtensionFactory
  implements IExecutableExtensionFactory
{
  public Object create()
  {
    Bundle bundle = Platform.getBundle("org.eclipse.compare");
    if (bundle == null) {
      return new RevertProfilePage();
    }
    return new RevertProfilePageWithCompare();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.RevertProfilePageExtensionFactory
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.model.RollbackProfileElement;
import org.eclipse.jface.dialogs.IDialogConstants;

class RevertProfilePageWithCompare$ProfileCompareEditorInput
  extends CompareEditorInput
{
  private Object root;
  private RevertProfilePageWithCompare.ProvElementNode l;
  private RevertProfilePageWithCompare.ProvElementNode r;
  final RevertProfilePageWithCompare this$0;
  
  public RevertProfilePageWithCompare$ProfileCompareEditorInput(RevertProfilePageWithCompare paramRevertProfilePageWithCompare, RollbackProfileElement[] rpe)
  {
    super(new CompareConfiguration());
    Assert.isTrue(rpe.length == 2);
    l = new RevertProfilePageWithCompare.ProvElementNode(paramRevertProfilePageWithCompare, rpe[0]);
    r = new RevertProfilePageWithCompare.ProvElementNode(paramRevertProfilePageWithCompare, rpe[1]);
  }
  
  protected Object prepareInput(IProgressMonitor monitor)
  {
    initLabels();
    Differencer d = new Differencer();
    root = d.findDifferences(false, monitor, null, null, l, r);
    return root;
  }
  
  private void initLabels()
  {
    CompareConfiguration cc = getCompareConfiguration();
    cc.setLeftEditable(false);
    cc.setRightEditable(false);
    cc.setLeftLabel(l.getName());
    cc.setLeftImage(l.getImage());
    cc.setRightLabel(r.getName());
    cc.setRightImage(r.getImage());
  }
  
  public String getOKButtonLabel()
  {
    return IDialogConstants.OK_LABEL;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.RevertProfilePageWithCompare.ProfileCompareEditorInput
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.model.InstalledIUElement;
import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
import org.eclipse.equinox.internal.p2.ui.model.RollbackProfileElement;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.swt.graphics.Image;

class RevertProfilePageWithCompare$ProvElementNode
  implements IStructureComparator, ITypedElement, IStreamContentAccessor
{
  private ProvElement pe;
  private IInstallableUnit iu;
  static final String BLANK = "";
  private String id = "";
  final RevertProfilePageWithCompare this$0;
  
  public RevertProfilePageWithCompare$ProvElementNode(RevertProfilePageWithCompare paramRevertProfilePageWithCompare, Object input)
  {
    pe = ((ProvElement)input); Class 
      tmp31_28 = RevertProfilePageWithCompare.class$0;
    if (tmp31_28 == null)
    {
      tmp31_28;
      try
      {
        tmpTernaryOp = (RevertProfilePageWithCompare.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    iu = ((IInstallableUnit)ProvUI.getAdapter(pe, tmp31_28));
    if (iu != null) {
      id = iu.getId();
    }
  }
  
  public Object[] getChildren()
  {
    Set<ProvElementNode> children = new HashSet();
    if ((pe instanceof RollbackProfileElement))
    {
      Object[] c = ((RollbackProfileElement)pe).getChildren(null);
      for (int i = 0; i < c.length; i++) {
        children.add(new ProvElementNode(this$0, c[i]));
      }
    }
    else if ((pe instanceof InstalledIUElement))
    {
      Object[] c = ((InstalledIUElement)pe).getChildren(null);
      for (int i = 0; i < c.length; i++) {
        children.add(new ProvElementNode(this$0, c[i]));
      }
    }
    return children.toArray();
  }
  
  public boolean equals(Object other)
  {
    if ((other instanceof ProvElementNode)) {
      return id.equals(id);
    }
    return super.equals(other);
  }
  
  public int hashCode()
  {
    return id.hashCode();
  }
  
  public Image getImage()
  {
    return pe.getImage(null);
  }
  
  public String getName()
  {
    if (iu != null) {
      return iu.getProperty("org.eclipse.equinox.p2.name", null);
    }
    return pe.getLabel(null);
  }
  
  public String getType()
  {
    return "???";
  }
  
  public InputStream getContents()
  {
    String contents = "";
    if (iu != null) {
      contents = iu.getVersion().toString();
    }
    return new ByteArrayInputStream(contents.getBytes());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.RevertProfilePageWithCompare.ProvElementNode
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.CompareUI;
import org.eclipse.compare.IStreamContentAccessor;
import org.eclipse.compare.ITypedElement;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IStructureComparator;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.model.InstalledIUElement;
import org.eclipse.equinox.internal.p2.ui.model.ProvElement;
import org.eclipse.equinox.internal.p2.ui.model.RollbackProfileElement;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.equinox.p2.ui.RevertProfilePage;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class RevertProfilePageWithCompare
  extends RevertProfilePage
{
  private static final int COMPARE_ID = 1026;
  Button compareButton;
  static Class class$0;
  
  public void createPageButtons(Composite parent)
  {
    if (ProvisioningUI.getDefaultUI().getProfileId() == null) {
      return;
    }
    compareButton = createButton(parent, 1026, ProvUIMessages.RevertProfilePage_CompareLabel);
    compareButton.setToolTipText(ProvUIMessages.RevertProfilePage_CompareTooltip);
    compareButton.setEnabled(computeCompareEnablement(getSelection()));
    super.createPageButtons(parent);
  }
  
  protected void buttonPressed(int buttonId)
  {
    switch (buttonId)
    {
    case 1026: 
      compare();
      break;
    default: 
      super.buttonPressed(buttonId);
    }
  }
  
  boolean computeCompareEnablement(IStructuredSelection structuredSelection)
  {
    Object[] selection = structuredSelection.toArray();
    if (selection.length == 2)
    {
      for (int i = 0; i < selection.length; i++) {
        if (!(selection[i] instanceof RollbackProfileElement)) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
  
  protected void handleSelectionChanged(IStructuredSelection selection)
  {
    super.handleSelectionChanged(selection);
    if (!selection.isEmpty())
    {
      if (selection.size() == 1)
      {
        if (compareButton != null) {
          compareButton.setEnabled(false);
        }
      }
      else if (compareButton != null) {
        compareButton.setEnabled(computeCompareEnablement(selection));
      }
    }
    else if (compareButton != null) {
      compareButton.setEnabled(false);
    }
  }
  
  private RollbackProfileElement[] getRollbackProfileElementsToCompare()
  {
    RollbackProfileElement[] result = new RollbackProfileElement[2];
    IStructuredSelection selection = getSelection();
    int i = 0;
    for (Iterator localIterator = selection.toList().iterator(); localIterator.hasNext();)
    {
      Object selected = localIterator.next();
      if ((selected != null) && ((selected instanceof RollbackProfileElement))) {
        result[(i++)] = ((RollbackProfileElement)selected);
      }
      if (i == 2) {
        break;
      }
    }
    return result;
  }
  
  void compare()
  {
    RollbackProfileElement[] rpe = getRollbackProfileElementsToCompare();
    CompareUI.openCompareDialog(new ProfileCompareEditorInput(rpe));
  }
  
  private class ProfileCompareEditorInput
    extends CompareEditorInput
  {
    private Object root;
    private RevertProfilePageWithCompare.ProvElementNode l;
    private RevertProfilePageWithCompare.ProvElementNode r;
    
    public ProfileCompareEditorInput(RollbackProfileElement[] rpe)
    {
      super();
      Assert.isTrue(rpe.length == 2);
      l = new RevertProfilePageWithCompare.ProvElementNode(RevertProfilePageWithCompare.this, rpe[0]);
      r = new RevertProfilePageWithCompare.ProvElementNode(RevertProfilePageWithCompare.this, rpe[1]);
    }
    
    protected Object prepareInput(IProgressMonitor monitor)
    {
      initLabels();
      Differencer d = new Differencer();
      root = d.findDifferences(false, monitor, null, null, l, r);
      return root;
    }
    
    private void initLabels()
    {
      CompareConfiguration cc = getCompareConfiguration();
      cc.setLeftEditable(false);
      cc.setRightEditable(false);
      cc.setLeftLabel(l.getName());
      cc.setLeftImage(l.getImage());
      cc.setRightLabel(r.getName());
      cc.setRightImage(r.getImage());
    }
    
    public String getOKButtonLabel()
    {
      return IDialogConstants.OK_LABEL;
    }
  }
  
  private class ProvElementNode
    implements IStructureComparator, ITypedElement, IStreamContentAccessor
  {
    private ProvElement pe;
    private IInstallableUnit iu;
    static final String BLANK = "";
    private String id = "";
    
    public ProvElementNode(Object input)
    {
      pe = ((ProvElement)input); Class 
        tmp31_28 = RevertProfilePageWithCompare.class$0;
      if (tmp31_28 == null)
      {
        tmp31_28;
        try
        {
          tmpTernaryOp = (RevertProfilePageWithCompare.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
        }
      }
      iu = ((IInstallableUnit)ProvUI.getAdapter(pe, tmp31_28));
      if (iu != null) {
        id = iu.getId();
      }
    }
    
    public Object[] getChildren()
    {
      Set<ProvElementNode> children = new HashSet();
      if ((pe instanceof RollbackProfileElement))
      {
        Object[] c = ((RollbackProfileElement)pe).getChildren(null);
        for (int i = 0; i < c.length; i++) {
          children.add(new ProvElementNode(RevertProfilePageWithCompare.this, c[i]));
        }
      }
      else if ((pe instanceof InstalledIUElement))
      {
        Object[] c = ((InstalledIUElement)pe).getChildren(null);
        for (int i = 0; i < c.length; i++) {
          children.add(new ProvElementNode(RevertProfilePageWithCompare.this, c[i]));
        }
      }
      return children.toArray();
    }
    
    public boolean equals(Object other)
    {
      if ((other instanceof ProvElementNode)) {
        return id.equals(id);
      }
      return super.equals(other);
    }
    
    public int hashCode()
    {
      return id.hashCode();
    }
    
    public Image getImage()
    {
      return pe.getImage(null);
    }
    
    public String getName()
    {
      if (iu != null) {
        return iu.getProperty("org.eclipse.equinox.p2.name", null);
      }
      return pe.getLabel(null);
    }
    
    public String getType()
    {
      return "???";
    }
    
    public InputStream getContents()
    {
      String contents = "";
      if (iu != null) {
        contents = iu.getVersion().toString();
      }
      return new ByteArrayInputStream(contents.getBytes());
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.RevertProfilePageWithCompare
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.engine.query.UserVisibleRootQuery;
import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.statushandlers.StatusManager;

public class SDKPolicy
  extends Policy
{
  public SDKPolicy()
  {
    setVisibleAvailableIUQuery(QueryUtil.createIUGroupQuery());
    
    setVisibleInstalledIUQuery(new UserVisibleRootQuery());
    setRepositoryPreferencePageId("org.eclipse.equinox.internal.p2.ui.sdk.SitesPreferencePage");
    setRepositoryPreferencePageName(ProvSDKMessages.SDKPolicy_PrefPageName);
    ProvSDKUIActivator.getDefault().updateWithPreferences(this);
  }
  
  public IStatus getNoProfileChosenStatus()
  {
    return ProvSDKUIActivator.getNoSelfProfileStatus();
  }
  
  public boolean continueWorkingOperation(ProfileChangeOperation operation, Shell shell)
  {
    boolean ok = super.continueWorkingWithOperation(operation, shell);
    if (!ok) {
      return false;
    }
    IProvisioningPlan plan = operation.getProvisioningPlan();
    if (plan == null) {
      return false;
    }
    IPreferenceStore prefs = ProvSDKUIActivator.getDefault().getPreferenceStore();
    String openPlan = prefs.getString("allowNonOKPlan");
    if ("always".equals(openPlan)) {
      return true;
    }
    if ("never".equals(openPlan))
    {
      StatusManager.getManager().handle(plan.getStatus(), 3);
      return false;
    }
    MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(shell, ProvSDKMessages.ProvSDKUIActivator_Question, ProvSDKMessages.ProvSDKUIActivator_OpenWizardAnyway, null, false, prefs, "allowNonOKPlan");
    if (dialog.getReturnCode() == 3) {
      StatusManager.getManager().handle(plan.getStatus(), 3);
    }
    return dialog.getReturnCode() == 2;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.SDKPolicy
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.ProfileScope;
import org.eclipse.equinox.p2.metadata.ILicense;
import org.eclipse.equinox.p2.ui.LicenseManager;
import org.osgi.service.prefs.Preferences;

public class SimpleLicenseManager
  extends LicenseManager
{
  Set<String> accepted = new HashSet();
  String profileId;
  
  public SimpleLicenseManager(String profileId)
  {
    this.profileId = profileId;
    initializeFromPreferences();
  }
  
  public SimpleLicenseManager()
  {
    this("_SELF_");
  }
  
  public boolean accept(ILicense license)
  {
    accepted.add(license.getUUID());
    updatePreferences();
    return true;
  }
  
  public boolean reject(ILicense license)
  {
    accepted.remove(license.getUUID());
    updatePreferences();
    return true;
  }
  
  public boolean isAccepted(ILicense license)
  {
    return accepted.contains(license.getUUID());
  }
  
  public boolean hasAcceptedLicenses()
  {
    return !accepted.isEmpty();
  }
  
  private Preferences getPreferences()
  {
    IAgentLocation location = (IAgentLocation)ProvSDKUIActivator.getDefault().getProvisioningAgent().getService(IAgentLocation.SERVICE_NAME);
    return new ProfileScope(location, profileId).getNode("org.eclipse.equinox.p2.ui.sdk");
  }
  
  private void initializeFromPreferences()
  {
    Preferences pref = getPreferences();
    if (pref != null)
    {
      String digestList = pref.get("licenseDigestList", "");
      StringTokenizer tokenizer = new StringTokenizer(digestList, ",");
      while (tokenizer.hasMoreTokens()) {
        accepted.add(tokenizer.nextToken().trim());
      }
    }
  }
  
  private void updatePreferences()
  {
    Preferences pref = getPreferences();
    StringBuffer result = new StringBuffer();
    Object[] indexedList = accepted.toArray();
    for (int i = 0; i < indexedList.length; i++)
    {
      if (i != 0) {
        result.append(",");
      }
      result.append((String)indexedList[i]);
    }
    pref.put("licenseDigestList", result.toString());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.equinox.p2.operations.RepositoryTracker;
import org.eclipse.equinox.p2.operations.UpdateOperation;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.Policy;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.MessageDialog;

public class UpdateHandler
  extends PreloadingRepositoryHandler
{
  boolean hasNoRepos = false;
  UpdateOperation operation;
  
  protected void doExecute(LoadMetadataRepositoryJob job)
  {
    if (hasNoRepos)
    {
      if (getProvisioningUI().getPolicy().getRepositoriesVisible())
      {
        boolean goToSites = MessageDialog.openQuestion(getShell(), ProvSDKMessages.UpdateHandler_NoSitesTitle, ProvSDKMessages.UpdateHandler_NoSitesMessage);
        if (goToSites) {
          getProvisioningUI().manipulateRepositories(getShell());
        }
      }
      return;
    }
    job.reportAccumulatedStatus();
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
      getProvisioningUI().openUpdateWizard(false, operation, job);
    }
  }
  
  protected void doPostLoadBackgroundWork(IProgressMonitor monitor)
    throws OperationCanceledException
  {
    operation = getProvisioningUI().getUpdateOperation(null, null);
    
    IStatus resolveStatus = operation.resolveModal(monitor);
    if (resolveStatus.getSeverity() == 8) {
      throw new OperationCanceledException();
    }
  }
  
  protected boolean preloadRepositories()
  {
    hasNoRepos = false;
    RepositoryTracker repoMan = getProvisioningUI().getRepositoryTracker();
    if (repoMan.getKnownRepositories(getProvisioningUI().getSession()).length == 0)
    {
      hasNoRepos = true;
      return false;
    }
    return super.preloadRepositories();
  }
  
  protected String getProgressTaskName()
  {
    return ProvSDKMessages.UpdateHandler_ProgressTaskName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.UpdateHandler
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk.prefs;

public class PreferenceConstants
{
  public static final String PREF_PAGE_PROVISIONING = "org.eclipse.equinox.internal.p2.ui.sdk.ProvisioningPreferencePage";
  public static final String PREF_PAGE_SITES = "org.eclipse.equinox.internal.p2.ui.sdk.SitesPreferencePage";
  public static final String PREF_SHOW_LATEST_VERSION = "showLatestVersion";
  public static final String PREF_OPEN_WIZARD_ON_ERROR_PLAN = "allowNonOKPlan";
  public static final String PREF_LICENSE_DIGESTS = "licenseDigestList";
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.ui.sdk.prefs.PreferenceConstants
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.ui.sdk.prefs;

import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKMessages;
import org.eclipse.equinox.internal.p2.ui.sdk.ProvSDKUIActivator;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.engine.ProfileScope;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;

public class PreferenceInitializer
  extends AbstractPreferenceInitializer
{
  public static void migratePreferences()
  {
    Preferences pref = new ProfileScope(getDefaultAgentLocation(), "_SELF_").getNode("org.eclipse.equinox.p2.ui.sdk");
    try
    {
      if (pref.keys().length == 0)
      {
        Preferences oldPref = new InstanceScope().getNode("org.eclipse.equinox.p2.ui.sdk");
        
        pref.put("allowNonOKPlan", oldPref.get("allowNonOKPlan", "prompt"));
        pref.putBoolean("showLatestVersion", oldPref.getBoolean("showLatestVersion", true));
        pref.flush();
      }
    }
    catch (BackingStoreException e)
    {
      StatusManager.getManager().handle(new Status(4, "org.eclipse.equinox.p2.ui.sdk", 0, ProvSDKMessages.PreferenceInitializer_Error, e), 1);
    }
  }
  
  public void initializeDefaultPreferences()
  {
    Preferences node = new DefaultScope().getNode("org.eclipse.equinox.p2.ui.sdk");
    
    node.putBoolean("showLatestVersion", true);
    node.put("allowNonOKPlan", "prompt");
  }
  
  private static IAgentLocation getDefaultAgentLocation()
  {
    ServiceReference<?> reference = ProvSDKUIActivator.getContext().getServiceReference(IAgentLocat
1 2

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