From a1934bf5e18b9f14af3eb45401bccd97cfb6067c Mon Sep 17 00:00:00 2001 From: Henri Kohlberg Date: Thu, 4 Oct 2018 15:53:27 +0200 Subject: [PATCH] Bug 4104: Adapted UI to fit new image upload form and fixed smaller bugs regarding tag buttons. --- .../sailing/gwt/ui/client/StringMessages.java | 3 +- .../gwt/ui/client/StringMessages.properties | 5 +- .../ui/client/StringMessages_de.properties | 5 +- .../gwt/ui/raceboard/tagging/TagButton.java | 5 +- .../ui/raceboard/tagging/TagButtonDialog.java | 2 +- .../tagging/TagButtonJsonDeSerializer.java | 34 ++-- .../ui/raceboard/tagging/TagInputPanel.java | 88 +++++----- .../tagging/TagModificationPanel.java | 3 +- .../ui/raceboard/tagging/TaggingPanel.java | 153 ++++++++++-------- .../tagging/TaggingPanelResources.java | 7 +- .../ui/raceboard/tagging/tagging-panel.gss | 56 ++----- .../adminconsole/URLFieldWithFileUpload.java | 1 + 12 files changed, 180 insertions(+), 182 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java index 27465ad3d00..87c4d4765a0 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java @@ -2129,8 +2129,9 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages, String tagSearchTags(); String tagLabelTag(); String tagLabelComment(); - String tagLabelImageURL(); + String tagLabelImage(); String tagLabelAction(); + String tagLabelVisibility(); String tagCreateTag(); String tagEditCustomTagButtons(); String tagAddCustomTagButton(); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties index 78fffb52216..22d481259af 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties @@ -2125,8 +2125,9 @@ tagsFilter=Tag Filter tagSearchTags=Search tagLabelTag=Tag tagLabelComment=Comment -tagLabelImageURL=Image URL +tagLabelImage=Image tagLabelAction=Action +tagLabelVisibility=Visibility tagCreateTag=Create Tag tagEditCustomTagButtons=Edit Tag-Buttons tagAddCustomTagButton=Add Tag-Button @@ -2149,7 +2150,7 @@ tagCreateFilterNotLoggedIn=You are not logged in so filters will not be saved! tagCreateFilterHint=Create a filter set to filter the list of tags. tagButtonNotSavable=Could not save tag-button on the server! tagNotEditable=You may not edit this tag! -tagPublicModificationPermissionMissing=Notice: You are not allowed to create public tags but you are allowed to create private tags instead. +tagPublicModificationPermissionMissing=You are not allowed to create public tags but you are allowed to create private tags instead. tagNotFound=Tag could not be found! tagInvalidURL=Invalid URL parameter tagSharedDialog=Shared tag diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties index 46f58f91baa..ad9a16289f7 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties @@ -2120,8 +2120,9 @@ tagsFilter=Tag Filter tagSearchTags=Suchen tagLabelTag=Tag tagLabelComment=Kommentar -tagLabelImageURL=Bild URL +tagLabelImage=Bild tagLabelAction=Aktion +tagLabelVisibility=Sichtbarkeit tagCreateTag=Tag hinzufügen tagEditCustomTagButtons=Tag-Buttons bearbeiten tagAddCustomTagButton=Tag-Button hinzufügen @@ -2144,7 +2145,7 @@ tagCreateFilterNotLoggedIn=Bitte einloggen um Filter speichern zu können! tagCreateFilterHint=Lege einen Filter an, um die sichtbaren Tags zu reduzieren. tagButtonNotSavable=Tag-Button konnten nicht auf dem Server gespeichert werden! tagNotEditable=Du darfst diesen Tag nicht bearbeiten! -tagPublicModificationPermissionMissing=Achtung: Du darfst nur private, jedoch keine öffentlichen Tags erstellen. +tagPublicModificationPermissionMissing=Du darfst nur private, jedoch keine öffentlichen Tags erstellen. tagNotFound=Tag wurde nicht gefunden! tagInvalidURL=URL Parameter nicht gültig tagSharedDialog=Geteilter Tag diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButton.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButton.java index f168c44acbb..c47a84cfce0 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButton.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButton.java @@ -30,7 +30,8 @@ public class TagButton extends Button { * @param visibleForPublic * should be true if everybody should see the generated tag, otherwise false */ - protected TagButton(String buttonName, String tag, String imageURL, int imageWidth, int imageHeight, String comment, boolean visibleForPublic) { + protected TagButton(String buttonName, String tag, String imageURL, int imageWidth, int imageHeight, String comment, + boolean visibleForPublic) { super(buttonName); setStyleName(style.tagDialogButton()); @@ -69,7 +70,7 @@ public class TagButton extends Button { protected String getComment() { return comment; } - + /** * Returns image width of corresponding tag. * diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonDialog.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonDialog.java index 58513121ac2..0f48d1e5ac8 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonDialog.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonDialog.java @@ -215,7 +215,7 @@ public class TagButtonDialog extends DialogBox { }); tagButtonTable.addColumn(tagColumn, stringMessages.tagLabelTag()); - tagButtonTable.addColumn(imageURLColumn, stringMessages.tagLabelImageURL()); + tagButtonTable.addColumn(imageURLColumn, stringMessages.tagLabelImage()); tagButtonTable.addColumn(commentColumn, stringMessages.tagLabelComment()); tagButtonTable.addColumn(actionsColumn, stringMessages.tagLabelAction()); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonJsonDeSerializer.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonJsonDeSerializer.java index d0d27fe6f7f..bcb6f808f59 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonJsonDeSerializer.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagButtonJsonDeSerializer.java @@ -25,17 +25,23 @@ public class TagButtonJsonDeSerializer { public JSONArray serialize(List tagButtons) { JSONArray result = new JSONArray(); - int i = 0; - for (TagButton button : tagButtons) { - JSONObject tagButtonObject = new JSONObject(); - tagButtonObject.put(FIELD_BUTTON_NAME, new JSONString(button.getText())); - tagButtonObject.put(FIELD_TAG, new JSONString(button.getTag())); - tagButtonObject.put(FIELD_COMMENT, new JSONString(button.getComment())); - tagButtonObject.put(FIELD_IMAGE_URL, new JSONString(button.getImageURL())); - tagButtonObject.put(FIELD_IMAGE_WIDTH, new JSONNumber(button.getImageWidth())); - tagButtonObject.put(FIELD_IMAGE_HEIGHT, new JSONNumber(button.getImageHeight())); - tagButtonObject.put(FIELD_VISIBLE_FOR_PUBLIC, JSONBoolean.getInstance(button.isVisibleForPublic())); - result.set(i++, tagButtonObject); + if (tagButtons != null) { + int i = 0; + for (TagButton button : tagButtons) { + JSONObject tagButtonObject = new JSONObject(); + tagButtonObject.put(FIELD_BUTTON_NAME, new JSONString(button.getText())); + tagButtonObject.put(FIELD_TAG, new JSONString(button.getTag())); + if (button.getComment() != null) { + tagButtonObject.put(FIELD_COMMENT, new JSONString(button.getComment())); + } + if (button.getImageURL() != null) { + tagButtonObject.put(FIELD_IMAGE_URL, new JSONString(button.getImageURL())); + tagButtonObject.put(FIELD_IMAGE_WIDTH, new JSONNumber(button.getImageWidth())); + tagButtonObject.put(FIELD_IMAGE_HEIGHT, new JSONNumber(button.getImageHeight())); + } + tagButtonObject.put(FIELD_VISIBLE_FOR_PUBLIC, JSONBoolean.getInstance(button.isVisibleForPublic())); + result.set(i++, tagButtonObject); + } } return result; } @@ -54,8 +60,10 @@ public class TagButtonJsonDeSerializer { JSONNumber tagButtonImageHeight = (JSONNumber) tagButtonValue.get(FIELD_IMAGE_HEIGHT); JSONBoolean tagButtonVisibleForPublic = (JSONBoolean) tagButtonValue.get(FIELD_VISIBLE_FOR_PUBLIC); result.add(new TagButton(tagButtonName.stringValue(), tagButtonTag.stringValue(), - tagButtonImageURL.stringValue(), (int) tagButtonImageWidth.doubleValue(), - (int) tagButtonImageHeight.doubleValue(), tagButtonComment.stringValue(), + tagButtonImageURL == null ? null : tagButtonImageURL.stringValue(), + tagButtonImageWidth == null ? -1 : (int) tagButtonImageWidth.doubleValue(), + tagButtonImageHeight == null ? -1 : (int) tagButtonImageHeight.doubleValue(), + tagButtonComment == null ? null : tagButtonComment.stringValue(), tagButtonVisibleForPublic.booleanValue())); } } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagInputPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagInputPanel.java index 586d2cb4904..1e9cc5f4128 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagInputPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagInputPanel.java @@ -3,8 +3,8 @@ package com.sap.sailing.gwt.ui.raceboard.tagging; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.CheckBox; import com.google.gwt.user.client.ui.FlowPanel; +import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.Label; -import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.TextArea; import com.google.gwt.user.client.ui.TextBox; import com.sap.sailing.domain.common.dto.TagDTO; @@ -23,22 +23,20 @@ public class TagInputPanel extends FlowPanel { private final TagPanelStyle style = TaggingPanelResources.INSTANCE.style(); - // default value for "Visible for public" checkbox private static final String DEFAULT_TAG = ""; private static final String DEFAULT_COMMENT = ""; private static final String DEFAULT_IMAGE_URL = ""; private static final boolean DEFAULT_VISIBLE_FOR_PUBLIC = false; + private final TaggingPanel taggingPanel; + private final Grid grid; private final TextBox tagTextBox; private final URLFieldWithFileUpload imageUrlUploaderPanel; private final TextArea commentTextArea; - private final SimplePanel checkboxWrapper; + private final FlowPanel checkboxWrapper; private final CheckBox visibleForPublicCheckBox; private final Label noPermissionForPublicTagsLabel; - private final TaggingPanel taggingPanel; - private final SailingServiceAsync sailingService; - private int imageWidth = -1; private int imageHeight = -1; @@ -49,55 +47,63 @@ public class TagInputPanel extends FlowPanel { StringMessages stringMessages) { setStyleName(style.tagInputPanel()); this.taggingPanel = taggingPanel; - this.sailingService = sailingService; - + grid = new Grid(4, 2); + // tag + Label tagLabel = new Label(stringMessages.tagLabelTag() + ":"); tagTextBox = new TextBox(); tagTextBox.setStyleName(style.tagInputPanelTag()); tagTextBox.setTitle(stringMessages.tagLabelTag()); tagTextBox.getElement().setPropertyString("placeholder", stringMessages.tagLabelTag()); - add(tagTextBox); - + grid.setWidget(0, 0, tagLabel); + grid.setWidget(0, 1, tagTextBox); + // image upload + Label imageLabel = new Label(stringMessages.tagLabelImage() + ":"); imageUrlUploaderPanel = new URLFieldWithFileUpload(stringMessages); imageUrlUploaderPanel.addValueChangeHandler(event -> { if (imageUrlUploaderPanel.getURL() == null || imageUrlUploaderPanel.getURL().isEmpty()) { imageWidth = -1; imageHeight = -1; } else { - sailingService.resolveImageDimensions(imageUrlUploaderPanel.getURL(), new AsyncCallback>() { - @Override - public void onSuccess(Pair imageSize) { - if (imageSize != null) { - imageWidth = imageSize.getA(); - imageHeight = imageSize.getB(); - } - } + sailingService.resolveImageDimensions(imageUrlUploaderPanel.getURL(), + new AsyncCallback>() { + @Override + public void onSuccess(Pair imageSize) { + if (imageSize != null) { + imageWidth = imageSize.getA(); + imageHeight = imageSize.getB(); + } + } - @Override - public void onFailure(Throwable caught) { - imageUrlUploaderPanel.setURL(""); - } - }); + @Override + public void onFailure(Throwable caught) { + imageUrlUploaderPanel.setURL(""); + } + }); } }); - add(imageUrlUploaderPanel); - + grid.setWidget(1, 0, imageLabel); + grid.setWidget(1, 1, imageUrlUploaderPanel); + // comment + Label commentLabel = new Label(stringMessages.tagLabelComment() + ":"); commentTextArea = new TextArea(); commentTextArea.setStyleName(style.tagInputPanelComment()); commentTextArea.setVisibleLines(4); commentTextArea.setTitle(stringMessages.tagLabelComment()); commentTextArea.getElement().setPropertyString("placeholder", stringMessages.tagLabelComment()); - add(commentTextArea); - - checkboxWrapper = new SimplePanel(); - checkboxWrapper.setStyleName(style.tagInputPanelIsVisibleForPublic()); + grid.setWidget(2, 0, commentLabel); + grid.setWidget(2, 1, commentTextArea); + // visibility + Label visibilityLabel = new Label(stringMessages.tagLabelVisibility() + ":"); visibleForPublicCheckBox = new CheckBox(stringMessages.tagVisibleForPublicCheckBox()); visibleForPublicCheckBox.setValue(DEFAULT_VISIBLE_FOR_PUBLIC); - checkboxWrapper.setWidget(visibleForPublicCheckBox); - add(checkboxWrapper); - noPermissionForPublicTagsLabel = new Label(stringMessages.tagPublicModificationPermissionMissing()); - noPermissionForPublicTagsLabel.setStyleName(style.tagInputPanelNoPermissionLabel()); - add(noPermissionForPublicTagsLabel); + checkboxWrapper = new FlowPanel(); + checkboxWrapper.add(visibleForPublicCheckBox); + checkboxWrapper.add(noPermissionForPublicTagsLabel); + grid.setWidget(3, 0, visibilityLabel); + grid.setWidget(3, 1, checkboxWrapper); + + add(grid); clearAllValues(); } @@ -133,7 +139,7 @@ public class TagInputPanel extends FlowPanel { * false */ protected boolean compareFieldsToTag(TagDTO tag) { - return getTag().equals(tag.getTag()) && getComment().equals(tag.getComment()) + return tag != null && getTag().equals(tag.getTag()) && getComment().equals(tag.getComment()) && getImageURL().equals(tag.getImageURL()) && isVisibleForPublic() == tag.isVisibleForPublic(); } @@ -146,7 +152,7 @@ public class TagInputPanel extends FlowPanel { * false */ protected boolean compareFieldsToTagButton(TagButton tagButton) { - return getTag().equals(tagButton.getTag()) && getComment().equals(tagButton.getComment()) + return tagButton != null && getTag().equals(tagButton.getTag()) && getComment().equals(tagButton.getComment()) && getImageURL().equals(tagButton.getImageURL()) && isVisibleForPublic() == tagButton.isVisibleForPublic(); } @@ -157,8 +163,10 @@ public class TagInputPanel extends FlowPanel { * @return true if all input fields are equal to default values, otherwise false */ protected boolean isInputEmpty() { - return getTag().equals(DEFAULT_TAG) && getComment().equals(DEFAULT_COMMENT) - && getImageURL().equals(DEFAULT_IMAGE_URL) && isVisibleForPublic() == DEFAULT_VISIBLE_FOR_PUBLIC; + return (getTag() == null || getTag().equals(DEFAULT_TAG)) + && (getComment() == null || getComment().equals(DEFAULT_COMMENT)) + && (getImageURL() == null || getImageURL().equals(DEFAULT_IMAGE_URL)) + && isVisibleForPublic() == DEFAULT_VISIBLE_FOR_PUBLIC; } protected String getTag() { @@ -221,10 +229,10 @@ public class TagInputPanel extends FlowPanel { protected void setCurrentStatus() { if (taggingPanel.hasPermissionToModifyPublicTags()) { - checkboxWrapper.setVisible(true); + visibleForPublicCheckBox.setVisible(true); noPermissionForPublicTagsLabel.setVisible(false); } else { - checkboxWrapper.setVisible(false); + visibleForPublicCheckBox.setVisible(false); noPermissionForPublicTagsLabel.setVisible(true); } } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagModificationPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagModificationPanel.java index 884acf97aa4..cb9134741ac 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagModificationPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TagModificationPanel.java @@ -6,8 +6,8 @@ import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Panel; import com.sap.sailing.gwt.ui.client.SailingServiceAsync; import com.sap.sailing.gwt.ui.client.StringMessages; -import com.sap.sailing.gwt.ui.raceboard.tagging.TaggingPanelResources.TagPanelStyle; import com.sap.sailing.gwt.ui.raceboard.tagging.TaggingPanel.State; +import com.sap.sailing.gwt.ui.raceboard.tagging.TaggingPanelResources.TagPanelStyle; import com.sap.sse.security.ui.client.UserService; /** @@ -49,6 +49,7 @@ public class TagModificationPanel extends FlowPanel { if (taggingPanel.isLoggedInAndRaceLogAvailable()) { taggingPanel.saveTag(inputPanel.getTag(), inputPanel.getComment(), inputPanel.getImageURL(), inputPanel.getImageWidth(), inputPanel.getImageHeight(), inputPanel.isVisibleForPublic()); + // TODO: Add callback to saveTag() to clear fields only if tag got really added inputPanel.clearAllValues(); } }); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanel.java index af5b30af23d..c38848465d0 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanel.java @@ -57,7 +57,6 @@ import com.sap.sse.security.ui.shared.UserDTO; * * @author Julian Rendl, Henri Kohlberg */ -// TODO: cache user settings and use observer pattern for cache public class TaggingPanel extends ComponentWithoutSettings implements RaceTimesInfoProviderListener, UserStatusEventHandler, TimeListener { @@ -248,48 +247,61 @@ public class TaggingPanel extends ComponentWithoutSettings * * @see #saveTag(String, Sting, String, boolean, TimePoint, boolean) */ - protected void saveTag(String tag, String comment, String imageURL, int imageWidth, int imageHeight, boolean visibleForPublic) { + protected void saveTag(String tag, String comment, String imageURL, int imageWidth, int imageHeight, + boolean visibleForPublic) { getResizedImageURLForImageURL(imageURL, imageHeight, imageWidth, new AsyncCallback() { @Override - public void onFailure(Throwable caught) { } + public void onFailure(Throwable caught) { + } @Override public void onSuccess(String resultingResizedImageURL) { saveTag(tag, comment, imageURL, resultingResizedImageURL, visibleForPublic, null); - }}); + } + }); } - - /** - * Calling this method you get a resized image URL for your original image URL - * @param imageURL URL of image which needs to be resized - * @param imageWidth width of image needing to be resized - * @param imageHeight height of image needing to be resized - * @param callback An asynchronous callback containing the result, a resized image URL + + /** + * Calling this method you get a resized image URL for your original image URL + * + * @param imageURL + * URL of image which needs to be resized + * @param imageWidth + * width of image needing to be resized + * @param imageHeight + * height of image needing to be resized + * @param callback + * An asynchronous callback containing the result, a resized image URL */ - protected void getResizedImageURLForImageURL(String imageURL, int imageWidth, int imageHeight, AsyncCallback callback) { - if(imageURL == null || imageURL.isEmpty()) { + protected void getResizedImageURLForImageURL(String imageURL, int imageWidth, int imageHeight, + AsyncCallback callback) { + if (imageURL == null || imageURL.isEmpty()) { callback.onSuccess(null); } else { - if(imageWidth < MediaTagConstants.TAGGING_IMAGE.getMinWidth() || imageHeight < MediaTagConstants.TAGGING_IMAGE.getMinHeight()) { - callback.onSuccess(null);//image to small + if (imageWidth < MediaTagConstants.TAGGING_IMAGE.getMinWidth() + || imageHeight < MediaTagConstants.TAGGING_IMAGE.getMinHeight()) { + callback.onSuccess(null);// image to small } else { - if (imageWidth > MediaTagConstants.TAGGING_IMAGE.getMaxWidth() || imageHeight > MediaTagConstants.TAGGING_IMAGE.getMaxHeight()) { + if (imageWidth > MediaTagConstants.TAGGING_IMAGE.getMaxWidth() + || imageHeight > MediaTagConstants.TAGGING_IMAGE.getMaxHeight()) { ArrayList tags = new ArrayList(); tags.add(MediaTagConstants.TAGGING_IMAGE); - sailingService.resizeImage(new ImageResizingTaskDTO(imageURL, new Date(), tags), new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - callback.onSuccess(null); - } - @Override - public void onSuccess(Set result) { - String resizedImageURL = null; - if(result.size()!=0) { - resizedImageURL = result.iterator().next().getSourceRef(); - } - callback.onSuccess(resizedImageURL); - } - }); + sailingService.resizeImage(new ImageResizingTaskDTO(imageURL, new Date(), tags), + new AsyncCallback>() { + @Override + public void onFailure(Throwable caught) { + callback.onSuccess(null); + } + + @Override + public void onSuccess(Set result) { + String resizedImageURL = null; + if (result.size() != 0) { + resizedImageURL = result.iterator().next().getSourceRef(); + } + callback.onSuccess(resizedImageURL); + } + }); } else { callback.onSuccess(imageURL); } @@ -306,13 +318,13 @@ public class TaggingPanel extends ComponentWithoutSettings * values: comment and imageURL will be replaced by an empty string, * raceTimePoint by current {@link #getTimerTime() timer position}. */ - protected void saveTag(String tag, String comment, String imageURL, String resizedImageURL, boolean visibleForPublic, - TimePoint raceTimePoint) { + protected void saveTag(String tag, String comment, String imageURL, String resizedImageURL, + boolean visibleForPublic, TimePoint raceTimePoint) { boolean tagIsNewTag = true; // check if tag already exists for (TagDTO tagDTO : tagListProvider.getAllTags()) { - if (tagDTO.equals(tag, comment, imageURL, resizedImageURL, visibleForPublic, userService.getCurrentUser().getName(), - new MillisecondsTimePoint(getTimerTime()))) { + if (tagDTO.equals(tag, comment, imageURL, resizedImageURL, visibleForPublic, + userService.getCurrentUser().getName(), new MillisecondsTimePoint(getTimerTime()))) { tagIsNewTag = false; break; } @@ -332,8 +344,8 @@ public class TaggingPanel extends ComponentWithoutSettings final String saveComment = (comment == null ? "" : comment); final TimePoint saveRaceTimePoint = (raceTimePoint == null ? new MillisecondsTimePoint(getTimerTime()) : raceTimePoint); - sailingService.addTag(leaderboardName, raceColumn.getName(), fleet.getName(), tag, saveComment, - imageURL, resizedImageURL, visibleForPublic, saveRaceTimePoint, new AsyncCallback() { + sailingService.addTag(leaderboardName, raceColumn.getName(), fleet.getName(), tag, saveComment, imageURL, + resizedImageURL, visibleForPublic, saveRaceTimePoint, new AsyncCallback() { @Override public void onFailure(Throwable caught) { Notification.notify(stringMessages.tagNotSavedReason(caught.toString()), @@ -408,42 +420,47 @@ public class TaggingPanel extends ComponentWithoutSettings * * @see TagDTO */ - protected void updateTag(TagDTO tagToUpdate, String tag, String comment, String imageURL, int imageWidth, int imageHeight, - boolean visibleForPublic) { - //A new resized image gets created every time a tag is updated(if tag shall contain an image) + protected void updateTag(TagDTO tagToUpdate, String tag, String comment, String imageURL, int imageWidth, + int imageHeight, boolean visibleForPublic) { + // A new resized image gets created every time a tag is updated(if tag shall contain an image) getResizedImageURLForImageURL(imageURL, imageHeight, imageWidth, new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { } + @Override + public void onFailure(Throwable caught) { + } - @Override - public void onSuccess(String resultingResizedImageURL) { - sailingService.updateTag(leaderboardName, raceColumn.getName(), fleet.getName(), tagToUpdate, tag, comment, - imageURL, resultingResizedImageURL, visibleForPublic, new AsyncCallback() { - @Override - public void onFailure(Throwable caught) { - Notification.notify(stringMessages.tagNotSavedReason(caught.getMessage()), - NotificationType.ERROR); - GWT.log(caught.getMessage()); - } + @Override + public void onSuccess(String resultingResizedImageURL) { + sailingService.updateTag(leaderboardName, raceColumn.getName(), fleet.getName(), tagToUpdate, tag, + comment, imageURL, resultingResizedImageURL, visibleForPublic, + new AsyncCallback() { + @Override + public void onFailure(Throwable caught) { + Notification.notify(stringMessages.tagNotSavedReason(caught.getMessage()), + NotificationType.ERROR); + GWT.log(caught.getMessage()); + } - @Override - public void onSuccess(SuccessInfo result) { - if (result.isSuccessful()) { - tagListProvider.remove(tagToUpdate); - // If old tag was or new tag is private, reload all private tags. Otherwise just refresh UI. - if (!tagToUpdate.isVisibleForPublic() || !visibleForPublic) { - reloadPrivateTags(); - } else { - updateContent(); - } - Notification.notify(stringMessages.tagSavedSuccessfully(), NotificationType.SUCCESS); + @Override + public void onSuccess(SuccessInfo result) { + if (result.isSuccessful()) { + tagListProvider.remove(tagToUpdate); + // If old tag was or new tag is private, reload all private tags. Otherwise just + // refresh UI. + if (!tagToUpdate.isVisibleForPublic() || !visibleForPublic) { + reloadPrivateTags(); } else { - Notification.notify(stringMessages.tagNotSavedReason(result.getMessage()), - NotificationType.ERROR); + updateContent(); } + Notification.notify(stringMessages.tagSavedSuccessfully(), + NotificationType.SUCCESS); + } else { + Notification.notify(stringMessages.tagNotSavedReason(result.getMessage()), + NotificationType.ERROR); } - }); - }}); + } + }); + } + }); } /** @@ -501,8 +518,8 @@ public class TaggingPanel extends ComponentWithoutSettings */ protected void addTagButton(TagButton tagButton) { tagButton.addClickHandler(event -> { - saveTag(tagButton.getTag(), tagButton.getComment(), tagButton.getImageURL(), - tagButton.getImageWidth(), tagButton.getImageHeight(), tagButton.isVisibleForPublic()); + saveTag(tagButton.getTag(), tagButton.getComment(), tagButton.getImageURL(), tagButton.getImageWidth(), + tagButton.getImageHeight(), tagButton.isVisibleForPublic()); }); tagButtons.add(tagButton); } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanelResources.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanelResources.java index 248b947f2ba..33b5480e603 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanelResources.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/TaggingPanelResources.java @@ -99,14 +99,9 @@ public interface TaggingPanelResources extends CellList.Resources, CellTable.Res String tagModificationPanelHeaderLabel(); String tagModificationPanelHeaderButton(); String tagInputPanel(); + String tagInputPanelLabel(); String tagInputPanelTag(); String tagInputPanelComment(); - String tagInputPanelImage(); - String tagInputPanelImageTextBox(); - String tagInputPanelImageButton(); - String tagInputPanelImageFormPanel(); - String tagInputPanelIsVisibleForPublic(); - String tagInputPanelNoPermissionLabel(); // tag filtering String tagFilterButton(); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/tagging-panel.gss b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/tagging-panel.gss index 9ab22783f60..62abba309aa 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/tagging-panel.gss +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/tagging/tagging-panel.gss @@ -258,64 +258,28 @@ padding-right: 5px; } -.tagInputPanel>*:not(:first-child) { - border-top: none; +.tagInputPanel table tr td:first-child { + vertical-align: top; } -/* CSS Hack: When selected input is :active or :hover, increase z-index and set position relative - to get default outline of browser not cut off */ -.tagInputPanel>*:active, .tagInputPanel>*:focus { - position: relative; - z-index: 1; +@external url-textbox; +.tagInputPanel .url-textbox { + width: auto !important; } -.tagInputPanel>* { - width: 100%; - padding: 2px; - border: 1px solid #cecece; +.tagInputPanelLabel { + vertical-align: top; } -.tagInputPanelTag { - border-radius: 4px 4px 0px 0px; -} - -.tagInputPanelImage { - -} - -.tagInputPanelImageTextBox { - border-style: 1px solid #cecece; -} - -.tagInputPanelImageButton { - float: right; -} - -.tagInputPanelImageFormPanel { - display: inline-block; - float: right; +.tagInputPanelTag, +.tagInputPanelComment { + width: 100%; } .tagInputPanelComment { - border-radius: 0 0 4px 0; resize: none; } -.tagInputPanelIsVisibleForPublic { - display: inline-block; - width: auto; - margin: -2px 0 5px; - padding: 2px 5px 2px 2px; - resize: none; - font-size: 80%; -} - -.tagInputPanelNoPermissionLabel{ - border: none; - font-size: 80%; - margin: 3px 0px 3px 0px; -} - /**************************** Tag filtering ****************************/ .tagFilterPanel { width: 100%; diff --git a/java/com.sap.sse.gwt.adminconsole/src/com/sap/sse/gwt/adminconsole/URLFieldWithFileUpload.java b/java/com.sap.sse.gwt.adminconsole/src/com/sap/sse/gwt/adminconsole/URLFieldWithFileUpload.java index b63c0873494..becbc193e7d 100755 --- a/java/com.sap.sse.gwt.adminconsole/src/com/sap/sse/gwt/adminconsole/URLFieldWithFileUpload.java +++ b/java/com.sap.sse.gwt.adminconsole/src/com/sap/sse/gwt/adminconsole/URLFieldWithFileUpload.java @@ -86,6 +86,7 @@ public class URLFieldWithFileUpload extends Composite implements HasValue