org.eclipse.equinox.p2.ui.importexport_1.0.1.v20120913-155635

38: invokeinterface 620 1 0
    //   1043: aload 15
    //   1045: athrow
    //   1046: aload_1
    //   1047: invokeinterface 620 1 0
    //   1052: iload_3
    //   1053: ireturn
    // Line number table:
    //   Java source line #107	-> byte code offset #0
    //   Java source line #110	-> byte code offset #7
    //   Java source line #111	-> byte code offset #16
    //   Java source line #123	-> byte code offset #26
    //   Java source line #124	-> byte code offset #31
    //   Java source line #127	-> byte code offset #42
    //   Java source line #128	-> byte code offset #59
    //   Java source line #131	-> byte code offset #60
    //   Java source line #129	-> byte code offset #67
    //   Java source line #130	-> byte code offset #69
    //   Java source line #131	-> byte code offset #71
    //   Java source line #132	-> byte code offset #78
    //   Java source line #131	-> byte code offset #81
    //   Java source line #132	-> byte code offset #88
    //   Java source line #134	-> byte code offset #91
    //   Java source line #136	-> byte code offset #96
    //   Java source line #139	-> byte code offset #100
    //   Java source line #140	-> byte code offset #109
    //   Java source line #155	-> byte code offset #119
    //   Java source line #156	-> byte code offset #124
    //   Java source line #158	-> byte code offset #135
    //   Java source line #159	-> byte code offset #150
    //   Java source line #160	-> byte code offset #152
    //   Java source line #161	-> byte code offset #159
    //   Java source line #160	-> byte code offset #162
    //   Java source line #163	-> byte code offset #172
    //   Java source line #165	-> byte code offset #178
    //   Java source line #167	-> byte code offset #181
    //   Java source line #168	-> byte code offset #194
    //   Java source line #169	-> byte code offset #204
    //   Java source line #171	-> byte code offset #207
    //   Java source line #173	-> byte code offset #220
    //   Java source line #174	-> byte code offset #229
    //   Java source line #175	-> byte code offset #240
    //   Java source line #176	-> byte code offset #247
    //   Java source line #177	-> byte code offset #256
    //   Java source line #178	-> byte code offset #265
    //   Java source line #181	-> byte code offset #270
    //   Java source line #182	-> byte code offset #281
    //   Java source line #183	-> byte code offset #310
    //   Java source line #185	-> byte code offset #370
    //   Java source line #189	-> byte code offset #371
    //   Java source line #190	-> byte code offset #379
    //   Java source line #193	-> byte code offset #380
    //   Java source line #187	-> byte code offset #386
    //   Java source line #189	-> byte code offset #388
    //   Java source line #190	-> byte code offset #396
    //   Java source line #193	-> byte code offset #397
    //   Java source line #194	-> byte code offset #400
    //   Java source line #189	-> byte code offset #403
    //   Java source line #190	-> byte code offset #411
    //   Java source line #193	-> byte code offset #412
    //   Java source line #195	-> byte code offset #415
    //   Java source line #196	-> byte code offset #423
    //   Java source line #197	-> byte code offset #426
    //   Java source line #199	-> byte code offset #433
    //   Java source line #200	-> byte code offset #445
    //   Java source line #201	-> byte code offset #454
    //   Java source line #203	-> byte code offset #459
    //   Java source line #204	-> byte code offset #465
    //   Java source line #206	-> byte code offset #472
    //   Java source line #208	-> byte code offset #475
    //   Java source line #209	-> byte code offset #480
    //   Java source line #210	-> byte code offset #498
    //   Java source line #211	-> byte code offset #507
    //   Java source line #212	-> byte code offset #515
    //   Java source line #213	-> byte code offset #541
    //   Java source line #214	-> byte code offset #559
    //   Java source line #215	-> byte code offset #568
    //   Java source line #216	-> byte code offset #576
    //   Java source line #217	-> byte code offset #602
    //   Java source line #220	-> byte code offset #623
    //   Java source line #221	-> byte code offset #631
    //   Java source line #222	-> byte code offset #632
    //   Java source line #223	-> byte code offset #639
    //   Java source line #224	-> byte code offset #644
    //   Java source line #225	-> byte code offset #660
    //   Java source line #226	-> byte code offset #676
    //   Java source line #227	-> byte code offset #693
    //   Java source line #228	-> byte code offset #698
    //   Java source line #229	-> byte code offset #711
    //   Java source line #230	-> byte code offset #718
    //   Java source line #231	-> byte code offset #727
    //   Java source line #232	-> byte code offset #734
    //   Java source line #234	-> byte code offset #745
    //   Java source line #235	-> byte code offset #766
    //   Java source line #236	-> byte code offset #773
    //   Java source line #237	-> byte code offset #782
    //   Java source line #238	-> byte code offset #802
    //   Java source line #234	-> byte code offset #808
    //   Java source line #242	-> byte code offset #818
    //   Java source line #243	-> byte code offset #835
    //   Java source line #244	-> byte code offset #847
    //   Java source line #245	-> byte code offset #854
    //   Java source line #246	-> byte code offset #905
    //   Java source line #247	-> byte code offset #923
    //   Java source line #248	-> byte code offset #950
    //   Java source line #250	-> byte code offset #971
    //   Java source line #252	-> byte code offset #979
    //   Java source line #253	-> byte code offset #980
    //   Java source line #258	-> byte code offset #994
    //   Java source line #259	-> byte code offset #996
    //   Java source line #260	-> byte code offset #1003
    //   Java source line #261	-> byte code offset #1012
    //   Java source line #262	-> byte code offset #1017
    //   Java source line #263	-> byte code offset #1022
    //   Java source line #265	-> byte code offset #1026
    //   Java source line #264	-> byte code offset #1035
    //   Java source line #265	-> byte code offset #1037
    //   Java source line #266	-> byte code offset #1043
    //   Java source line #265	-> byte code offset #1046
    //   Java source line #268	-> byte code offset #1052
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	1054	0	this	ImportFromInstallationPage
    //   0	1054	1	monitor	IProgressMonitor
    //   6	932	2	progress	org.eclipse.core.runtime.SubMonitor
    //   55	2	3	rt	boolean
    //   81	1	3	rt	boolean
    //   95	958	3	rt	boolean
    //   24	10	4	getSuperValidateDest	Callable<Boolean>
    //   145	3	4	destination	String
    //   162	1	4	destination	String
    //   176	754	4	destination	String
    //   29	53	5	executor	java.util.concurrent.ExecutorService
    //   117	10	5	getDestinationValue	Callable<String>
    //   179	523	5	toBeImportedProfileId	String
    //   40	3	6	getSuperDestTask	java.util.concurrent.Future<Boolean>
    //   122	41	6	executor	java.util.concurrent.ExecutorService
    //   192	42	6	config	File
    //   658	197	6	manager	IMetadataRepositoryManager
    //   69	10	7	localObject1	Object
    //   133	3	7	getDestTask	Object
    //   202	156	7	configArea	URI
    //   674	250	7	artifactManager	IArtifactRepositoryManager
    //   150	10	8	localObject2	Object
    //   205	209	8	is	Object
    //   691	28	8	registry	org.eclipse.equinox.p2.engine.IProfileRegistry
    //   218	268	9	p2DataArea	File
    //   725	21	9	existingProfiles	IProfile[]
    //   833	3	9	location	org.eclipse.equinox.p2.core.IAgentLocation
    //   227	30	10	props	java.util.Properties
    //   424	52	10	createAgent	boolean
    //   764	40	10	existingProfile	IProfile
    //   845	12	10	engineDataArea	URI
    //   263	81	11	url	String
    //   505	311	11	factory	org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory
    //   903	10	11	metaRepo	org.eclipse.equinox.p2.repository.metadata.IMetadataRepository
    //   386	15	12	localObject3	Object
    //   539	275	12	artiRepo	org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
    //   751	65	12	localArtifactRepositoryFactory1	org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory
    //   948	10	12	artiRepo	org.eclipse.equinox.p2.repository.artifact.IArtifactRepository
    //   566	194	13	metaFatory	org.eclipse.equinox.p2.repository.metadata.spi.MetadataRepositoryFactory
    //   600	10	14	metaRepo	org.eclipse.equinox.p2.repository.metadata.IMetadataRepository
    //   1035	9	15	localObject4	Object
    //   59	1	41	localException1	Exception
    //   370	1	42	localIOException1	java.io.IOException
    //   379	1	43	localIOException2	java.io.IOException
    //   396	1	44	localIOException3	java.io.IOException
    //   411	1	45	localIOException4	java.io.IOException
    //   631	1	46	localProvisionException	org.eclipse.equinox.p2.core.ProvisionException
    //   979	1	47	localException2	Exception
    // Exception table:
    //   from	to	target	type
    //   42	56	59	java/lang/Exception
    //   42	60	69	finally
    //   135	150	150	finally
    //   220	367	370	java/io/IOException
    //   371	376	379	java/io/IOException
    //   220	371	386	finally
    //   388	393	396	java/io/IOException
    //   403	408	411	java/io/IOException
    //   181	631	631	org/eclipse/equinox/p2/core/ProvisionException
    //   100	979	979	java/lang/Exception
    //   100	1026	1035	finally
  }
  
  protected void giveFocusToDestination()
  {
    destinationBrowseButton.setFocus();
  }
  
  protected void handleDestinationBrowseButtonPressed()
  {
    DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell());
    dialog.setText(getDialogTitle());
    dialog.setFilterPath(getDestinationValue());
    String selectedFileName = dialog.open();
    if (selectedFileName != null) {
      setDestinationValue(selectedFileName);
    }
  }
  
  protected void handleDestinationChanged(String newDestination)
  {
    try
    {
      getContainer().run(true, false, new IRunnableWithProgress()
      {
        public void run(IProgressMonitor monitor)
        {
          Object input = null;
          if (validateDestinationGroup(monitor))
          {
            final IProfile currentProfile = toBeImportedProfile;
            ProfileElement element = new ProfileElement(null, currentProfile.getProfileId())
            {
              public IQueryable<?> getQueryable()
              {
                return currentProfile;
              }
            };
            element.setQueryable(currentProfile);
            input = element;
          }
          final Object viewerInput = input;
          Display.getDefault().asyncExec(new Runnable()
          {
            public void run()
            {
              viewer.setInput(viewerInput);
              updatePageCompletion();
            }
          });
        }
      });
    }
    catch (InvocationTargetException e)
    {
      setErrorMessage(e.getLocalizedMessage());
      setPageComplete(false);
    }
    catch (InterruptedException localInterruptedException) {}
  }
  
  protected boolean validDestination()
  {
    if (destinationNameField == null) {
      return true;
    }
    File file = new File(getDestinationValue());
    return (file.exists()) && (file.isDirectory());
  }
  
  class ImportFromInstallationLabelProvider
    extends IUDetailsLabelProvider
  {
    ImportFromInstallationLabelProvider() {}
    
    public String getColumnText(Object element, int columnIndex)
    {
      String text = super.getColumnText(element, columnIndex);
      if (columnIndex == 0)
      {
        Class tmp15_12 = ImportFromInstallationPage.class$0;
        if (tmp15_12 == null)
        {
          tmp15_12;
          try
          {
            tmpTernaryOp = (ImportFromInstallationPage.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
          }
          catch (ClassNotFoundException localClassNotFoundException)
          {
            throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
          }
        }
        IInstallableUnit iu = (IInstallableUnit)ProvUI.getAdapter(element, tmp15_12);
        return getIUNameWithDetail(iu);
      }
      return text;
    }
    
    public Color getForeground(Object element)
    {
      Class tmp4_1 = ImportFromInstallationPage.class$0;
      if (tmp4_1 == null)
      {
        tmp4_1;
        try
        {
          tmpTernaryOp = (ImportFromInstallationPage.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
        }
      }
      IInstallableUnit iu = (IInstallableUnit)ProvUI.getAdapter(element, tmp4_1);
      if (hasInstalled(iu)) {
        return Display.getDefault().getSystemColor(15);
      }
      return super.getForeground(element);
    }
  }
  
  protected ITableLabelProvider getLabelProvider()
  {
    return new ImportFromInstallationLabelProvider();
  }
  
  public void dispose()
  {
    super.dispose();
    if (otherInstanceAgent != null)
    {
      otherInstanceAgent.stop();
      otherInstanceAgent = null;
      toBeImportedProfile = null;
    }
    if (getWizard().performCancel()) {
      cleanLocalRepository();
    }
  }
  
  public void cleanLocalRepository()
  {
    if ((metaURIs != null) && (metaURIs.length > 0))
    {
      IProvisioningAgent runningAgent = getProvisioningUI().getSession().getProvisioningAgent();
      IMetadataRepositoryManager manager = (IMetadataRepositoryManager)runningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
      URI[] arrayOfURI1;
      int j = (arrayOfURI1 = metaURIs).length;
      for (int i = 0; i < j; i++)
      {
        URI uri = arrayOfURI1[i];
        manager.removeRepository(uri);
      }
      IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager)runningAgent.getService(IArtifactRepositoryManager.SERVICE_NAME);
      URI[] arrayOfURI2;
      int k = (arrayOfURI2 = artiURIs).length;
      for (j = 0; j < k; j++)
      {
        URI uri = arrayOfURI2[j];
        artifactManager.removeRepository(uri);
      }
    }
  }
  
  public Object[] getCheckedIUElements()
  {
    return viewer.getCheckedElements();
  }
  
  public Object[] getSelectedIUElements()
  {
    return null;
  }
  
  public void setCheckedElements(Object[] elements)
  {
    new UnsupportedOperationException();
  }
  
  public ProvisioningContext getProvisioningContext()
  {
    ProvisioningContext context = new ProvisioningContext(getProvisioningUI().getSession().getProvisioningAgent());
    context.setArtifactRepositories(artiURIs);
    context.setMetadataRepositories(metaURIs);
    return context;
  }
}

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

import java.util.Collection;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.internal.p2.importexport.internal.ImportExportActivator;
import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
import org.eclipse.equinox.internal.p2.ui.dialogs.InstallWizard;
import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.InstallOperation;
import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.osgi.framework.Bundle;

public class ImportFromInstallationWizard
  extends InstallWizard
  implements IImportWizard
{
  public ImportFromInstallationWizard()
  {
    this(ProvisioningUI.getDefaultUI(), null, null, null);
  }
  
  public ImportFromInstallationWizard(ProvisioningUI ui, InstallOperation operation, Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob preloadJob)
  {
    super(ui, operation, initialSelections, preloadJob);
    IDialogSettings workbenchSettings = ImportExportActivator.getDefault().getDialogSettings();
    String sectionName = "ImportFromInstallationWizard";
    IDialogSettings section = workbenchSettings.getSection(sectionName);
    if (section == null) {
      section = workbenchSettings.addNewSection(sectionName);
    }
    setDialogSettings(section);
  }
  
  public void init(IWorkbench workbench, IStructuredSelection selection)
  {
    setWindowTitle(Messages.ImportWizard_WINDOWTITLE);
    setDefaultPageImageDescriptor(ImageDescriptor.createFromURL(Platform.getBundle("org.eclipse.equinox.p2.ui.importexport").getEntry("icons/install_wiz.gif")));
    setNeedsProgressMonitor(true);
  }
  
  protected ISelectableIUsPage createMainPage(IUElementListRoot input, Object[] selections)
  {
    return new ImportFromInstallationPage(ui, this);
  }
  
  protected ProvisioningContext getProvisioningContext()
  {
    return ((ImportFromInstallationPage)mainPage).getProvisioningContext();
  }
}

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

import org.eclipse.jface.viewers.CheckboxTreeViewer;

class ImportPage$GetCheckedElement
  implements Runnable
{
  Object[] checkedElements = null;
  final ImportPage this$0;
  
  ImportPage$GetCheckedElement(ImportPage paramImportPage) {}
  
  public void run()
  {
    checkedElements = this$0.viewer.getCheckedElements();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.internal.wizard.ImportPage.GetCheckedElement
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

class ImportPage$InstallationContentProvider
  implements ITreeContentProvider
{
  final ImportPage this$0;
  
  ImportPage$InstallationContentProvider(ImportPage paramImportPage) {}
  
  public void dispose() {}
  
  public Object[] getElements(Object inputElement)
  {
    return (Object[])inputElement;
  }
  
  public void inputChanged(Viewer viewer1, Object oldInput, Object newInput) {}
  
  public Object[] getChildren(Object parentElement)
  {
    return new Object[0];
  }
  
  public Object getParent(Object element)
  {
    return null;
  }
  
  public boolean hasChildren(Object element)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.internal.wizard.ImportPage.InstallationContentProvider
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;

import org.eclipse.equinox.internal.p2.importexport.IUDetail;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;

class ImportPage$InstallationLabelProvider
  extends LabelProvider
  implements ITableLabelProvider, IColorProvider
{
  final ImportPage this$0;
  
  ImportPage$InstallationLabelProvider(ImportPage paramImportPage) {}
  
  public Image getColumnImage(Object element, int columnIndex)
  {
    return null;
  }
  
  public String getColumnText(Object element, int columnIndex)
  {
    IInstallableUnit iu = ((IUDetail)element).getIU();
    switch (columnIndex)
    {
    case 0: 
      return this$0.getIUNameWithDetail(iu);
    case 1: 
      return iu.getVersion().toString();
    case 2: 
      return iu.getId();
    }
    throw new RuntimeException("Should not happen");
  }
  
  public Color getForeground(Object element)
  {
    Class tmp8_5 = ImportPage.class$0;
    if (tmp8_5 == null)
    {
      tmp8_5;
      try
      {
        tmpTernaryOp = (ImportPage.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
      }
    }
    if (this$0.hasInstalled((IInstallableUnit)ProvUI.getAdapter(element, tmp8_5))) {
      return Display.getDefault().getSystemColor(15);
    }
    return null;
  }
  
  public Color getBackground(Object element)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.internal.wizard.ImportPage.InstallationLabelProvider
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;

import org.eclipse.equinox.internal.p2.importexport.IUDetail;
import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.PatternFilter;

class ImportPage$P2ImportIUPatternFilter
  extends PatternFilter
{
  boolean checkName;
  boolean checkVersion;
  boolean checkId = false;
  String patternString;
  final ImportPage this$0;
  
  public ImportPage$P2ImportIUPatternFilter(ImportPage arg1, IUColumnConfig[] columnConfig)
  {
    for (int i = 0; i < columnConfig.length; i++)
    {
      int field = columnConfig[i].getColumnType();
      if (field == 0) {
        checkId = true;
      } else if (field == 1) {
        checkName = true;
      } else if (field == 2) {
        checkVersion = true;
      }
    }
  }
  
  public boolean isElementSelectable(Object element)
  {
    return element instanceof IUDetail;
  }
  
  public void setPattern(String patternString)
  {
    super.setPattern(patternString);
    this.patternString = patternString;
  }
  
  protected boolean isParentMatch(Viewer viewer1, Object element)
  {
    if ((patternString == null) || (patternString.length() == 0)) {
      return true;
    }
    return super.isParentMatch(viewer1, element);
  }
  
  protected boolean isLeafMatch(Viewer viewer1, Object element)
  {
    String text = null;
    if ((element instanceof IUDetail))
    {
      IInstallableUnit iu = ((IUDetail)element).getIU();
      if (checkName)
      {
        text = iu.getProperty("org.eclipse.equinox.p2.name", null);
        if ((text != null) && (wordMatches(text))) {
          return true;
        }
      }
      if ((checkId) || ((checkName) && (text == null)))
      {
        text = iu.getId();
        if (wordMatches(text)) {
          return true;
        }
      }
      if (checkVersion)
      {
        text = iu.getVersion().toString();
        if (wordMatches(text)) {
          return true;
        }
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.internal.wizard.ImportPage.P2ImportIUPatternFilter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.importexport.internal.wizard;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.equinox.internal.p2.importexport.IUDetail;
import org.eclipse.equinox.internal.p2.importexport.P2ImportExport;
import org.eclipse.equinox.internal.p2.importexport.VersionIncompatibleException;
import org.eclipse.equinox.internal.p2.importexport.internal.Messages;
import org.eclipse.equinox.internal.p2.ui.ProvUI;
import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.dialogs.ISelectableIUsPage;
import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard;
import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.engine.ProvisioningContext;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;
import org.eclipse.equinox.p2.query.CompoundQueryable;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.ui.ProvisioningUI;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.dialogs.PatternFilter;

public class ImportPage
  extends AbstractImportPage
  implements ISelectableIUsPage
{
  private List<IUDetail> features;
  
  class InstallationContentProvider
    implements ITreeContentProvider
  {
    InstallationContentProvider() {}
    
    public void dispose() {}
    
    public Object[] getElements(Object inputElement)
    {
      return (Object[])inputElement;
    }
    
    public void inputChanged(Viewer viewer1, Object oldInput, Object newInput) {}
    
    public Object[] getChildren(Object parentElement)
    {
      return new Object[0];
    }
    
    public Object getParent(Object element)
    {
      return null;
    }
    
    public boolean hasChildren(Object element)
    {
      return false;
    }
  }
  
  class InstallationLabelProvider
    extends LabelProvider
    implements ITableLabelProvider, IColorProvider
  {
    InstallationLabelProvider() {}
    
    public Image getColumnImage(Object element, int columnIndex)
    {
      return null;
    }
    
    public String getColumnText(Object element, int columnIndex)
    {
      IInstallableUnit iu = ((IUDetail)element).getIU();
      switch (columnIndex)
      {
      case 0: 
        return getIUNameWithDetail(iu);
      case 1: 
        return iu.getVersion().toString();
      case 2: 
        return iu.getId();
      }
      throw new RuntimeException("Should not happen");
    }
    
    public Color getForeground(Object element)
    {
      Class tmp8_5 = ImportPage.class$0;
      if (tmp8_5 == null)
      {
        tmp8_5;
        try
        {
          tmpTernaryOp = (ImportPage.class$0 = Class.forName("org.eclipse.equinox.p2.metadata.IInstallableUnit"));
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
        }
      }
      if (hasInstalled((IInstallableUnit)ProvUI.getAdapter(element, tmp8_5))) {
        return Display.getDefault().getSystemColor(15);
      }
      return null;
    }
    
    public Color getBackground(Object element)
    {
      return null;
    }
  }
  
  class P2ImportIUPatternFilter
    extends PatternFilter
  {
    boolean checkName;
    boolean checkVersion;
    boolean checkId = false;
    String patternString;
    
    public P2ImportIUPatternFilter(IUColumnConfig[] columnConfig)
    {
      for (int i = 0; i < columnConfig.length; i++)
      {
        int field = columnConfig[i].getColumnType();
        if (field == 0) {
          checkId = true;
        } else if (field == 1) {
          checkName = true;
        } else if (field == 2) {
          checkVersion = true;
        }
      }
    }
    
    public boolean isElementSelectable(Object element)
    {
      return element instanceof IUDetail;
    }
    
    public void setPattern(String patternString)
    {
      super.setPattern(patternString);
      this.patternString = patternString;
    }
    
    protected boolean isParentMatch(Viewer viewer1, Object element)
    {
      if ((patternString == null) || (patternString.length() == 0)) {
        return true;
      }
      return super.isParentMatch(viewer1, element);
    }
    
    protected boolean isLeafMatch(Viewer viewer1, Object element)
    {
      String text = null;
      if ((element instanceof IUDetail))
      {
        IInstallableUnit iu = ((IUDetail)element).getIU();
        if (checkName)
        {
          text = iu.getProperty("org.eclipse.equinox.p2.name", null);
          if ((text != null) && (wordMatches(text))) {
            return true;
          }
        }
        if ((checkId) || ((checkName) && (text == null)))
        {
          text = iu.getId();
          if (wordMatches(text)) {
            return true;
          }
        }
        if (checkVersion)
        {
          text = iu.getVersion().toString();
          if (wordMatches(text)) {
            return true;
          }
        }
      }
      return false;
    }
  }
  
  private final List<URI> loadRepos = new ArrayList();
  private final Map<IUDetail, IUDetail[]> newProposedFeature = new HashMap();
  private Button contactAll;
  private Button installLatest;
  private String oldDestination;
  static Class class$0;
  
  public ImportPage(ProvisioningUI ui, ProvisioningOperationWizard wizard)
  {
    super("importpage", ui, wizard);
    setTitle(Messages.ImportPage_TITLE);
    setDescription(Messages.ImportPage_DESCRIPTION);
  }
  
  protected void createContents(Composite composite)
  {
    createDestinationGroup(composite);
    createInstallationTable(composite);
    createAdditionOptions(composite);
  }
  
  private void createAdditionOptions(Composite parent)
  {
    Composite composite = new Composite(parent, 2048);
    GridLayout layout = new GridLayout();
    numColumns = 1;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(4, 4, true, false));
    
    contactAll = new Button(composite, 32);
    contactAll.setText(ProvUIMessages.AvailableIUsPage_ResolveAllCheckbox);
    
    installLatest = new Button(composite, 32);
    installLatest.setText(Messages.ImportPage_InstallLatestVersion);
    installLatest.setSelection(true);
  }
  
  protected ITreeContentProvider getContentProvider()
  {
    return new InstallationContentProvider();
  }
  
  protected ITableLabelProvider getLabelProvider()
  {
    return new InstallationLabelProvider();
  }
  
  protected int getBrowseDialogStyle()
  {
    return 4096;
  }
  
  protected String getDestinationLabel()
  {
    return Messages.ImportPage_DESTINATION_LABEL;
  }
  
  protected String getDialogTitle()
  {
    return Messages.ImportPage_FILEDIALOG_TITLE;
  }
  
  protected IUDetail[] getInput()
  {
    return new IUDetail[0];
  }
  
  protected String getInvalidDestinationMessage()
  {
    return Messages.ImportPage_DEST_ERROR;
  }
  
  protected void giveFocusToDestination()
  {
    destinationNameField.setFocus();
  }
  
  protected void updatePageCompletion()
  {
    super.updatePageCompletion();
    if (isPageComplete()) {
      getProvisioningWizard().operationSelectionsChanged(this);
    }
  }
  
  protected void handleDestinationChanged(String newDestination)
  {
    if (validateDestinationGroup())
    {
      if (!newDestination.equals(oldDestination))
      {
        loadRepos.clear();
        newProposedFeature.clear();
      }
      InputStream input = null;
      try
      {
        input = new BufferedInputStream(new FileInputStream(getDestinationValue()));
        features = importexportService.importP2F(input);
        viewer.setInput(features.toArray(new IUDetail[features.size()]));
        input.close();
      }
      catch (VersionIncompatibleException e)
      {
        MessageDialog.openWarning(getShell(), Messages.ImportPage_TITLE, e.getMessage());
      }
      catch (FileNotFoundException localFileNotFoundException)
      {
        MessageDialog.openError(getShell(), Messages.ImportPage_TITLE, Messages.ImportPage_FILENOTFOUND);
      }
      catch (IOException e)
      {
        MessageDialog.openError(getShell(), Messages.ImportPage_TITLE, e.getLocalizedMessage());
      }
    }
    else
    {
      viewer.setInput(null);
    }
  }
  
  protected void setDestinationValue(String selectedFileName)
  {
    oldDestination = getDestinationValue();
    super.setDestinationValue(selectedFileName);
  }
  
  protected boolean validDestination()
  {
    File target = new File(getDestinationValue());
    return (super.validDestination()) && (target.exists()) && (target.canRead());
  }
  
  public Object[] getCheckedIUElements()
  {
    Object[] checked = viewer.getCheckedElements();
    List<IUDetail> checkedFeatures = new ArrayList(checked.length);
    for (int i = 0; i < checked.length; i++)
    {
      IUDetail feature = (IUDetail)checked[i];
      IUDetail[] existingFeatures = (IUDetail[])newProposedFeature.get(feature);
      if (existingFeatures == null)
      {
        checkedFeatures.add(feature);
      }
      else
      {
        IUDetail matchPolicy = null;
        IUDetail[] arrayOfIUDetail1;
        int j = (arrayOfIUDetail1 = existingFeatures).length;
        for (int i = 0; i < j; i++)
        {
          IUDetail f = arrayOfIUDetail1[i];
          if (matchPolicy == null) {
            matchPolicy = f;
          } else if (matchPolicy.getIU().getVersion().compareTo(f.getIU().getVersion()) < 0)
          {
            if (installLatest.getSelection()) {
              matchPolicy = f;
            }
          }
          else {
            matchPolicy = f;
          }
        }
        if (matchPolicy != null) {
          checkedFeatures.add(matchPolicy);
        }
      }
    }
    return checkedFeatures.toArray(new IUDetail[checkedFeatures.size()]);
  }
  
  public Object[] getSelectedIUElements()
  {
    return null;
  }
  
  public void setCheckedElements(Object[] elements)
  {
    new UnsupportedOperationException();
  }
  
  public ProvisioningContext getProvisioningContext()
  {
    if (agent != null)
    {
      Object[] checked = viewer.getCheckedElements();
      List<URI> referredRepos = new ArrayList(checked.length);
      Object[] arrayOfObject1;
      int j = (arrayOfObject1 = checked).length;
      for (int i = 0; i < j; i++)
      {
        Object checkItem = arrayOfObject1[i];
        IUDetail feature = (IUDetail)checkItem;
        for (Iterator localIterator = feature.getReferencedRepositories().iterator(); localIterator.hasNext();)
        {
          URI uri = (URI)localIterator.next();
          referredRepos.add(uri);
        }
      }
      ProvisioningContext context = new ProvisioningContext(agent);
      if (!contactAll.getSelection())
      {
        context.setArtifactRepositories((URI[])referredRepos.toArray(new URI[referredRepos.size()]));
        context.setMetadataRepositories((URI[])referredRepos.toArray(new URI[referredRepos.size()]));
      }
      return context;
    }
    return null;
  }
  
  public boolean hasUnloadedRepo()
  {
    Object[] arrayOfObject;
    int j = (arrayOfObject = viewer.getCheckedElements()).length;
    for (int i = 0; i < j; i++)
    {
      Object checked = arrayOfObject[i];
      IUDetail feature = (IUDetail)checked;
      for (Iterator localIterator = feature.getReferencedRepositories().iterator(); localIterator.hasNext();)
      {
        URI uri = (URI)localIterator.next();
        if (!loadRepos.contains(uri)) {
          return true;
        }
      }
    }
    return false;
  }
  
  class GetCheckedElement
    implements Runnable
  {
    Object[] checkedElements = null;
    
    GetCheckedElement() {}
    
    public void run()
    {
      checkedElements = viewer.getCheckedElements();
    }
  }
  
  public Object[] getChecked()
  {
    if (Display.findDisplay(Thread.currentThread()) != null) {
      return viewer.getCheckedElements();
    }
    GetCheckedElement get = new GetCheckedElement();
    Display.getDefault().syncExec(get);
    return checkedElements;
  }
  
  public void recompute(IProgressMonitor monitor)
    throws InterruptedException
  {
    SubMonitor sub = SubMonitor.convert(monitor, Messages.ImportPage_QueryFeaturesJob, 1000);
    if (agent != null)
    {
      IMetadataRepositoryManager metaManager = (IMetadataRepositoryManager)agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
      IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
      Object[] checked = getChecked();
      sub.setWorkRemaining(100 * checked.length);
      Object[] arrayOfObject1;
      int j = (arrayOfObject1 = checked).length;
      for (int i = 0; i < j; i++)
      {
        Object item = arrayOfObject1[i];
        IUDetail feature = (IUDetail)item;
        if (!newProposedFeature.containsKey(feature))
        {
          if (sub.isCanceled()) {
            throw new InterruptedException();
          }
          SubMonitor sub2 = sub.newChild(100, 7);
          sub2.setWorkRemaining(feature.getReferencedRepositories().size() * 500 + 100);
          List<IRepository<IInstallableUnit>> repos = new ArrayList();
          for (Iterator localIterator1 = feature.getReferencedRepositories().iterator(); localIterator1.hasNext();)
          {
            URI uri = (URI)localIterator1.next();
            if (!metaManager.contains(uri)) {
              metaManager.addRepository(uri);
            }
            metaManager.setEnabled(uri, true);
            try
            {
              repos.add(metaManager.loadRepository(uri, sub2.newChild(500)));
            }
            catch (ProvisionException e)
            {
              e.printStackTrace();
            }
            catch (OperationCanceledException e)
            {
              throw new InterruptedException(e.getLocalizedMessage());
            }
            if (!artifactManager.contains(uri)) {
              artifactManager.addRepository(uri);
            }
            artifactManager.setEnabled(uri, true);
          }
          if (sub2.isCanceled()) {
            throw new InterruptedException();
          }
          Set<IInstallableUnit> result = new CompoundQueryable((IQueryable[])repos.toArray(new IRepository[repos.size()])).query(QueryUtil.createIUQuery(feature.getIU().getId(), new VersionRange(feature.getIU().getVersion(), true, null, false)), sub2
1 2 3 4 5 6

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