/**
  * Answers all available programs in the operating system. Note that a <code>Display</code> must
  * already exist to guarantee that this method returns an appropriate result.
  *
  * @return an array of programs
  */
 public static Program[] getPrograms() {
   NSAutoreleasePool pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init();
   try {
     List<Program> vector = new ArrayList<>();
     NSWorkspace workspace = NSWorkspace.sharedWorkspace();
     NSArray array =
         new NSArray(
             OS.NSSearchPathForDirectoriesInDomains(
                 OS.NSAllApplicationsDirectory, OS.NSAllDomainsMask, true));
     int count = (int) /*64*/ array.count();
     for (int i = 0; i < count; i++) {
       NSString path = new NSString(array.objectAtIndex(i));
       NSFileManager fileManager = NSFileManager.defaultManager();
       NSDirectoryEnumerator enumerator = fileManager.enumeratorAtPath(path);
       if (enumerator != null) {
         id id;
         while ((id = enumerator.nextObject()) != null) {
           enumerator.skipDescendents();
           NSString fullPath = path.stringByAppendingPathComponent(new NSString(id.id));
           if (workspace.isFilePackageAtPath(fullPath)) {
             NSBundle bundle = NSBundle.bundleWithPath(fullPath);
             if (bundle != null) {
               Program program = getProgram(bundle);
               if (program != null) vector.add(program);
             }
           }
         }
       }
     }
     return vector.toArray(new Program[vector.size()]);
   } finally {
     pool.release();
   }
 }
Example #2
0
    public NSArray statementsToDropPrimaryKeyConstraintsOnEntityGroups(
        NSArray entityGroups,
        EOSchemaSynchronizationModelChanges changes,
        EOSchemaGenerationOptions options) {
      if (entityGroups == null) return NSArray.EmptyArray;
      if (changes == null) changes = newChanges();

      NSMutableArray expressions = new NSMutableArray();
      for (Enumeration enumerator = entityGroups.objectEnumerator();
          enumerator.hasMoreElements(); ) {
        NSArray entities = (NSArray) enumerator.nextElement();
        EOEntity _last =
            (EOEntity)
                entities.lastObject(); // only need entity to get the table name for the group
        String nameInObjectStore =
            _nameInObjectStoreForEntityGroupWithChangeDictionary(
                entities, changes.changesForTableNamed(_last.externalName()));
        if ((nameInObjectStore != null) && (!"".equals(nameInObjectStore))) {
          expressions.addObject(
              this._expressionForString(
                  "delete from _SYS_RELATIONSHIP where source_table = '"
                      + nameInObjectStore
                      + "' or dest_table = '"
                      + nameInObjectStore
                      + "'"));
        }
      }
      return expressions.immutableClone();
    }
Example #3
0
 public boolean listIsEmpty() {
   NSArray list = found;
   if (list != null && list.count() > 0) return false;
   list = (NSArray) valueForBinding("forcedList");
   if (list != null && list.count() > 0) return false;
   list = personList();
   if (list != null && list.count() > 0) return false;
   return true;
 }
Example #4
0
 /*
  * [PJYF Oct 19 2004]
  * This is a bad hack to get WO to create indes for external keys.
  * We use the primary key constrain generation to create our indexes.
  * But we need to be carefull not to overwrite previous constrains
  *
  */
 protected boolean isSinglePrimaryKeyAttribute(EOAttribute attribute) {
   if (attribute == null) return false;
   EOEntity entity = (EOEntity) attribute.entity();
   if ((entity == null) || entity.isAbstractEntity() || (entity.externalName() == null))
     return false;
   NSArray primaryKeyAttributes = entity.primaryKeyAttributes();
   if (primaryKeyAttributes.count() != 1) return false;
   return attribute.name().equals(((EOAttribute) primaryKeyAttributes.lastObject()).name());
 }
 /**
  * Look up an object by id number. Assumes the editing context is appropriately locked.
  *
  * @param ec The editing context to use
  * @param id The id to look up
  * @return The object, or null if no such id exists
  */
 public static UserMessageSubscription forId(EOEditingContext ec, int id) {
   UserMessageSubscription obj = null;
   if (id > 0) {
     NSArray<UserMessageSubscription> objects = objectsMatchingValues(ec, "id", new Integer(id));
     if (objects != null && objects.count() > 0) {
       obj = objects.objectAtIndex(0);
     }
   }
   return obj;
 }
 @MarshalsPointer
 public static long toNative(List<NSURLProtectionSpaceProxyType> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (NSURLProtectionSpaceProxyType o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<CNInstantMessageAddressPropertyKey> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (CNInstantMessageAddressPropertyKey o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<MPMoviePlayerThumbnailRequest> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSDictionary> array = new NSMutableArray<>();
   for (MPMoviePlayerThumbnailRequest i : l) {
     array.add(i.getDictionary());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<AVSampleRateConverterSettings> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSDictionary> array = new NSMutableArray<>();
   for (AVSampleRateConverterSettings i : l) {
     array.add(i.getDictionary());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<NSStreamSOCKSProxyVersion> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (NSStreamSOCKSProxyVersion o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #11
0
 @MarshalsPointer
 public static long toNative(List<HMPredicateKeyPath> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (HMPredicateKeyPath o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #12
0
 @MarshalsPointer
 public static long toNative(List<CKErrorUserInfoKey> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (CKErrorUserInfoKey o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #13
0
 @MarshalsPointer
 public static long toNative(List<AVMetadataFormat> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (AVMetadataFormat o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<AVAudioSessionOrientation> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (AVAudioSessionOrientation o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<UIImagePickerControllerEditingInfo> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSDictionary> array = new NSMutableArray<>();
   for (UIImagePickerControllerEditingInfo i : l) {
     array.add(i.getDictionary());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
 @MarshalsPointer
 public static long toNative(List<HKDietaryQuantityTypeIdentifier> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (HKDietaryQuantityTypeIdentifier o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #17
0
 @MarshalsPointer
 public static long toNative(List<SCNLightingModel> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSString> array = new NSMutableArray<>();
   for (SCNLightingModel o : l) {
     array.add(o.value());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #18
0
 @MarshalsPointer
 public static long toNative(List<CIContextOptions> l, long flags) {
   if (l == null) {
     return 0L;
   }
   NSArray<NSDictionary> array = new NSMutableArray<>();
   for (CIContextOptions i : l) {
     array.add(i.getDictionary());
   }
   return NSObject.Marshaler.toNative(array, flags);
 }
Example #19
0
 public WOActionResults submit() {
   if (selection == null) {
     search();
     if (found != null && found.count() > 0) {
       selection = (PersonLink) found.objectAtIndex(0);
     } else {
       selection = defaultSelectionValue();
     }
   }
   setValueForBinding(selection, "selection");
   return (WOActionResults) valueForBinding("selectAction");
 }
Example #20
0
 /**
  * Renvoie le premier objet simple trouve dans la liste triee. Pour recuperer un tableau, utiliser
  * fetchAll(EOEditingContext, EOQualifier, NSArray).
  *
  * @param editingContext
  * @param qualifier
  * @param sortOrderings
  * @return Renvoie le premier objet trouve correspondant au qualifier, null si aucun trouve
  */
 public static EOTypeGroupe fetchFirstByQualifier(
     EOEditingContext editingContext, EOQualifier qualifier, NSArray sortOrderings) {
   NSArray eoObjects = fetchAll(editingContext, qualifier, sortOrderings);
   EOTypeGroupe eoObject;
   int count = eoObjects.count();
   if (count == 0) {
     eoObject = null;
   } else {
     eoObject = (EOTypeGroupe) eoObjects.objectAtIndex(0);
   }
   return eoObject;
 }
Example #21
0
  public void initCustomerIssues() {
    EOFetchSpecification fs;
    NSDictionary bindings = null;
    Session s = (Session) session();
    NSMutableArray qual = new NSMutableArray();
    NSMutableArray qual1 = new NSMutableArray();
    EOQualifier qualifier;

    // 'Open items'
    // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='CLOSED'", null));
    // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='RESOLVED'", null));
    // qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugStatus !='VERIFIED'", null));

    // Taser
    qual1.addObject(EOQualifier.qualifierWithQualifierFormat("type = 'Prospect'", null));
    qual1.addObject(EOQualifier.qualifierWithQualifierFormat("type = 'Customer'", null));
    qual.addObject(new EOOrQualifier(qual1));

    // Single Customer
    if (customerId() != null) {
      qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugId=" + customerId(), null));
      showProductSelector = true;
    } else {
      // Products
      if (selectedProducts.count() == 1) {
        if (selectedProducts.contains("Trusted Access")) {
          qual.addObject(
              EOQualifier.qualifierWithQualifierFormat(
                  "product.productName = 'Device: Trusted Access'", null));
        } else if (selectedProducts.contains("Secure Storage")) {
          qual.addObject(
              EOQualifier.qualifierWithQualifierFormat(
                  "product.productName = 'Device: Secure Storage'", null));
        }
      }
    }

    Object orderings[] = {
      EOSortOrdering.sortOrderingWithKey("version", EOSortOrdering.CompareAscending),
      EOSortOrdering.sortOrderingWithKey("targetMilestone", EOSortOrdering.CompareAscending),
      EOSortOrdering.sortOrderingWithKey(
          "priority", EOSortOrdering.CompareCaseInsensitiveAscending),
      EOSortOrdering.sortOrderingWithKey(
          "bugSeverity", EOSortOrdering.CompareCaseInsensitiveAscending),
    };

    fs = new EOFetchSpecification("Item", new EOAndQualifier(qual), new NSArray(orderings));
    fs.setRefreshesRefetchedObjects(true);

    ((EODatabaseDataSource) customerIssueDisplayGroup.dataSource()).setFetchSpecification(fs);
    customerIssueDisplayGroup.fetch();
  }
Example #22
0
 public String _alterPhraseDeletingColumnsWithNames(
     NSArray columnNames, NSArray entityGroup, EOSchemaGenerationOptions options) {
   StringBuffer phrase = new StringBuffer();
   int j = columnNames.count();
   for (int i = 0; i < j; i++) {
     phrase.append(
         ""
             + (i == 0 ? "" : this._alterPhraseJoinString())
             + "remove column "
             + columnNames.objectAtIndex(i));
   }
   return phrase.toString();
 }
 @MarshalsPointer
 public static List<MPMoviePlayerThumbnailRequest> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<MPMoviePlayerThumbnailRequest> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new MPMoviePlayerThumbnailRequest(o.get(i)));
   }
   return list;
 }
Example #24
0
  public NSArray customerIssues() {
    NSMutableArray allChildren = new NSMutableArray();
    NSMutableArray qual = new NSMutableArray();
    Item customer;
    Item child;

    if (customerIssues == null) {

      if (bugId() != null) {
        qual.addObject(EOQualifier.qualifierWithQualifierFormat("bugId=" + bugId(), null));
        EOFetchSpecification spec =
            new EOFetchSpecification("Item", new EOAndQualifier(qual), null);

        // Perform actual fetch
        customerIssues =
            (NSArray) session().defaultEditingContext().objectsWithFetchSpecification(spec);

      } else {

        Enumeration enumer = ((NSArray) customerIssueDisplayGroup.allObjects()).objectEnumerator();
        // For each Customer
        while (enumer.hasMoreElements()) {
          customer = (Item) enumer.nextElement();
          NSArray children = (NSArray) customer.valueForKey("allChildren");

          // Add all of their issues (if they haven't been added already
          Enumeration enumer2 = children.objectEnumerator();
          while (enumer2.hasMoreElements()) {
            child = (Item) enumer2.nextElement();
            if (!allChildren.contains(child)) {
              allChildren.addObject(child);
            }
          }
        }
        Object orderings[] = {
          EOSortOrdering.sortOrderingWithKey("version", EOSortOrdering.CompareAscending),
          EOSortOrdering.sortOrderingWithKey("targetMilestone", EOSortOrdering.CompareAscending),
          EOSortOrdering.sortOrderingWithKey(
              "priority", EOSortOrdering.CompareCaseInsensitiveAscending),
          EOSortOrdering.sortOrderingWithKey(
              "bugSeverity", EOSortOrdering.CompareCaseInsensitiveAscending),
        };

        // Sort the issues
        customerIssues =
            EOSortOrdering.sortedArrayUsingKeyOrderArray(allChildren, new NSArray(orderings));
      }
    }
    return customerIssues;
  }
 @MarshalsPointer
 public static List<UIImagePickerControllerEditingInfo> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<UIImagePickerControllerEditingInfo> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new UIImagePickerControllerEditingInfo(o.get(i)));
   }
   return list;
 }
Example #26
0
 public static Employee fetchEmployee(EOEditingContext editingContext, EOQualifier qualifier) {
   NSArray<Employee> eoObjects = _Employee.fetchEmployees(editingContext, qualifier, null);
   Employee eoObject;
   int count = eoObjects.count();
   if (count == 0) {
     eoObject = null;
   } else if (count == 1) {
     eoObject = (Employee) eoObjects.objectAtIndex(0);
   } else {
     throw new IllegalStateException(
         "There was more than one Employee that matched the qualifier '" + qualifier + "'.");
   }
   return eoObject;
 }
 @MarshalsPointer
 public static List<AVSampleRateConverterSettings> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<AVSampleRateConverterSettings> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new AVSampleRateConverterSettings(o.get(i)));
   }
   return list;
 }
 @MarshalsPointer
 public static List<CBCentralManagerOptions> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CBCentralManagerOptions> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new CBCentralManagerOptions(o.get(i)));
   }
   return list;
 }
Example #29
0
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<SCNLightingModel> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSString> o = (NSArray<NSString>) NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<SCNLightingModel> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(SCNLightingModel.valueOf(o.get(i)));
   }
   return list;
 }
Example #30
0
 public static Group fetchGroup(EOEditingContext editingContext, EOQualifier qualifier) {
   NSArray<Group> eoObjects = _Group.fetchGroups(editingContext, qualifier, null);
   Group eoObject;
   int count = eoObjects.count();
   if (count == 0) {
     eoObject = null;
   } else if (count == 1) {
     eoObject = (Group) eoObjects.objectAtIndex(0);
   } else {
     throw new IllegalStateException(
         "There was more than one Group that matched the qualifier '" + qualifier + "'.");
   }
   return eoObject;
 }