Search in sources :

Example 1 with ShortcutInfo

use of org.rstudio.core.client.command.ShortcutInfo in project rstudio by rstudio.

the class ShortcutInfoPanel method getShortcutContent.

protected Widget getShortcutContent() {
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    List<ShortcutInfo> shortcuts = ShortcutManager.INSTANCE.getActiveShortcutInfo();
    String[][] groupNames = { new String[] { "Tabs", "Panes", "Files" }, new String[] { "Source Navigation", "Execute" }, new String[] { "Source Editor", "Debug" }, new String[] { "Source Control", "Build", "Console", "Terminal", "Other" } };
    int pctWidth = 100 / groupNames.length;
    sb.appendHtmlConstant("<table width='100%'><tr>");
    for (String[] colGroupNames : groupNames) {
        sb.appendHtmlConstant("<td width='" + pctWidth + "%'>");
        for (String colGroupName : colGroupNames) {
            sb.appendHtmlConstant("<h2>");
            sb.appendEscaped(colGroupName);
            sb.appendHtmlConstant("</h2><table>");
            for (int i = 0; i < shortcuts.size(); i++) {
                ShortcutInfo info = shortcuts.get(i);
                if (info.getDescription() == null || info.getShortcuts().size() == 0 || !info.getGroupName().equals(colGroupName)) {
                    continue;
                }
                sb.appendHtmlConstant("<tr><td><strong>");
                sb.appendHtmlConstant(StringUtil.joinStrings(info.getShortcuts(), ", "));
                sb.appendHtmlConstant("</strong></td><td>");
                sb.appendEscaped(info.getDescription());
                sb.appendHtmlConstant("</td></tr>");
            }
            sb.appendHtmlConstant("</table>");
            if (colGroupName == "Panes") {
                sb.appendHtmlConstant("<p>Add Shift to zoom (maximize) pane.</p>");
            }
        }
        sb.appendHtmlConstant("</td>");
    }
    sb.appendHtmlConstant("</td></tr></table>");
    HTMLPanel panel = new HTMLPanel(sb.toSafeHtml());
    return panel;
}
Also used : ShortcutInfo(org.rstudio.core.client.command.ShortcutInfo) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HTMLPanel(com.google.gwt.user.client.ui.HTMLPanel)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 HTMLPanel (com.google.gwt.user.client.ui.HTMLPanel)1 ShortcutInfo (org.rstudio.core.client.command.ShortcutInfo)1