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 void completeInitialization(SessionInfo sessionInfo) { StandardIcons icons = StandardIcons.INSTANCE; if (sessionInfo.isVcsEnabled()) { addLeftSeparator(); ToolbarPopupMenu vcsMenu = new ToolbarPopupMenu(); vcsMenu.addItem(commands_.vcsFileDiff().createMenuItem(false)); vcsMenu.addItem(commands_.vcsFileLog().createMenuItem(false)); vcsMenu.addItem(commands_.vcsFileRevert().createMenuItem(false)); vcsMenu.addSeparator(); vcsMenu.addItem(commands_.vcsViewOnGitHub().createMenuItem(false)); vcsMenu.addItem(commands_.vcsBlameOnGitHub().createMenuItem(false)); vcsMenu.addSeparator(); vcsMenu.addItem(commands_.vcsCommit().createMenuItem(false)); vcsMenu.addSeparator(); vcsMenu.addItem(commands_.vcsPull().createMenuItem(false)); vcsMenu.addItem(commands_.vcsCleanup().createMenuItem(false)); vcsMenu.addItem(commands_.vcsPush().createMenuItem(false)); vcsMenu.addSeparator(); vcsMenu.addItem(commands_.vcsShowHistory().createMenuItem(false)); vcsMenu.addSeparator(); vcsMenu.addItem(commands_.versionControlProjectSetup().createMenuItem(false)); ImageResource vcsIcon = null; if (sessionInfo.getVcsName().equals(VCSConstants.GIT_ID)) vcsIcon = icons.git(); else if (sessionInfo.getVcsName().equals(VCSConstants.SVN_ID)) vcsIcon = icons.svn(); ToolbarButton vcsButton = new ToolbarButton(null, vcsIcon, vcsMenu); vcsButton.setTitle("Version control"); addLeftWidget(vcsButton); } if (sessionInfo.getShinyappsInstalled()) { addLeftSeparator(); ToolbarButton deployButton = commands_.shinyAppsDeploy().createToolbarButton(); deployButton.setText("Deploy"); addLeftWidget(deployButton); } // project popup menu ProjectPopupMenu projectMenu = new ProjectPopupMenu(sessionInfo, commands_); addRightWidget(projectMenu.getToolbarButton()); }
private Toolbar createToolbar() { Toolbar toolbar = new EditingTargetToolbar(commands_, true); toolbar.addLeftWidget(commands_.printSourceDoc().createToolbarButton()); toolbar.addLeftSeparator(); toolbar.addLeftWidget(findReplace_.createFindReplaceButton()); ImageResource icon = ThemeResources.INSTANCE.codeTransform(); ToolbarPopupMenu menu = new ToolbarPopupMenu(); menu.addItem(commands_.goToHelp().createMenuItem(false)); menu.addItem(commands_.goToFunctionDefinition().createMenuItem(false)); ToolbarButton codeTools = new ToolbarButton("", icon, menu); codeTools.setTitle("Code Tools"); toolbar.addLeftWidget(codeTools); toolbar.addRightWidget(commands_.executeCode().createToolbarButton()); toolbar.addRightSeparator(); toolbar.addRightWidget(commands_.executeLastCode().createToolbarButton()); return toolbar; }
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_); }