use of org.rstudio.studio.client.common.presentation.model.SlideNavigationItem in project rstudio by rstudio.
the class SlideNavigationPresenter method onSlideNavigationChanged.
@Override
public void onSlideNavigationChanged(SlideNavigationChangedEvent event) {
slideNavigation_ = event.getNavigation();
SlideNavigationMenu navigationMenu = view_.getNavigationMenu();
navigationMenu.clear();
if (slideNavigation_ != null) {
JsArray<SlideNavigationItem> items = slideNavigation_.getItems();
for (int i = 0; i < items.length(); i++) {
// get slide
final SlideNavigationItem item = items.get(i);
// build html
SafeHtmlBuilder menuHtml = new SafeHtmlBuilder();
for (int j = 0; j < item.getIndent(); j++) menuHtml.appendHtmlConstant(" ");
menuHtml.appendEscaped(item.getTitle());
navigationMenu.addItem(new MenuItem(menuHtml.toSafeHtml(), new Command() {
@Override
public void execute() {
view_.navigate(item.getIndex());
}
}));
}
navigationMenu.setVisible(true);
navigationMenu.setDropDownVisible(slideNavigation_.getItems().length() > 1);
} else {
navigationMenu.setVisible(false);
}
}
use of org.rstudio.studio.client.common.presentation.model.SlideNavigationItem in project rstudio by rstudio.
the class TextEditingTargetPresentationHelper method buildSlideMenu.
public void buildSlideMenu(final String path, boolean isDirty, final EditingTarget editor, final CommandWithArg<StatusBarPopupRequest> onCompleted) {
// rpc response handler
SimpleRequestCallback<SlideNavigation> requestCallback = new SimpleRequestCallback<SlideNavigation>() {
@Override
public void onResponseReceived(SlideNavigation slideNavigation) {
// create the menu and make sure we have some slides to return
StatusBarPopupMenu menu = new StatusBarPopupMenu();
if (slideNavigation.getTotalSlides() == 0) {
onCompleted.execute(new StatusBarPopupRequest(menu, null));
return;
}
MenuItem defaultMenuItem = null;
int length = slideNavigation.getItems().length();
for (int i = 0; i < length; i++) {
SlideNavigationItem item = slideNavigation.getItems().get(i);
String title = item.getTitle();
if (StringUtil.isNullOrEmpty(title))
title = "(Untitled Slide)";
StringBuilder indentBuilder = new StringBuilder();
for (int level = 0; level < item.getIndent(); level++) indentBuilder.append(" ");
SafeHtmlBuilder labelBuilder = new SafeHtmlBuilder();
labelBuilder.appendHtmlConstant(indentBuilder.toString());
labelBuilder.appendEscaped(title);
final int targetSlide = i;
final MenuItem menuItem = new MenuItem(labelBuilder.toSafeHtml(), new Command() {
public void execute() {
navigateToSlide(editor, targetSlide);
}
});
menu.addItem(menuItem);
// see if this is the default menu item
if (defaultMenuItem == null && item.getLine() >= (docDisplay_.getSelectionStart().getRow())) {
defaultMenuItem = menuItem;
}
}
StatusBarPopupRequest request = new StatusBarPopupRequest(menu, defaultMenuItem);
onCompleted.execute(request);
}
};
// send code over the wire if we are dirty
if (isDirty) {
server_.getSlideNavigationForCode(docDisplay_.getCode(), FileSystemItem.createFile(path).getParentPathString(), requestCallback);
} else {
server_.getSlideNavigationForFile(path, requestCallback);
}
}
Aggregations