Skip to content

Commit fe7d861

Browse files
authored
Merge pull request #429 from dlemmermann/develop
From develop.
2 parents 48ef800 + a58f083 commit fe7d861

63 files changed

Lines changed: 501 additions & 127 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/com/dlsc/jfxcentral2/app/JFXCentral2App.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
import one.jpro.routing.sessionmanager.SessionManager;
7474
import simplefx.experimental.parts.FXFuture;
7575

76+
import java.awt.image.BufferedImage;
77+
import java.io.File;
7678
import java.util.Locale;
7779
import java.util.Objects;
7880
import java.util.function.Supplier;
@@ -90,10 +92,17 @@ public class JFXCentral2App extends Application {
9092
@Override
9193
public void start(Stage stage) {
9294

95+
// This is a workaround to prevent a deadlock between the TrayIcon and the JPro ImageManager
96+
BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
97+
bi.createGraphics();
98+
9399
if (!WebAPI.isBrowser()) {
94100
System.setProperty("prism.lcdtext", "false");
95101
System.setProperty("routing.scrollpane", PrettyScrollPane.class.getName());
96102
}
103+
// set jpro.imagemanager.cache to ~/.jfxcentral/imagecache
104+
System.setProperty("jpro.imagemanager.cache", new File(new File(System.getProperty("user.home")), ".jfxcentral/imagecache").getAbsolutePath());
105+
System.out.println("jpro.imagemanager.cache: " + System.getProperty("jpro.imagemanager.cache"));
97106

98107
stage.initStyle(StageStyle.UNDECORATED);
99108

@@ -153,6 +162,8 @@ public Route createRoute() {
153162
}
154163
return new RefreshPage(size);
155164
}))
165+
.and(RouteUtils.redirect("/home", "/"))
166+
.and(RouteUtils.redirect("/index", "/"))
156167
.and(createCategoryOrDetailRoute("/blogs", Blog.class, () -> new BlogsCategoryPage(size), id -> new BlogDetailsPage(size, id))) // new routing for showcases
157168
.and(createCategoryOrDetailRoute("/books", Book.class, () -> new BooksCategoryPage(size), id -> new BookDetailsPage(size, id)))
158169
.and(createCategoryOrDetailRoute("/companies", Company.class, () -> new CompaniesCategoryPage(size), id -> new CompanyDetailsPage(size, id))) // new routing for showcases

app/src/main/java/com/dlsc/jfxcentral2/app/pages/LinksOfTheWeekPage.java

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@
1010
import com.dlsc.jfxcentral2.components.tiles.TileViewBase;
1111
import com.dlsc.jfxcentral2.model.Size;
1212
import com.dlsc.jfxcentral2.utils.IkonUtil;
13+
import javafx.beans.binding.Bindings;
1314
import javafx.beans.property.ObjectProperty;
1415
import javafx.collections.FXCollections;
1516
import javafx.collections.ObservableList;
1617
import javafx.scene.Node;
18+
import javafx.scene.control.Button;
19+
import javafx.scene.control.Label;
20+
import javafx.scene.layout.HBox;
21+
import javafx.scene.layout.Priority;
1722
import javafx.util.Callback;
1823
import org.kordamp.ikonli.Ikon;
24+
import org.kordamp.ikonli.bootstrapicons.BootstrapIcons;
25+
import org.kordamp.ikonli.javafx.FontIcon;
1926

2027
import java.time.format.DateTimeFormatter;
2128
import java.time.format.FormatStyle;
@@ -54,7 +61,6 @@ protected Ikon getCategoryIkon() {
5461
@Override
5562
public Node content() {
5663

57-
5864
// header
5965
LinksOfTheWeekHeader header = new LinksOfTheWeekHeader();
6066
header.sizeProperty().bind(sizeProperty());
@@ -66,24 +72,62 @@ public Node content() {
6672

6773
// this is a category page, but we still need to use the details content pane for layout purposes
6874
DetailsContentPane detailsContentPane = new DetailsContentPane();
75+
detailsContentPane.getStyleClass().add("lotw-details-content-pane");
6976
detailsContentPane.sizeProperty().bind(sizeProperty());
7077
detailsContentPane.getCenterNodes().add(linksOfTheWeekView);
7178

79+
detailsContentPane.setLeftTopExtraNode(createPaginationBox(linksOfTheWeekView));
80+
7281
// this must be the last change to the details content pane, otherwise the menu shows wrong items
7382
detailsContentPane.getMenuView().getItems().setAll(createMenuItems(linksOfTheWeekView));
7483

75-
linksOfTheWeekView.selectedIndexProperty().addListener((ob, ov, nv) ->{
84+
linksOfTheWeekView.selectedIndexProperty().addListener((ob, ov, nv) -> {
7685
int size = detailsContentPane.getMenuView().getItems().size();
77-
if(nv.intValue() >= 0 && nv.intValue() < size) {
86+
if (nv.intValue() >= 0 && nv.intValue() < size) {
7887
detailsContentPane.getMenuView().setSelectedIndex(nv.intValue());
79-
}else {
88+
} else {
8089
detailsContentPane.getMenuView().setSelectedIndex(-1);
8190
}
8291
});
8392

8493
return wrapContent(header, detailsContentPane);
8594
}
8695

96+
private HBox createPaginationBox(LinksOfTheWeekView linksOfTheWeekView) {
97+
Button previousButton = new Button();
98+
previousButton.getStyleClass().add("prev-button");
99+
previousButton.setGraphic(new FontIcon(BootstrapIcons.ARROW_LEFT_CIRCLE_FILL));
100+
previousButton.setMouseTransparent(false);
101+
previousButton.setOnAction(e -> linksOfTheWeekView.goToPreviousPage());
102+
previousButton.disableProperty().bind(linksOfTheWeekView.selectedIndexProperty().isEqualTo(0));
103+
104+
Label pageLabel = new Label();
105+
pageLabel.getStyleClass().add("page-label");
106+
pageLabel.textProperty().bind(Bindings.createStringBinding(() -> {
107+
int index = linksOfTheWeekView.selectedIndexProperty().get();
108+
int size = linksOfTheWeekView.getLinksOfTheWeeks().size();
109+
return (index + 1) + " / " + size;
110+
}, linksOfTheWeekView.selectedIndexProperty(), linksOfTheWeekView.getLinksOfTheWeeks()));
111+
pageLabel.setMaxWidth(Double.MAX_VALUE);
112+
HBox.setHgrow(pageLabel, Priority.ALWAYS);
113+
114+
Button nextButton = new Button();
115+
nextButton.getStyleClass().add("next-button");
116+
nextButton.setMouseTransparent(false);
117+
nextButton.setGraphic(new FontIcon(BootstrapIcons.ARROW_RIGHT_CIRCLE_FILL));
118+
nextButton.setOnAction(e -> linksOfTheWeekView.goToNextPage());
119+
nextButton.disableProperty().bind(linksOfTheWeekView.selectedIndexProperty().isEqualTo(linksOfTheWeekView.getLinksOfTheWeeks().size() - 1));
120+
121+
HBox paginationBox = new HBox(previousButton, pageLabel, nextButton);
122+
paginationBox.getStyleClass().add("pagination-box");
123+
paginationBox.managedProperty().bind(paginationBox.visibleProperty());
124+
paginationBox.visibleProperty().bind(Bindings.createBooleanBinding(() ->
125+
linksOfTheWeekView.getLinksOfTheWeeks().size() > 1 && sizeProperty().get() == Size.LARGE,
126+
linksOfTheWeekView.getLinksOfTheWeeks(), sizeProperty())
127+
);
128+
return paginationBox;
129+
}
130+
87131
@Override
88132
protected ObservableList<LinksOfTheWeek> getCategoryItems() {
89133
return FXCollections.observableArrayList(DataRepository2.getInstance().getLinksOfTheWeek());
@@ -101,13 +145,13 @@ protected SearchFilterView<LinksOfTheWeek> createSearchFilterView() {
101145

102146
protected List<MenuView.Item> createMenuItems(LinksOfTheWeekView linksOfTheWeekView) {
103147
List<LinksOfTheWeek> linksOfTheWeek = DataRepository2.getInstance().getLinksOfTheWeek();
104-
List<LinksOfTheWeek> weeks = new ArrayList<>(linksOfTheWeek);
148+
List<LinksOfTheWeek> weeks = new ArrayList<>(linksOfTheWeek);
105149

106150
return weeks
107151
.stream()
108152
.sorted(Comparator.comparing(LinksOfTheWeek::getCreatedOn).reversed())
109153
.limit(20)
110-
.map(links -> new MenuView.Item(DATE_FORMATTER.format(links.getCreatedOn()), null, null, () -> linksOfTheWeekView.goToPage(linksOfTheWeek.size()-linksOfTheWeek.indexOf(links)-1)))
154+
.map(links -> new MenuView.Item(DATE_FORMATTER.format(links.getCreatedOn()), null, null, () -> linksOfTheWeekView.goToPage(linksOfTheWeek.size() - linksOfTheWeek.indexOf(links) - 1)))
111155
.toList();
112156
}
113157
}

app/src/main/java/com/dlsc/jfxcentral2/app/pages/OpenJFXPage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public Node content() {
8989
}
9090

9191
private void updateUI(PullRequestsFilterView pullRequestsFilterView, PullRequestsView pullRequestsView) {
92+
filteredList.setPredicate(null);
9293
filteredList.setPredicate(pullRequestsFilterView.getPredicate());
9394
if (!pullRequests.isEmpty()) {
9495
pullRequestsFilterView.setDisable(false);

app/src/main/java/module-info.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
requires org.kordamp.ikonli.whhg;
7373
requires org.kordamp.ikonli.win10;
7474
requires org.kordamp.ikonli.zondicons;
75-
requires FXTrayIcon;
75+
requires com.dustinredmond.fxtrayicon;
7676
requires com.dlsc.jfxcentral2.iconfont;
7777
// ikonli icon packs END
7878

-46.6 KB
Loading
Binary file not shown.

components/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
</properties>
2121

2222
<dependencies>
23+
24+
<dependency>
25+
<groupId>one.jpro</groupId>
26+
<artifactId>jpro-imagemanager</artifactId>
27+
<version>0.1.0</version>
28+
</dependency>
29+
2330
<dependency>
2431
<groupId>com.google.code.gson</groupId>
2532
<artifactId>gson</artifactId>

components/src/main/java/com/dlsc/jfxcentral2/components/DetailsContentPane.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,24 @@
1010
import javafx.beans.Observable;
1111
import javafx.beans.binding.Bindings;
1212
import javafx.beans.property.ListProperty;
13+
import javafx.beans.property.ObjectProperty;
1314
import javafx.beans.property.SimpleListProperty;
15+
import javafx.beans.property.SimpleObjectProperty;
1416
import javafx.collections.FXCollections;
1517
import javafx.collections.ObservableList;
1618
import javafx.geometry.Orientation;
1719
import javafx.geometry.Pos;
1820
import javafx.scene.Node;
21+
import javafx.scene.layout.BorderPane;
1922
import javafx.scene.layout.HBox;
2023
import javafx.scene.layout.Priority;
24+
import javafx.scene.layout.Region;
2125
import javafx.scene.layout.VBox;
2226

2327
public class DetailsContentPane extends PaneBase {
2428

2529
private final MenuView menuView = new MenuView();
30+
private final BorderPane leftSidePane = new BorderPane();
2631

2732
private final CommentsView commentsView = new CommentsView();
2833
private final FeaturesContainer featuresContainer = new FeaturesContainer();
@@ -48,7 +53,11 @@ public DetailsContentPane() {
4853
menuView.visibleProperty().bind(sizeProperty().isEqualTo(Size.LARGE));
4954
menuView.managedProperty().bind(menuView.visibleProperty());
5055

51-
HBox.setHgrow(menuView, Priority.NEVER);
56+
leftSidePane.setCenter(menuView);
57+
leftSidePane.topProperty().bind(leftTopExtraNodeProperty());
58+
leftSidePane.setMaxHeight(Region.USE_PREF_SIZE);
59+
60+
HBox.setHgrow(leftSidePane, Priority.NEVER);
5261

5362
commentsView.sizeProperty().bind(sizeProperty());
5463
commentsView.setVisible(SocialUtil.isSocialFeaturesEnabled());
@@ -145,13 +154,13 @@ private void updateUI() {
145154
centerBox.getChildren().addAll(detailBoxesContainer, commentsView);
146155

147156
if (size.equals(Size.SMALL) || size.equals(Size.MEDIUM)) {
148-
VBox intermediateBox = new VBox(menuView, centerBox, featuresContainer);
157+
VBox intermediateBox = new VBox(leftSidePane, centerBox, featuresContainer);
149158
intermediateBox.getStyleClass().add("intermediate-box");
150159
intermediateBox.setAlignment(Pos.TOP_CENTER);
151160
HBox.setHgrow(intermediateBox, Priority.ALWAYS);
152161
contentBox.getChildren().setAll(intermediateBox);
153162
} else {
154-
contentBox.getChildren().setAll(menuView, centerBox, featuresContainer);
163+
contentBox.getChildren().setAll(leftSidePane, centerBox, featuresContainer);
155164
}
156165
}
157166

@@ -174,4 +183,18 @@ public void setCenterNodes(ObservableList<Node> centerNodes) {
174183
public ObservableList<DetailsBoxBase<?>> getDetailBoxes() {
175184
return detailBoxes;
176185
}
186+
187+
private final ObjectProperty<Node> leftTopExtraNode = new SimpleObjectProperty<>(this, "leftTopExtraNode");
188+
189+
public Node getLeftTopExtraNode() {
190+
return leftTopExtraNode.get();
191+
}
192+
193+
public ObjectProperty<Node> leftTopExtraNodeProperty() {
194+
return leftTopExtraNode;
195+
}
196+
197+
public void setLeftTopExtraNode(Node leftTopExtraNode) {
198+
this.leftTopExtraNode.set(leftTopExtraNode);
199+
}
177200
}

components/src/main/java/com/dlsc/jfxcentral2/components/FeaturesContainer.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.dlsc.jfxcentral2.model.Feature;
1616
import com.dlsc.jfxcentral2.model.Feature.Type;
1717
import com.dlsc.jfxcentral2.utils.IkonUtil;
18+
import com.dlsc.jfxcentral2.utils.ModelObjectTool;
1819
import com.dlsc.jfxcentral2.utils.PageUtil;
1920
import javafx.beans.property.ListProperty;
2021
import javafx.beans.property.ObjectProperty;
@@ -108,28 +109,9 @@ private String getRemark(ModelObject mo) {
108109

109110
private ObjectProperty<Image> getImageProperty(ModelObject mo) {
110111
Objects.requireNonNull(mo, "model object can not be null");
112+
// HERE
111113

112-
if (mo instanceof Video video) {
113-
return ImageManager.getInstance().youTubeImageProperty(video);
114-
} else if (mo instanceof Tip tip) {
115-
return ImageManager.getInstance().tipBannerImageProperty(tip);
116-
} else if (mo instanceof Tutorial tutorial) {
117-
return ImageManager.getInstance().tutorialImageProperty(tutorial);
118-
} else if (mo instanceof Library library) {
119-
return ImageManager.getInstance().libraryImageProperty(library);
120-
} else if (mo instanceof RealWorldApp app) {
121-
return ImageManager.getInstance().realWorldAppBannerImageProperty(app);
122-
} else if (mo instanceof Person person) {
123-
return ImageManager.getInstance().personImageProperty(person);
124-
} else if (mo instanceof Blog blog) {
125-
return ImageManager.getInstance().blogIconImageProperty(blog);
126-
} else if (mo instanceof Tool tool) {
127-
return ImageManager.getInstance().toolImageProperty(tool);
128-
} else if (mo instanceof Book book) {
129-
return ImageManager.getInstance().bookCoverImageProperty(book);
130-
} else {
131-
throw new IllegalArgumentException("model object of type " + mo.getClass().getSimpleName() + " is not supported");
132-
}
114+
return ModelObjectTool.getModelPreviewImageProperty(mo, true);
133115
}
134116

135117
private Type getType(ModelObject mo) {

0 commit comments

Comments
 (0)