Skip to content

Commit

Permalink
editor presentation model for crnk-ui #517
Browse files Browse the repository at this point in the history
  • Loading branch information
remmeier committed Jun 20, 2019
1 parent 3c9c00f commit e4fa964
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@
@JsonApiResource(type = "meta/primitiveType")
public class MetaPrimitiveType extends MetaType {

public static final String ID_STRING = "base.string";

public static final String ID_INT = "base.int";

public static final String ID_BYTE = "base.byte";

public static final String ID_SHORT = "base.short";

public static final String ID_LONG = "base.long";
}
4 changes: 2 additions & 2 deletions crnk-meta/src/main/java/io/crnk/meta/model/MetaType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.crnk.meta.model;

import java.lang.reflect.Type;

import com.fasterxml.jackson.annotation.JsonIgnore;
import io.crnk.core.engine.internal.utils.ClassUtils;
import io.crnk.core.engine.internal.utils.PreconditionUtil;
Expand All @@ -8,8 +10,6 @@
import io.crnk.core.resource.annotations.LookupIncludeBehavior;
import io.crnk.core.resource.annotations.SerializeType;

import java.lang.reflect.Type;

@JsonApiResource(type = "meta/type")
public class MetaType extends MetaElement {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.crnk.ui.presentation.factory;

import io.crnk.meta.model.MetaPrimitiveType;
import io.crnk.meta.model.MetaType;
import io.crnk.ui.presentation.PresentationEnvironment;
import io.crnk.ui.presentation.PresentationType;
Expand All @@ -16,9 +17,11 @@ public boolean accepts(PresentationEnvironment env) {
@Override
public PresentationElement create(PresentationEnvironment env) {
MetaType type = env.getType();
Class implClass = type.getElementType().getImplementationClass();
boolean isNumber = implClass == long.class || implClass == byte.class || implClass == short.class
|| implClass == int.class || Number.class.isAssignableFrom(implClass);
String id = type.getId();
boolean isNumber = MetaPrimitiveType.ID_SHORT.equals(id) ||
MetaPrimitiveType.ID_BYTE.equals(id) ||
MetaPrimitiveType.ID_INT.equals(id) ||
MetaPrimitiveType.ID_LONG.equals(id);
boolean isCell = env.getAcceptedTypes().contains(PresentationType.CELL);

PlainTextElement element = new PlainTextElement();
Expand Down

0 comments on commit e4fa964

Please sign in to comment.