Skip to content

Commit

Permalink
Merge pull request #506 from dlsc-software-consulting-gmbh/features-a…
Browse files Browse the repository at this point in the history
…dd-cssplayground
  • Loading branch information
dlemmermann authored Oct 1, 2023
2 parents f006a1c + dc8d88e commit 041309b
Show file tree
Hide file tree
Showing 28 changed files with 5,893 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void start(Stage stage) {
Scene scene = new Scene(customStage, 1400, 800);
scene.setFill(Color.web("070B32"));
scene.widthProperty().addListener((it -> updateSizeProperty(scene)));
scene.getStylesheets().add(Objects.requireNonNull(NodeUtil.class.getResource("/com/dlsc/jfxcentral2/theme.css")).toExternalForm());
scene.getStylesheets().add(Objects.requireNonNull(NodeUtil.class.getResource("/com/dlsc/jfxcentral2/jfxcentral2-theme.css")).toExternalForm());

updateSizeProperty(scene);

Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/com/dlsc/jfxcentral2/app/pages/PageBase.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dlsc.jfxcentral2.app.pages;

import com.dlsc.jfxcentral2.app.pages.details.UtilityDetailsPage;
import com.dlsc.jfxcentral2.components.CopyrightView;
import com.dlsc.jfxcentral2.components.FooterView;
import com.dlsc.jfxcentral2.components.Mode;
Expand Down Expand Up @@ -99,7 +100,7 @@ public Node wrapContent(Region... content) {
vbox.getChildren().addAll(topStackPane, sponsorsView, footerView, copyrightView);

StackPane glassPane = new StackPane();
glassPane.getStyleClass().add("glass-pane");
glassPane.getStyleClass().add("page-glass-pane");
glassPane.visibleProperty().bind(topMenuBar.usedProperty().or(blockingProperty()));
glassPane.setOnMouseClicked(evt -> setShowHamburgerMenu(false));

Expand All @@ -112,6 +113,19 @@ public Node wrapContent(Region... content) {
StackPane root = new StackPane(vbox, glassPane, hamburgerMenuView);
root.getStyleClass().add("background");

/*
* The CSS playground is a special case, because it used for testing custom CSS styles.
*/
if (this instanceof UtilityDetailsPage utilityDetailsPage) {
if (!utilityDetailsPage.getItem().getId().equals("cssplayground")) {
root.getStyleClass().add("normal-page");
}else {
root.getStyleClass().add("css-playground-page");
}
} else {
root.getStyleClass().add("normal-page");
}

return root;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected Node createTopNode() {
return null;
}

public Node getTopNode() {
return topWrapper.getChildren().get(0);
}

protected Node createBottomNode() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.dlsc.jfxcentral.data.DataRepository2;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.components.CustomMarkdownView;
import com.dlsc.jfxcentral2.utilities.cssplayground.CssPlaygroundView;
import com.dlsc.jfxcentral2.utilities.pathextractor.SVGPathExtractorView;
import com.dlsc.jfxcentral2.utils.ModelObjectTool;
import javafx.scene.Node;
import javafx.scene.control.Label;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.Logger;
import org.kordamp.ikonli.elusive.Elusive;
import org.kordamp.ikonli.fileicons.FileIcons;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.materialdesign2.MaterialDesignS;
Expand Down Expand Up @@ -41,18 +43,24 @@ protected Node createBottomNode() {
}

private Node createToolPane(Utility model) {
if (ModelObjectTool.isUtilityCanBeUsed(model)) {
if (StringUtils.containsIgnoreCase(model.getDescription(), "path")) {
//if (ModelObjectTool.isUtilityCanBeUsed(model)) {
if (StringUtils.equalsIgnoreCase(model.getId(), "pathextractor")) {
setTitle("SVG Path Extractor");
setIcon(MaterialDesignS.SHAPE_OUTLINE);
SVGPathExtractorView view = new SVGPathExtractorView(model);
view.sizeProperty().bind(sizeProperty());
return view;
} else if (StringUtils.equalsIgnoreCase(model.getId(), "cssplayground")) {
setTitle("Css Playground");
setIcon(Elusive.CSS);
CssPlaygroundView cssPlaygroundView = new CssPlaygroundView();
cssPlaygroundView.sizeProperty().bind(sizeProperty());
return cssPlaygroundView;
}
return createComingSoonPane();
}

return createComingSoonPane();
return createComingSoonPane();
//}
//return createComingSoonPane();
}

private Node readmeView(Utility model) {
Expand All @@ -63,7 +71,7 @@ private Node readmeView(Utility model) {
}

private Node createComingSoonPane() {
Label label = new Label("Coming soon. Stay tuned!" ,new FontIcon(FileIcons.CAFFE2));
Label label = new Label("Coming soon. Stay tuned!", new FontIcon(FileIcons.CAFFE2));
label.getStyleClass().add("coming-soon-label");
return label;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.dlsc.jfxcentral.data.model.DevelopmentStatus;
import com.dlsc.jfxcentral.data.model.Utility;
import com.dlsc.jfxcentral2.components.AvatarView;
import com.dlsc.jfxcentral2.utils.ModelObjectTool;
import com.dlsc.jfxcentral2.utils.SaveAndLikeUtil;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
Expand All @@ -24,7 +23,7 @@ public UtilityTileView(Utility utility) {
titleProperty().set(utility.getName());
setDescription(utility.getDescription());

setDisable(!ModelObjectTool.isUtilityCanBeUsed(utility));
//setDisable(!ModelObjectTool.isUtilityCanBeUsed(utility));

updateLinkedObjectBadges();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.dlsc.jfxcentral2.utilities.cssplayground;

import com.dlsc.jfxcentral2.components.FileHandlerView;
import com.dlsc.jfxcentral2.components.PaneBase;
import com.dlsc.jfxcentral2.utils.StringUtil;
import javafx.concurrent.Service;
import javafx.concurrent.Task;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import org.kordamp.ikonli.antdesignicons.AntDesignIconsOutlined;
import org.kordamp.ikonli.javafx.FontIcon;

import java.util.List;


public class CssPlaygroundView extends PaneBase {

private final Label tipsLabel;
private final VBox container ;

public CssPlaygroundView() {
getStyleClass().add("css-playground-view");

FileHandlerView fileHandlerView = new FileHandlerView(true, true, true);
fileHandlerView.getSupportedExtensions().add(".css");
fileHandlerView.setText("Click or drop CSS files here");
fileHandlerView.managedProperty().bind(fileHandlerView.visibleProperty());
fileHandlerView.setVisible(false);

tipsLabel = new Label(StringUtil.LOADING_TIPS);
tipsLabel.getStyleClass().add("tips-label");
tipsLabel.setGraphic(new FontIcon(AntDesignIconsOutlined.CLOUD_DOWNLOAD));

container = new VBox();
container.getChildren().addAll(fileHandlerView, tipsLabel);
container.getStyleClass().add("container");

getChildren().setAll(container);

CssShowcaseService service = new CssShowcaseService();
service.setOnSucceeded(event -> {
CssShowcaseView cssShowcaseView = service.getValue();
fileHandlerView.setOnUploadedFile(file -> cssShowcaseView.cssFileHandler(List.of(file)));
fileHandlerView.setVisible(true);

container.getChildren().remove(tipsLabel);
container.getChildren().add(cssShowcaseView);
});

service.start();
}

private static class CssShowcaseService extends Service<CssShowcaseView> {
@Override
protected Task<CssShowcaseView> createTask() {
return new Task<>() {
@Override
protected CssShowcaseView call() {
return new CssShowcaseView();
}
};
}
}
}

Loading

0 comments on commit 041309b

Please sign in to comment.