Examples of ModulePrefs


Examples of com.google.gwt.gadgets.client.Gadget.ModulePrefs

    // Root elements
    Element module = (Element) d.appendChild(d.createElement("Module"));
    Element modulePrefs = (Element) module.appendChild(d.createElement("ModulePrefs"));

    // Write out the ModulePrefs tag
    ModulePrefs prefs = type.getAnnotation(ModulePrefs.class);
    if (prefs != null) {
      GadgetUtils.writeAnnotationToElement(logger, prefs, modulePrefs,
          "requirements");
      GadgetUtils.writeRequirementsToElement(logger, d, modulePrefs,
          prefs.requirements());
    }

    // Write out the UserPref tags
    JClassType preferenceType = typeOracle.findType(Preference.class.getName().replace('$', '.'));
    assert preferenceType != null;
View Full Code Here

Examples of com.google.gwt.gadgets.client.Gadget.ModulePrefs

    Element modulePrefs = (Element) module.appendChild(d.createElement("ModulePrefs"));

    addInjectedModulePrefs(logger, type, modulePrefs);

    // Write out the ModulePrefs tag
    ModulePrefs prefs = type.getAnnotation(ModulePrefs.class);
    if (prefs != null) {
      GadgetUtils.writeAnnotationToElement(logger, prefs, modulePrefs,
          "requirements", "locales");
      GadgetUtils.writeRequirementsToElement(logger, d, modulePrefs,
          prefs.requirements());
      GadgetUtils.writeLocalesToElement(logger, d, modulePrefs, prefs.locales());

    }

    // Write out the UserPref tags
    JClassType preferenceType = typeOracle.findType(Preference.class.getName().replace(
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

        Gadget gadget = processor.process(context);
        GadgetSpec spec = gadget.getSpec();

        JSONObject gadgetJson = new JSONObject();

        ModulePrefs prefs = spec.getModulePrefs();

        // TODO: modularize response fields based on requested items.
        JSONObject views = new JSONObject();
        for (View view : spec.getViews().values()) {
          views.put(view.getName(), new JSONObject()
               // .put("content", view.getContent())
               .put("type", view.getType().toString())
               .put("quirks", view.getQuirks())
               .put("preferredHeight", view.getPreferredHeight())
               .put("preferredWidth", view.getPreferredWidth()));
        }

        // Features.
        Set<String> feats = prefs.getFeatures().keySet();
        String[] features = feats.toArray(new String[feats.size()]);

        // Links
        JSONObject links = new JSONObject();
        for (LinkSpec link : prefs.getLinks().values()) {
          links.put(link.getRel(), link.getHref());
        }

        JSONObject userPrefs = new JSONObject();

        // User pref specs
        for (UserPref pref : spec.getUserPrefs()) {
          JSONObject up = new JSONObject()
              .put("displayName", pref.getDisplayName())
              .put("type", pref.getDataType().toString().toLowerCase())
              .put("default", pref.getDefaultValue())
              .put("enumValues", pref.getEnumValues())
              .put("orderedEnumValues", getOrderedEnums(pref));
          userPrefs.put(pref.getName(), up);
        }

        // TODO: This should probably just copy all data from
        // ModulePrefs.getAttributes(), but names have to be converted to
        // camel case.
        gadgetJson.put("iframeUrl", urlGenerator.getIframeUrl(gadget))
                  .put("url",context.getUrl().toString())
                  .put("moduleId", context.getModuleId())
                  .put("title", prefs.getTitle())
                  .put("titleUrl", prefs.getTitleUrl().toString())
                  .put("views", views)
                  .put("features", features)
                  .put("userPrefs", userPrefs)
                  .put("links", links)

                  // extended meta data
                  .put("directoryTitle", prefs.getDirectoryTitle())
                  .put("thumbnail", prefs.getThumbnail().toString())
                  .put("screenshot", prefs.getScreenshot().toString())
                  .put("author", prefs.getAuthor())
                  .put("authorEmail", prefs.getAuthorEmail())
                  .put("authorAffiliation", prefs.getAuthorAffiliation())
                  .put("authorLocation", prefs.getAuthorLocation())
                  .put("authorPhoto", prefs.getAuthorPhoto())
                  .put("authorAboutme", prefs.getAuthorAboutme())
                  .put("authorQuote", prefs.getAuthorQuote())
                  .put("authorLink", prefs.getAuthorLink())
                  .put("categories", prefs.getCategories())
                  .put("screenshot", prefs.getScreenshot().toString())
                  .put("height", prefs.getHeight())
                  .put("width", prefs.getWidth())
                  .put("showStats", prefs.getShowStats())
                  .put("showInDirectory", prefs.getShowInDirectory())
                  .put("singleton", prefs.getSingleton())
                  .put("scaling", prefs.getScaling())
                  .put("scrolling", prefs.getScrolling())
                  .put("description", prefs.getDescription());
        return gadgetJson;
      } catch (ProcessingException e) {
        throw new RpcException(context, e);
      } catch (JSONException e) {
        // Shouldn't be possible
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

    }
  }

  private void addHasFeatureConfig(Gadget gadget, Map<String, Object> config) {
    // Add gadgets.util support. This is calculated dynamically based on request inputs.
    ModulePrefs prefs = gadget.getSpec().getModulePrefs();
    Collection<Feature> features = prefs.getFeatures().values();
    Map<String, Map<String, Object>> featureMap = Maps.newHashMapWithExpectedSize(features.size());
    for (Feature feature : features) {
     
      // Flatten out the multimap a bit for backwards compatibility:  map keys
      // with just 1 value into the string, treat others as arrays
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

    }
  }

  private void addHasFeatureConfig(Gadget gadget, Map<String, Object> config) {
    // Add gadgets.util support. This is calculated dynamically based on request inputs.
    ModulePrefs prefs = gadget.getSpec().getModulePrefs();
    Collection<Feature> features = prefs.getFeatures().values();
    Map<String, Map<String, Object>> featureMap = Maps.newHashMapWithExpectedSize(features.size());
    for (Feature feature : features) {
     
      // Flatten out the multimap a bit for backwards compatibility:  map keys
      // with just 1 value into the string, treat others as arrays
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

   
    protected JSONObject getGadgetJson(Gadget gadget, GadgetSpec spec)
        throws JSONException {
        JSONObject gadgetJson = new JSONObject();

        ModulePrefs prefs = spec.getModulePrefs();

        // TODO: modularize response fields based on requested items.
        JSONObject views = new JSONObject();
        for (View view : spec.getViews().values()) {
          JSONObject jv = new JSONObject()
               // .put("content", view.getContent())
               .put("type", view.getType().toString())
               .put("quirks", view.getQuirks())
               .put("preferredHeight", view.getPreferredHeight())
               .put("preferredWidth", view.getPreferredWidth());
          Map<String, String> vattrs = view.getAttributes();
          if(vattrs.size()>0){
            JSONObject ja = new JSONObject(vattrs);
            jv.put("attributes", ja);
          }
          views.put(view.getName(), jv);
        }

        // Features.
        Set<String> feats = prefs.getFeatures().keySet();
        String[] features = feats.toArray(new String[feats.size()]);

        // Links
        JSONObject links = new JSONObject();
        for (LinkSpec link : prefs.getLinks().values()) {
          links.put(link.getRel(), link.getHref());
        }

        JSONObject userPrefs = new JSONObject();

        // User pref specs
        for (UserPref pref : spec.getUserPrefs()) {
          JSONObject up = new JSONObject()
              .put("displayName", pref.getDisplayName())
              .put("type", pref.getDataType().toString().toLowerCase())
              .put("default", pref.getDefaultValue())
              .put("enumValues", pref.getEnumValues())
              .put("orderedEnumValues", getOrderedEnums(pref));
          userPrefs.put(pref.getName(), up);
        }

        // TODO: This should probably just copy all data from
        // ModulePrefs.getAttributes(), but names have to be converted to
        // camel case.
        gadgetJson.put("iframeUrl", urlGenerator.getIframeUrl(gadget))
                  .put("url",context.getUrl().toString())
                  .put("moduleId", context.getModuleId())
                  .put("title", prefs.getTitle())
                  .put("titleUrl", prefs.getTitleUrl().toString())
                  .put("views", views)
                  .put("features", features)
                  .put("userPrefs", userPrefs)
                  .put("links", links)

                  // extended meta data
                  .put("directoryTitle", prefs.getDirectoryTitle())
                  .put("thumbnail", prefs.getThumbnail().toString())
                  .put("screenshot", prefs.getScreenshot().toString())
                  .put("author", prefs.getAuthor())
                  .put("authorEmail", prefs.getAuthorEmail())
                  .put("authorAffiliation", prefs.getAuthorAffiliation())
                  .put("authorLocation", prefs.getAuthorLocation())
                  .put("authorPhoto", prefs.getAuthorPhoto())
                  .put("authorAboutme", prefs.getAuthorAboutme())
                  .put("authorQuote", prefs.getAuthorQuote())
                  .put("authorLink", prefs.getAuthorLink())
                  .put("categories", prefs.getCategories())
                  .put("screenshot", prefs.getScreenshot().toString())
                  .put("height", prefs.getHeight())
                  .put("width", prefs.getWidth())
                  .put("showStats", prefs.getShowStats())
                  .put("showInDirectory", prefs.getShowInDirectory())
                  .put("singleton", prefs.getSingleton())
                  .put("scaling", prefs.getScaling())
                  .put("scrolling", prefs.getScrolling());
        return gadgetJson;
    }
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

  }
 
  private Gadget mockGadget(boolean nocache, boolean debug) {
    final GadgetSpec spec = createMock(GadgetSpec.class);
    expect(spec.getUrl()).andReturn(GADGET_URI).anyTimes();
    final ModulePrefs prefs = createMock(ModulePrefs.class);
    expect(prefs.getFeatures()).andReturn(Maps.<String, Feature>newHashMap()).anyTimes();
    replay(prefs);
    expect(spec.getModulePrefs()).andReturn(prefs).anyTimes();
    replay(spec);
    GadgetContext context = createMock(GadgetContext.class);
    expect(context.getContainer()).andReturn(CONTAINER).anyTimes();
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

  // Actually generates the mock gadget. Used for error (null value) tests.
  private Gadget mockGadget(String targetUrl, boolean isTypeUrl, String viewStr, String lang,
      String country, boolean isDebug, boolean ignoreCache, Map<String, String> specPrefs,
      Map<String, String> inPrefs, boolean needsPrefSubst, List<String> features) {
    View view = createMock(View.class);
    ModulePrefs modulePrefs = createMock(ModulePrefs.class);
    GadgetSpec spec = createMock(GadgetSpec.class);
    GadgetContext context = createMock(GadgetContext.class);
    Gadget gadget = createMock(Gadget.class);
   
    // Base URL/view.
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

  // Actually generates the mock gadget. Used for error (null value) tests.
  protected Gadget mockGadget(String targetUrl, boolean isTypeUrl, String viewStr, String lang,
      String country, boolean isDebug, boolean ignoreCache, Map<String, String> specPrefs,
      Map<String, String> inPrefs, boolean needsPrefSubst, List<String> features) {
    View view = createMock(View.class);
    ModulePrefs modulePrefs = createMock(ModulePrefs.class);
    GadgetSpec spec = createMock(GadgetSpec.class);
    GadgetContext context = createMock(GadgetContext.class);
    Gadget gadget = createMock(Gadget.class);
   
    // Base URL/view.
View Full Code Here

Examples of org.apache.shindig.gadgets.spec.ModulePrefs

  protected Gadget mockGadget(String targetUrl, boolean isTypeUrl, String currentViewStr, String lang,
      String country, boolean isDebug, boolean ignoreCache, boolean sanitize, boolean cajoled,
      Map<String, String> specPrefs, Map<String, String> inPrefs, boolean needsPrefSubst, List<String> features) {
    View currentView = createMock(View.class);
    View secondView = createMock(View.class);
    ModulePrefs modulePrefs = createMock(ModulePrefs.class);
    GadgetSpec spec = createMock(GadgetSpec.class);
    GadgetContext context = createMock(GadgetContext.class);
    Gadget gadget = createMock(Gadget.class);

    // Base URL/view.
    Uri targetUri = Uri.parse(targetUrl);
    if (isTypeUrl) {
      expect(currentView.getType()).andReturn(ContentType.URL).anyTimes();
      expect(currentView.getHref()).andReturn(targetUri).anyTimes();
      expect(secondView.getType()).andReturn(ContentType.HTML).anyTimes();
      expect(spec.getUrl()).andReturn(targetUri).anyTimes();
    } else {
      expect(currentView.getType()).andReturn(ContentType.HTML).anyTimes();
      expect(spec.getUrl()).andReturn(targetUri).anyTimes();
      expect(secondView.getType()).andReturn(ContentType.URL).anyTimes();
      expect(secondView.getHref()).andReturn(targetUri).anyTimes();
    }
    expect(currentView.getName()).andReturn(currentViewStr).anyTimes();
    expect(secondView.getName()).andReturn(ANOTHER_VIEW).anyTimes();

    // Basic context info
    Locale locale = new Locale(lang, country);
    expect(context.getUrl()).andReturn(SPEC_URI).anyTimes();
    expect(context.getContainer()).andReturn(CONTAINER).anyTimes();
    expect(context.getLocale()).andReturn(locale).anyTimes();
    expect(context.getDebug()).andReturn(isDebug).anyTimes();
    expect(context.getIgnoreCache()).andReturn(ignoreCache).anyTimes();
    expect(context.getToken()).andReturn(null).anyTimes();
    expect(context.getSanitize()).andReturn(sanitize).anyTimes();
    expect(context.getCajoled()).andReturn(cajoled).anyTimes();

    // All Features (doesn't distinguish between transitive and not)
    expect(gadget.getAllFeatures()).andReturn(features).anyTimes();
    Map<String, Feature> featureMap = Maps.newLinkedHashMap();
    for (String feature : features) {
      featureMap.put(feature, null);
    }
    expect(gadget.getViewFeatures()).andReturn(featureMap).anyTimes();
    expect(modulePrefs.getFeatures()).andReturn(featureMap).anyTimes();

    // User prefs
    Map<String, UserPref> specPrefMap = Maps.newLinkedHashMap();
    for (Map.Entry<String, String> specPref : specPrefs.entrySet()) {
      UserPref up = createMock(UserPref.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.