Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit bf4e24c

Browse files
SORMAS-Foundation#2673 Minor refactorings from the review
1 parent 69970ba commit bf4e24c

2 files changed

Lines changed: 16 additions & 20 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/caze/CaseDataView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected void initView(String params) {
7979
LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SAMPLES_LOC),
8080
LayoutUtil.fluidColumnLoc(4, 0, 6, 0, EVENTS_LOC),
8181
LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SORMAS_TO_SORMAS_LOC),
82-
SurvnetGateway.layoutFragment());
82+
LayoutUtil.fluidColumnLoc(4, 0, 6, 0, SurvnetGateway.SURVNET_GATEWAY_LOC));
8383

8484
DetailSubComponentWrapper container = new DetailSubComponentWrapper(() -> editComponent);
8585
container.setWidth(100, Unit.PERCENTAGE);

sormas-ui/src/main/java/de/symeda/sormas/ui/survnet/SurvnetGateway.java

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
import java.util.List;
44
import java.util.function.Supplier;
55

6+
import javax.servlet.http.HttpServletResponse;
7+
68
import com.vaadin.icons.VaadinIcons;
9+
import com.vaadin.server.Sizeable.Unit;
710
import com.vaadin.ui.Alignment;
811
import com.vaadin.ui.Button;
912
import com.vaadin.ui.CustomLayout;
@@ -18,25 +21,18 @@
1821
import de.symeda.sormas.api.i18n.Strings;
1922
import de.symeda.sormas.ui.utils.ButtonHelper;
2023
import 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
*/
2728
public 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

Comments
 (0)