public GlobalToolbar( Commands commands, FileTypeCommands fileTypeCommands, Provider<CodeSearch> pCodeSearch) { super(); commands_ = commands; pCodeSearch_ = pCodeSearch; ThemeResources res = ThemeResources.INSTANCE; addStyleName(res.themeStyles().globalToolbar()); // add newSourceDoc command ToolbarPopupMenu newMenu = new ToolbarPopupMenu(); newMenu.addItem(commands.newSourceDoc().createMenuItem(false)); // dynamically add other commands ArrayList<FileTypeCommands.CommandWithId> fileNewCommands = fileTypeCommands.commandsWithIds(FileTypeRegistry.R); for (FileTypeCommands.CommandWithId cmd : fileNewCommands) newMenu.addItem(cmd.command.createMenuItem(false)); // create and add new menu StandardIcons icons = StandardIcons.INSTANCE; ToolbarButton newButton = new ToolbarButton("", icons.stock_new(), newMenu); addLeftWidget(newButton); addLeftSeparator(); // open button + mru addLeftWidget(commands.openSourceDoc().createToolbarButton()); ToolbarPopupMenu mruMenu = new ToolbarPopupMenu(); mruMenu.addItem(commands.mru0().createMenuItem(false)); mruMenu.addItem(commands.mru1().createMenuItem(false)); mruMenu.addItem(commands.mru2().createMenuItem(false)); mruMenu.addItem(commands.mru3().createMenuItem(false)); mruMenu.addItem(commands.mru4().createMenuItem(false)); mruMenu.addItem(commands.mru5().createMenuItem(false)); mruMenu.addItem(commands.mru6().createMenuItem(false)); mruMenu.addItem(commands.mru7().createMenuItem(false)); mruMenu.addItem(commands.mru8().createMenuItem(false)); mruMenu.addItem(commands.mru9().createMenuItem(false)); mruMenu.addSeparator(); mruMenu.addItem(commands.clearRecentFiles().createMenuItem(false)); ToolbarButton mruButton = new ToolbarButton(mruMenu, false); mruButton.setTitle("Open recent files"); addLeftWidget(mruButton); addLeftSeparator(); addLeftWidget(commands.saveSourceDoc().createToolbarButton()); addLeftWidget(commands.saveAllSourceDocs().createToolbarButton()); addLeftSeparator(); addLeftWidget(commands.printSourceDoc().createToolbarButton()); }
public GlobalToolbar(Commands commands, EventBus eventBus, Provider<CodeSearch> pCodeSearch) { super(); commands_ = commands; pCodeSearch_ = pCodeSearch; ThemeResources res = ThemeResources.INSTANCE; addStyleName(res.themeStyles().globalToolbar()); // add new source doc commands newMenu_ = new ToolbarPopupMenu(); newMenu_.addItem(commands.newSourceDoc().createMenuItem(false)); newMenu_.addSeparator(); newMenu_.addItem(commands.newRMarkdownDoc().createMenuItem(false)); newMenu_.addSeparator(); newMenu_.addItem(commands.newTextDoc().createMenuItem(false)); newMenu_.addItem(commands.newCppDoc().createMenuItem(false)); newMenu_.addSeparator(); newMenu_.addItem(commands.newSweaveDoc().createMenuItem(false)); newMenu_.addItem(commands.newRHTMLDoc().createMenuItem(false)); newMenu_.addItem(commands.newRPresentationDoc().createMenuItem(false)); newMenu_.addItem(commands.newRDocumentationDoc().createMenuItem(false)); // create and add new menu StandardIcons icons = StandardIcons.INSTANCE; ToolbarButton newButton = new ToolbarButton("", icons.stock_new(), newMenu_); addLeftWidget(newButton); addLeftSeparator(); // open button + mru addLeftWidget(commands.openSourceDoc().createToolbarButton()); ToolbarPopupMenu mruMenu = new ToolbarPopupMenu(); mruMenu.addItem(commands.mru0().createMenuItem(false)); mruMenu.addItem(commands.mru1().createMenuItem(false)); mruMenu.addItem(commands.mru2().createMenuItem(false)); mruMenu.addItem(commands.mru3().createMenuItem(false)); mruMenu.addItem(commands.mru4().createMenuItem(false)); mruMenu.addItem(commands.mru5().createMenuItem(false)); mruMenu.addItem(commands.mru6().createMenuItem(false)); mruMenu.addItem(commands.mru7().createMenuItem(false)); mruMenu.addItem(commands.mru8().createMenuItem(false)); mruMenu.addItem(commands.mru9().createMenuItem(false)); mruMenu.addSeparator(); mruMenu.addItem(commands.clearRecentFiles().createMenuItem(false)); ToolbarButton mruButton = new ToolbarButton(mruMenu, false); mruButton.setTitle("Open recent files"); addLeftWidget(mruButton); addLeftSeparator(); addLeftWidget(commands.saveSourceDoc().createToolbarButton()); addLeftWidget(commands.saveAllSourceDocs().createToolbarButton()); addLeftSeparator(); addLeftWidget(commands.printSourceDoc().createToolbarButton()); addLeftSeparator(); CodeSearch codeSearch = pCodeSearch_.get(); codeSearch.setObserver( new CodeSearch.Observer() { @Override public void onCancel() { codeSearchFocusContext_.restore(); } @Override public void onCompleted() { codeSearchFocusContext_.clear(); } @Override public String getCueText() { return null; } }); searchWidget_ = codeSearch.getSearchWidget(); addLeftWidget(searchWidget_); }