public void onChange(ChangeEvent event) {
contentPanel.showWidget(1);
topSaveControls.statusLabel.setText("");
bottomSaveControls.statusLabel.setText("");
BaseContentItem selectedContentItem = contentItemListBox.getSelectedContentItem();
contentItemIdLabel.setText(String.valueOf(selectedContentItem.getId()));
contentEditor.setContent(selectedContentItem.getContent());
timestamp.setText(DateUtil.formatDateTime(selectedContentItem.getTimestamp()));
importanceSelector.selectConstant(selectedContentItem.getImportance());
contentItemTypeSelector.selectConstant(selectedContentItem.getContentItemType());
setAssetControlVisibility();
showSpecialAttributesPanel(selectedContentItem.getContentItemType());
// First clear or set these fields to default values.
// Otherwise, if the user changes the content item type, they may
// see data from some other content item in the form fields.
startDatePicker.setValue(DateUtil.getDateMidnight());
startTime.setText("");
endDatePicker.setValue(DateUtil.getDateMidnight());
endTime.setText("");
setDateTriggerText();
updateEditor.setText("");
summaryEditor.setContent("");
nameTextBox.setText("");
aliasesTextBox.setText("");
playerTypeSelector.selectConstant(PlayerType.PERSON);
photoSelector.setSelection(null);
assetTypeSelector.selectConstant(AssetType.IMAGE);
captionTextArea.setText("");
previewUrlTextBox.setText("");
imageUrlTextBox.setText("");
headlineTextBox.setText("");
narrativeTypeSelector.selectConstant(NarrativeType.FEATURE);
narrativeDateBox.setValue(null);
narrativeSummaryTextArea.setContent("");
parentPlayer = null;
formatParentPlayerDisplay();
switch (selectedContentItem.getContentItemType()) {
case EVENT:
EventContentItem eventContentItem = (EventContentItem) selectedContentItem;
Date startDate = eventContentItem.getEventStartDate();
Date endDate = eventContentItem.getEventEndDate();
if (startDate == null) {
startDate = new Date();
}
startDatePicker.setValue(startDate);
startDatePicker.setCurrentMonth(startDatePicker.getValue());
startTime.setValue(DateUtil.formatTime(startDate));
hasSeparateEndDate.setValue(endDate != null, true);
endDatePicker.setValue(endDate == null ? startDatePicker.getValue() : endDate);
endDatePicker.setCurrentMonth(endDatePicker.getValue());
endTime.setText(endDate == null ? startTime.getText() : DateUtil.formatTime(endDate));
setDateTriggerText();
updateEditor.setText(eventContentItem.getEventUpdate());
summaryEditor.setContent(eventContentItem.getEventSummary());
break;
case PLAYER:
if (selectedContentItem.getLivingStoryId() == null) {
PlayerContentItem playerContentItem = (PlayerContentItem) selectedContentItem;
nameTextBox.setText(playerContentItem.getName());
aliasesTextBox.setText(GlobalUtil.join(",", playerContentItem.getAliases()));
playerTypeSelector.selectConstant(playerContentItem.getPlayerType());
photoSelector.setSelection(playerContentItem.getPhotoContentItem());
} else {
parentPlayer =
((StoryPlayerContentItem) selectedContentItem).getParentPlayerContentItem();
formatParentPlayerDisplay();
}
break;
case ASSET:
AssetContentItem assetContentItem = (AssetContentItem) selectedContentItem;
AssetType assetType = assetContentItem.getAssetType();
assetTypeSelector.selectConstant(assetType);
setAssetControlVisibility();
captionTextArea.setText(assetContentItem.getCaption());
previewUrlTextBox.setText(assetContentItem.getPreviewUrl());
if (assetType == AssetType.IMAGE) {
contentEditor.setContent("");
imageUrlTextBox.setText(selectedContentItem.getContent());
}
break;
case NARRATIVE:
NarrativeContentItem narrativeContentItem = (NarrativeContentItem) selectedContentItem;
headlineTextBox.setText(narrativeContentItem.getHeadline());
narrativeTypeSelector.selectConstant(narrativeContentItem.getNarrativeType());
narrativeDateBox.setValue(narrativeContentItem.getNarrativeDate());
narrativeSummaryTextArea.setContent(narrativeContentItem.getNarrativeSummary());
break;
case BACKGROUND:
BackgroundContentItem backgroundContentItem =
(BackgroundContentItem) selectedContentItem;
if (backgroundContentItem.isConcept()) {
conceptNameTextBox.setText(backgroundContentItem.getConceptName());
}
break;
}
int themeCount = themeListBox.getItemCount();
Set<Long> themesInContentItem = selectedContentItem.getThemeIds();
for (int i = 0; i < themeCount; i++) {
themeListBox.setItemSelected(i, themesInContentItem.contains(
Long.parseLong(themeListBox.getValue(i))));
}
currentContributorIdsToNamesMap.clear();
for (Long contributorId : selectedContentItem.getContributorIds()) {
currentContributorIdsToNamesMap.put(contributorId,
unassignedPlayersIdToContentItemMap.get(contributorId).getName());
}
formatCurrentContributorList();
contributorSuggestPanel.clear();
if (mapsKeyExists) {
Location location = selectedContentItem.getLocation();
if (location != null) {
Double latitude = location.getLatitude();
latitudeTextBox.setText(latitude == null ? "" : latitude.toString());
Double longitude = location.getLongitude();
longitudeTextBox.setText(longitude == null ? "" : longitude.toString());
if (latitude != null && longitude != null) {
recenterMap();
}
String description = location.getDescription();
locationDescriptionTextArea.setText(description == null ? "" : description);
}
// Ensure that the state of the location controls are accurate for the content item data.
adjustLocationControls();
controlGeocodeButton();
}
// Set the source information related fields
String sourceDescription = selectedContentItem.getSourceDescription();
sourceDescriptionBox.setText(sourceDescription == null ? "" : sourceDescription);
sourceContentItemSelector.setSelection(selectedContentItem.getSourceContentItem());
updateSelectedLinkedContentItems(selectedContentItem);
updateDisplayedPublishStatus(selectedContentItem);
topSaveControls.deleteButton.setEnabled(true);