Skip to content

Commit

Permalink
Implement ChooserDialog order
Browse files Browse the repository at this point in the history
  • Loading branch information
eschleb committed Jun 20, 2024
1 parent 0e5c2ad commit add6c9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.slf4j.Logger;
Expand Down Expand Up @@ -87,6 +89,12 @@ private WorkbenchDefinition<T> getWorkbench(final Object factoryObject, final Ch
private List<ContentViewDefinition<T>> getContentViews(final Object factoryObject, final ChooserDialogFactory annotation) {
return Arrays.stream(factoryObject.getClass().getDeclaredMethods())
.filter(method -> method.getReturnType().isAssignableFrom(ContentViewDefinition.class))
.sorted(Comparator.comparingInt(method ->
Optional
.ofNullable(method.getAnnotation(ChooserDialogFactory.Order.class))
.map(ChooserDialogFactory.Order::value)
.orElse(-1)
))
.map(method -> {
try {
//noinspection unchecked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@
String id();
String label();
boolean hasFullTextSearch() default true;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@interface Order {
int value();
}
}

0 comments on commit add6c9e

Please sign in to comment.