Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSMutableArray$ListItr


     * Creates a JSON/JavaScript-formatted hash of the list item offsets and their display strings.
     * @return the hash representation
     */
    private String possibleValuesHashForScript() {
        NSDictionary valuesDict = cachedPossibleValues();
        NSMutableArray jsHashValues = new NSMutableArray();
        for (int i = 0; i < valuesDict.count(); i++) {
            String displayString = (String)valuesDict.objectForKey(i);
            if (displayString != null) {
                displayString = displayString.replaceAll("'", "\\\\'");
            }
            jsHashValues.addObject(i + " : '" + displayString + "'");
        }
        return "{ " + jsHashValues.componentsJoinedByString(", ") + " }";
    }
View Full Code Here


    /**
     * Creates a JSON/JavaScript-formatted array of the selected list items' offsets.
     * @return the array representation
     */
    private String selectedValuesArrayForScript() {
        NSMutableArray offsets = new NSMutableArray();
        NSArray sortedList = maybeSortedList();
        for (Enumeration selectionsEnum = selections().objectEnumerator(); selectionsEnum.hasMoreElements();) {
            Object obj = selectionsEnum.nextElement();
            int offset = indexOfObjectInArrayUsingERXEOControlUtilitiesEOEquals(obj, sortedList);
            if (offset >= 0) {
                offsets.addObject(offset);
            }
        }
        return "[" + offsets.componentsJoinedByString(", ") + "]";
    }
View Full Code Here

  private static final Logger log = Logger.getLogger( WOHostUtilities.class );
 
  @SuppressWarnings("unchecked")
  static NSArray initLocalHosts()
  {
    NSMutableArray localNSMutableArray = new NSMutableArray();
    try
    {
      InetAddress localInetAddress1 = InetAddress.getLocalHost();
      _addInetAddress(localInetAddress1, localNSMutableArray);
    } catch (Exception localException1) {
      NSLog.err.appendln("<WOHostUtilities>: Couldn't invoke getLocalHost(): " + localException1);
    }

    try
    {
      InetAddress[] arrayOfInetAddress1 = InetAddress.getAllByName("localhost");
      _addInetAddressArray(arrayOfInetAddress1, localNSMutableArray);
    } catch (Exception localException2) {
      NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for 'localhost': " + localException2);
    }
    try
    {
      InetAddress[] arrayOfInetAddress2 = InetAddress.getAllByName("127.0.0.1");
      _addInetAddressArray(arrayOfInetAddress2, localNSMutableArray);
    } catch (Exception localException3) {
      NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddress for '127.0.0.1': " + localException3);
    }
   
    NSArray<String> ips = ERXProperties.arrayForKey( LOCALHOST_IPS_PROPERTY_KEY );
   
    if( ips != null ) {
      for ( String ip : ips ) {
        try {
          InetAddress address = InetAddress.getByName( ip );
          _addInetAddress( address, localNSMutableArray );
          log.debug( "Added the address " + address + " as a local host." );
        } catch (Exception e) {
          log.error( "Could not add localhost IP " + ip );
        }
      }
    }

    int i = localNSMutableArray.count();
    for (int j = 0; j < i; ++j) {
      InetAddress localInetAddress2 = (InetAddress)localNSMutableArray.objectAtIndex(j);
      try {
        InetAddress[] arrayOfInetAddress3 = InetAddress.getAllByName(localInetAddress2.getHostName());
        _addInetAddressArray(arrayOfInetAddress3, localNSMutableArray);
      } catch (Exception localException4) {
        NSLog.err.appendln("<WOHostUtilities>: Couldn't get InetAddresses for '" + localInetAddress2.getHostName() + "': " + localException4);
View Full Code Here

        else if (_selectedValues != null)
        {
          selections = _selectedValues.valueInComponent(parent);
        }
       
        NSMutableArray selectedObjects = null;
        if (selections != null) {
            if ( ! (selections instanceof NSArray)) {
              selectedObjects = new NSMutableArray(selections)
            }               
           else if ( !(selections instanceof NSMutableArray)) {
               selectedObjects = new NSMutableArray((NSArray)selections);  
           }
           else {
             selectedObjects = (NSMutableArray)selections;
           }
        }
         
        NSArray list = (NSArray) _list.valueInComponent(parent);
       
        Object previousGroup = null;
        boolean didOpenOptionGroup = false;
        boolean shouldEscapeHTML = _escapeHTML != null ? _escapeHTML.booleanValueInComponent(parent) : true;
       
        for(int i = 0; i < list.count(); i++)
        {
             Object listItem = list.objectAtIndex(i);
             _item.setValue(listItem, parent);
            
             Object currentGroup = group.valueInComponent(parent);
             if ( ! currentGroup.equals(previousGroup))
             {
                 previousGroup = currentGroup;

                 if (didOpenOptionGroup)
                 {
                     response._appendContentAsciiString("\n</optgroup>");
                 }
                
                 response._appendContentAsciiString("\n<optgroup label=\"");
                 if (label != null)
                 {
                     if (shouldEscapeHTML)
                     {
                         response.appendContentHTMLString(label.valueInComponent(parent).toString());
                     }
                     else
                     {
                         response.appendContentString(label.valueInComponent(parent).toString());
                     }
                 }

                response._appendContentAsciiString("\">");
                didOpenOptionGroup = true;
             }
             response._appendContentAsciiString("\n<option");
            
             if (itemStyle != null) {
                 String style = (String) itemStyle.valueInComponent(parent);
                 if (style != null) {
                   response._appendTagAttributeAndValue("style", style, true);
                 }
             }
             if (itemClass != null) {
                 String cssClass = (String) itemClass.valueInComponent(parent);
                 if (cssClass != null) {
                   response._appendTagAttributeAndValue("class", cssClass, true);
                 }
             }
            
             String valueAsString = null;
             String displayStringAsString = null;
             if (_displayString != null || _value != null)
             {

                if (_displayString != null)
                {
                    Object displayString = _displayString.valueInComponent(parent);
                    if (displayString != null)
                    {
                        displayStringAsString = displayString.toString();
                        if (_value != null)
                        {
                            Object value = _value.valueInComponent(parent);
                            if (value != null)
                            {
                                valueAsString = value.toString();
                            }
                        }
                        else
                        {
                            valueAsString = displayStringAsString;
                        }
                   }
                }
                else
                {
                    Object value = _value.valueInComponent(parent);
                    if (value != null)
                    {
                        valueAsString = value.toString();
                        displayStringAsString = valueAsString;
                    }
               }
           }
           else
           {
               displayStringAsString = listItem.toString();
               valueAsString = displayStringAsString;
           }
           
            boolean isSelectedItem = false;
            if (_selections != null)
            {
                isSelectedItem = selectedObjects == null ? false : selectedObjects.containsObject(listItem);
            }
            else if (_selectedValues != null)
            {
                if (_value != null)
                {
                    isSelectedItem = selectedObjects == null ? false : selectedObjects.containsObject(valueAsString);
                }
            }
            
            if (isSelectedItem)
            {
View Full Code Here

    addScriptResourceInHead(res, "effects.js");
    addScriptResourceInHead(res, "dragdrop.js");
  }

  public NSDictionary createAjaxOptions() {
    NSMutableArray ajaxOptionsArray = new NSMutableArray();
    ajaxOptionsArray.addObject(new AjaxOption("tag", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("treeTag", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("only", AjaxOption.STRING_ARRAY));
    ajaxOptionsArray.addObject(new AjaxOption("overlap", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("constraint", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("containment", AjaxOption.STRING_ARRAY));
    ajaxOptionsArray.addObject(new AjaxOption("handle", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("hoverclass", AjaxOption.STRING));
    ajaxOptionsArray.addObject(new AjaxOption("ghosting", AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxOption("dropOnEmpty", AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxOption("scroll", AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxOption("onChange", AjaxOption.SCRIPT));
    NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
    return options;
  }
View Full Code Here

 
  /**
   * @return options for Ajax.Request that is made when the link is clicked
   */
  protected NSMutableDictionary ajaxRequestOptions() {
    NSMutableArray ajaxOptionsArray = new NSMutableArray();
    ajaxOptionsArray.addObject(new AjaxConstantOption("asynchronous", Boolean.FALSE, AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxConstantOption("evalScripts", Boolean.FALSE, AjaxOption.BOOLEAN));
    ajaxOptionsArray.addObject(new AjaxOption("onFailure", AjaxOption.FUNCTION_1));
   
    // onSuccess callback handler to open AMD
    StringBuilder sb = new StringBuilder(500);
    sb.append(AjaxModalDialog.openDialogFunctionName(modalDialogId()));
    sb.append('(')
   
    // Override for dialog name
    if (hasBinding("title")) { 
      sb.append(AjaxValue.javaScriptEscaped(valueForBinding("title")));
    }   
    sb.append(");");
    ajaxOptionsArray.addObject(new AjaxConstantOption("onSuccess", sb.toString(), AjaxOption.FUNCTION_1));

    return AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
  }
View Full Code Here

     * @param endChar the end char to check for
     *
     * @return nested NSMutableArray.
     */
    public static NSMutableArray convertedPropertyKeyArray(NSArray keyArray, char startChar, char endChar) {
        NSMutableArray result = new NSMutableArray();
        Object firstValue = null;
        if(keyArray.count() > 0) {
            firstValue = keyArray.objectAtIndex(0);
        }
        if(firstValue != null) {
            boolean isKeyArrayFormat = false;
            if(firstValue instanceof String)
                isKeyArrayFormat = convertedPropertyKeyFromString((String)firstValue, startChar, endChar) != null;
            if(firstValue instanceof String && !isKeyArrayFormat) {
                ERD2WContainer c=new ERD2WContainer();
                c.name = "";
                c.keys = new NSMutableArray(keyArray);
                result.addObject(c);
            } else {
                NSMutableArray tmp = null;
                for (Enumeration e = keyArray.objectEnumerator(); e.hasMoreElements();) {
                    if(isKeyArrayFormat) {
                        String currentValue = (String)e.nextElement();
                        String currentLabel = convertedPropertyKeyFromString(currentValue, startChar, endChar);
                        if(currentLabel != null) {
                            ERD2WContainer c=new ERD2WContainer();
                            c.name = currentLabel;
                            tmp = new NSMutableArray();
                            c.keys = tmp;
                            result.addObject(c);
                        } else {
                            tmp.addObject(currentValue);
                        }
                    } else {
                        NSArray current = (NSArray)e.nextElement();
                        ERD2WContainer c=new ERD2WContainer();
                        c.name = (String)current.objectAtIndex(0);
View Full Code Here

    public static NSArray displayableArrayForKeyPathArray(NSArray array, String entityForReportName){
      if(array == null) {
        return null;
      }
      NSMutableArray result = new NSMutableArray();
      for(Enumeration e = array.objectEnumerator(); e.hasMoreElements(); ){
        String key = (String)e.nextElement();
        result.addObject(new ERXKeyValuePair(key, ERDirectToWeb.displayNameForPropertyKey(key, entityForReportName)));
      }
      return result;
    }
View Full Code Here

     *
     * @param context WOContext providing component to resolve bindings in
     * @return binding values converted into Ajax options
     */
    protected NSMutableDictionary createOptions(WOContext context) {
        NSMutableArray ajaxOptionsArray = new NSMutableArray();

        // Standard options from Control.Rating
        ajaxOptionsArray.addObject(new AjaxOption("min", AjaxOption.NUMBER));
        ajaxOptionsArray.addObject(new AjaxOption("max", AjaxOption.NUMBER));
        ajaxOptionsArray.addObject(new AjaxOption("value", AjaxOption.NUMBER));
        ajaxOptionsArray.addObject(new AjaxOption("capture", AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("classNames", AjaxOption.DICTIONARY));
        ajaxOptionsArray.addObject(new AjaxOption("multiple", AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("rated", AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("reverse", AjaxOption.BOOLEAN));
        ajaxOptionsArray.addObject(new AjaxOption("afterChange", AjaxOption.FUNCTION_1));
       
        // updateParameterName is renamed to formValueName to be more WO like
        ajaxOptionsArray.addObject(new AjaxConstantOption("updateParameterName", "formValueName", formValueName(context), AjaxOption.STRING));

        // These parameters are mutually exclusive at present, but dataUpdateUrl could be used with an input if there is a reason for it.
        // I can't think of one right now
        if ( ! actAsInput(context)) {
            ajaxOptionsArray.addObject(new AjaxConstantOption("dataUpdateUrl", AjaxUtils.ajaxComponentActionUrl(context), AjaxOption.STRING));
            ajaxOptionsArray.addObject(new AjaxOption("updateOptions", AjaxOption.DICTIONARY));
        }
        else {
            ajaxOptionsArray.addObject(new AjaxConstantOption("input", id(context) + "_input", AjaxOption.STRING));
        }

        return AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, context.component(), associations());
    }
View Full Code Here

        pkSpec.setFetchesRawRows(true);
        pkSpec.setRawRowKeyPaths(entity.primaryKeyAttributeNames());
        pkSpec.setHints( new NSDictionary( expression, EODatabaseContext.CustomQueryExpressionHintKey ) );

        NSArray pkDicts = ec.objectsWithFetchSpecification(pkSpec);
        NSMutableArray pks = new NSMutableArray();
        String pkAtttributeName = entity.primaryKeyAttributes().lastObject().name();

        for ( Enumeration rowEnumerator = pkDicts.objectEnumerator(); rowEnumerator.hasMoreElements(); ) {
            NSDictionary row = (NSDictionary) rowEnumerator.nextElement();
            pks.addObject( row.objectForKey( pkAtttributeName ));
        }

        EOFetchSpecification spec = new EOFetchSpecification(entityName, null, sortOrderings);
        spec.setRefreshesRefetchedObjects( refreshesCache );
        return new ERXFetchSpecificationBatchIterator( spec, pks, ec, batchSize);
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSMutableArray$ListItr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.