Search in sources :

Example 1 with SwitchToDocEvent

use of org.rstudio.studio.client.workbench.views.source.events.SwitchToDocEvent in project rstudio by rstudio.

the class DocsMenu method setDocs.

public void setDocs(ImageResource[] icons, String[] names, String[] paths) {
    clearItems();
    names_.clear();
    menuItems_.clear();
    // de-duplicate names
    names = deduplicate(names, paths);
    assert icons.length == names.length && names.length == paths.length;
    if (icons.length == 0) {
        addItem(new DisabledMenuItem("(No documents)"));
    }
    for (int i = 0; i < icons.length; i++) {
        String label = AppCommand.formatMenuLabel(icons[i], names[i] + "   ", null);
        final int tabIndex = i;
        MenuItem item = addItem(label, true, new Command() {

            public void execute() {
                if (panel_ != null)
                    panel_.hide(false);
                events_.fireEvent(new SwitchToDocEvent(tabIndex));
            }
        });
        item.setTitle(paths[i]);
        names_.add(names[i]);
        menuItems_.add(item);
    }
}
Also used : DisabledMenuItem(org.rstudio.core.client.command.DisabledMenuItem) AppCommand(org.rstudio.core.client.command.AppCommand) Command(com.google.gwt.user.client.Command) SwitchToDocEvent(org.rstudio.studio.client.workbench.views.source.events.SwitchToDocEvent) MenuItem(com.google.gwt.user.client.ui.MenuItem) DisabledMenuItem(org.rstudio.core.client.command.DisabledMenuItem)

Aggregations

Command (com.google.gwt.user.client.Command)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 AppCommand (org.rstudio.core.client.command.AppCommand)1 DisabledMenuItem (org.rstudio.core.client.command.DisabledMenuItem)1 SwitchToDocEvent (org.rstudio.studio.client.workbench.views.source.events.SwitchToDocEvent)1