new SingleContentItemSelectionPanel();
contentPanel.add(selectionPanel);
contentPanel.add(createButtonPanel(popup, new ContentItemSelectionHandler() {
@Override
public void onSelect() {
BaseContentItem contentItem = selectionPanel.getSelection();
String headline = null;
if (contentItem.getContentItemType() == ContentItemType.EVENT) {
headline = ((EventContentItem) contentItem).getEventUpdate();
} else if (contentItem.getContentItemType() == ContentItemType.NARRATIVE) {
headline = ((NarrativeContentItem) contentItem).getHeadline();
} else {
Window.alert("You must link to an event or top level narrative!");
contentItem = null;
}
if (contentItem != null && contentItem.displayTopLevel()) {
richTextUtil.createJavascriptLink(richText.getElement(),
"goToContentItem(" + contentItem.getId() + ")",
"Jump to: " + headline.replace("\"", "'"));
}
}
}));
popup.add(contentPanel);
popup.showRelativeTo(insertContentItem);
} else if (sender == insertContentItem) {
PopupPanel popup = new PopupPanel();
FlowPanel contentPanel = new FlowPanel();
final SingleContentItemSelectionPanel selectionPanel =
new SingleContentItemSelectionPanel();
contentPanel.add(selectionPanel);
contentPanel.add(createButtonPanel(popup, new ContentItemSelectionHandler() {
@Override
public void onSelect() {
BaseContentItem contentItem = selectionPanel.getSelection();
if (contentItem != null) {
richTextUtil.createJavascriptLink(richText.getElement(),
"showContentItemPopup(" + contentItem.getId() + ", this)");
}
}
}));
popup.add(contentPanel);
popup.showRelativeTo(insertContentItem);
} else if (sender == insertSource) {
PopupPanel popup = new PopupPanel();
FlowPanel contentPanel = new FlowPanel();
final TextBox descriptionBox = new TextBox();
HorizontalPanel descriptionPanel = new HorizontalPanel();
descriptionPanel.add(new Label("Source description:"));
descriptionPanel.add(descriptionBox);
contentPanel.add(descriptionPanel);
final SingleContentItemSelectionPanel selectionPanel =
new SingleContentItemSelectionPanel();
contentPanel.add(selectionPanel);
contentPanel.add(createButtonPanel(popup, new ContentItemSelectionHandler() {
@Override
public void onSelect() {
String description = descriptionBox.getText();
BaseContentItem contentItem = selectionPanel.getSelection();
if (!description.isEmpty() || contentItem != null) {
String selectedText = richTextUtil.getSelection(richText.getElement());
richTextUtil.insertHTML(richText.getElement(), selectedText + " " +
new SourceLink(description, contentItem == null ? -1
: contentItem.getId()).getOuterHTML());
}
}
}));
popup.add(contentPanel);
popup.showRelativeTo(insertSource);
} else if (sender == insertLightbox) {
PopupPanel popup = new PopupPanel();
FlowPanel contentPanel = new FlowPanel();
final SingleContentItemSelectionPanel selectionPanel =
new SingleContentItemSelectionPanel();
contentPanel.add(selectionPanel);
contentPanel.add(createButtonPanel(popup, new ContentItemSelectionHandler() {
@Override
public void onSelect() {
BaseContentItem contentItem = selectionPanel.getSelection();
if (contentItem != null) {
richTextUtil.createJavascriptLink(richText.getElement(),
"showLightboxForContentItem('" + contentItem.getTypeString()
+ "', " + contentItem.getId() + ")");
}
}
}));
popup.add(contentPanel);
popup.showRelativeTo(insertLightbox);