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);
}
}
Aggregations