Search in sources :

Example 1 with SlideNavigation

use of org.rstudio.studio.client.common.presentation.model.SlideNavigation in project rstudio by rstudio.

the class Presentation method initPresentationNavigator.

private void initPresentationNavigator(JavaScriptObject jsNavigator) {
    // record current slides
    SlideNavigation navigation = jsNavigator.cast();
    handlerManager_.fireEvent(new SlideNavigationChangedEvent(navigation));
}
Also used : SlideNavigationChangedEvent(org.rstudio.studio.client.common.presentation.events.SlideNavigationChangedEvent) SlideNavigation(org.rstudio.studio.client.common.presentation.model.SlideNavigation)

Example 2 with SlideNavigation

use of org.rstudio.studio.client.common.presentation.model.SlideNavigation 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("&nbsp;&nbsp;");
                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);
    }
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) Command(com.google.gwt.user.client.Command) StatusBarPopupMenu(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu) StatusBarPopupRequest(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest) MenuItem(com.google.gwt.user.client.ui.MenuItem) SlideNavigation(org.rstudio.studio.client.common.presentation.model.SlideNavigation) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) SlideNavigationItem(org.rstudio.studio.client.common.presentation.model.SlideNavigationItem) SimpleRequestCallback(org.rstudio.studio.client.common.SimpleRequestCallback)

Aggregations

SlideNavigation (org.rstudio.studio.client.common.presentation.model.SlideNavigation)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 Command (com.google.gwt.user.client.Command)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 SimpleRequestCallback (org.rstudio.studio.client.common.SimpleRequestCallback)1 SlideNavigationChangedEvent (org.rstudio.studio.client.common.presentation.events.SlideNavigationChangedEvent)1 SlideNavigationItem (org.rstudio.studio.client.common.presentation.model.SlideNavigationItem)1 StatusBarPopupMenu (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupMenu)1 StatusBarPopupRequest (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBarPopupRequest)1