mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
created an action column for the regatta table for the regatta administration
This commit is contained in:
1 parent
3bce3616e0
commit
834fc5ef9c
6 files changed
+86
-18
No files matched your search
+22
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.ChangeEvent;
|
||||
@@ -18,6 +19,7 @@ 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.TextColumn;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CaptionPanel;
|
||||
@@ -215,12 +217,28 @@ public class EventStructureManagementPanel extends SimplePanel implements Regatt
|
||||
}
|
||||
};
|
||||
|
||||
ImagesBarColumn<RegattaDTO, RegattaConfigImagesBarCell> regattaActionColumn = new ImagesBarColumn<RegattaDTO, RegattaConfigImagesBarCell>(
|
||||
new RegattaConfigImagesBarCell(stringMessages));
|
||||
regattaActionColumn.setFieldUpdater(new FieldUpdater<RegattaDTO, String>() {
|
||||
@Override
|
||||
public void update(int index, RegattaDTO regatta, String value) {
|
||||
if ("ACTION_REMOVE".equals(value)) {
|
||||
if (Window.confirm("Do you really want to remove the regatta: '" + regatta.name + "' ?")) {
|
||||
removeRegatta(regatta);
|
||||
}
|
||||
} else if ("ACTION_EDIT".equals(value)) {
|
||||
} else if ("ACTION_EDIT_RACES".equals(value)) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
regattaTable = new CellTable<RegattaDTO>(200, tableRes);
|
||||
regattaTable.setWidth("100%");
|
||||
regattaTable.addColumn(regattaNameColumn, stringMessages.regattaName());
|
||||
regattaTable.addColumn(regattaBoatClassColumn, stringMessages.boatClass());
|
||||
regattaTable.addColumn(regattaSeriesColumn, stringMessages.series());
|
||||
regattaTable.addColumn(regattaFleetsColumn, stringMessages.fleets());
|
||||
regattaTable.addColumn(regattaActionColumn, stringMessages.actions());
|
||||
|
||||
regattaSelectionModel = new SingleSelectionModel<RegattaDTO>();
|
||||
regattaSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
|
||||
@@ -236,6 +254,10 @@ public class EventStructureManagementPanel extends SimplePanel implements Regatt
|
||||
parentPanel.add(regattaTable);
|
||||
}
|
||||
|
||||
private void removeRegatta(RegattaDTO regatta) {
|
||||
|
||||
}
|
||||
|
||||
private void onEventSelectionChanged() {
|
||||
int selIndex = eventsComboBox.getSelectedIndex();
|
||||
String selItemText = eventsComboBox.getItemText(selIndex);
|
||||
|
||||
+7
@@ -6,6 +6,8 @@ import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.dom.client.EventTarget;
|
||||
import com.google.gwt.dom.client.NativeEvent;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.text.shared.SafeHtmlRenderer;
|
||||
import com.google.gwt.text.shared.SimpleSafeHtmlRenderer;
|
||||
@@ -13,6 +15,11 @@ import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||
|
||||
public abstract class ImagesBarCell extends AbstractSafeHtmlCell<String> {
|
||||
|
||||
interface ImagesBarTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<div name=\"{0}\" style=\"{1}\" title=\"{2}\">{3}</div>")
|
||||
SafeHtml cell(String name, SafeStyles styles, String title, SafeHtml value);
|
||||
}
|
||||
|
||||
public ImagesBarCell() {
|
||||
super(SimpleSafeHtmlRenderer.getInstance(), "click", "keydown");
|
||||
}
|
||||
|
||||
-6
@@ -3,7 +3,6 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safecss.shared.SafeStylesUtils;
|
||||
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.text.shared.SafeHtmlRenderer;
|
||||
@@ -11,11 +10,6 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class LeaderboardConfigImagesBarCell extends ImagesBarCell {
|
||||
|
||||
interface ImagesBarTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<div name=\"{0}\" style=\"{1}\" title=\"{2}\">{3}</div>")
|
||||
SafeHtml cell(String name, SafeStyles styles, String title, SafeHtml value);
|
||||
}
|
||||
|
||||
public LeaderboardConfigImagesBarCell(StringMessages stringConstants) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
|
||||
-6
@@ -3,7 +3,6 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safecss.shared.SafeStylesUtils;
|
||||
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.text.shared.SafeHtmlRenderer;
|
||||
@@ -11,11 +10,6 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class LeaderboardGroupConfigImagesBarCell extends ImagesBarCell {
|
||||
|
||||
interface ImagesBarTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<div name=\"{0}\" style=\"{1}\" title=\"{2}\">{3}</div>")
|
||||
SafeHtml cell(String name, SafeStyles styles, String title, SafeHtml value);
|
||||
}
|
||||
|
||||
public LeaderboardGroupConfigImagesBarCell(StringMessages stringConstants) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
|
||||
-6
@@ -3,7 +3,6 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safecss.shared.SafeStylesUtils;
|
||||
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.text.shared.SafeHtmlRenderer;
|
||||
@@ -13,11 +12,6 @@ public class LeaderboardRaceConfigImagesBarCell extends ImagesBarCell {
|
||||
|
||||
private StringMessages stringConstants;
|
||||
|
||||
interface ImagesBarTemplates extends SafeHtmlTemplates {
|
||||
@SafeHtmlTemplates.Template("<div name=\"{0}\" style=\"{1}\" title=\"{2}\">{3}</div>")
|
||||
SafeHtml cell(String name, SafeStyles styles, String title, SafeHtml value);
|
||||
}
|
||||
|
||||
public LeaderboardRaceConfigImagesBarCell(StringMessages stringConstants) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safecss.shared.SafeStyles;
|
||||
import com.google.gwt.safecss.shared.SafeStylesUtils;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.text.shared.SafeHtmlRenderer;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class RegattaConfigImagesBarCell extends ImagesBarCell {
|
||||
|
||||
public RegattaConfigImagesBarCell(StringMessages stringConstants) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
}
|
||||
|
||||
public RegattaConfigImagesBarCell(SafeHtmlRenderer<String> renderer, StringMessages stringConstants) {
|
||||
super();
|
||||
this.stringConstants = stringConstants;
|
||||
}
|
||||
|
||||
private static ImagesBarTemplates templates = GWT.create(ImagesBarTemplates.class);
|
||||
|
||||
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
|
||||
private static final SafeHtml ICON_EDIT = makeImage(resources.editIcon());
|
||||
|
||||
private static final SafeHtml ICON_REMOVE = makeImage(resources.removeIcon());
|
||||
|
||||
private static final SafeHtml ICON_EDIT_RACES = makeImage(resources.linkIcon());
|
||||
|
||||
private StringMessages stringConstants;
|
||||
|
||||
@Override
|
||||
protected void render(com.google.gwt.cell.client.Cell.Context context, SafeHtml data, SafeHtmlBuilder sb) {
|
||||
/*
|
||||
* Always do a null check on the value. Cell widgets can pass null to
|
||||
* cells if the underlying data contains a null, or if the data arrives
|
||||
* out of order.
|
||||
*/
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SafeStyles imgStyle = SafeStylesUtils.fromTrustedString("float:left;cursor:hand;cursor:pointer;padding-right:5px;");
|
||||
|
||||
SafeHtml rendered = templates.cell("ACTION_EDIT", imgStyle, stringConstants.actionEdit(), ICON_EDIT);
|
||||
sb.append(rendered);
|
||||
|
||||
rendered = templates.cell("ACTION_EDIT_RACES", imgStyle, stringConstants.actionRaceEdit(), ICON_EDIT_RACES);
|
||||
sb.append(rendered);
|
||||
|
||||
rendered = templates.cell("ACTION_REMOVE", imgStyle, stringConstants.actionRemove(), ICON_REMOVE);
|
||||
sb.append(rendered);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user