Skip to content

Commit

Permalink
feat: Enhance Page Definition to introduce sections - MEED-5878 - Mee…
Browse files Browse the repository at this point in the history
…ds-io/MIPs#120

This change will allow to define pages layout using sections, cells and columns.
  • Loading branch information
boubaker committed Apr 20, 2024
1 parent 3b7b1ed commit 586f909
Show file tree
Hide file tree
Showing 37 changed files with 1,043 additions and 1,431 deletions.
Expand Up @@ -25,6 +25,9 @@
import org.exoplatform.portal.pom.data.ApplicationData;
import org.exoplatform.portal.pom.spi.portlet.Portlet;

import lombok.Getter;
import lombok.Setter;

/**
* May 13, 2004
*
Expand Down Expand Up @@ -52,10 +55,6 @@ public class Application<S> extends ModelObject implements Cloneable {

private String theme;

private String width;

private String height;

private Properties properties;

private String[] accessPermissions;
Expand All @@ -65,6 +64,10 @@ public class Application<S> extends ModelObject implements Cloneable {
/** We cannot allow the type to change once the object is created. */
private final ApplicationType<S> type;

@Getter
@Setter
private ModelStyle style;

public Application(ApplicationData<S> data) {
super(data.getStorageId());

Expand Down Expand Up @@ -223,11 +226,52 @@ public void setTheme(String theme) {
this.theme = theme;
}

@Override
public String getCssClass() {
if (cssClass == null && style == null) {
return null;
} else {
StringBuilder cssClasses = new StringBuilder();
if (cssClass != null) {
cssClasses.append(cssClass);
}
if (style != null) {
cssClasses.append(" ");
cssClasses.append(style.getCssClass());
}
return cssClasses.toString();
}
}

@Override
public String getBorderColor() {
if (style != null && style.getBorderColor() != null) {
return style.getBorderColor();
} else {
return super.getBorderColor();
}
}

@Override
public ApplicationData build() {
return new ApplicationData<S>(storageId, storageName, getType(), state, id, title, icon, description, showInfoBar,
showApplicationState, showApplicationMode, theme, width, height, cssClass, borderColor, Utils.safeImmutableMap(properties),
Utils.safeImmutableList(accessPermissions));
return new ApplicationData<S>(getStorageId(),
getStorageName(),
getType(),
getState(),
getId(),
getTitle(),
getIcon(),
getDescription(),
getShowInfoBar(),
getShowApplicationState(),
getShowApplicationMode(),
getTheme(),
getWidth(),
getHeight(),
getCssClass(),
getBorderColor(),
Utils.safeImmutableMap(properties),
Utils.safeImmutableList(accessPermissions));
}

public static Application<Portlet> createPortletApplication(ApplicationData<Portlet> data) {
Expand Down
@@ -0,0 +1,68 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.exoplatform.portal.config.model;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class Cell extends Container {

private int colSpan = 1;

private int rowSpan = 1;

private ModelStyle style;

@Override
public String getCssClass() {
StringBuilder cssClasses = new StringBuilder();
if (cssClass != null) {
cssClasses.append(cssClass);
}
cssClasses.append(" grid-cell");
cssClasses.append(" grid-cell-colspan-md-").append(colSpan);
cssClasses.append(" grid-cell-colspan-lg-").append(colSpan);
cssClasses.append(" grid-cell-colspan-xl-").append(colSpan);
cssClasses.append(" grid-cell-rowspan-md-").append(rowSpan);
cssClasses.append(" grid-cell-rowspan-lg-").append(rowSpan);
cssClasses.append(" grid-cell-rowspan-xl-").append(rowSpan);
if (style != null) {
cssClasses.append(" ");
cssClasses.append(style.getCssClass());
}
return cssClasses.toString();
}

@Override
public String getBorderColor() {
if (style != null && style.getBorderColor() != null) {
return style.getBorderColor();
} else {
return super.getBorderColor();
}
}

@Override
public String getTemplate() {
return "CellContainer";
}

}
@@ -0,0 +1,51 @@
/**
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association contact@meeds.io
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package org.exoplatform.portal.config.model;

import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class Column extends Container {

private int colSpan = 1;

@Override
public String getCssClass() {
StringBuilder cssClasses = new StringBuilder();
if (cssClass != null) {
cssClasses.append(cssClass);
}
cssClasses.append(" flex-cell");
cssClasses.append(" grid-cell-colspan-md-").append(colSpan);
cssClasses.append(" grid-cell-colspan-lg-").append(colSpan);
cssClasses.append(" grid-cell-colspan-xl-").append(colSpan);
cssClasses.append(" grid-cell-rowspan-md-1");
cssClasses.append(" grid-cell-rowspan-lg-1");
cssClasses.append(" grid-cell-rowspan-xl-1");
return cssClasses.toString();
}

@Override
public String getTemplate() {
return "CellContainer";
}

}
Expand Up @@ -57,9 +57,6 @@ public class Container extends ModelObject implements Cloneable {

protected String profiles;

// Here to please jibx binding but not used anymore
protected String decorator;

protected String[] accessPermissions;

protected String[] moveAppsPermissions;
Expand All @@ -77,21 +74,12 @@ public Container(String storageId) {
super(storageId);
setDefaultPermissions();
//
this.children = new ArrayList<ModelObject>();
this.children = new ArrayList<>();
}

public Container(ContainerData data) {
super(data.getStorageId());

//
ArrayList<ModelObject> children = new ArrayList<ModelObject>();
for (ComponentData child : data.getChildren()) {
ModelObject m = ModelObject.build(child);
if (m != null) {
children.add(ModelObject.build(child));
}
}

//
this.id = data.getId();
this.name = data.getName();
Expand All @@ -110,7 +98,13 @@ public Container(ContainerData data) {
this.moveAppsPermissions = permisssions != null ? permisssions.toArray(new String[permisssions.size()]) : null;
permisssions = data.getMoveContainersPermissions();
this.moveContainersPermissions = permisssions != null ? permisssions.toArray(new String[permisssions.size()]) : null;
this.children = children;
this.children = new ArrayList<>();
for (ComponentData child : data.getChildren()) {
ModelObject m = ModelObject.build(child);
if (m != null) {
children.add(ModelObject.build(child));
}
}
}

private void setDefaultPermissions() {
Expand Down Expand Up @@ -208,16 +202,6 @@ public void setMoveContainersPermissions(String[] moveContainersPermissions) {
this.moveContainersPermissions = moveContainersPermissions;
}

public String getDecorator() {
// Here to please jibx binding but not used anymore
return null;
}

// Here to please jibx binding but not used anymore
public void setDecorator(String decorator) {
// Here to please jibx binding but not used anymore
}

public String getProfiles() {
return profiles;
}
Expand All @@ -228,55 +212,50 @@ public void setProfiles(String profiles) {

@Override
public ContainerData build() {
List<ComponentData> children = buildChildren();
return new ContainerData(storageId,
id,
name,
icon,
template,
factoryId,
title,
description,
width,
height,
cssClass,
borderColor,
profiles,
return new ContainerData(getStorageId(),
getId(),
getName(),
getIcon(),
getTemplate(),
getFactoryId(),
getTitle(),
getDescription(),
getWidth(),
getHeight(),
getCssClass(),
getBorderColor(),
getProfiles(),
Utils.safeImmutableList(accessPermissions),
Utils.safeImmutableList(moveAppsPermissions),
Utils.safeImmutableList(moveContainersPermissions),
children);
buildChildren());
}

@Override
public void resetStorage() {
super.resetStorage();
if (children != null && !children.isEmpty()) {
for (ModelObject child : children) {
if (getChildren() != null && !getChildren().isEmpty()) {
for (ModelObject child : getChildren()) {
child.resetStorage();
}
}
}

@Override
public Container clone() {
try {
return (Container) super.clone();
} catch (CloneNotSupportedException e) {
return new Container(build());
}
public Container clone() { // NOSONAR
return new Container(build());
}

protected List<ComponentData> buildChildren() {
if (StringUtils.isNotBlank(profiles)) {
Set<String> activeProfiles = Tools.parseCommaList(profiles);
protected List<ComponentData> buildChildren() { // NOSONAR
if (StringUtils.isNotBlank(getProfiles())) {
Set<String> activeProfiles = Tools.parseCommaList(getProfiles());
if (ExoContainer.getProfiles()
.stream()
.noneMatch(activeProfiles::contains)) {
return Collections.emptyList();
}
}
if (children != null && !children.isEmpty()) {
if (getChildren() != null && !getChildren().isEmpty()) {
ArrayList<ComponentData> dataChildren = new ArrayList<>();
for (int i = 0; i < children.size(); i++) {
ModelObject node = children.get(i);
Expand Down

0 comments on commit 586f909

Please sign in to comment.