Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meed Layout Editor - Meeds-io/MIPs#120 #876

Merged
merged 14 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion component/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<name>GateIn Portal Component API</name>

<properties>
<exo.test.coverage.ratio>0</exo.test.coverage.ratio>
<exo.test.coverage.ratio>0.01</exo.test.coverage.ratio>
</properties>

<dependencies>
Expand Down Expand Up @@ -291,6 +291,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Used to add BuildNumber in application.properties -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.exoplatform.portal.config.model.ApplicationType;

import lombok.Getter;
import lombok.Setter;

/**
* Created by the eXo platform team User: Benjamin Mestrallet Date: 15 juin 2004
*/
Expand Down Expand Up @@ -58,6 +62,10 @@ public class Application implements Serializable {
/** . */
private String contentId;

@Getter
@Setter
private List<String> supportedModes;

public String getContentId() {
return contentId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
package org.exoplatform.portal.config.model;

import org.exoplatform.container.ExoContainerContext;
import org.exoplatform.portal.application.Preference;
import org.exoplatform.portal.mop.service.LayoutService;
import org.exoplatform.portal.pom.config.Utils;
import org.exoplatform.portal.pom.data.ApplicationData;
import org.exoplatform.portal.pom.spi.portlet.Portlet;
import org.exoplatform.portal.pom.spi.portlet.PortletBuilder;

import lombok.Getter;
import lombok.Setter;

/**
* May 13, 2004
Expand Down Expand Up @@ -54,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 @@ -67,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 cssStyle;

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

Expand All @@ -86,6 +87,8 @@ public Application(ApplicationData<S> data) {
this.theme = data.getTheme();
this.width = data.getWidth();
this.height = data.getHeight();
this.cssClass = data.getCssClass();
this.borderColor = data.getBorderColor();
this.properties = new Properties(data.getProperties());
this.accessPermissions = data.getAccessPermissions().toArray(new String[data.getAccessPermissions().size()]);
this.type = data.getType();
Expand Down Expand Up @@ -223,11 +226,52 @@ public void setTheme(String theme) {
this.theme = theme;
}

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

@Override
public String getBorderColor() {
if (cssStyle != null && cssStyle.getBorderColor() != null) {
return cssStyle.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, 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
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,8 @@ public class Container extends ModelObject implements Cloneable {

protected String description;

protected String width;

protected String height;

protected String cssClass;

protected String profiles;

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

protected String[] accessPermissions;

protected String[] moveAppsPermissions;
Expand All @@ -76,28 +67,19 @@ public class Container extends ModelObject implements Cloneable {

public Container() {
setDefaultPermissions();
children = new ArrayList<ModelObject>();
children = new ArrayList<>();
}

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 @@ -109,13 +91,20 @@ public Container(ContainerData data) {
this.width = data.getWidth();
this.height = data.getHeight();
this.cssClass = data.getCssClass();
this.borderColor = data.getBorderColor();
this.profiles = data.getProfiles();
this.accessPermissions = data.getAccessPermissions().toArray(new String[data.getAccessPermissions().size()]);
List<String> permisssions = data.getMoveAppsPermissions();
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 @@ -157,22 +146,6 @@ public void setChildren(ArrayList<ModelObject> children) {
this.children = children;
}

public String getHeight() {
return height;
}

public void setHeight(String height) {
this.height = height;
}

public String getWidth() {
return width;
}

public void setWidth(String width) {
this.width = width;
}

public String getDescription() {
return description;
}
Expand Down Expand Up @@ -229,24 +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 getCssClass() {
return cssClass;
}

public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}

public String getProfiles() {
return profiles;
}
Expand All @@ -257,54 +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,
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