protected void setImagesToModel(UnitVmModel model, List<String> images) {
   String oldCdImage = model.getCdImage().getSelectedItem();
   model.getCdImage().setItems(images);
   model
       .getCdImage()
       .setSelectedItem((oldCdImage != null) ? oldCdImage : Linq.firstOrDefault(images));
 }
 private void doUpdateTimeZone(final String selectedTimeZone) {
   final Collection<TimeZoneModel> timeZones = TimeZoneModel.getTimeZones(getTimeZoneType());
   getModel().getTimeZone().setItems(timeZones);
   getModel()
       .getTimeZone()
       .setSelectedItem(
           Linq.firstOrDefault(timeZones, new Linq.TimeZonePredicate(selectedTimeZone)));
 }
Esempio n. 3
0
  public void postUpdateHost(Collection<VDS> hosts) {
    // Filter hosts
    hosts = Linq.where(hosts, new Linq.HostStatusPredicate(VDSStatus.Up));

    // Allow only hosts with version above 2.2 for export storage.
    ArrayList<VDS> list = new ArrayList<VDS>();
    if (getCurrentStorageItem() != null
        && getCurrentStorageItem().getRole() == StorageDomainType.ImportExport) {
      for (VDS host : hosts) {
        if (host.getVdsGroupCompatibilityVersion().compareTo(new Version("2.2"))
            >= 0) { //$NON-NLS-1$
          list.add(host);
        }
      }
      hosts = list;
    }

    VDS oldSelectedItem = getHost().getSelectedItem();
    VDS selectedItem = null;

    // On Edit of active storage - only SPM is available. In edit of storage in maintenance,
    // any host can perform the operation, thus no need to filter to use just the SPM
    if (getStorage() != null && getStorage().getStatus() != StorageDomainStatus.Maintenance) {
      VDS spm = getSPM(hosts);
      hosts = spm != null ? Collections.singletonList(spm) : Collections.<VDS>emptyList();
    }

    // Try to select previously selected host.
    if (oldSelectedItem != null) {
      selectedItem = Linq.firstOrDefault(hosts, new Linq.HostPredicate(oldSelectedItem.getId()));
    }

    // Select a default - if there's a SPM choose it, otherwise choose the first host in the list.
    if (selectedItem == null) {
      VDS spm = getSPM(hosts);
      selectedItem = spm == null ? Linq.firstOrDefault(hosts) : spm;
    }

    getHost().setItems(hosts, selectedItem);
  }
 protected void doChangeDefautlHost(Guid hostGuid) {
   if (hostGuid != null) {
     Guid vdsId = hostGuid;
     if (getModel().getDefaultHost().getItems() != null) {
       getModel()
           .getDefaultHost()
           .setSelectedItem(
               Linq.firstOrDefault(
                   getModel().getDefaultHost().getItems(), new Linq.HostPredicate(vdsId)));
     }
     getModel().getIsAutoAssign().setEntity(false);
   } else {
     getModel().getIsAutoAssign().setEntity(true);
   }
 }
  public ArrayList<StorageDomain> filterStorageDomains(ArrayList<StorageDomain> storageDomains) {
    // filter only the Active storage domains (Active regarding the relevant storage pool).
    ArrayList<StorageDomain> list = new ArrayList<StorageDomain>();
    for (StorageDomain a : storageDomains) {
      if (Linq.isDataActiveStorageDomain(a)) {
        list.add(a);
      }
    }

    // Filter according to system tree selection.
    if (getSystemTreeSelectedItem() != null
        && getSystemTreeSelectedItem().getType() == SystemTreeItemType.Storage) {
      StorageDomain selectStorage = (StorageDomain) getSystemTreeSelectedItem().getEntity();
      StorageDomain sd =
          Linq.firstOrDefault(list, new Linq.StoragePredicate(selectStorage.getId()));
      list = new ArrayList<StorageDomain>(Arrays.asList(new StorageDomain[] {sd}));
    }

    return list;
  }