Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.UserPrefs


      expect(up.getDefaultValue()).andReturn(specPref.getValue()).anyTimes();
      replay(up);
      specPrefList.add(up);
    }
    expect(spec.getUserPrefs()).andReturn(specPrefList).anyTimes();
    UserPrefs ctxPrefs = new UserPrefs(inPrefs);
    expect(context.getUserPrefs()).andReturn(ctxPrefs).anyTimes();
    expect(view.needsUserPrefSubstitution()).andReturn(needsPrefSubst).anyTimes();
   
    // Link all the mocks together
    expect(spec.getModulePrefs()).andReturn(modulePrefs).anyTimes();
View Full Code Here


      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

      expect(up.getDefaultValue()).andReturn(specPref.getValue()).anyTimes();
      replay(up);
      specPrefMap.put(up.getName(),up);
    }
    expect(spec.getUserPrefs()).andReturn(specPrefMap).anyTimes();
    UserPrefs ctxPrefs = new UserPrefs(inPrefs);
    expect(context.getUserPrefs()).andReturn(ctxPrefs).anyTimes();
    expect(context.getParameter(Param.REFRESH.getKey())).andReturn(null).anyTimes();
    expect(view.needsUserPrefSubstitution()).andReturn(needsPrefSubst).anyTimes();
   
    // Link all the mocks together
View Full Code Here

  }

  @Test
  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

  }

  @Test
  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

                 "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse("#"), xml);
    GadgetContext context = new GadgetContext() {
      @Override
      public UserPrefs getUserPrefs() {
        return new UserPrefs(ImmutableMap.of("foo", "shindig"));
      }
    };

    spec = substituter.substitute(context, spec);
View Full Code Here

      expect(up.getDefaultValue()).andReturn(specPref.getValue()).anyTimes();
      replay(up);
      specPrefMap.put(up.getName(),up);
    }
    expect(spec.getUserPrefs()).andReturn(specPrefMap).anyTimes();
    UserPrefs ctxPrefs = new UserPrefs(inPrefs);
    expect(context.getUserPrefs()).andReturn(ctxPrefs).anyTimes();
    expect(context.getParameter(Param.REFRESH.getKey())).andReturn(null).anyTimes();
    expect(currentView.needsUserPrefSubstitution()).andReturn(needsPrefSubst).anyTimes();
    expect(secondView.needsUserPrefSubstitution()).andReturn(!needsPrefSubst).anyTimes();
View Full Code Here

  }

  @Test
  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

  }

  @Test
  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

* Substitutes user prefs into the spec.
*/
public class UserPrefSubstituter implements Substituter {

  public void addSubstitutions(Substitutions substituter, GadgetContext context, GadgetSpec spec) {
    UserPrefs values = context.getUserPrefs();

    for (UserPref pref : spec.getUserPrefs().values()) {
      String name = pref.getName();
      String value = values.getPref(name);
      if (value == null) {
        value = pref.getDefaultValue();
        if (value == null) {
          value = "";
        }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.UserPrefs

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.