Skip to content

Commit

Permalink
MID-9278 display (deprecating embedded=true/false) annotation integrated
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Nov 13, 2023
1 parent 77a8fc3 commit d91889e
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ default boolean isIgnored() {
*/
boolean isEmphasized();

DisplayHint getDisplay();

/**
* Returns display name.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* "display" annotation enumeration also replaces emphasized=true.
*/
public enum Display {
public enum DisplayHint {

/**
* Item shouldn't be visible.
Expand Down Expand Up @@ -43,11 +43,11 @@ public enum Display {

final String value;

Display(final String value) {
DisplayHint(final String value) {
this.value = value;
}

public static Display findByValue(String value) {
public static DisplayHint findByValue(String value) {
if (value == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public interface MutableDefinition extends Definition {

void setEmphasized(boolean emphasized);

void setDisplay(DisplayHint display);

void setDisplayName(String displayName);

void setDisplayOrder(Integer displayOrder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.*;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.Definition;
import com.evolveum.midpoint.prism.ItemProcessing;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.SchemaMigration;
import com.evolveum.midpoint.prism.SmartVisitation;
import com.evolveum.midpoint.prism.Visitor;
import com.evolveum.midpoint.prism.schema.SchemaRegistry;

import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -123,6 +119,10 @@ default String getDeprecatedSince() {
return delegate().getDeprecatedSince();
}

@Override
default DisplayHint getDisplay() {
return delegate().getDisplay();
}
@Override
default boolean isEmphasized() {
return delegate().isEmphasized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public abstract class DefinitionImpl extends AbstractFreezable implements Mutabl
@NotNull protected QName typeName;
protected ItemProcessing processing;
protected boolean isAbstract = false;
protected DisplayHint display;
protected String displayName;
protected Integer displayOrder;
protected String help;
Expand Down Expand Up @@ -201,6 +202,18 @@ public void setElaborate(boolean elaborate) {
setAnnotation(PrismConstants.A_ELABORATE, elaborate);
}

@Override
public DisplayHint getDisplay() {
return display;
}

@Override
public void setDisplay(DisplayHint display) {
checkMutable();
this.display = display;
setAnnotation(PrismConstants.A_DISPLAY, display);
}

@Override
public boolean isEmphasized() {
return emphasized;
Expand All @@ -210,7 +223,7 @@ public boolean isEmphasized() {
public void setEmphasized(boolean emphasized) {
checkMutable();
this.emphasized = emphasized;
setAnnotation(PrismConstants.A_DISPLAY, emphasized ? Display.EMPHASIZED : null);
setAnnotation(PrismConstants.A_DISPLAY, emphasized ? DisplayHint.EMPHASIZED : null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
@Experimental
public class DummyPrismObjectDefinition implements PrismObjectDefinition<Objectable> {

@Override
public DisplayHint getDisplay() {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public ItemName getItemName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.Display;
import com.evolveum.midpoint.prism.DisplayHint;

import com.sun.xml.xsom.XSAnnotation;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -49,11 +49,11 @@ public enum Annotation {
@Deprecated
EMPHASIZED(A_EMPHASIZED, Boolean.class, true),

DISPLAY(A_DISPLAY, Display.class, null, new AnnotationProcessor() {
DISPLAY(A_DISPLAY, DisplayHint.class, null, new AnnotationProcessor() {

@Override
protected @Nullable Object convert(@NotNull Annotation annotation, @NotNull Element element) {
return Display.findByValue(element.getTextContent());
return DisplayHint.findByValue(element.getTextContent());
}
}),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="display" type="tns:DisplayType">
<xsd:element name="display" type="tns:DisplayHintType">
<xsd:annotation>
<xsd:documentation>
Enumeration annotation that specifies how the item should be displayed.
Expand All @@ -173,7 +173,7 @@
</xsd:annotation>
</xsd:element>

<xsd:simpleType name="DisplayType">
<xsd:simpleType name="DisplayHintType">
<xsd:annotation>
<xsd:documentation>
Display hints for an item.
Expand Down

0 comments on commit d91889e

Please sign in to comment.