Package org.cyclop.model

Examples of org.cyclop.model.UserPreferences


  @Inject
  private JsonMarshaller marshaller;

  @Test
  public void testMarshal() {
    UserPreferences up = new UserPreferences();
    up.setShowCqlCompletionHint(false);
    String res = marshaller.marshal(up);
    assertEquals(
        "{\"e_hi\":\"0\",\"e_he\":\"1\",\"e_ro\":0,\"i_hi\":\"1\",\"i_ce\":\"0\",\"i_pa\":\"0\",\"p_ei\":5,\"p_hi\":50,\"p_ii\":100}",
        res);
  }
View Full Code Here


        res);
  }

  @Test
  public void testUnmarshal() {
    UserPreferences res = marshaller.unmarshal(UserPreferences.class, "{\"e_hi\":\"0\",\"e_he\":\"1\"}");

    UserPreferences up = new UserPreferences();
    up.setShowCqlCompletionHint(false);
    assertEquals(up, res);
  }
View Full Code Here

    assertEquals(up, res);
  }

  @Test
  public void testUnmarshalDefaults() {
    UserPreferences res = marshaller.unmarshal(UserPreferences.class, "{\"e_hi\":\"0\"}");

    UserPreferences up = new UserPreferences();
    up.setShowCqlCompletionHint(false);
    assertEquals(up, res);
  }
View Full Code Here

  private BootstrapPagingNavigator createPager(IPageableItems pageable) {
    BootstrapPagingNavigator pager = new BootstrapPagingNavigator("rowsPager", pageable, new PagerConfigurator() {

      @Override
      public void onItemsPerPageChanged(AjaxRequestTarget target, long newItemsPerPage) {
        UserPreferences prefs = um.readPreferences().setPagerEditorItems(newItemsPerPage);
        um.storePreferences(prefs);
        appendTableResizeJs(target);
      }

      @Override
View Full Code Here

  @Inject
  private CookieStorage cookieStorage;

  @Override
  public boolean storePreferences(UserPreferences preferences) {
    UserPreferences readPrefs = readPreferences();
    if (readPrefs.equals(preferences)) {
      LOG.debug("Preferences did not change - no update required {}", preferences);
      return false;
    }
    LOG.debug("Updating preferences {}", preferences);
    cookieStorage.storeCookieAsJson(CookieStorage.CookieName.cyclop_prefs, preferences);
View Full Code Here

  @Override
  public UserPreferences readPreferences() {
    Optional<UserPreferences> preferencesOpt = cookieStorage.readCookieAsJson(
        CookieStorage.CookieName.cyclop_prefs, UserPreferences.class);
    UserPreferences preferences = preferencesOpt.orElseGet(UserPreferences::new);
    if (!preferencesOpt.isPresent()) {
      LOG.debug("User preferences not found as cookie - using default");
    }
    return preferences;
  }
View Full Code Here

    setRenderBodyOnly(true);
    cqlHelpPanel = new CqlHelpPanel("cqlHelp");
    add(cqlHelpPanel);

    UserPreferences preferences = userManager.readPreferences();
    cqlCompletionHintPanel = new CompletionHintPanel("cqlInfoHint", "Completion Hint");
    cqlCompletionHintPanel.setVisible(preferences.isShowCqlCompletionHint());
    add(cqlCompletionHintPanel);

    queryResultPanel = new SwitchableQueryResultPanel("queryResultPanel", queryResultModel,
        ViewType.fromOrientation(preferences.getResultOrientation()));
    add(queryResultPanel);
    queryResultPanel.setOutputMarkupPlaceholderTag(true);

    EditorPanel queryEditorPanel = initQueryEditorPanel(params);
    Form<String> editorForm = initForm(queryEditorPanel);
View Full Code Here

    historyContainer.add(historyTable);
    pager = new BootstrapPagingNavigator("historyPager", historyTable, new PagerConfigurator() {

      @Override
      public void onItemsPerPageChanged(AjaxRequestTarget target, long newItemsPerPage) {
        UserPreferences prefs = um.readPreferences().setPagerHistoryItems(newItemsPerPage);
        um.storePreferences(prefs);

      }

      @Override
View Full Code Here

    super(id);
    setRenderBodyOnly(true);
  }

  public ButtonsPanel withResultOrientation(final ButtonListener.ResultOrientationChange buttonListener) {
    UserPreferences preferences = userManager.readPreferences();
    int initialState = preferences.getResultOrientation();
    AjaxFallbackLink<Void> completion = new IconButton("resultOrientation", initialState,
        "glyphicon glyphicon-arrow-down", "glyphicon glyphicon-arrow-right") {
      @Override
      protected void onClick(AjaxRequestTarget target, int state) {
        UserPreferences preferences = userManager.readPreferences();
        preferences.setResultOrientation(state);
        userManager.storePreferences(preferences);
        buttonListener.onClick(target, state);
      }
    };
    add(completion);
View Full Code Here

    add(completion);
    return this;
  }

  public ButtonsPanel withCompletion(final ButtonListener.CompletionChange buttonListener) {
    UserPreferences preferences = userManager.readPreferences();
    boolean completionEnabled = preferences.isShowCqlCompletionHint();
    AjaxFallbackLink<Void> completion = new StateButton("completion", completionEnabled, "btn btn-sm btn-primary",
        "btn btn-sm btn-primary active") {
      @Override
      protected void onClick(AjaxRequestTarget target, boolean pressed) {
        UserPreferences preferences = userManager.readPreferences();
        preferences.setShowCqlCompletionHint(pressed);
        userManager.storePreferences(preferences);

        buttonListener.onClick(target, pressed);
      }
    };
View Full Code Here

TOP

Related Classes of org.cyclop.model.UserPreferences

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.