Skip to content

Commit

Permalink
Refactoring from "OnlineTool" to "Utility".
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemmermann committed Sep 29, 2023
1 parent d2f9e2c commit 4b867a1
Show file tree
Hide file tree
Showing 24 changed files with 151 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.dlsc.jfxcentral.data.model.IkonliPack;
import com.dlsc.jfxcentral.data.model.Library;
import com.dlsc.jfxcentral.data.model.ModelObject;
import com.dlsc.jfxcentral.data.model.OnlineTool;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral.data.model.Person;
import com.dlsc.jfxcentral.data.model.RealWorldApp;
import com.dlsc.jfxcentral.data.model.Tip;
Expand All @@ -34,7 +34,7 @@
import com.dlsc.jfxcentral2.app.pages.category.DownloadsCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.IconsCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.LibrariesCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.OnlineToolsCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.UtilitiesCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.PeopleCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.ShowcasesCategoryPage;
import com.dlsc.jfxcentral2.app.pages.category.TipCategoryPage;
Expand All @@ -47,7 +47,7 @@
import com.dlsc.jfxcentral2.app.pages.details.DownloadDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.IconPackDetailPage;
import com.dlsc.jfxcentral2.app.pages.details.LibraryDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.OnlineToolsDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.UtilityDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.PersonDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.ShowcaseDetailsPage;
import com.dlsc.jfxcentral2.app.pages.details.TipDetailsPage;
Expand Down Expand Up @@ -201,7 +201,7 @@ public Route createRoute() {
.and(createCategoryOrDetailRoute("/tutorials", Tutorial.class, () -> new TutorialsCategoryPage(size), id -> new TutorialDetailsPage(size, id))) // new routing for showcases
.and(createCategoryOrDetailRoute("/videos", Video.class, () -> new VideosCategoryPage(size), id -> new VideoDetailsPage(size, id)))
.and(createCategoryOrDetailRoute("/icons", IkonliPack.class, () -> new IconsCategoryPage(size), id -> new IconPackDetailPage(size, id)))
.and(createCategoryOrDetailRoute("/onlinetools", OnlineTool.class, () -> new OnlineToolsCategoryPage(size), id -> new OnlineToolsDetailsPage(size, id)))
.and(createCategoryOrDetailRoute("/utilities", Utility.class, () -> new UtilitiesCategoryPage(size), id -> new UtilityDetailsPage(size, id)))
.and(RouteUtils.get("/credits", r -> new CreditsPage(size)))
.and(RouteUtils.get("/legal", r -> new LegalPage(size, LegalPage.Section.TERMS)))
.and(RouteUtils.get("/legal/terms", r -> new LegalPage(size, LegalPage.Section.TERMS)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void refresh() {
Menu realWorld = new Menu("Real World Apps");
Menu tips = new Menu("Tips & Tricks");
Menu icons = new Menu("Icons");
Menu onlineTools = new Menu("Online Tools");
Menu utilities = new Menu("Utilities");
Menu documentation = new Menu("Documentation");

DataRepository2 repository = DataRepository2.getInstance();
Expand All @@ -90,7 +90,7 @@ public void refresh() {
repository.getRealWorldApps().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(realWorld, mo));
repository.getTips().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(tips, mo));
repository.getIkonliPacks().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(icons, mo));
repository.getOnlineTools().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(onlineTools, mo));
repository.getUtilities().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(utilities, mo));
repository.getDocumentation().stream().sorted(Comparator.comparing(ModelObject::getName)).forEach(mo -> createMenuItem(documentation, mo, modelObject -> {
String docUrl = null;
try {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void refresh() {
trayIcon.addMenuItem(reportIssue);

trayIcon.addSeparator();
trayIcon.addMenuItem(onlineTools);
trayIcon.addMenuItem(utilities);
trayIcon.addSeparator();

trayIcon.addMenuItem(documentation);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.dlsc.jfxcentral2.app.pages.category;

import com.dlsc.jfxcentral.data.DataRepository2;
import com.dlsc.jfxcentral.data.model.OnlineTool;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.app.pages.CategoryPageBase;
import com.dlsc.jfxcentral2.components.filters.OnlineToolsFilterView;
import com.dlsc.jfxcentral2.components.filters.UtilitiesFilterView;
import com.dlsc.jfxcentral2.components.filters.SearchFilterView;
import com.dlsc.jfxcentral2.components.tiles.OnlineToolTileView;
import com.dlsc.jfxcentral2.components.tiles.UtilityTileView;
import com.dlsc.jfxcentral2.components.tiles.TileViewBase;
import com.dlsc.jfxcentral2.model.Size;
import com.dlsc.jfxcentral2.utils.IkonUtil;
Expand All @@ -15,30 +15,30 @@
import javafx.util.Callback;
import org.kordamp.ikonli.Ikon;

public class OnlineToolsCategoryPage extends CategoryPageBase<OnlineTool> {
public class UtilitiesCategoryPage extends CategoryPageBase<Utility> {

public OnlineToolsCategoryPage(ObjectProperty<Size> size) {
public UtilitiesCategoryPage(ObjectProperty<Size> size) {
super(size);
}

@Override
public String title() {
return "JFXCentral - Online Develop Tools";
return "JFXCentral - Utilities";
}

@Override
public String description() {
return "Online tools for developing JavaFX applications.";
return "Utilities for developing JavaFX applications.";
}

@Override
protected String getCategoryTitle() {
return "Online Tools";
return "Utilities";
}

@Override
protected Ikon getCategoryIkon() {
return IkonUtil.getModelIkon(OnlineTool.class);
return IkonUtil.getModelIkon(Utility.class);
}

@Override
Expand All @@ -47,18 +47,18 @@ protected int getNumberOfGridViewRows() {
}

@Override
protected Callback<OnlineTool, TileViewBase<OnlineTool>> getTileViewProvider() {
return OnlineToolTileView::new;
protected Callback<Utility, TileViewBase<Utility>> getTileViewProvider() {
return UtilityTileView::new;
}

@Override
protected SearchFilterView<OnlineTool> createSearchFilterView() {
return new OnlineToolsFilterView();
protected SearchFilterView<Utility> createSearchFilterView() {
return new UtilitiesFilterView();
}

@Override
protected ObservableList<OnlineTool> getCategoryItems() {
return FXCollections.observableArrayList(DataRepository2.getInstance().getOnlineTools());
protected ObservableList<Utility> getCategoryItems() {
return FXCollections.observableArrayList(DataRepository2.getInstance().getUtilities());
}

}
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package com.dlsc.jfxcentral2.app.pages.details;

import com.dlsc.jfxcentral.data.model.OnlineTool;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.app.pages.DetailsPageBase;
import com.dlsc.jfxcentral2.components.DetailsContentPane;
import com.dlsc.jfxcentral2.components.headers.OnlineToolDetailHeader;
import com.dlsc.jfxcentral2.components.overviewbox.OnlineToolOverviewBox;
import com.dlsc.jfxcentral2.components.headers.UtilityDetailHeader;
import com.dlsc.jfxcentral2.components.overviewbox.UtilityOverviewBox;
import com.dlsc.jfxcentral2.model.Size;
import javafx.beans.property.ObjectProperty;
import javafx.scene.Node;

public class OnlineToolsDetailsPage extends DetailsPageBase<OnlineTool> {
public class UtilityDetailsPage extends DetailsPageBase<Utility> {

public OnlineToolsDetailsPage(ObjectProperty<Size> size, String itemId) {
super(size, OnlineTool.class, itemId);
public UtilityDetailsPage(ObjectProperty<Size> size, String itemId) {
super(size, Utility.class, itemId);
}


@Override
public Node content() {
OnlineTool onlineTool = getItem();
Utility utility = getItem();

// header
OnlineToolDetailHeader header = new OnlineToolDetailHeader(onlineTool);
UtilityDetailHeader header = new UtilityDetailHeader(utility);
header.sizeProperty().bind(sizeProperty());

// overview
OnlineToolOverviewBox overviewBox = new OnlineToolOverviewBox(onlineTool);
UtilityOverviewBox overviewBox = new UtilityOverviewBox(utility);
overviewBox.sizeProperty().bind(sizeProperty());

// details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@
import com.dlsc.jfxcentral.data.model.Tool;
import com.dlsc.jfxcentral.data.model.Tutorial;
import com.dlsc.jfxcentral.data.model.Video;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.utils.IkonUtil;
import com.dlsc.jfxcentral2.utils.PageUtil;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import one.jpro.platform.routing.LinkUtil;
import org.apache.commons.lang3.StringUtils;
import org.kordamp.ikonli.javafx.FontIcon;

public class SearchResultCell extends ListCell<ModelObject> {

private FontIcon fontIcon = new FontIcon();
private Label titleLabel = new Label();
private Label subtitleLabel = new Label();
private final FontIcon fontIcon = new FontIcon();
private final Label titleLabel = new Label();
private final Label subtitleLabel = new Label();

public SearchResultCell() {
getStyleClass().add("search-result-list-cell");
Expand Down Expand Up @@ -102,6 +101,8 @@ private String getTypePrefix(Class<? extends ModelObject> clazz) {
return "Post";
} else if (clazz.equals(IkonliPack.class)) {
return "Icon Pack";
} else if (clazz.equals(Utility.class)) {
return "Utility";
} else {
return "Item";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ public List<ModelObject> search(String pattern) {
search(repository.getDownloads(), pattern, results);
search(repository.getTutorials(), pattern, results);
search(repository.getTips(), pattern, results);
search(repository.getUtilities(), pattern, results);
search(repository.getIkonliPacks(), pattern, results);


return results;
}

Expand Down Expand Up @@ -214,11 +216,11 @@ protected void layoutBySize() {
showcasesBtn.getStyleClass().add("showcases-button");
LinkUtil.setLink(showcasesBtn, "/showcases");

Button onlineToolsBtn = new Button("Online Tools");
onlineToolsBtn.setFocusTraversable(false);
onlineToolsBtn.setMinWidth(Region.USE_PREF_SIZE);
onlineToolsBtn.getStyleClass().add("online-tools-button");
LinkUtil.setLink(onlineToolsBtn, "/onlinetools");
Button utilitiesButton = new Button("Utilities");
utilitiesButton.setFocusTraversable(false);
utilitiesButton.setMinWidth(Region.USE_PREF_SIZE);
utilitiesButton.getStyleClass().add("online-tools-button");
LinkUtil.setLink(utilitiesButton, "/utilities");

Button documentationBtn = new Button("Documentation");
documentationBtn.setFocusTraversable(false);
Expand Down Expand Up @@ -248,7 +250,7 @@ protected void layoutBySize() {

searchField.setVisible(true);
searchField.setMinWidth(Region.USE_PREF_SIZE);
contentBox.getChildren().setAll(logoWrapper, new Spacer(), resourcesBtn, communityBtn, showcasesBtn, onlineToolsBtn, documentationBtn, downloadsBtn, separatorRegion, loginBtn, searchField);
contentBox.getChildren().setAll(logoWrapper, new Spacer(), resourcesBtn, communityBtn, showcasesBtn, utilitiesButton, documentationBtn, downloadsBtn, separatorRegion, loginBtn, searchField);
} else {
Region logoutRegion = new Region();
logoutRegion.getStyleClass().add("logout-region");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.dlsc.jfxcentral2.components.filters;

import com.dlsc.jfxcentral.data.model.OnlineTool;
import com.dlsc.jfxcentral.data.model.Utility;
import org.apache.commons.lang3.StringUtils;

import java.util.Comparator;
import java.util.List;

public class OnlineToolsFilterView extends SimpleModelObjectSearchFilterView<OnlineTool> {
public class UtilitiesFilterView extends SimpleModelObjectSearchFilterView<Utility> {

public OnlineToolsFilterView() {
getStyleClass().addAll("online-tools-filter-view", "tools-filter-view");
public UtilitiesFilterView() {
getStyleClass().addAll("utilities-filter-view", "tools-filter-view");

setSearchPromptText("Search online tools");
setSearchPromptText("Search utilities");

setSortGroup(new SortGroup<>("ORDER",
List.of(
new SortItem<>("Status", Comparator.comparing((OnlineTool modelObject) -> modelObject.getStatus().ordinal())),
new SortItem<>("From A to Z", Comparator.comparing((OnlineTool modelObject) -> modelObject.getName().toLowerCase())),
new SortItem<>("From Z to A", Comparator.comparing((OnlineTool modelObject) -> modelObject.getName().toLowerCase()).reversed())
new SortItem<>("Status", Comparator.comparing((Utility modelObject) -> modelObject.getStatus().ordinal())),
new SortItem<>("From A to Z", Comparator.comparing((Utility modelObject) -> modelObject.getName().toLowerCase())),
new SortItem<>("From Z to A", Comparator.comparing((Utility modelObject) -> modelObject.getName().toLowerCase()).reversed())
)
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ public HamburgerMenuView(boolean mobile) {
}

HamburgerMenu showcases = new HamburgerMenu("Showcases", "/showcases");
HamburgerMenu onlineTools = new HamburgerMenu("Online Tools", "/onlinetools");
HamburgerMenu utilities = new HamburgerMenu("Utilities", "/utilities");
HamburgerMenu documentation = new HamburgerMenu("Documentation", "/documentation");
HamburgerMenu downloads = new HamburgerMenu("Downloads", "/downloads");

setMaxHeight(Region.USE_PREF_SIZE);

getMenus().addAll(resourcesMenu, communityMenu, showcases,onlineTools, documentation);
getMenus().addAll(resourcesMenu, communityMenu, showcases,utilities, documentation);
if (!mobile) {
getMenus().add(downloads);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.dlsc.jfxcentral2.components.headers;

import com.dlsc.jfxcentral.data.model.ModelObject;
import com.dlsc.jfxcentral.data.model.OnlineTool;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.components.CustomImageView;
import com.dlsc.jfxcentral2.components.SaveAndLikeButton;
import com.dlsc.jfxcentral2.utils.IkonUtil;
Expand Down Expand Up @@ -42,8 +42,8 @@ public SimpleDetailHeader(T model) {
getStyleClass().add("simple-detail-header");

setCenter(createCenterNode());
if (model instanceof OnlineTool onlineTool) {
setSummary(onlineTool.getDescription());
if (model instanceof Utility utility) {
setSummary(utility.getDescription());
}else {
setSummary(model.getSummary());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.dlsc.jfxcentral2.components.headers;

import com.dlsc.jfxcentral.data.ImageManager;
import com.dlsc.jfxcentral.data.model.Utility;

public class UtilityDetailHeader extends SimpleDetailHeader<Utility> {

public UtilityDetailHeader(Utility utility) {
super(utility);

getStyleClass().addAll("utility-detail-header");

imageProperty().bind(ImageManager.getInstance().utilityImageProperty(utility));

// setWebsite(StringUtils.isNotBlank(getModel().getHomepage()) ? getModel().getHomepage() : getModel().getRepository());
// setWebsiteButtonText(StringUtils.isNotBlank(getModel().getHomepage()) ? "WEBSITE" : "REPOSITORY");
setShareUrl("utilities/" + utility.getId());
setShareText("Found this utility on @JFXCentral: " + utility.getName());
setShareTitle("Utility: " + utility.getName());
setBackText("UTILITIES");
setBackUrl("/utilities");
}
}
Loading

0 comments on commit 4b867a1

Please sign in to comment.