Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.gradle
.studio
.idea
*.ipr
*.iml
*.iws
build/*
deploy/*
modules/*/build/*
out
test-run
test-run
classes/*
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

buildscript {
ext.cubaVersion = '6.8.0'
repositories {
Expand Down Expand Up @@ -36,7 +35,7 @@ def bintrayRepositoryUrl = "https://api.bintray.com/maven/balvi/cuba-components/
cuba {
artifact {
group = 'de.balvi.cuba.declarativecontrollers'
version = '0.5.0'
version = '0.5.1'
isSnapshot = false
}
tomcat {
Expand Down Expand Up @@ -84,7 +83,7 @@ cobertura {
coverageCheckTotalLineRate = 40
coverageCheckHaltOnFailure = true
coverageSourceDirs = sourceDirs
// coverageCheckLineRate = 1
coverageCheckLineRate = 40
coverageCheckRegexes = [[regex: '.*\\$.*', branchRate: 0, lineRate: 0]]

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package de.balvi.cuba.declarativecontrollers.web.annotationexecutor;

import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.components.Frame;
import de.balvi.cuba.declarativecontrollers.web.annotationexecutor.browse.BrowseAnnotationExecutor;
import de.balvi.cuba.declarativecontrollers.web.annotationexecutor.browse.BrowseFieldAnnotationExecutor;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -28,14 +31,14 @@ protected Annotation[] getClassAnnotations(Frame frame) {
return frame.getClass().getAnnotations();
}

protected Collection<? extends AnnotationExecutor> getSupportedAnnotationExecutors(Collection<? extends AnnotationExecutor> potentialAnnotationExecutors, Annotation annotation) {
protected <T extends AnnotationExecutor> Collection<T> getSupportedAnnotationExecutors(Collection<T> potentialAnnotationExecutors, Annotation annotation) {
Collection<AnnotationExecutor> result = new ArrayList<AnnotationExecutor>();
for (AnnotationExecutor annotationExecutor : potentialAnnotationExecutors) {
if (annotationExecutor.supports(annotation)) {
result.add(annotationExecutor);
}
}
return result;

return (Collection<T>) result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private void executeInitForFieldAnnotations(AnnotatableAbstractLookup browse, Ma

for (Annotation annotation : fieldAnnotations) {

Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedBrowseFieldAnnotationExecutors(annotation);
Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getBrowseFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(browse, field);
Expand All @@ -41,7 +41,7 @@ private void executeInitForFieldAnnotations(AnnotatableAbstractLookup browse, Ma

private void executeInitForClassAnnotations(AnnotatableAbstractLookup browse, Map<String, Object> params) {
for (Annotation annotation : getClassAnnotations(browse)) {
Collection<BrowseAnnotationExecutor> supportedAnnotationExecutors = getSupportedBrowseAnnotationExecutors(annotation);
Collection<BrowseAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getBrowseAnnotationExecutors(), annotation);

for (BrowseAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.init(annotation, browse, params);
Expand All @@ -50,7 +50,6 @@ private void executeInitForClassAnnotations(AnnotatableAbstractLookup browse, Ma
}



@Override
public void executeReady(AnnotatableAbstractLookup browse, Map<String, Object> params) {
executeReadyForClassAnnotations(browse, params);
Expand All @@ -63,7 +62,7 @@ private void executeReadyForFieldAnnotations(AnnotatableAbstractLookup browse, M
Annotation[] fieldAnnotations = field.getAnnotations();
for (Annotation annotation : fieldAnnotations) {

Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedBrowseFieldAnnotationExecutors(annotation);
Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getBrowseFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(browse, field);
Expand All @@ -78,7 +77,7 @@ private void executeReadyForFieldAnnotations(AnnotatableAbstractLookup browse, M
private void executeReadyForClassAnnotations(AnnotatableAbstractLookup browse, Map<String, Object> params) {
for (Annotation annotation : getClassAnnotations(browse)) {

Collection<BrowseAnnotationExecutor> supportedAnnotations = getSupportedBrowseAnnotationExecutors(annotation);
Collection<BrowseAnnotationExecutor> supportedAnnotations = getSupportedAnnotationExecutors(getBrowseAnnotationExecutors(), annotation);

for (BrowseAnnotationExecutor annotationExecutor : supportedAnnotations) {
annotationExecutor.ready(annotation, browse, params);
Expand All @@ -87,6 +86,7 @@ private void executeReadyForClassAnnotations(AnnotatableAbstractLookup browse, M
}


/*
protected Collection<BrowseAnnotationExecutor> getSupportedBrowseAnnotationExecutors(Annotation annotation) {
Collection<BrowseAnnotationExecutor> annotationExecutors = getBrowseAnnotationExecutors();
return (Collection<BrowseAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);
Expand All @@ -96,7 +96,7 @@ protected Collection<BrowseFieldAnnotationExecutor> getSupportedBrowseFieldAnnot
Collection<BrowseFieldAnnotationExecutor> annotationExecutors = getBrowseFieldAnnotationExecutors();
return (Collection<BrowseFieldAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);
}

*/
protected Collection<BrowseAnnotationExecutor> getBrowseAnnotationExecutors() {
return AppBeans.getAll(BrowseAnnotationExecutor.class).values();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void executeInit(AnnotatableAbstractEditor editor, Map<String, Object> pa
private void executeInitForClassAnnotations(AnnotatableAbstractEditor editor, Map<String, Object> params) {
for (Annotation annotation : getClassAnnotations(editor)) {

Collection<EditorAnnotationExecutor> supportedAnnotationExecutors = getSupportedEditorAnnotationExecutors(annotation);
Collection<EditorAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getEditorAnnotationExecutors(), annotation);

for (EditorAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.init(annotation, editor, params);
Expand All @@ -38,7 +38,7 @@ private void executeInitForFieldAnnotations(AnnotatableAbstractEditor editor, Ma
Annotation[] fieldAnnotations = field.getAnnotations();
for (Annotation annotation : fieldAnnotations) {

Collection<EditorFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedEditorFieldAnnotationExecutors(annotation);
Collection<EditorFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getEditorFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(editor, field);
Expand All @@ -62,7 +62,7 @@ private void executeInitForFieldAnnotations(AnnotatableAbstractEditor editor) {
for (Field field : getDeclaredFields(editor)) {
Annotation[] fieldAnnotations = field.getAnnotations();
for (Annotation annotation : fieldAnnotations) {
Collection<EditorFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedEditorFieldAnnotationExecutors(annotation);
Collection<EditorFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getEditorFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(editor, field);
Expand All @@ -78,14 +78,15 @@ private void executePostInitForClassAnnotations(AnnotatableAbstractEditor editor

for (Annotation annotation : getClassAnnotations(editor)) {

Collection<EditorAnnotationExecutor> supportedAnnotationExecutors = getSupportedEditorAnnotationExecutors(annotation);
Collection<EditorAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getEditorAnnotationExecutors(), annotation);

for (EditorAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.postInit(annotation, editor);
}
}
}

/*
protected Collection<EditorAnnotationExecutor> getSupportedEditorAnnotationExecutors(Annotation annotation) {
Collection<EditorAnnotationExecutor> annotationExecutors = getEditorAnnotationExecutors();
return (Collection<EditorAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);
Expand All @@ -96,6 +97,7 @@ protected Collection<EditorFieldAnnotationExecutor> getSupportedEditorFieldAnnot
return (Collection<EditorFieldAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);

}
*/

protected Collection<EditorAnnotationExecutor> getEditorAnnotationExecutors() {
return AppBeans.getAll(EditorAnnotationExecutor.class).values();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.balvi.cuba.declarativecontrollers.web.entitycombined;

import com.haulmont.cuba.gui.components.EntityCombinedScreen;

import javax.inject.Inject;
import java.util.Map;

public class AnnotatableAbstractCombined extends EntityCombinedScreen {

@Inject
protected CombinedAnnotationDispatcher combinedAnnotationDispatcher;

private Map<String, Object> params;

@Override
public void init(Map<String, Object> params) {
super.init(params);
this.params = params;
combinedAnnotationDispatcher.executeInit(this, params);
}

@Override
public void ready() {
combinedAnnotationDispatcher.executeReady(this, params);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package de.balvi.cuba.declarativecontrollers.web.entitycombined;

import java.util.Map;

public interface CombinedAnnotationDispatcher {

String NAME = "dbcdc_CombinedAnnotationExecutorService";

void executeInit(AnnotatableAbstractCombined browse, Map<String, Object> params);
void executeReady(AnnotatableAbstractCombined browse, Map<String, Object> params);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package de.balvi.cuba.declarativecontrollers.web.entitycombined;

import com.haulmont.cuba.core.global.AppBeans;
import de.balvi.cuba.declarativecontrollers.web.annotationexecutor.AbstractAnnotationDispatcherBean;
import de.balvi.cuba.declarativecontrollers.web.annotationexecutor.browse.BrowseAnnotationExecutor;
import de.balvi.cuba.declarativecontrollers.web.annotationexecutor.browse.BrowseFieldAnnotationExecutor;
import org.springframework.stereotype.Component;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.Collection;
import java.util.Map;

@Component(CombinedAnnotationDispatcher.NAME)
class CombinedAnnotationDispatcherBean extends AbstractAnnotationDispatcherBean<BrowseAnnotationExecutor, BrowseFieldAnnotationExecutor> implements CombinedAnnotationDispatcher {

@Override
public void executeInit(AnnotatableAbstractCombined browse, Map<String, Object> params) {
executeInitForClassAnnotations(browse, params);
executeInitForFieldAnnotations(browse, params);
}

private void executeInitForFieldAnnotations(AnnotatableAbstractCombined browse, Map<String, Object> params) {
for (Field field : getDeclaredFields(browse)) {
Annotation[] fieldAnnotations = field.getAnnotations();

for (Annotation annotation : fieldAnnotations) {

Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getCombinedFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(browse, field);
for (BrowseFieldAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.init(annotation, browse, fieldValue, params);
}
}

}
}
}

private void executeInitForClassAnnotations(AnnotatableAbstractCombined browse, Map<String, Object> params) {
for (Annotation annotation : getClassAnnotations(browse)) {
Collection<BrowseAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getCombinedAnnotationExecutors(), annotation);

for (BrowseAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.init(annotation, browse, params);
}
}
}


@Override
public void executeReady(AnnotatableAbstractCombined browse, Map<String, Object> params) {
executeReadyForClassAnnotations(browse, params);
executeReadyForFieldAnnotations(browse, params);
}

private void executeReadyForFieldAnnotations(AnnotatableAbstractCombined browse, Map<String, Object> params) {
for (Field field : getDeclaredFields(browse)) {

Annotation[] fieldAnnotations = field.getAnnotations();
for (Annotation annotation : fieldAnnotations) {

Collection<BrowseFieldAnnotationExecutor> supportedAnnotationExecutors = getSupportedAnnotationExecutors(getCombinedFieldAnnotationExecutors(), annotation);

if (supportedAnnotationExecutors != null && supportedAnnotationExecutors.size() > 0) {
com.haulmont.cuba.gui.components.Component fieldValue = getFieldValue(browse, field);
for (BrowseFieldAnnotationExecutor annotationExecutor : supportedAnnotationExecutors) {
annotationExecutor.ready(annotation, browse, fieldValue, params);
}
}
}
}
}

private void executeReadyForClassAnnotations(AnnotatableAbstractCombined browse, Map<String, Object> params) {
for (Annotation annotation : getClassAnnotations(browse)) {

Collection<BrowseAnnotationExecutor> supportedAnnotations = getSupportedAnnotationExecutors(getCombinedAnnotationExecutors(), annotation);

for (BrowseAnnotationExecutor annotationExecutor : supportedAnnotations) {
annotationExecutor.ready(annotation, browse, params);
}
}
}

/*
protected Collection<BrowseAnnotationExecutor> getSupportedCombinedAnnotationExecutors(Annotation annotation) {
Collection<BrowseAnnotationExecutor> annotationExecutors = getCombinedAnnotationExecutors();
return (Collection<BrowseAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);
}

protected Collection<BrowseFieldAnnotationExecutor> getSupportedCombinedFieldAnnotationExecutors(Annotation annotation) {
Collection<BrowseFieldAnnotationExecutor> annotationExecutors = getCombinedFieldAnnotationExecutors();
return (Collection<BrowseFieldAnnotationExecutor>) getSupportedAnnotationExecutors(annotationExecutors, annotation);
}
*/
protected Collection<BrowseAnnotationExecutor> getCombinedAnnotationExecutors() {
return AppBeans.getAll(BrowseAnnotationExecutor.class).values();
}


protected Collection<BrowseFieldAnnotationExecutor> getCombinedFieldAnnotationExecutors() {
return AppBeans.getAll(BrowseFieldAnnotationExecutor.class).values();

}

}

Loading