mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 06:47:15 +00:00
added a created and edit editor for videos of an event
This commit is contained in:
1 parent
508dc7550a
commit
05c7d89cdd
11 files changed
+523
-12
No files matched your search
-4
@@ -2159,8 +2159,4 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void migrateImageAndVideoURLsOfEvent(Event event) {
|
||||
// TODO: convert imageURLs, sponsorImageURLs and videoURLs collections of event to new image and video descriptor classes
|
||||
}
|
||||
}
|
||||
+3
@@ -50,6 +50,7 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
|
||||
protected StringConstantsListEditorComposite leaderboardGroupList;
|
||||
protected List<LeaderboardGroupDTO> availableLeaderboardGroups;
|
||||
protected ImagesListComposite imagesListComposite;
|
||||
protected VideosListComposite videosListComposite;
|
||||
|
||||
protected static class EventParameterValidator implements Validator<EventDTO> {
|
||||
|
||||
@@ -160,6 +161,7 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
|
||||
leaderboardGroupList.addValueChangeHandler(valueChangeHandler);
|
||||
|
||||
imagesListComposite = new ImagesListComposite(stringMessages);
|
||||
videosListComposite = new VideosListComposite(stringMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -240,6 +242,7 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
|
||||
tabPanel.add(new ScrollPanel(videoURLList), stringMessages.videoURLs());
|
||||
tabPanel.add(new ScrollPanel(sponsorImageURLList), stringMessages.sponsorImageURLs());
|
||||
tabPanel.add(new ScrollPanel(imagesListComposite), "Images");
|
||||
tabPanel.add(new ScrollPanel(videosListComposite), "Videos");
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -55,5 +55,6 @@ public class EventEditDialog extends EventDialog {
|
||||
}
|
||||
leaderboardGroupList.setValue(leaderboardGroupNames);
|
||||
imagesListComposite.fillImages(event.getImages());
|
||||
videosListComposite.fillVideos(event.getVideos());
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -41,8 +41,12 @@ public abstract class ImageDialog extends DataEntryDialog<ImageDTO> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(ImageDTO eventToValidate) {
|
||||
public String getErrorMessage(ImageDTO imageToValidate) {
|
||||
String errorMessage = null;
|
||||
|
||||
if(imageToValidate.getSourceRef() == null || imageToValidate.getSourceRef().isEmpty()) {
|
||||
errorMessage = "You must provide a valid URL for the image";
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
@@ -70,7 +74,7 @@ public abstract class ImageDialog extends DataEntryDialog<ImageDTO> {
|
||||
|
||||
@Override
|
||||
protected ImageDTO getResult() {
|
||||
ImageDTO result = new ImageDTO(imageURLAndUploadComposite.getURL(), new Date());
|
||||
ImageDTO result = new ImageDTO(imageURLAndUploadComposite.getURL(), creationDate);
|
||||
result.setTitle(titleTextBox.getValue());
|
||||
result.setSubtitle(subtitleTextBox.getValue());
|
||||
result.setCopyright(copyrightTextBox.getValue());
|
||||
|
||||
+3
-3
@@ -192,15 +192,15 @@ public class ImagesListComposite extends Composite {
|
||||
table.addColumn(sizeColumn, "Size");
|
||||
table.addColumn(tagsColumn, "Tags");
|
||||
table.addColumn(imageActionColumn, stringMessages.actions());
|
||||
table.addColumnSortHandler(getEventTableColumnSortHandler(imageListDataProvider.getList(), titleColumn, createdAtDateColumn));
|
||||
table.addColumnSortHandler(getImageTableColumnSortHandler(imageListDataProvider.getList(), titleColumn, createdAtDateColumn));
|
||||
table.getColumnSortList().push(createdAtDateColumn);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
private ListHandler<ImageDTO> getEventTableColumnSortHandler(List<ImageDTO> eventRecords,
|
||||
private ListHandler<ImageDTO> getImageTableColumnSortHandler(List<ImageDTO> imageRecords,
|
||||
TextColumn<ImageDTO> titleColumn, TextColumn<ImageDTO> createdAtDateColumn) {
|
||||
ListHandler<ImageDTO> result = new ListHandler<ImageDTO>(eventRecords);
|
||||
ListHandler<ImageDTO> result = new ListHandler<ImageDTO>(imageRecords);
|
||||
result.setComparator(titleColumn, new Comparator<ImageDTO>() {
|
||||
@Override
|
||||
public int compare(ImageDTO i1, ImageDTO i2) {
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.text.shared.SafeHtmlRenderer;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.ImagesBarCell;
|
||||
import com.sap.sse.gwt.client.IconResources;
|
||||
|
||||
public class VideoConfigImagesBarCell extends ImagesBarCell {
|
||||
static final String ACTION_REMOVE = "ACTION_REMOVE";
|
||||
static final String ACTION_EDIT = "ACTION_EDIT";
|
||||
private final StringMessages stringMessages;
|
||||
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
|
||||
public VideoConfigImagesBarCell(StringMessages stringMessages) {
|
||||
super();
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
public VideoConfigImagesBarCell(SafeHtmlRenderer<String> renderer, StringMessages stringMessages) {
|
||||
super();
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<ImageSpec> getImageSpecs() {
|
||||
return Arrays.asList(
|
||||
new ImageSpec(ACTION_EDIT, stringMessages.actionEdit(), makeImagePrototype(resources.editIcon())),
|
||||
new ImageSpec(ACTION_REMOVE, stringMessages.actionRemove(), makeImagePrototype(IconResources.INSTANCE.removeIcon()))
|
||||
);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.media.VideoDTO;
|
||||
|
||||
public class VideoCreateDialog extends VideoDialog {
|
||||
|
||||
public VideoCreateDialog(StringMessages stringMessages, DialogCallback<VideoDTO> callback) {
|
||||
super(new VideoParameterValidator(stringMessages), stringMessages, callback);
|
||||
createdAtLabel = new Label(creationDate.toString());
|
||||
titleTextBox = createTextBox(null);
|
||||
titleTextBox.setVisibleLength(50);
|
||||
subtitleTextBox = createTextBox(null);
|
||||
subtitleTextBox.setVisibleLength(50);
|
||||
copyrightTextBox = createTextBox(null);
|
||||
copyrightTextBox.setVisibleLength(50);
|
||||
lengthIntegerBox = createIntegerBox(null, 10);
|
||||
tagsListEditor.setValue(Collections.<String>emptyList());
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.common.media.MimeType;
|
||||
import com.sap.sse.gwt.adminconsole.URLFieldWithFileUpload;
|
||||
import com.sap.sse.gwt.client.IconResources;
|
||||
import com.sap.sse.gwt.client.controls.IntegerBox;
|
||||
import com.sap.sse.gwt.client.controls.listedit.StringListInlineEditorComposite;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
import com.sap.sse.gwt.client.media.VideoDTO;
|
||||
|
||||
public abstract class VideoDialog extends DataEntryDialog<VideoDTO> {
|
||||
protected final StringMessages stringMessages;
|
||||
protected final URLFieldWithFileUpload videoURLAndUploadComposite;
|
||||
protected final Date creationDate;
|
||||
protected Label createdAtLabel;
|
||||
protected TextBox titleTextBox;
|
||||
protected TextBox subtitleTextBox;
|
||||
protected TextBox copyrightTextBox;
|
||||
protected final ListBox mimeTypeListBox;
|
||||
protected IntegerBox lengthIntegerBox;
|
||||
protected final URLFieldWithFileUpload thumbnailURLAndUploadComposite;
|
||||
protected StringListInlineEditorComposite tagsListEditor;
|
||||
|
||||
protected static class VideoParameterValidator implements Validator<VideoDTO> {
|
||||
private StringMessages stringMessages;
|
||||
|
||||
public VideoParameterValidator(StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(VideoDTO videoToValidate) {
|
||||
String errorMessage = null;
|
||||
|
||||
if(videoToValidate.getSourceRef() == null || videoToValidate.getSourceRef().isEmpty()) {
|
||||
errorMessage = "You must provide a valid URL for the video.";
|
||||
} else if (videoToValidate.getMimeType() == null) {
|
||||
errorMessage = "You must select the mime type for the video.";
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
public VideoDialog(VideoParameterValidator validator, StringMessages stringMessages, DialogCallback<VideoDTO> callback) {
|
||||
super(stringMessages.video(), null, stringMessages.ok(), stringMessages.cancel(), validator,
|
||||
callback);
|
||||
this.stringMessages = stringMessages;
|
||||
this.creationDate = new Date();
|
||||
getDialogBox().getWidget().setWidth("730px");
|
||||
final ValueChangeHandler<Iterable<String>> valueChangeHandler = new ValueChangeHandler<Iterable<String>>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<Iterable<String>> event) {
|
||||
validate();
|
||||
}
|
||||
};
|
||||
|
||||
mimeTypeListBox = createListBox(false);
|
||||
mimeTypeListBox.addItem("Select a mime type");
|
||||
mimeTypeListBox.addItem(MimeType.aac.name());
|
||||
mimeTypeListBox.addItem(MimeType.mp4.name());
|
||||
mimeTypeListBox.addItem(MimeType.ogg.name());
|
||||
mimeTypeListBox.addItem(MimeType.ogv.name());
|
||||
mimeTypeListBox.addItem(MimeType.qt.name());
|
||||
|
||||
videoURLAndUploadComposite = new URLFieldWithFileUpload(stringMessages);
|
||||
thumbnailURLAndUploadComposite = new URLFieldWithFileUpload(stringMessages);
|
||||
final List<String> tagSuggestions = Arrays.asList(new String[] { "Highlight", "Featured" });
|
||||
tagsListEditor = new StringListInlineEditorComposite(Collections.<String> emptyList(),
|
||||
new StringListInlineEditorComposite.ExpandedUi(stringMessages, IconResources.INSTANCE.removeIcon(), /* suggestValues */
|
||||
tagSuggestions, "Enter tags for the video", 50));
|
||||
tagsListEditor.addValueChangeHandler(valueChangeHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VideoDTO getResult() {
|
||||
VideoDTO result = new VideoDTO(videoURLAndUploadComposite.getURL(), getSelectedMimeType(), creationDate);
|
||||
result.setTitle(titleTextBox.getValue());
|
||||
result.setSubtitle(subtitleTextBox.getValue());
|
||||
result.setCopyright(copyrightTextBox.getValue());
|
||||
List<String> tags = new ArrayList<String>();
|
||||
for (String tag: tagsListEditor.getValue()) {
|
||||
tags.add(tag);
|
||||
}
|
||||
result.setTags(tags);
|
||||
return result;
|
||||
}
|
||||
|
||||
private MimeType getSelectedMimeType() {
|
||||
MimeType result = null;
|
||||
int selectedIndex = mimeTypeListBox.getSelectedIndex();
|
||||
if(selectedIndex > 0) {
|
||||
result = MimeType.valueOf(mimeTypeListBox.getSelectedValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
final VerticalPanel panel = new VerticalPanel();
|
||||
panel.setWidth("100%");
|
||||
Widget additionalWidget = super.getAdditionalWidget();
|
||||
if (additionalWidget != null) {
|
||||
panel.add(additionalWidget);
|
||||
}
|
||||
|
||||
Grid formGrid = new Grid(9, 2);
|
||||
panel.add(formGrid);
|
||||
|
||||
formGrid.setWidget(0, 0, new Label("Created at:"));
|
||||
formGrid.setWidget(0, 1, createdAtLabel);
|
||||
formGrid.setWidget(1, 0, new Label("Video URL:"));
|
||||
formGrid.setWidget(1, 1, videoURLAndUploadComposite);
|
||||
formGrid.setWidget(2, 0, new Label("Mime Type:"));
|
||||
formGrid.setWidget(2, 1, mimeTypeListBox);
|
||||
|
||||
|
||||
formGrid.setWidget(3, 0, new Label(stringMessages.title() + ":"));
|
||||
formGrid.setWidget(3, 1, titleTextBox);
|
||||
formGrid.setWidget(4, 0, new Label("Subtitle:"));
|
||||
formGrid.setWidget(4, 1, subtitleTextBox);
|
||||
formGrid.setWidget(5, 0, new Label("Copyright:"));
|
||||
formGrid.setWidget(5, 1, copyrightTextBox);
|
||||
formGrid.setWidget(6, 0, new Label("Tags:"));
|
||||
formGrid.setWidget(6, 1, tagsListEditor);
|
||||
|
||||
formGrid.setWidget(7, 0, new Label("Video-Length (s):"));
|
||||
formGrid.setWidget(7, 1, lengthIntegerBox);
|
||||
formGrid.setWidget(8, 0, new Label("Thumbnail-URL:"));
|
||||
formGrid.setWidget(8, 1, thumbnailURLAndUploadComposite);
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
videoURLAndUploadComposite.setFocus(true);
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.media.VideoDTO;
|
||||
|
||||
public class VideoEditDialog extends VideoDialog {
|
||||
public VideoEditDialog(VideoDTO video, StringMessages stringMessages, DialogCallback<VideoDTO> callback) {
|
||||
super(new VideoParameterValidator(stringMessages), stringMessages, callback);
|
||||
createdAtLabel = new Label(video.getCreatedAtDate().toString());
|
||||
videoURLAndUploadComposite.setURL(video.getSourceRef());
|
||||
titleTextBox = createTextBox(video.getTitle());
|
||||
titleTextBox.setVisibleLength(50);
|
||||
subtitleTextBox = createTextBox(video.getSubtitle());
|
||||
subtitleTextBox.setVisibleLength(50);
|
||||
copyrightTextBox = createTextBox(video.getCopyright());
|
||||
copyrightTextBox.setVisibleLength(50);
|
||||
lengthIntegerBox = createIntegerBox(video.getLengthInSeconds(), 10);
|
||||
List<String> tags = new ArrayList<String>();
|
||||
tags.addAll(video.getTags());
|
||||
tagsListEditor.setValue(tags);
|
||||
}
|
||||
}
|
||||
+270
@@ -0,0 +1,270 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.cell.client.FieldUpdater;
|
||||
import com.google.gwt.cell.client.SafeHtmlCell;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.cellview.client.CellTable;
|
||||
import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sailing.domain.common.impl.NaturalComparator;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
import com.sap.sse.gwt.client.media.VideoDTO;
|
||||
|
||||
/**
|
||||
* /** A composite showing the list of media videos
|
||||
*
|
||||
* @author Frank Mittag (C5163974)
|
||||
*/
|
||||
public class VideosListComposite extends Composite {
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
private CellTable<VideoDTO> videoTable;
|
||||
private SingleSelectionModel<VideoDTO> videoSelectionModel;
|
||||
private ListDataProvider<VideoDTO> videoListDataProvider;
|
||||
private final Label noVideosLabel;
|
||||
|
||||
private final SimplePanel mainPanel;
|
||||
private final VerticalPanel panel;
|
||||
|
||||
public static class AnchorCell extends AbstractCell<SafeHtml> {
|
||||
@Override
|
||||
public void render(com.google.gwt.cell.client.Cell.Context context, SafeHtml safeHtml, SafeHtmlBuilder sb) {
|
||||
sb.append(safeHtml);
|
||||
}
|
||||
}
|
||||
|
||||
interface AnchorTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<a target=\"_blank\" href=\"{0}\">{1}</a>")
|
||||
SafeHtml cell(String url, String displayName);
|
||||
}
|
||||
|
||||
private static AnchorTemplates ANCHORTEMPLATE = GWT.create(AnchorTemplates.class);
|
||||
|
||||
private final AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class);
|
||||
|
||||
public VideosListComposite(final StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
|
||||
mainPanel = new SimplePanel();
|
||||
panel = new VerticalPanel();
|
||||
mainPanel.setWidget(panel);
|
||||
|
||||
HorizontalPanel videosControlsPanel = new HorizontalPanel();
|
||||
videosControlsPanel.setSpacing(5);
|
||||
panel.add(videosControlsPanel);
|
||||
|
||||
Button createVideoBtn = new Button("Add video");
|
||||
createVideoBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openCreateVideoDialog();
|
||||
}
|
||||
});
|
||||
videosControlsPanel.add(createVideoBtn);
|
||||
|
||||
videoSelectionModel = new SingleSelectionModel<VideoDTO>();
|
||||
videoListDataProvider = new ListDataProvider<VideoDTO>();
|
||||
videoTable = createImagesTable();
|
||||
videoTable.ensureDebugId("ImagesCellTable");
|
||||
videoTable.setVisible(false);
|
||||
|
||||
videoSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
|
||||
@Override
|
||||
public void onSelectionChange(SelectionChangeEvent event) {
|
||||
}
|
||||
});
|
||||
|
||||
panel.add(videoTable);
|
||||
|
||||
noVideosLabel = new Label("No videos defined yet.");
|
||||
noVideosLabel.ensureDebugId("NoVideosLabel");
|
||||
noVideosLabel.setWordWrap(false);
|
||||
panel.add(noVideosLabel);
|
||||
|
||||
initWidget(mainPanel);
|
||||
}
|
||||
|
||||
private CellTable<VideoDTO> createImagesTable() {
|
||||
CellTable<VideoDTO> table = new CellTable<VideoDTO>(/* pageSize */10000, tableRes);
|
||||
videoListDataProvider.addDataDisplay(table);
|
||||
table.setWidth("100%");
|
||||
|
||||
AnchorCell anchorCell = new AnchorCell();
|
||||
Column<VideoDTO, SafeHtml> shortVideoNameColumn = new Column<VideoDTO, SafeHtml>(anchorCell) {
|
||||
@Override
|
||||
public SafeHtml getValue(VideoDTO video) {
|
||||
String linkName = "";
|
||||
int index = video.getSourceRef().lastIndexOf("/");
|
||||
if(index > 0) {
|
||||
linkName = video.getSourceRef().substring(index+1, video.getSourceRef().length());
|
||||
}
|
||||
return ANCHORTEMPLATE.cell(video.getSourceRef(), linkName);
|
||||
}
|
||||
};
|
||||
|
||||
TextColumn<VideoDTO> titleColumn = new TextColumn<VideoDTO>() {
|
||||
@Override
|
||||
public String getValue(VideoDTO image) {
|
||||
return image.getTitle() != null ? image.getTitle() : "";
|
||||
}
|
||||
};
|
||||
|
||||
TextColumn<VideoDTO> createdAtDateColumn = new TextColumn<VideoDTO>() {
|
||||
@Override
|
||||
public String getValue(VideoDTO image) {
|
||||
return DateAndTimeFormatterUtil.formatDateAndTime(image.getCreatedAtDate());
|
||||
}
|
||||
};
|
||||
|
||||
SafeHtmlCell tagsCell = new SafeHtmlCell();
|
||||
Column<VideoDTO, SafeHtml> tagsColumn = new Column<VideoDTO, SafeHtml>(tagsCell) {
|
||||
@Override
|
||||
public SafeHtml getValue(VideoDTO image) {
|
||||
SafeHtmlBuilder builder = new SafeHtmlBuilder();
|
||||
int tagsCount = image.getTags().size();
|
||||
int i = 1;
|
||||
for (String tag : image.getTags()) {
|
||||
builder.appendEscaped(tag);
|
||||
if (i < tagsCount) {
|
||||
builder.appendHtmlConstant(", ");
|
||||
// not more than 4 tags per line
|
||||
if (i % 4 == 0) {
|
||||
builder.appendHtmlConstant("<br>");
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return builder.toSafeHtml();
|
||||
}
|
||||
};
|
||||
|
||||
ImagesBarColumn<VideoDTO, VideoConfigImagesBarCell> videoActionColumn = new ImagesBarColumn<VideoDTO, VideoConfigImagesBarCell>(
|
||||
new VideoConfigImagesBarCell(stringMessages));
|
||||
videoActionColumn.setFieldUpdater(new FieldUpdater<VideoDTO, String>() {
|
||||
@Override
|
||||
public void update(int index, VideoDTO image, String value) {
|
||||
if (ImageConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
|
||||
videoListDataProvider.getList().remove(image);
|
||||
updateTableVisisbilty();
|
||||
} else if (ImageConfigImagesBarCell.ACTION_EDIT.equals(value)) {
|
||||
openEditVideoDialog(image);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
titleColumn.setSortable(true);
|
||||
createdAtDateColumn.setSortable(true);
|
||||
|
||||
table.addColumn(shortVideoNameColumn, "Short name");
|
||||
table.addColumn(titleColumn, stringMessages.title());
|
||||
table.addColumn(createdAtDateColumn, "Created At");
|
||||
table.addColumn(tagsColumn, "Tags");
|
||||
table.addColumn(videoActionColumn, stringMessages.actions());
|
||||
table.addColumnSortHandler(getVideoTableColumnSortHandler(videoListDataProvider.getList(), titleColumn, createdAtDateColumn));
|
||||
table.getColumnSortList().push(createdAtDateColumn);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
private ListHandler<VideoDTO> getVideoTableColumnSortHandler(List<VideoDTO> videoRecords,
|
||||
TextColumn<VideoDTO> titleColumn, TextColumn<VideoDTO> createdAtDateColumn) {
|
||||
ListHandler<VideoDTO> result = new ListHandler<VideoDTO>(videoRecords);
|
||||
result.setComparator(titleColumn, new Comparator<VideoDTO>() {
|
||||
@Override
|
||||
public int compare(VideoDTO i1, VideoDTO i2) {
|
||||
return new NaturalComparator().compare(i1.getTitle(), i2.getTitle());
|
||||
}
|
||||
});
|
||||
result.setComparator(createdAtDateColumn, new Comparator<VideoDTO>() {
|
||||
@Override
|
||||
public int compare(VideoDTO e1, VideoDTO e2) {
|
||||
int result;
|
||||
if (e1.getCreatedAtDate() != null && e2.getCreatedAtDate() != null) {
|
||||
result = e2.getCreatedAtDate().compareTo(e1.getCreatedAtDate());
|
||||
} else if (e1.getCreatedAtDate() == null && e2.getCreatedAtDate() != null) {
|
||||
result = 1;
|
||||
} else if (e1.getCreatedAtDate() != null && e2.getCreatedAtDate() == null) {
|
||||
result = -1;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
private void openCreateVideoDialog() {
|
||||
VideoCreateDialog dialog = new VideoCreateDialog(stringMessages, new DialogCallback<VideoDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ok(VideoDTO newVideo) {
|
||||
videoListDataProvider.getList().add(newVideo);
|
||||
updateTableVisisbilty();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void openEditVideoDialog(final VideoDTO selectedVideo) {
|
||||
VideoEditDialog dialog = new VideoEditDialog(selectedVideo, stringMessages, new DialogCallback<VideoDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ok(VideoDTO updatedImage) {
|
||||
videoListDataProvider.getList().remove(selectedVideo);
|
||||
videoListDataProvider.getList().add(updatedImage);
|
||||
updateTableVisisbilty();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void updateTableVisisbilty() {
|
||||
if (videoListDataProvider.getList().isEmpty()) {
|
||||
videoTable.setVisible(false);
|
||||
noVideosLabel.setVisible(true);
|
||||
} else {
|
||||
videoTable.setVisible(true);
|
||||
noVideosLabel.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void fillVideos(List<VideoDTO> videos) {
|
||||
videoSelectionModel.clear();
|
||||
videoListDataProvider.getList().clear();
|
||||
videoListDataProvider.getList().addAll(videos);
|
||||
|
||||
updateTableVisisbilty();
|
||||
}
|
||||
|
||||
public List<VideoDTO> getAllVideos() {
|
||||
return videoListDataProvider.getList();
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.util.Date;
|
||||
import com.sap.sse.common.media.MimeType;
|
||||
|
||||
public class VideoDTO extends AbstractMediaDTO {
|
||||
private int lengthInSeconds;
|
||||
private Integer lengthInSeconds;
|
||||
private String thumbnailRef;
|
||||
|
||||
/** for GWT */
|
||||
@@ -16,11 +16,11 @@ public class VideoDTO extends AbstractMediaDTO {
|
||||
super(videoRef, mimeType, createdAtDate);
|
||||
}
|
||||
|
||||
public int getLengthInSeconds() {
|
||||
public Integer getLengthInSeconds() {
|
||||
return lengthInSeconds;
|
||||
}
|
||||
|
||||
public void setLengthInSeconds(int lengthInSeconds) {
|
||||
public void setLengthInSeconds(Integer lengthInSeconds) {
|
||||
this.lengthInSeconds = lengthInSeconds;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user