com.dlsc.preferencesfx.model.Group Java Examples

The following examples show how to use com.dlsc.preferencesfx.model.Group. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionsServerSettingsPanel.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
public Category getServerTab() {
    return Category.of(LabelGrabber.INSTANCE.getLabel("server.settings.heading"),
            new ImageView(new Image("file:icons/serversettingsicon.png")),
            Group.of(LabelGrabber.INSTANCE.getLabel("mobile.lyrics.heading"),
                    Setting.of(LabelGrabber.INSTANCE.getLabel("use.mobile.lyrics.label"), useMobileLyricsProperty)
                            .customKey(useMobLyricsKey),
                    Setting.of(LabelGrabber.INSTANCE.getLabel("port.number.label"), mobileLyricsField, lyricsPortNumberProperty)
                            .customKey(mobLyricsPortKey)
            ),
            Group.of(LabelGrabber.INSTANCE.getLabel("mobile.remote.heading"),
                    Setting.of(LabelGrabber.INSTANCE.getLabel("use.remote.control.label"), useMobileRemoteProperty)
                            .customKey(useRemoteControlKey),
                    Setting.of(LabelGrabber.INSTANCE.getLabel("port.number.label"), remoteField, remotePortNumberProperty)
                            .customKey(remoteControlPortKey),
                    Setting.of(LabelGrabber.INSTANCE.getLabel("remote.control.password"), passwordProperty)
                            .customKey(remoteControlPasswordKey)
            )
    );
}
 
Example #2
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a map which links {@link Setting} to {@link Category} in a list of {@code categories}.
 *
 * @param categories the categories of which to create a map of
 * @return a {@link HashMap} containing {@link Setting}, mapped to their
 *         corresponding {@link Category}
 * @apiNote does not flatten the categories
 */
public static HashMap<Setting, Category> mapSettingsToCategories(List<Category> categories) {
  HashMap<Setting, Category> settingCategoryMap = new HashMap<>();
  for (Category category : categories) {
    if (category.getGroups() != null) {
      for (Group group : category.getGroups()) {
        if (group.getSettings() != null) {
          for (Setting setting : group.getSettings()) {
            settingCategoryMap.put(setting, category);
          }
        }
      }
    }
  }
  return settingCategoryMap;
}
 
Example #3
Source File: OneCategoryExample.java    From PreferencesFX with Apache License 2.0 6 votes vote down vote up
private PreferencesFx createPreferences() {
  return PreferencesFx.of(OneCategoryExample.class,
      Category.of("General",
          Group.of("Greeting",
              Setting.of("Welcome Text", welcomeText)
          ),
          Group.of("Display",
              Setting.of("Brightness", brightness),
              Setting.of("Night mode", nightMode),
              Setting.of("Scaling", scaling)
                  .validate(DoubleRangeValidator.atLeast(1, "Scaling needs to be at least 1"))
          )
      )
  ).persistWindowState(false)
   .saveSettings(true)
   .debugHistoryMode(false)
   .buttonsVisibility(true)
   .instantPersistent(false);
}
 
Example #4
Source File: CategoryPresenter.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link Form} with {@link Group} and {@link Setting} of this {@link Category}.
 *
 * @return the created form.
 */
private Form createForm() {
  Form form = Form.of();
  // assign groups from this category
  List<Group> groups = categoryModel.getGroups();
  // if there are no groups, initialize them anyways as a list
  if (groups == null) {
    groups = new ArrayList<>();
  }

  // get groups of this form
  List<com.dlsc.formsfx.model.structure.Group> formGroups = form.getGroups();

  // create PreferenceGroups from Groups
  for (int i = 0; i < groups.size(); i++) {
    PreferencesFxGroup preferencesGroup =
        (PreferencesFxGroup) PreferencesFxGroup.of().title(groups.get(i).getDescription());
    groups.get(i).setPreferencesGroup(preferencesGroup);
    formGroups.add(preferencesGroup);
    // fill groups with settings (as FormsFX fields)
    for (Setting setting : groups.get(i).getSettings()) {
      formGroups.get(i).getElements().add(setting.getElement());
    }
  }

  applyInstantPersistence(model.isInstantPersistent(), form);

  return form;
}
 
Example #5
Source File: InternationalizedExample.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private PreferencesFx createPreferences() {
  return PreferencesFx.of(InternationalizedExample.class,
      Category.of("general",
          Group.of("greeting",
              Setting.of("welcome", welcomeText)
          ),
          Group.of("display",
              Setting.of("brightness", brightness),
              Setting.of("night_mode", nightMode)
          )
      ),
      Category.of("screen")
          .expand()
          .subCategories(
              Category.of("scaling_ordering",
                  Group.of(
                      Setting.of("scaling", scaling)
                          .validate(DoubleRangeValidator.atLeast(1, "scaling_validate")),
                      Setting.of("screen_name", screenName),
                      Setting.of("resolution", resolutionItems, resolutionSelection),
                      Setting.of("orientation", orientationItems, orientationSelection)
                  ).description("screen_options"),
                  Group.of(
                      Setting.of("font_size", fontSize, 6, 36),
                      Setting.of("line_spacing", lineSpacing, 0, 3, 1)
                  )
              )
          ),
      Category.of("favorites",
          Setting.of("favorites", favoritesItems, favoritesSelection),
          Setting.of("favorite_number", customControl, customControlProperty)
      )
  ).i18n(rbs).persistWindowState(false)
   .saveSettings(true).debugHistoryMode(false).buttonsVisibility(true);
}
 
Example #6
Source File: NodeExample.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private PreferencesFx createPreferences() {
  // asciidoctor Documentation - tag::setupPreferences[]
  return PreferencesFx.of(NodeExample.class,
      Category.of("General",
          Group.of("Greeting",
              Setting.of("Welcome Text", welcomeText)
          ),
          Group.of("Display",
              Setting.of("Brightness", brightness),
              Setting.of("Night mode", nightMode)
          )
      ),
      Category.of("Screen", screenIcon)
          .expand()
          .subCategories(
              Category.of("Scaling & Ordering",
                  Group.of(
                      Setting.of("Scaling", scaling)
                          .validate(DoubleRangeValidator
                              .atLeast(1, "Scaling needs to be at least 1")
                          ),
                      Setting.of("Screen name", screenName),
                      Setting.of("Resolution", resolutionItems, resolutionSelection),
                      Setting.of("Orientation", orientationItems, orientationSelection)
                  ).description("Screen Options"),
                  Group.of(
                      Setting.of("Font Size", fontSize, 6, 36),
                      Setting.of("Line Spacing", lineSpacing, 0, 3, 1)
                  )
              )
          ),
      Category.of("Favorites",
          Setting.of("Favorites", favoritesItems, favoritesSelection),
          Setting.of("Favorite Number", customControl, customControlProperty)
      )
  ).persistWindowState(false).saveSettings(true).debugHistoryMode(false).buttonsVisibility(true);
  // asciidoctor Documentation - end::setupPreferences[]
}
 
Example #7
Source File: StandardExample.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private PreferencesFx createPreferences() {
  // asciidoctor Documentation - tag::setupPreferences[]
  return PreferencesFx.of(StandardExample.class,
      Category.of("General",
          Group.of("Greeting",
              Setting.of("Welcome Text", welcomeText)
          ),
          Group.of("Display",
              Setting.of("Brightness", brightness),
              Setting.of("Night mode", nightMode)
          )
      ),
      Category.of("Screen")
          .expand()
          .subCategories(
              Category.of("Scaling & Ordering",
                  Group.of(
                      Setting.of("Scaling", scaling)
                          .validate(DoubleRangeValidator
                              .atLeast(1, "Scaling needs to be at least 1")
                          ),
                      Setting.of("Screen name", screenName),
                      Setting.of("Resolution", resolutionItems, resolutionSelection),
                      Setting.of("Orientation", orientationItems, orientationSelection)
                  ).description("Screen Options"),
                  Group.of(
                      Setting.of("Font Size", fontSize, 6, 36),
                      Setting.of("Line Spacing", lineSpacing, 0, 3, 1)
                  )
              )
          ),
      Category.of("Favorites",
          Setting.of("Favorites", favoritesItems, favoritesSelection),
          Setting.of("Favorite Number", customControl, customControlProperty)
      )
  ).persistWindowState(false).saveSettings(true).debugHistoryMode(false).buttonsVisibility(true);
  // asciidoctor Documentation - end::setupPreferences[]
}
 
Example #8
Source File: SearchHandler.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private void markMatches() {
  if (settingMatches >= 1) {
    filteredSettingsLst.forEach(Setting::mark);
  }
  if (groupMatches >= 1) {
    filteredGroupsLst.forEach(Group::mark);
  }
}
 
Example #9
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of all the groups which are contained in a list of {@code categories}
 * recursively.
 *
 * @param categories the categories to fetch the groups from
 * @return all groups of the categories
 */
public static List<Group> categoriesToGroups(List<Category> categories) {
  return categories.stream()
      .map(Category::getGroups)     // get groups from categories
      .filter(Objects::nonNull)     // remove all null
      .flatMap(Collection::stream)
      .collect(Collectors.toList());
}
 
Example #10
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a map which links {@link Group} to {@link Category} in a list of {@code categories}.
 *
 * @param categories the categories of which to create a map of
 * @return a {@link HashMap} containing {@link Group}, mapped to their
 *         corresponding {@link Category}
 * @apiNote does not flatten the categories
 */
public static HashMap<Group, Category> mapGroupsToCategories(List<Category> categories) {
  HashMap<Group, Category> groupCategoryMap = new HashMap<>();
  for (Category category : categories) {
    if (category.getGroups() != null) {
      for (Group group : category.getGroups()) {
        groupCategoryMap.put(group, category);
      }
    }
  }
  return groupCategoryMap;
}
 
Example #11
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of all the settings which are contained in a list of {@code categories}
 * recursively.
 *
 * @param categories the categories to fetch the elements from
 * @return all elements of the categories
 */
public static List<Element> categoriesToElements(List<Category> categories) {
  return categories.stream()
      .map(Category::getGroups)     // get groups from categories
      .filter(Objects::nonNull)     // remove all null
      .flatMap(Collection::stream)  // recursively flatten all categories
      .map(Group::getSettings)      // get settings from groups
      .filter(Objects::nonNull)     // remove all null
      .flatMap(Collection::stream)  // recursively flatten all settings
      .map(Setting::getElement)
      .map(Element.class::cast)
      .collect(Collectors.toList());
}
 
Example #12
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a list of all the settings which are contained in a list of {@code categories}
 * recursively.
 *
 * @param categories the categories to fetch the settings from
 * @return all settings of the categories
 */
public static List<Setting> categoriesToSettings(List<Category> categories) {
  return categories.stream()
      .map(Category::getGroups)     // get groups from categories
      .filter(Objects::nonNull)     // remove all null
      .flatMap(Collection::stream)  // recursively flatten all categories
      .map(Group::getSettings)      // get settings from groups
      .filter(Objects::nonNull)     // remove all null
      .flatMap(Collection::stream)  // recursively flatten all settings
      .collect(Collectors.toList());
}
 
Example #13
Source File: Preferences.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private PreferencesFx createPreferences() {
  return PreferencesFx.of(PreferencesModule.class,
      Category.of("General",
          Group.of("Greeting",
              Setting.of("Welcome Text", welcomeText)
          ),
          Group.of("Display",
              Setting.of("Brightness", brightness),
              Setting.of("Night mode", nightMode)
          )
      ),
      Category.of("Screen")
          .subCategories(
              Category.of("Scaling & Ordering",
                  Group.of(
                      Setting.of("Scaling", scaling)
                          .validate(DoubleRangeValidator
                              .atLeast(1, "Scaling needs to be at least 1")
                          ),
                      Setting.of("Screen name", screenName),
                      Setting.of("Resolution", resolutionItems, resolutionSelection),
                      Setting.of("Orientation", orientationItems, orientationSelection)
                  ).description("Screen Options"),
                  Group.of(
                      Setting.of("Font Size", fontSize, 6, 36),
                      Setting.of("Line Spacing", lineSpacing, 0, 3, 1)
                  )
              )
          ),
      Category.of("Favorites",
          Setting.of("Favorites", favoritesItems, favoritesSelection),
          Setting.of("Favorite Number", customControl, customControlProperty)
      )
  ).persistWindowState(false).saveSettings(true).debugHistoryMode(false).buttonsVisibility(true);
}
 
Example #14
Source File: OptionsGeneralPanel.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
public Category getGeneralTab() {
    bindings.put(smallSongSizeControllerField, showSmallSongProperty.not());
    bindings.put(smallBibleSizeControllerField, showSmallBibleProperty.not());

    return Category.of(LabelGrabber.INSTANCE.getLabel("general.options.heading"), new ImageView(new Image("file:icons/generalsettingsicon.png")))
            .subCategories(
                    Category.of(LabelGrabber.INSTANCE.getLabel("interface.options.options"),
                            Group.of(LabelGrabber.INSTANCE.getLabel("general.interface.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("interface.language.label"), languageItemsList, languageSelectionProperty).customKey(languageFileKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("interface.theme.label"), applicationThemeList, applicationThemeProperty).customKey(darkThemeKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("db.song.preview.label"), dbSongPreviewList, dbSongPreviewProperty).customKey(dbSongPreviewKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("show.video.library.panel"), new SimpleBooleanProperty(QueleaProperties.get().getDisplayVideoTab())).customKey(videoTabKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("show.extra.live.panel.toolbar.options.label"), new SimpleBooleanProperty(QueleaProperties.get().getShowExtraLivePanelToolbarOptions())).customKey(showExtraLivePanelToolbarOptionsKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("thumbnail.size.label"), thumbnailSizeProperty, 100, 1000).customKey(thumbnailSizeKey)
                            ),
                            Group.of(LabelGrabber.INSTANCE.getLabel("small.song.text.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("show.small.song.text.label"), showSmallSongProperty).customKey(showSmallSongTextKey),
                                    getPositionSelector(LabelGrabber.INSTANCE.getLabel("small.song.position.label"), false, QueleaProperties.get().getSmallSongTextPositionV(), showSmallSongProperty, bindings).customKey(smallSongTextVPositionKey),
                                    getPositionSelector(LabelGrabber.INSTANCE.getLabel("small.song.position.label"), true, QueleaProperties.get().getSmallSongTextPositionH(), showSmallSongProperty, bindings).customKey(smallSongTextHPositionKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("small.song.size.label"), smallSongSizeControllerField, smallSongSizeSpinnerProperty).customKey(smallSongTextSizeKey)
                            ),
                            Group.of(LabelGrabber.INSTANCE.getLabel("small.bible.text.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("show.small.bible.text.label"), showSmallBibleProperty).customKey(showSmallBibleTextKey),
                                    getPositionSelector(LabelGrabber.INSTANCE.getLabel("small.bible.position.label"), false, QueleaProperties.get().getSmallBibleTextPositionV(), showSmallBibleProperty, bindings).customKey(smallBibleTextVPositionKey),
                                    getPositionSelector(LabelGrabber.INSTANCE.getLabel("small.bible.position.label"), true, QueleaProperties.get().getSmallBibleTextPositionH(), showSmallBibleProperty, bindings).customKey(smallBibleTextHPositionKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("small.bible.size.label"), smallBibleSizeControllerField, smallBibleSizeSpinnerProperty).customKey(smallBibleTextSizeKey)
                            )
                    ),
                    Category.of(LabelGrabber.INSTANCE.getLabel("user.options.options"),
                            Group.of(LabelGrabber.INSTANCE.getLabel("general.user.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("check.for.update.label"), new SimpleBooleanProperty(QueleaProperties.get().checkUpdate())).customKey(checkUpdateKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("1.monitor.warn.label"), new SimpleBooleanProperty(QueleaProperties.get().showSingleMonitorWarning())).customKey(singleMonitorWarningKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("auto.translate.label"), new SimpleBooleanProperty(QueleaProperties.get().getAutoTranslate())).customKey(autoTranslateKey)
                            ),
                            Group.of(LabelGrabber.INSTANCE.getLabel("theme.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("allow.item.theme.override.global"), new SimpleBooleanProperty(QueleaProperties.get().getItemThemeOverride())).customKey(itemThemeOverrideKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("preview.on.image.change.label"), new SimpleBooleanProperty(QueleaProperties.get().getPreviewOnImageUpdate())).customKey(previewOnImageChangeKey)
                            ),
                            Group.of(LabelGrabber.INSTANCE.getLabel("schedule.options"),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("one.line.mode.label"), new SimpleBooleanProperty(QueleaProperties.get().getOneLineMode())).customKey(oneLineModeKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("autoplay.vid.label"), new SimpleBooleanProperty(QueleaProperties.get().getAutoPlayVideo())).customKey(autoplayVidKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("advance.on.live.label"), new SimpleBooleanProperty(QueleaProperties.get().getAdvanceOnLive())).customKey(advanceOnLiveKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("overflow.song.label"), new SimpleBooleanProperty(QueleaProperties.get().getSongOverflow())).customKey(songOverflowKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("copy.song.db.default"), new SimpleBooleanProperty(QueleaProperties.get().getDefaultSongDBUpdate())).customKey(defaultSongDbUpdateKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("clear.live.on.remove.schedule"), new SimpleBooleanProperty(QueleaProperties.get().getClearLiveOnRemove())).customKey(clearLiveOnRemoveKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("embed.media.in.schedule"), new SimpleBooleanProperty(QueleaProperties.get().getEmbedMediaInScheduleFile())).customKey(scheduleEmbedMediaKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("slide.transition.label"), new SimpleBooleanProperty(QueleaProperties.get().getUseSlideTransition())).customKey(useSlideTransitionKey)
                            )

                    ),
                    Category.of(LabelGrabber.INSTANCE.getLabel("text.options.options"),
                            Group.of(
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("capitalise.start.line.label"), new SimpleBooleanProperty(QueleaProperties.get().checkCapitalFirst())).customKey(capitalFirstKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("uniform.font.size.label"), new SimpleBooleanProperty(QueleaProperties.get().getUseUniformFontSize())).customKey(uniformFontSizeKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("max.font.size.label"), maxFontSizeProperty, 12, 300).customKey(maxFontSizeKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("additional.line.spacing.label"), additionalSpacingProperty, 0, 50).customKey(additionalLineSpacingKey),
                                    Setting.of(LabelGrabber.INSTANCE.getLabel("max.chars.line.label"), maxCharsProperty, 10, 160).customKey(maxCharsKey)
                            )
                    )
            ).expand();
}
 
Example #15
Source File: DisplayGroup.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
public Group getGroup() {
    return group;
}
 
Example #16
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 3 votes vote down vote up
/**
 * Filters a list of {@code groups} by a given {@code description}.
 *
 * @param groups      the list of groups to be filtered
 * @param description to be searched for
 * @return a list of {@code groups}, containing (ignoring case) the given {@code description}
 */
public static List<Group> filterGroupsByDescription(List<Group> groups, String description) {
  return groups.stream()
      .filter(group -> !Strings.isNullOrEmpty(group.getDescription()))
      .filter(group -> containsIgnoreCase(group.getDescription(), description))
      .collect(Collectors.toList());
}
 
Example #17
Source File: PreferencesFxUtils.java    From PreferencesFX with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a list of all the settings which are contained in a list of {@code groups}
 * recursively.
 *
 * @param groups the groups to fetch the settings from
 * @return all settings of the groups
 */
public static List<Setting> groupsToSettings(List<Group> groups) {
  return groups.stream()
      .map(Group::getSettings)
      .flatMap(Collection::stream)
      .collect(Collectors.toList());
}