示例#1
0
 public static void updateRepositoryUsingElements(
     final ProvisioningUI ui, final MetadataRepositoryElement[] elements) {
   ui.signalRepositoryOperationStart();
   IMetadataRepositoryManager metaManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
   IArtifactRepositoryManager artManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
   try {
     int visibilityFlags = ui.getRepositoryTracker().getMetadataRepositoryFlags();
     URI[] currentlyEnabled = metaManager.getKnownRepositories(visibilityFlags);
     URI[] currentlyDisabled =
         metaManager.getKnownRepositories(
             IRepositoryManager.REPOSITORIES_DISABLED | visibilityFlags);
     for (int i = 0; i < elements.length; i++) {
       URI location = elements[i].getLocation();
       if (elements[i].isEnabled()) {
         if (containsURI(currentlyDisabled, location))
           // It should be enabled and is not currently
           setColocatedRepositoryEnablement(ui, location, true);
         else if (!containsURI(currentlyEnabled, location)) {
           // It is not known as enabled or disabled.  Add it.
           metaManager.addRepository(location);
           artManager.addRepository(location);
         }
       } else {
         if (containsURI(currentlyEnabled, location))
           // It should be disabled, and is currently enabled
           setColocatedRepositoryEnablement(ui, location, false);
         else if (!containsURI(currentlyDisabled, location)) {
           // It is not known as enabled or disabled.  Add it and then disable it.
           metaManager.addRepository(location);
           artManager.addRepository(location);
           setColocatedRepositoryEnablement(ui, location, false);
         }
       }
       String name = elements[i].getName();
       if (name != null && name.length() > 0) {
         metaManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
         artManager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
       }
     }
     // Are there any elements that need to be deleted?  Go over the original state
     // and remove any elements that weren't in the elements we were given
     Set<String> nowKnown = new HashSet<String>();
     for (int i = 0; i < elements.length; i++)
       nowKnown.add(URIUtil.toUnencodedString(elements[i].getLocation()));
     for (int i = 0; i < currentlyEnabled.length; i++) {
       if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyEnabled[i]))) {
         metaManager.removeRepository(currentlyEnabled[i]);
         artManager.removeRepository(currentlyEnabled[i]);
       }
     }
     for (int i = 0; i < currentlyDisabled.length; i++) {
       if (!nowKnown.contains(URIUtil.toUnencodedString(currentlyDisabled[i]))) {
         metaManager.removeRepository(currentlyDisabled[i]);
         artManager.removeRepository(currentlyDisabled[i]);
       }
     }
   } finally {
     ui.signalRepositoryOperationComplete(null, true);
   }
 }
示例#2
0
  /** Tests the wizard when the uninstall is preresolved. This is the normal SDK workflow. */
  public void testUninstallWizardResolved() {
    ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>();
    iusInvolved.add(top1);
    iusInvolved.add(top2);
    UninstallOperation op = getProvisioningUI().getUninstallOperation(iusInvolved, null);
    op.resolveModal(getMonitor());
    UninstallWizard wizard = new UninstallWizard(getProvisioningUI(), op, iusInvolved, null);
    WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
    dialog.setBlockOnOpen(false);
    dialog.create();
    dialog.open();
    ProfileModificationJob longOp = null;

    try {
      SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
      // We should have a good plan
      assertTrue(page1.isPageComplete());
      ResolutionResultsWizardPage page2 = (ResolutionResultsWizardPage) wizard.getNextPage(page1);
      dialog.showPage(page2);
      assertTrue(page2.isPageComplete());

      // if another operation is scheduled for this profile, we should not be allowed to proceed
      longOp = getLongTestOperation();
      getProvisioningUI().schedule(longOp, StatusManager.LOG);
      assertTrue(page1.isPageComplete());
      // causes recalculation of plan and status
      wizard.recomputePlan(dialog);
      // can't move to next page while op is running
      assertFalse(page1.isPageComplete());
      longOp.cancel();
    } finally {
      dialog.getShell().close();
      if (longOp != null) longOp.cancel();
    }
  }
示例#3
0
 public static List<IInstallableUnit> elementsToIUs(Object[] elements) {
   ArrayList<IInstallableUnit> theIUs = new ArrayList<IInstallableUnit>(elements.length);
   for (int i = 0; i < elements.length; i++) {
     IInstallableUnit iu = ProvUI.getAdapter(elements[i], IInstallableUnit.class);
     if (iu != null) theIUs.add(iu);
   }
   return theIUs;
 }
示例#4
0
  /**
   * Tests the wizard without the resolution having been done ahead of time. This is not the SDK
   * workflow, but should be supported.
   */
  public void testUninstallWizardUnresolved() {
    // This test is pretty useless right now but at least it opens the wizard
    ArrayList<IInstallableUnit> iusInvolved = new ArrayList<IInstallableUnit>();
    iusInvolved.add(top1);
    iusInvolved.add(top2);
    UninstallOperation operation = getProvisioningUI().getUninstallOperation(iusInvolved, null);
    UninstallWizard wizard = new UninstallWizard(getProvisioningUI(), operation, iusInvolved, null);
    WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard);
    dialog.setBlockOnOpen(false);
    dialog.create();
    dialog.open();

    try {
      SelectableIUsPage page1 = (SelectableIUsPage) wizard.getPage(SELECTION_PAGE);
      assertTrue(page1.isPageComplete());
      // Should be able to resolve a plan
      wizard.recomputePlan(dialog);
      // Still ok
      assertTrue(page1.isPageComplete());

    } finally {
      dialog.getShell().close();
    }
  }
示例#5
0
 public static IInstallableUnit getIU(Object element) {
   if (element instanceof IInstallableUnit) return (IInstallableUnit) element;
   if (element instanceof IIUElement) return ((IIUElement) element).getIU();
   return ProvUI.getAdapter(element, IInstallableUnit.class);
 }
示例#6
0
 private static void setColocatedRepositoryEnablement(
     ProvisioningUI ui, URI location, boolean enable) {
   ProvUI.getArtifactRepositoryManager(ui.getSession()).setEnabled(location, enable);
   ProvUI.getMetadataRepositoryManager(ui.getSession()).setEnabled(location, enable);
 }
示例#7
0
 public static IInstallableUnit elementToIU(Object selectedElement) {
   return ProvUI.getAdapter(selectedElement, IInstallableUnit.class);
 }