/** @return */
 public static boolean isEnablePageDelete() {
   if (isExtractPagesEnable()) {
     UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
     return userPrefsHelper.getBoolean(
         V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_PAGE_DELETE, true);
   }
   return false;
 }
  /**
   * check user preference for document version retain configuration
   *
   * @return
   */
  public static boolean isRetainPriorVersion() {
    UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
    String docPriorVersionAction =
        userPrefsHelper.getSingleString(
            V_IMAGE_VIEWER_CONFIG,
            F_IMAGE_VIEWER_SELECTED_DOC_PRIOR_VERSION_ACTION,
            RETAIN_PRIOR_DOCUMENT_VERSIONS);

    return DELETE_PRIOR_DOCUMENT_VERSIONS.equals(docPriorVersionAction) ? false : true;
  }
 /** @return */
 public static boolean isExtractPagesEnable() {
   UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
   return userPrefsHelper.getBoolean(
       V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_EXTRACT_PAGES, true);
 }
 /** @return */
 private static UserPreferencesHelper getUserPrefenceHelper() {
   return UserPreferencesHelper.getInstance(
       M_VIEWS_COMMON,
       PortalConfiguration.getInstance().getPrefScopesHelper().getSelectedPreferenceScope());
 }
 private void resetUsersPreferences() {
   UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_SIDE_PANEL);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_INVERT_IMAGE);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_ANNOTATIONS);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_HIGHLIGHT_DATA_FIELDS_ENABLED);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_DATANAME_IN_TARGET_INCLUDED);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_MAGNIFY_FIELDS);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_BOLD_SELECTED);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ITALIC_SELECTED);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_UNDERLINE_SELECTED);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_NOTE_FONT_SIZE);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_STICKY_NOTE_COLOUR);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_HIGHLIGHTER_COLOUR);
   userPrefsHelper.resetValue(
       V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_COLOUR);
   userPrefsHelper.resetValue(
       V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_OPACITY);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DISPLAY_ZOOM_LIVEL);
   userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_STAMP);
   if (SessionContext.findSessionContext().getUser().isAdministrator()) {
     userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_EXTRACT_PAGES);
     userPrefsHelper.resetValue(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_PAGE_DELETE);
     userPrefsHelper.resetValue(
         V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DOC_PRIOR_VERSION_ACTION);
   }
 }
 private void setUsersPreferences() {
   UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
   showSidePanel =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_SIDE_PANEL, true);
   invertImage =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_INVERT_IMAGE, false);
   showAnnotations =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_ANNOTATIONS, true);
   highlightDataFieldsEnabled =
       userPrefsHelper.getBoolean(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_HIGHLIGHT_DATA_FIELDS_ENABLED, true);
   datanameInTargetIncluded =
       userPrefsHelper.getBoolean(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_DATANAME_IN_TARGET_INCLUDED, true);
   magnifyFields =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_MAGNIFY_FIELDS, false);
   boldSelected =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_BOLD_SELECTED, false);
   italicSelected =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ITALIC_SELECTED, false);
   underlineSelected =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_UNDERLINE_SELECTED, false);
   selectedNoteFontSize =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_NOTE_FONT_SIZE, DEFAULT_NOTE_FONT_SIZE);
   stickyNoteColour =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_STICKY_NOTE_COLOUR, "yellow");
   highlighterColour =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_HIGHLIGHTER_COLOUR, "#FF0000");
   dataFieldHighlightColour =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG,
           F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_COLOUR,
           "#FF0000");
   dataFieldHighlightOpacity =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_OPACITY, "0.5");
   selectedDisplayZoomLevel =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_DISPLAY_ZOOM_LIVEL, "FIT_TO_WINDOW");
   enableExtractPage =
       userPrefsHelper.getBoolean(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_EXTRACT_PAGES, true);
   allowDeleteFromOriginal =
       userPrefsHelper.getBoolean(V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ENABLE_PAGE_DELETE, true);
   docPriorVersionAction =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG,
           F_IMAGE_VIEWER_SELECTED_DOC_PRIOR_VERSION_ACTION,
           RETAIN_PRIOR_DOCUMENT_VERSIONS);
   spawnProcessType =
       userPrefsHelper.getSingleString(
           V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SPAWN_PROCESS_TYPE, SUB_PROCESS_TYPE);
   ImageViewerStampsBean.getCurrent()
       .setSelectedStampId(
           userPrefsHelper.getSingleString(
               V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_STAMP, ""));
 }
  public void save() {
    UserPreferencesHelper userPrefsHelper = getUserPrefenceHelper();
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_SIDE_PANEL, String.valueOf(showSidePanel));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_INVERT_IMAGE, String.valueOf(invertImage));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SHOW_ANNOTATIONS, String.valueOf(showAnnotations));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_HIGHLIGHT_DATA_FIELDS_ENABLED,
        String.valueOf(highlightDataFieldsEnabled));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_DATANAME_IN_TARGET_INCLUDED,
        String.valueOf(datanameInTargetIncluded));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_MAGNIFY_FIELDS, String.valueOf(magnifyFields));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_BOLD_SELECTED, String.valueOf(boldSelected));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_ITALIC_SELECTED, String.valueOf(italicSelected));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_UNDERLINE_SELECTED,
        String.valueOf(underlineSelected));
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_NOTE_FONT_SIZE, selectedNoteFontSize);
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_STICKY_NOTE_COLOUR, stickyNoteColour);
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SELECTED_HIGHLIGHTER_COLOUR, highlighterColour);
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_COLOUR,
        dataFieldHighlightColour);

    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_SELECTED_DATA_FIELD_HIGHLIGHTER_OPACITY,
        dataFieldHighlightOpacity);
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_SELECTED_DISPLAY_ZOOM_LIVEL,
        selectedDisplayZoomLevel);
    userPrefsHelper.setString(
        V_IMAGE_VIEWER_CONFIG,
        F_IMAGE_VIEWER_SELECTED_STAMP,
        ImageViewerStampsBean.getCurrent().getSelectedStampId());

    // non-admin user can't change values
    if (SessionContext.findSessionContext().getUser().isAdministrator()) {
      userPrefsHelper.setString(
          V_IMAGE_VIEWER_CONFIG,
          F_IMAGE_VIEWER_ENABLE_EXTRACT_PAGES,
          String.valueOf(enableExtractPage));
      allowDeleteFromOriginal = enableExtractPage && allowDeleteFromOriginal;
      userPrefsHelper.setString(
          V_IMAGE_VIEWER_CONFIG,
          F_IMAGE_VIEWER_ENABLE_PAGE_DELETE,
          String.valueOf(allowDeleteFromOriginal));
      userPrefsHelper.setString(
          V_IMAGE_VIEWER_CONFIG,
          F_IMAGE_VIEWER_SELECTED_DOC_PRIOR_VERSION_ACTION,
          docPriorVersionAction);
      userPrefsHelper.setString(
          V_IMAGE_VIEWER_CONFIG, F_IMAGE_VIEWER_SPAWN_PROCESS_TYPE, spawnProcessType);
    }
    MessageDialog.addInfoMessage(
        messageBean.getString("views.imageViewerConfig.save.successMessage"));
  }