33import java .util .List ;
44import java .util .function .Supplier ;
55
6+ import javax .servlet .http .HttpServletResponse ;
7+
68import com .vaadin .icons .VaadinIcons ;
9+ import com .vaadin .server .Sizeable .Unit ;
710import com .vaadin .ui .Alignment ;
811import com .vaadin .ui .Button ;
912import com .vaadin .ui .CustomLayout ;
1821import de .symeda .sormas .api .i18n .Strings ;
1922import de .symeda .sormas .ui .utils .ButtonHelper ;
2023import de .symeda .sormas .ui .utils .CssStyles ;
21- import de .symeda .sormas .ui .utils .LayoutUtil ;
22- import de .symeda .sormas .ui .utils .LayoutUtil .FluidColumn ;
2324
2425/**
2526 * Provides UI components to integrate with the SurvNet gateway
2627 */
2728public class SurvnetGateway {
2829
29- private static final String SURVNET_GATEWAY_LOC = "survnetGateway" ;
30+ public static final String SURVNET_GATEWAY_LOC = "survnetGateway" ;
3031
3132 private SurvnetGateway () {
3233 //NOOP
3334 }
3435
35- public static FluidColumn layoutFragment () {
36- //TODO only add it if the feature is active? Then LayoutUtil.fluidRow would have to ignore null values.
37- return LayoutUtil .fluidColumnLoc (4 , 0 , 6 , 0 , SURVNET_GATEWAY_LOC );
38- }
39-
4036 public static void addComponentToLayout (CustomLayout targetLayout , Supplier <List <String >> caseUuids ) {
4137 if (!FacadeProvider .getSurvnetGatewayFacade ().isFeatureEnabled ()) {
4238 return ;
@@ -48,14 +44,14 @@ public static void addComponentToLayout(CustomLayout targetLayout, Supplier<List
4844 Button button = ButtonHelper
4945 .createIconButton (Captions .SurvnetGateway_send , VaadinIcons .OUTBOX , e -> sendToSurvnet (caseUuids .get ()), ValoTheme .BUTTON_PRIMARY );
5046
51- HorizontalLayout l = new HorizontalLayout (header , button );
52- l .setExpandRatio (button , 1 );
53- l .setComponentAlignment (header , Alignment .MIDDLE_LEFT );
54- l .setComponentAlignment (button , Alignment .MIDDLE_RIGHT );
55- l . setSizeFull ( );
47+ HorizontalLayout layout = new HorizontalLayout (header , button );
48+ layout .setExpandRatio (button , 1 );
49+ layout .setComponentAlignment (header , Alignment .MIDDLE_LEFT );
50+ layout .setComponentAlignment (button , Alignment .MIDDLE_RIGHT );
51+ layout . setWidth ( 100 , Unit . PERCENTAGE );
5652
57- l .addStyleNames (CssStyles .SIDE_COMPONENT );
58- targetLayout .addComponent (l , SURVNET_GATEWAY_LOC );
53+ layout .addStyleNames (CssStyles .SIDE_COMPONENT );
54+ targetLayout .addComponent (layout , SURVNET_GATEWAY_LOC );
5955 }
6056
6157 private static void sendToSurvnet (List <String > caseUuids ) {
@@ -66,16 +62,16 @@ private static void sendToSurvnet(List<String> caseUuids) {
6662 String message ;
6763
6864 switch (statusCode ) {
69- case 200 : //HttpStatus.OK :
70- case 204 : //HttpStatus .SC_NO_CONTENT:
65+ case HttpServletResponse . SC_OK :
66+ case HttpServletResponse .SC_NO_CONTENT :
7167 type = Notification .Type .HUMANIZED_MESSAGE ;
7268 message = I18nProperties .getString (Strings .SurvnetGateway_notificationEntrySent );
7369 break ;
74- case 400 : //HttpStatus .SC_BAD_REQUEST
70+ case HttpServletResponse .SC_BAD_REQUEST :
7571 type = Notification .Type .ERROR_MESSAGE ;
7672 message = I18nProperties .getString (Strings .SurvnetGateway_notificationEntryNotSent );
7773 break ;
78- default ://HttpStatus.SC_BAD_REQUEST
74+ default :
7975 type = Notification .Type .ERROR_MESSAGE ;
8076 message = I18nProperties .getString (Strings .SurvnetGateway_notificationErrorSending );
8177 }
0 commit comments