mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 01:59:35 +00:00
changed StringListEditorComposite to use Iterable instead of List; major refactoring for UserDetailsView
This commit is contained in:
1 parent
340f722d80
commit
381539e91a
41 files changed
+316
-316
No files matched your search
@@ -56,5 +56,6 @@ bin.includes = META-INF/,\
|
||||
AdminConsoleProgressBar.css,\
|
||||
Home.css,\
|
||||
Home.html,\
|
||||
base.css
|
||||
base.css,\
|
||||
com.sap.sailing.gwt.ui.Search/
|
||||
output.. = WEB-INF/classes/
|
||||
+1
-1
@@ -11,7 +11,7 @@ interface AdminConsoleResources extends ClientBundle {
|
||||
@Source("com/sap/sailing/gwt/ui/client/images/settingsActionIcon.png")
|
||||
ImageResource settingsActionIcon();
|
||||
|
||||
@Source("com/sap/sailing/gwt/ui/client/images/remove.png")
|
||||
@Source("com/sap/sse/gwt/client/images/remove.png")
|
||||
ImageResource removeIcon();
|
||||
|
||||
@Source("com/sap/sailing/gwt/ui/client/images/edit.png")
|
||||
|
||||
+4
-4
@@ -26,11 +26,11 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.StringListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.DeviceConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.DeviceConfigurationDTO.RegattaConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.DeviceConfigurationMatcherDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sse.gwt.client.controls.listedit.StringListEditorComposite;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
|
||||
public class DeviceConfigurationDetailComposite extends Composite {
|
||||
@@ -300,9 +300,9 @@ public class DeviceConfigurationDetailComposite extends Composite {
|
||||
}
|
||||
};
|
||||
|
||||
private ValueChangeHandler<List<String>> dirtyValueMarker = new ValueChangeHandler<List<String>>() {
|
||||
private ValueChangeHandler<Iterable<String>> dirtyValueMarker = new ValueChangeHandler<Iterable<String>>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<List<String>> event) {
|
||||
public void onValueChange(ValueChangeEvent<Iterable<String>> event) {
|
||||
markAsDirty(true);
|
||||
}
|
||||
};
|
||||
|
||||
+3
-3
@@ -20,12 +20,12 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialogWithBootstrap;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.StringListInlineEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.BetterDateTimeBox;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseAreaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.VenueDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.StringListInlineEditorComposite;
|
||||
|
||||
public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO> {
|
||||
private final AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
@@ -122,9 +122,9 @@ public abstract class EventDialog extends DataEntryDialogWithBootstrap<EventDTO>
|
||||
callback);
|
||||
this.leaderboardGroups = leaderboardGroups;
|
||||
this.stringMessages = stringMessages;
|
||||
final ValueChangeHandler<List<String>> valueChangeHandler = new ValueChangeHandler<List<String>>() {
|
||||
final ValueChangeHandler<Iterable<String>> valueChangeHandler = new ValueChangeHandler<Iterable<String>>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<List<String>> event) {
|
||||
public void onValueChange(ValueChangeEvent<Iterable<String>> event) {
|
||||
validate();
|
||||
}
|
||||
};
|
||||
|
||||
+19
-15
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.dom.client.Style.FontWeight;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
@@ -19,11 +17,11 @@ import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.Color;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ExpandedListEditorUi;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ExpandedListEditorUi;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
|
||||
public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
public FleetListEditorComposite(List<FleetDTO> initialValues, StringMessages stringMessages, ImageResource removeImage) {
|
||||
public FleetListEditorComposite(Iterable<FleetDTO> initialValues, StringMessages stringMessages, ImageResource removeImage) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage));
|
||||
}
|
||||
|
||||
@@ -33,6 +31,12 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
super(stringMessages, removeImage, /*canRemoveItems*/true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected StringMessages getStringMessages() {
|
||||
return (StringMessages) super.getStringMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createAddWidget() {
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
@@ -48,7 +52,7 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
final ListBox colorListBox = createColorListBox(nameBox, orderNoBox);
|
||||
colorListBox.ensureDebugId("ColorListBox");
|
||||
|
||||
final Button addButton = new Button(stringMessages.add());
|
||||
final Button addButton = new Button(getStringMessages().add());
|
||||
addButton.ensureDebugId("AddButton");
|
||||
addButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
@@ -57,11 +61,11 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
}
|
||||
});
|
||||
|
||||
hPanel.add(new Label(stringMessages.color() + ":"));
|
||||
hPanel.add(new Label(getStringMessages().color() + ":"));
|
||||
hPanel.add(colorListBox);
|
||||
hPanel.add(new Label(stringMessages.name() + ":"));
|
||||
hPanel.add(new Label(getStringMessages().name() + ":"));
|
||||
hPanel.add(nameBox);
|
||||
hPanel.add(new Label(stringMessages.rank() + ":"));
|
||||
hPanel.add(new Label(getStringMessages().rank() + ":"));
|
||||
hPanel.add(orderNoBox);
|
||||
hPanel.add(addButton);
|
||||
return hPanel;
|
||||
@@ -71,17 +75,17 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
protected Widget createValueWidget(int rowIndex, FleetDTO fleet) {
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.setSpacing(4);
|
||||
Label fleetLabel = new Label(stringMessages.fleet() + " '" + fleet.getName() + "' :");
|
||||
Label fleetLabel = new Label(getStringMessages().fleet() + " '" + fleet.getName() + "' :");
|
||||
fleetLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);
|
||||
hPanel.add(fleetLabel);
|
||||
|
||||
String valueText = "";
|
||||
if(fleet.getColor() != null) {
|
||||
valueText += stringMessages.color() + " '" + fleet.getColor().toString() + "'";
|
||||
valueText += getStringMessages().color() + " '" + fleet.getColor().toString() + "'";
|
||||
} else {
|
||||
valueText += stringMessages.noColor();
|
||||
valueText += getStringMessages().noColor();
|
||||
}
|
||||
valueText += ", " + stringMessages.rank() + " " + fleet.getOrderNo();
|
||||
valueText += ", " + getStringMessages().rank() + " " + fleet.getOrderNo();
|
||||
|
||||
hPanel.add(new Label(valueText));
|
||||
|
||||
@@ -121,7 +125,7 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
}
|
||||
}
|
||||
});
|
||||
colorListBox.addItem(stringMessages.noColor());
|
||||
colorListBox.addItem(getStringMessages().noColor());
|
||||
for (FleetColors value : FleetColors.values()) {
|
||||
colorListBox.addItem(value.name());
|
||||
}
|
||||
@@ -147,7 +151,7 @@ public class FleetListEditorComposite extends ListEditorComposite<FleetDTO> {
|
||||
|
||||
private String getColorText(FleetColors color) {
|
||||
if (color == null) {
|
||||
return stringMessages.noColor();
|
||||
return getStringMessages().noColor();
|
||||
}
|
||||
return color.name().charAt(0) + color.name().toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,10 +10,10 @@ import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.user.client.ui.TabPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
|
||||
public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAndFleetsDialog {
|
||||
|
||||
|
||||
+1
-1
@@ -14,12 +14,12 @@ import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.TabPanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.DeviceConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.DeviceConfigurationDTO.RegattaConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
|
||||
public class RegattaWithSeriesAndFleetsEditDialog extends RegattaWithSeriesAndFleetsDialog {
|
||||
|
||||
|
||||
+13
-8
@@ -29,10 +29,10 @@ import com.sap.sailing.domain.common.LeaderboardNameConstants;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnInSeriesDTO;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.StringListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.StringListInlineEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.StringListEditorComposite;
|
||||
import com.sap.sse.gwt.client.controls.listedit.StringListInlineEditorComposite;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
@@ -206,9 +206,9 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
|
||||
raceNamesEditor = new StringListInlineEditorComposite(getExistingRacesOfSeries(), new RaceNamesEditorUi(regatta, stringMessages, resources.removeIcon(), seriesName));
|
||||
raceNamesEditor.ensureDebugId("RaceNamesStringListEditorComposite");
|
||||
raceNamesEditor.addValueChangeHandler(new ValueChangeHandler<List<String>>() {
|
||||
raceNamesEditor.addValueChangeHandler(new ValueChangeHandler<Iterable<String>>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<List<String>> event) {
|
||||
public void onValueChange(ValueChangeEvent<Iterable<String>> event) {
|
||||
validate();
|
||||
}
|
||||
});
|
||||
@@ -269,6 +269,11 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
this.addRacesHintLabel = new Label("");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StringMessages getStringMessages() {
|
||||
return (StringMessages) super.getStringMessages();
|
||||
}
|
||||
|
||||
private List<String> resolveRaceNamesToAdd() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
String racePrefix = raceNamePrefixTextBox.getText();
|
||||
@@ -346,7 +351,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
HorizontalPanel addRacesPanel = new HorizontalPanel();
|
||||
addRacesPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
addRacesPanel.setSpacing(5);
|
||||
addRacesPanel.add(new Label(stringMessages.addRaces()));
|
||||
addRacesPanel.add(new Label(getStringMessages().addRaces()));
|
||||
|
||||
for(int i = 1; i <= 50; i++) {
|
||||
addRacesFromListBox.addItem("" + i);
|
||||
@@ -368,9 +373,9 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
});
|
||||
|
||||
addRacesPanel.add(addRacesFromListBox);
|
||||
addRacesPanel.add(new Label(stringMessages.to()));
|
||||
addRacesPanel.add(new Label(getStringMessages().to()));
|
||||
addRacesPanel.add(addRacesToListBox);
|
||||
addRacesPanel.add(new Label(stringMessages.withNamePrefix()));
|
||||
addRacesPanel.add(new Label(getStringMessages().withNamePrefix()));
|
||||
|
||||
raceNamePrefixTextBox.setWidth("20px");
|
||||
if (LeaderboardNameConstants.DEFAULT_SERIES_NAME.equals(seriesName)) {
|
||||
@@ -399,7 +404,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
}
|
||||
validate();
|
||||
} else {
|
||||
Window.alert(stringMessages.pleaseSelectASeriesFirst());
|
||||
Window.alert(getStringMessages().pleaseSelectASeriesFirst());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+3
-4
@@ -19,8 +19,8 @@ import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.LeaderboardNameConstants;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
@@ -136,10 +136,9 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
|
||||
fleetListComposite = new FleetListEditorComposite(Arrays.asList(new FleetDTO(LeaderboardNameConstants.DEFAULT_FLEET_NAME, 0, null)), stringMessages, resources.removeIcon());
|
||||
fleetListComposite.ensureDebugId("FleetListEditorComposite");
|
||||
fleetListComposite.addValueChangeHandler(new ValueChangeHandler<List<FleetDTO>>() {
|
||||
|
||||
fleetListComposite.addValueChangeHandler(new ValueChangeHandler<Iterable<FleetDTO>>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<List<FleetDTO>> event) {
|
||||
public void onValueChange(ValueChangeEvent<Iterable<FleetDTO>> event) {
|
||||
validate();
|
||||
}
|
||||
});
|
||||
|
||||
+13
-9
@@ -1,7 +1,6 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.dom.client.Style.FontWeight;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
@@ -12,14 +11,14 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ExpandedListEditorUi;
|
||||
import com.sap.sailing.gwt.ui.client.shared.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ExpandedListEditorUi;
|
||||
import com.sap.sse.gwt.client.controls.listedit.ListEditorComposite;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
|
||||
public class SeriesWithFleetsListEditor extends ListEditorComposite<SeriesDTO> {
|
||||
|
||||
public SeriesWithFleetsListEditor(List<SeriesDTO> initialValues, StringMessages stringMessages, ImageResource removeImage, boolean enableFleetRemoval) {
|
||||
public SeriesWithFleetsListEditor(Iterable<SeriesDTO> initialValues, StringMessages stringMessages, ImageResource removeImage, boolean enableFleetRemoval) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage, enableFleetRemoval));
|
||||
}
|
||||
|
||||
@@ -28,15 +27,20 @@ public class SeriesWithFleetsListEditor extends ListEditorComposite<SeriesDTO> {
|
||||
super(stringMessages, removeImage, canRemoveItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StringMessages getStringMessages() {
|
||||
return (StringMessages) super.getStringMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createAddWidget() {
|
||||
Button addSeriesButton = new Button(stringMessages.addSeries());
|
||||
Button addSeriesButton = new Button(getStringMessages().addSeries());
|
||||
addSeriesButton.ensureDebugId("AddSeriesButton");
|
||||
addSeriesButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
SeriesWithFleetsCreateDialog dialog = new SeriesWithFleetsCreateDialog(Collections
|
||||
.unmodifiableCollection(context.getValue()), stringMessages, new DialogCallback<SeriesDTO>() {
|
||||
.unmodifiableCollection(context.getValue()), getStringMessages(), new DialogCallback<SeriesDTO>() {
|
||||
@Override
|
||||
public void cancel() {
|
||||
}
|
||||
@@ -57,7 +61,7 @@ public class SeriesWithFleetsListEditor extends ListEditorComposite<SeriesDTO> {
|
||||
protected Widget createValueWidget(int rowIndex, SeriesDTO seriesDTO) {
|
||||
HorizontalPanel hPanel = new HorizontalPanel();
|
||||
hPanel.setSpacing(5);
|
||||
Label seriesLabel = new Label(stringMessages.series() + " '" + seriesDTO.getName() + "' :");
|
||||
Label seriesLabel = new Label(getStringMessages().series() + " '" + seriesDTO.getName() + "' :");
|
||||
seriesLabel.setWordWrap(false);
|
||||
seriesLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);
|
||||
hPanel.add(seriesLabel);
|
||||
@@ -66,9 +70,9 @@ public class SeriesWithFleetsListEditor extends ListEditorComposite<SeriesDTO> {
|
||||
|
||||
if (seriesDTO.getFleets() != null && seriesDTO.getFleets().size() > 0) {
|
||||
if(seriesDTO.getFleets().size() == 1) {
|
||||
fleetText = "1 " + stringMessages.fleet();
|
||||
fleetText = "1 " + getStringMessages().fleet();
|
||||
} else {
|
||||
fleetText = seriesDTO.getFleets().size() + " " + stringMessages.fleets();
|
||||
fleetText = seriesDTO.getFleets().size() + " " + getStringMessages().fleets();
|
||||
}
|
||||
fleetText += ": " + seriesDTO.getFleets().toString();
|
||||
} else {
|
||||
|
||||
+1
-5
@@ -1,14 +1,10 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.i18n.client.Messages;
|
||||
|
||||
public interface StringMessages extends Messages {
|
||||
public interface StringMessages extends com.sap.sse.gwt.client.StringMessages {
|
||||
public static final StringMessages INSTANCE = GWT.create(StringMessages.class);
|
||||
|
||||
String helloWorld();
|
||||
String kielWeel2011();
|
||||
String stgAccount();
|
||||
String tracTracEvents();
|
||||
String swissTimingEvents();
|
||||
String trackedBefore();
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
helloWorld=Hello World
|
||||
kielWeel2011=Kiel Week 2011
|
||||
stgAccount=STG Account
|
||||
tracTracEvents=TracTrac Events
|
||||
swissTimingEvents=SwissTiming Events
|
||||
trackedBefore=History of tracked events
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
helloWorld=Hello World
|
||||
kielWeel2011=Kiel Week 2011
|
||||
stgAccount=STG Account
|
||||
tracTracEvents=TracTrac Events
|
||||
swissTimingEvents=SwissTiming Events
|
||||
trackedBefore=Historie verfolgter Events
|
||||
|
||||
-3
@@ -1,7 +1,4 @@
|
||||
# If you want new properties translated then sent this over GMR (Mark Angell <mangell@gmr.com>)
|
||||
helloWorld=Привет Мир
|
||||
kielWeel2011=Кильская Неделя 2011
|
||||
stgAccount=Счет STG
|
||||
tracTracEvents=События Трак Трак
|
||||
swissTimingEvents=События Swiss Timing
|
||||
trackedBefore=Ранее Отслеженные
|
||||
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
|
||||
/**
|
||||
* Base class for "collapsed" list editing UIs for use in a {@link ListEditorComposite}. An editing strategy of this
|
||||
* type shows the list of values in a single character string, together with an "Edit" button which pops up a dialog
|
||||
* that contains an "expanded" editor of type {@link ExpandedListEditorUi}.
|
||||
* <p>
|
||||
*
|
||||
* To implement a "collapsed" editor, subclasses have to provide the {@link String} representation of a value list in
|
||||
* method {@link #getCollapsedValueText(List)} and need to provide the widget used to edit the list. This widget will be
|
||||
* displayed in the pop-up dialog, together with a "Save" and a "Cancel" button. It is a common pattern to use a
|
||||
* {@link ListEditorComposite} with the respective {@link ExpandedListEditorUi} strategy that will be passed through
|
||||
* from this class's constructor to the {@link #createExpandedUi(List, ExpandedListEditorUi)} method.<p>
|
||||
*
|
||||
* Implementing subclasses may choose to override the {@link #onRowAdded()} and/or the {@link #onRowRemoved()} method(s)
|
||||
* to be notified of changes to the list.
|
||||
*
|
||||
* @author Lukas Niemeier
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
* @param <ValueType>
|
||||
*/
|
||||
public abstract class CollapsedListEditorUi<ValueType> extends ListEditorUi<ValueType> {
|
||||
private static final int collapsedTitleMaxLength = 20;
|
||||
|
||||
private final String popupDialogTitle;
|
||||
private final ExpandedListEditorUi<ValueType> expandedUi;
|
||||
private TextBox collapsedValuesBox;
|
||||
private Button collapsedEditButton;
|
||||
|
||||
public CollapsedListEditorUi(StringMessages stringMessages, String popupDialogTitle,
|
||||
ExpandedListEditorUi<ValueType> expandedUi) {
|
||||
super(stringMessages);
|
||||
this.popupDialogTitle = popupDialogTitle;
|
||||
this.expandedUi = expandedUi;
|
||||
}
|
||||
|
||||
protected abstract String getCollapsedValueText(List<ValueType> value);
|
||||
|
||||
protected abstract ListEditorComposite<ValueType> createExpandedUi(List<ValueType> initialValues,
|
||||
ExpandedListEditorUi<ValueType> ui);
|
||||
|
||||
@Override
|
||||
public void setContext(ListEditorComposite<ValueType> context) {
|
||||
super.setContext(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Widget initWidget() {
|
||||
HorizontalPanel panel = new HorizontalPanel();
|
||||
collapsedValuesBox = new TextBox();
|
||||
collapsedValuesBox.setReadOnly(true);
|
||||
|
||||
collapsedEditButton = new Button(stringMessages.edit());
|
||||
collapsedEditButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new PopupEditDialog(context.getValue(), expandedUi, popupDialogTitle,
|
||||
new DialogCallback<List<ValueType>>() {
|
||||
|
||||
@Override
|
||||
public void ok(List<ValueType> editedObject) {
|
||||
context.setValue(editedObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
panel.add(collapsedValuesBox);
|
||||
panel.add(collapsedEditButton);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
String text = getCollapsedValueText(context.getValue());
|
||||
String shortText = text;
|
||||
if (shortText.length() > collapsedTitleMaxLength) {
|
||||
shortText = shortText.substring(0, collapsedTitleMaxLength) + "...";
|
||||
}
|
||||
collapsedValuesBox.setText(shortText);
|
||||
collapsedValuesBox.setTitle(text);
|
||||
}
|
||||
|
||||
private class PopupEditDialog extends DataEntryDialog<List<ValueType>> {
|
||||
|
||||
private ListEditorComposite<ValueType> expandedComposite;
|
||||
|
||||
public PopupEditDialog(List<ValueType> initialValues, ExpandedListEditorUi<ValueType> ui, String dialogTitle,
|
||||
DataEntryDialog.DialogCallback<List<ValueType>> callback) {
|
||||
super(dialogTitle, "", stringMessages.save(), stringMessages.cancel(), null, callback);
|
||||
expandedComposite = createExpandedUi(initialValues, ui);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
return expandedComposite;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<ValueType> getResult() {
|
||||
return expandedComposite.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowAdded() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowRemoved() {
|
||||
}
|
||||
}
|
||||
|
||||
-132
@@ -1,132 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.PushButton;
|
||||
import com.google.gwt.user.client.ui.ValueBoxBase;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
/**
|
||||
* A base class for an editing UI strategy for a list of objects of type <code>ValueType</code> for use in a
|
||||
* {@link ListEditorComposite} instance. The widget that renders this list editing UI strategy has a section at the top
|
||||
* that allows the user to add a new list entry. The widget used for this must be provided by implementing subclasses
|
||||
* through the {@link #createAddWidget()} method. Next to this widget, an "Add" button is displayed.
|
||||
* <p>
|
||||
*
|
||||
* Beneath this section for adding new values, a grid with the existing values is displayed. Each value is rendered by a
|
||||
* widget provided by implementing subclasses through the {@link #createValueWidget(int, Object)} method. If the
|
||||
* <code>canRemoveItems</code> constructor parameter was set to <code>true</code> then next to each of these widgets, a
|
||||
* "Remove" button is shown.
|
||||
* <p>
|
||||
*
|
||||
* Implementing subclasses may choose to override the {@link #onRowAdded()} and/or the {@link #onRowRemoved()} method(s)
|
||||
* to be notified of changes to the list.
|
||||
*
|
||||
* @author Lukas Niemeier
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
* @param <ValueType>
|
||||
*/
|
||||
public abstract class ExpandedListEditorUi<ValueType> extends ListEditorUi<ValueType> {
|
||||
private final ImageResource removeImage;
|
||||
|
||||
private Grid expandedValuesGrid;
|
||||
private final boolean canRemoveItems;
|
||||
|
||||
/**
|
||||
* @param removeImage
|
||||
* may be <code>null</code> if <code>canRemoveItems==false</code>; otherwise, must contain a valid image
|
||||
* to be used by the "Remove" button
|
||||
* @param canRemoveItems
|
||||
* if <code>true</code>, next to each widget rendering one value in the value list a "Remove" push button will
|
||||
* be shown using the <code>removeImage</code>
|
||||
*/
|
||||
public ExpandedListEditorUi(StringMessages stringMessages, ImageResource removeImage, boolean canRemoveItems) {
|
||||
super(stringMessages);
|
||||
this.removeImage = removeImage;
|
||||
this.canRemoveItems = canRemoveItems;
|
||||
}
|
||||
|
||||
protected abstract Widget createAddWidget();
|
||||
|
||||
protected abstract Widget createValueWidget(int rowIndex, ValueType newValue);
|
||||
|
||||
@Override
|
||||
public Widget initWidget() {
|
||||
expandedValuesGrid = new Grid(0, 2);
|
||||
expandedValuesGrid.ensureDebugId("ExpandedValuesGrid");
|
||||
|
||||
VerticalPanel panel = new VerticalPanel();
|
||||
panel.add(createAddWidget());
|
||||
panel.add(expandedValuesGrid);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
expandedValuesGrid.clear();
|
||||
for (ValueType value : context.getValue()) {
|
||||
addRow(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRow(ValueType newValue) {
|
||||
int rowIndex = expandedValuesGrid.insertRow(expandedValuesGrid.getRowCount());
|
||||
if (canRemoveItems) {
|
||||
PushButton removeButton = new PushButton(new Image(removeImage));
|
||||
removeButton.ensureDebugId("RemoveButton");
|
||||
removeButton.setTitle(stringMessages.remove());
|
||||
removeButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
int rowToRemove = expandedValuesGrid.getCellForEvent(event).getRowIndex();
|
||||
removeRow(rowToRemove);
|
||||
}
|
||||
});
|
||||
expandedValuesGrid.setWidget(rowIndex, 1, removeButton);
|
||||
}
|
||||
expandedValuesGrid.setWidget(rowIndex, 0, createValueWidget(rowIndex, newValue));
|
||||
}
|
||||
|
||||
private void removeRow(int rowIndexToRemove) {
|
||||
expandedValuesGrid.removeRow(rowIndexToRemove);
|
||||
context.getValue().remove(rowIndexToRemove);
|
||||
context.onChange();
|
||||
|
||||
onRowRemoved();
|
||||
}
|
||||
|
||||
protected void setValueFromValueWidget(ValueBoxBase<ValueType> valueWidget, ValueType newValue, boolean fireEvents) {
|
||||
for (int i = 0; i < expandedValuesGrid.getRowCount(); i++) {
|
||||
Widget gridWidget = expandedValuesGrid.getWidget(i, 0);
|
||||
if (gridWidget.getElement() == valueWidget.getElement()) {
|
||||
context.getValue().set(i, newValue);
|
||||
if (fireEvents) {
|
||||
context.onChange();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addValue(ValueType newValue) {
|
||||
context.getValue().add(newValue);
|
||||
addRow(newValue);
|
||||
context.onChange();
|
||||
|
||||
onRowAdded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowAdded() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRowRemoved() {
|
||||
}
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.HasValue;
|
||||
|
||||
/**
|
||||
* A widget that lets users edit a list of <code>ValueType</code> objects. How the values are displayed and made
|
||||
* editable is controlled by the {@link ListEditorUiStrategy} passed to the constructor. There are two standard UI
|
||||
* strategies: a "collapsed" strategy provided by the abstract class {@link CollapsedListEditorUi} and an "expanded"
|
||||
* strategy, provided by the abstract class {@link ExpandedListEditorUi}. The collapsed strategy displays the values
|
||||
* separated by commas in a single text box and has an "edit' button that pops up a dialog with an "expanded" editing
|
||||
* view for the list. The "expanded" strategy has a widget at its top that can be used to add an element, including an
|
||||
* "Add" button, and beneath it a grid with one row per value where each row holds a (potentially editable) widget
|
||||
* displaying a value, and a "remove" button next to it. The popup that displays the "expanded" strategy editor has a
|
||||
* "Save" and a "Cancel" button at its bottom.<p>
|
||||
*
|
||||
* To use this micro-framework for list editing, you can either provide only an "expanded" editor, or you can provide
|
||||
* a "collapsed" and an "expanded" editor which are then used as a cascade. If your values are of type {@link String}, you
|
||||
* may use the pre-defined {@link StringListEditorComposite} or {@link StringListInlineEditorComposite} classes. A
|
||||
* "collapsed" editor UI strategy requires the corresponding "expanded" strategy (which is used for the "edit" pop-up
|
||||
* dialog) as a constructor argument.
|
||||
*
|
||||
* @author Lukas Niemeier
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
* @param <ValueType>
|
||||
*/
|
||||
public class ListEditorComposite<ValueType> extends Composite implements HasValue<List<ValueType>>,
|
||||
HasValueChangeHandlers<List<ValueType>> {
|
||||
|
||||
private final ListEditorUiStrategy<ValueType> activeUi;
|
||||
|
||||
private List<ValueType> values;
|
||||
|
||||
public ListEditorComposite(List<ValueType> initialValues, ListEditorUiStrategy<ValueType> activeUi) {
|
||||
this.values = new ArrayList<ValueType>(initialValues);
|
||||
this.activeUi = activeUi;
|
||||
this.activeUi.setContext(this);
|
||||
|
||||
initWidget(activeUi.initWidget());
|
||||
activeUi.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ValueType> getValue() {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<ValueType> newValues) {
|
||||
setValue(newValues, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(List<ValueType> newValues, boolean fireEvents) {
|
||||
this.values = newValues;
|
||||
activeUi.refresh();
|
||||
if (fireEvents) {
|
||||
onChange();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<List<ValueType>> handler) {
|
||||
return addHandler(handler, ValueChangeEvent.getType());
|
||||
}
|
||||
|
||||
public void onChange() {
|
||||
ValueChangeEvent.fire(this, getValue());
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public abstract class ListEditorUi<ValueType> implements ListEditorUiStrategy<ValueType> {
|
||||
protected final StringMessages stringMessages;
|
||||
protected ListEditorComposite<ValueType> context;
|
||||
|
||||
public ListEditorUi(StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContext(ListEditorComposite<ValueType> context) {
|
||||
this.context = context;
|
||||
}
|
||||
}
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
/**
|
||||
* Describes what a UI strategy for a {@link ListEditorComposite value list editor} must provide and which callbacks it
|
||||
* will receive. The {@link #initWidget()} method provides the core UI element used to display an editable or uneditable
|
||||
* list of values of type <code>ValueType</code>. When the {@link #refresh()} method is invoked by the framework, the
|
||||
* implementing class needs to update the contents of the widget returned from {@link #initWidget} based on the
|
||||
* {@link ListEditorComposite#getValue() values} of the context editor that was passed to
|
||||
* {@link #setContext(ListEditorComposite)} during editor initialization.<p>
|
||||
*
|
||||
* Objects will receive calls to {@link #onRowAdded()} when a value was added to the list, and {@link #onRowRemoved()} when
|
||||
* a value was removed from the list.<p>
|
||||
*
|
||||
* There are two default implementations of this interface: {@link CollapsedListEditorUi} and {@link ExpandedListEditorUi}.
|
||||
*
|
||||
* @author Lukas Niemeier
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
* @param <ValueType>
|
||||
*/
|
||||
public interface ListEditorUiStrategy<ValueType> {
|
||||
/**
|
||||
* Called by the framework before any other operations of this object are called.
|
||||
*
|
||||
* @param context
|
||||
* the editor using this strategy to display and/or edit the value list. The
|
||||
* {@link ListEditorComposite#getValue()} method can be used to obtain the current
|
||||
* list of values from the editor.
|
||||
*/
|
||||
void setContext(ListEditorComposite<ValueType> context);
|
||||
|
||||
/**
|
||||
* Called by the framework to obtain the UI widget to display to the user to show and/or make
|
||||
* editable the list of values managed by the context {@link ListEditorComposite editor}.
|
||||
*/
|
||||
Widget initWidget();
|
||||
|
||||
/**
|
||||
* Instructs this object to refresh the contents of the widget returned from {@link #initWidget()}
|
||||
* based on the {@link ListEditorComposite#getValue() values} managed by the editor. This method
|
||||
* is called when the entire value list has changed or has been set for the first time.
|
||||
*/
|
||||
void refresh();
|
||||
|
||||
/**
|
||||
* Called by the framework after a value was added to the list. Note that this is not the place
|
||||
* for this UI strategy to actually implement the UI changes. Those are expected to already have
|
||||
* happened before.
|
||||
*/
|
||||
void onRowAdded();
|
||||
|
||||
/**
|
||||
* Called by the framework after a value was removed from the list. Note that this is not the place for this UI
|
||||
* strategy to actually implement the UI changes. Those are expected to already have happened before.
|
||||
*/
|
||||
void onRowRemoved();
|
||||
}
|
||||
-106
@@ -1,106 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyUpEvent;
|
||||
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class StringListEditorComposite extends ListEditorComposite<String> {
|
||||
public StringListEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
String popupDialogTitle, ImageResource removeImage, List<String> suggestValues) {
|
||||
super(initialValues, new CollapsedUi(stringMessages, popupDialogTitle,
|
||||
new ExpandedUi(stringMessages, removeImage, suggestValues)));
|
||||
}
|
||||
|
||||
public StringListEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
ImageResource removeImage, List<String> suggestValues) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage, suggestValues));
|
||||
}
|
||||
|
||||
public StringListEditorComposite(List<String> initialValues, ListEditorUiStrategy<String> activeUi) {
|
||||
super(initialValues, activeUi);
|
||||
}
|
||||
|
||||
public static class CollapsedUi extends CollapsedListEditorUi<String> {
|
||||
|
||||
public CollapsedUi(StringMessages stringMessages, String dialogTitle, ExpandedListEditorUi<String> expandedUi) {
|
||||
super(stringMessages, dialogTitle, expandedUi);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCollapsedValueText(List<String> value) {
|
||||
StringBuilder valuesText = new StringBuilder();
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
if (i > 0) {
|
||||
valuesText.append(',');
|
||||
}
|
||||
valuesText.append(value.get(i));
|
||||
}
|
||||
String condensedValue = valuesText.toString();
|
||||
return condensedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListEditorComposite<String> createExpandedUi(List<String> initialValues, ExpandedListEditorUi<String> ui) {
|
||||
return new StringListEditorComposite(initialValues, ui);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExpandedUi extends ExpandedListEditorUi<String> {
|
||||
|
||||
protected final MultiWordSuggestOracle inputOracle;
|
||||
|
||||
public ExpandedUi(StringMessages stringMessages, ImageResource removeImage, List<String> suggestValues) {
|
||||
super(stringMessages, removeImage, /*canRemoveItems*/true);
|
||||
this.inputOracle = new MultiWordSuggestOracle();
|
||||
inputOracle.addAll(suggestValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContext(ListEditorComposite<String> context) {
|
||||
super.setContext(context);
|
||||
inputOracle.addAll(context.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createAddWidget() {
|
||||
final SuggestBox inputBox = new SuggestBox(inputOracle);
|
||||
inputBox.ensureDebugId("InputSuggestBox");
|
||||
final Button addButton = new Button(stringMessages.add());
|
||||
addButton.ensureDebugId("AddButton");
|
||||
addButton.setEnabled(false);
|
||||
addButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
addValue(inputBox.getValue());
|
||||
inputBox.setText("");
|
||||
}
|
||||
});
|
||||
inputBox.addKeyUpHandler(new KeyUpHandler() {
|
||||
@Override
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
addButton.setEnabled(!inputBox.getValue().isEmpty());
|
||||
}
|
||||
});
|
||||
HorizontalPanel panel = new HorizontalPanel();
|
||||
panel.add(inputBox);
|
||||
panel.add(addButton);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createValueWidget(int rowIndex, String newValue) {
|
||||
return new Label(newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
-138
@@ -1,138 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.controls.listedit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.dom.client.InputElement;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyUpEvent;
|
||||
import com.google.gwt.event.dom.client.KeyUpHandler;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.MultiWordSuggestOracle;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
|
||||
public class StringListInlineEditorComposite extends StringListEditorComposite {
|
||||
public StringListInlineEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
String popupDialogTitle, ImageResource removeImage, List<String> suggestValues, int textBoxSize) {
|
||||
super(initialValues, new CollapsedUi(stringMessages, popupDialogTitle,
|
||||
new ExpandedUi(stringMessages, removeImage, suggestValues, textBoxSize)));
|
||||
}
|
||||
|
||||
public StringListInlineEditorComposite(List<String> initialValues, StringMessages stringMessages,
|
||||
ImageResource removeImage, List<String> suggestValues, int textBoxSize) {
|
||||
super(initialValues, new ExpandedUi(stringMessages, removeImage, suggestValues, textBoxSize));
|
||||
}
|
||||
|
||||
public StringListInlineEditorComposite(List<String> initialValues, ListEditorUiStrategy<String> activeUi) {
|
||||
super(initialValues, activeUi);
|
||||
}
|
||||
|
||||
public static class CollapsedUi extends CollapsedListEditorUi<String> {
|
||||
|
||||
public CollapsedUi(StringMessages stringMessages, String dialogTitle, ExpandedListEditorUi<String> expandedUi) {
|
||||
super(stringMessages, dialogTitle, expandedUi);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCollapsedValueText(List<String> value) {
|
||||
StringBuilder valuesText = new StringBuilder();
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
if (i > 0) {
|
||||
valuesText.append(',');
|
||||
}
|
||||
valuesText.append(value.get(i));
|
||||
}
|
||||
String condensedValue = valuesText.toString();
|
||||
return condensedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ListEditorComposite<String> createExpandedUi(List<String> initialValues, ExpandedListEditorUi<String> ui) {
|
||||
return new StringListInlineEditorComposite(initialValues, ui);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ExpandedUi extends ExpandedListEditorUi<String> {
|
||||
|
||||
private final MultiWordSuggestOracle inputOracle;
|
||||
private final int textBoxSize;
|
||||
|
||||
public ExpandedUi(StringMessages stringMessages, ImageResource removeImage, List<String> suggestValues, int textBoxSize) {
|
||||
super(stringMessages, removeImage, /*canRemoveItems*/true);
|
||||
this.inputOracle = new MultiWordSuggestOracle();
|
||||
this.textBoxSize = textBoxSize;
|
||||
|
||||
inputOracle.addAll(suggestValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContext(ListEditorComposite<String> context) {
|
||||
super.setContext(context);
|
||||
inputOracle.addAll(context.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createAddWidget() {
|
||||
final SuggestBox inputBox = new SuggestBox(inputOracle);
|
||||
|
||||
InputElement inputElement = inputBox.getElement().cast();
|
||||
inputElement.setSize(textBoxSize);
|
||||
|
||||
final Button addButton = new Button(stringMessages.add());
|
||||
addButton.setEnabled(false);
|
||||
addButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
addValue(inputBox.getValue());
|
||||
inputBox.setText("");
|
||||
}
|
||||
});
|
||||
inputBox.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
addButton.setEnabled(!inputBox.getValue().isEmpty());
|
||||
}
|
||||
});
|
||||
|
||||
HorizontalPanel panel = new HorizontalPanel();
|
||||
panel.add(inputBox);
|
||||
panel.add(addButton);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget createValueWidget(final int rowIndex, String newValue) {
|
||||
final TextBox textBox = new TextBox();
|
||||
textBox.setVisibleLength(textBoxSize);
|
||||
textBox.ensureDebugId("ValueTextBox");
|
||||
textBox.setValue(newValue);
|
||||
|
||||
textBox.addKeyUpHandler(new KeyUpHandler() {
|
||||
@Override
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
textBox.setFocus(false);
|
||||
// this ensures that the value is copied into the TextBox.getValue() result and a ChangeEvent is fired
|
||||
textBox.setFocus(true);
|
||||
}
|
||||
});
|
||||
|
||||
textBox.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<String> event) {
|
||||
String newValue = event.getValue();
|
||||
setValueFromValueWidget(textBox, newValue, true);
|
||||
}
|
||||
});
|
||||
return textBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 691 B |
Reference in new issue
Block a user