use of org.rstudio.core.client.widget.CanFocus in project rstudio by rstudio.
the class FocusTransitionManager method register.
private void register(final Widget widget) {
if (registration_.contains(widget))
return;
registration_.add(widget);
widget.addDomHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
boolean forward = !event.isShiftKeyDown();
Widget target = get(widget, forward);
if (target == null)
return;
if (target instanceof CanFocus) {
event.stopPropagation();
event.preventDefault();
focus((CanFocus) target);
} else if (target instanceof Focusable) {
event.stopPropagation();
event.preventDefault();
focus((Focusable) target);
}
}
}
}, KeyDownEvent.getType());
}
use of org.rstudio.core.client.widget.CanFocus in project rstudio by rstudio.
the class RmdOutputPanel method initToolbar.
@Override
protected void initToolbar(Toolbar toolbar, Commands commands) {
slideNavigationMenu_ = new SlideNavigationToolbarMenu(toolbar, 400, 100, true);
fileLabel_ = new ToolbarLabel();
fileLabel_.addStyleName(ThemeStyles.INSTANCE.subtitle());
fileLabel_.getElement().getStyle().setMarginRight(7, Unit.PX);
toolbar.addLeftWidget(fileLabel_);
fileLabelSeparator_ = toolbar.addLeftSeparator();
ToolbarButton popoutButton = commands.viewerPopout().createToolbarButton();
popoutButton.setText("Open in Browser");
toolbar.addLeftWidget(popoutButton);
findTextBox_ = new FindTextBox("Find");
findTextBox_.setIconVisible(true);
findTextBox_.setOverrideWidth(120);
findTextBox_.getElement().getStyle().setMarginRight(6, Unit.PX);
findSeparator_ = toolbar.addLeftSeparator();
toolbar.addLeftWidget(findTextBox_);
findTextBox_.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// enter key triggers a find
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
findInTopic(findTextBox_.getValue().trim(), findTextBox_);
findTextBox_.focus();
} else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
findTextBox_.setValue("");
}
}
private void findInTopic(String term, CanFocus findInputSource) {
// get content window
WindowEx contentWindow = getFrame().getWindow();
if (contentWindow == null)
return;
if (!contentWindow.find(term, false, false, true, false)) {
RStudioGinjector.INSTANCE.getGlobalDisplay().showMessage(MessageDialog.INFO, "Find in Page", "No occurences found", findInputSource);
}
}
});
toolbar.addLeftSeparator();
publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_DOCUMENT, true, null);
toolbar.addRightWidget(publishButton_);
toolbar.addRightSeparator();
toolbar.addRightWidget(commands.viewerRefresh().createToolbarButton());
}
use of org.rstudio.core.client.widget.CanFocus in project rstudio by rstudio.
the class HTMLPreviewPanel method createToolbar.
private Toolbar createToolbar(Commands commands) {
Toolbar toolbar = new Toolbar();
toolbar.addLeftWidget(new ToolbarLabel("Preview: "));
fileLabel_ = new ToolbarLabel();
fileLabel_.addStyleName(ThemeStyles.INSTANCE.subtitle());
fileLabel_.getElement().getStyle().setMarginRight(7, Unit.PX);
toolbar.addLeftWidget(fileLabel_);
toolbar.addLeftSeparator();
toolbar.addLeftWidget(commands.openHtmlExternal().createToolbarButton());
showLogButtonSeparator_ = toolbar.addLeftSeparator();
showLogButton_ = commands.showHtmlPreviewLog().createToolbarButton();
toolbar.addLeftWidget(showLogButton_);
saveHtmlPreviewAsSeparator_ = toolbar.addLeftSeparator();
if (Desktop.isDesktop()) {
saveHtmlPreviewAs_ = commands.saveHtmlPreviewAs().createToolbarButton();
toolbar.addLeftWidget(saveHtmlPreviewAs_);
} else {
ToolbarPopupMenu menu = new ToolbarPopupMenu();
menu.addItem(commands.saveHtmlPreviewAs().createMenuItem(false));
menu.addItem(commands.saveHtmlPreviewAsLocalFile().createMenuItem(false));
saveHtmlPreviewAs_ = toolbar.addLeftWidget(new ToolbarButton("Save As", commands.saveSourceDoc().getImageResource(), menu));
}
publishButtonSeparator_ = toolbar.addLeftSeparator();
toolbar.addLeftWidget(publishButton_ = new RSConnectPublishButton(RSConnect.CONTENT_TYPE_DOCUMENT, true, null));
findTextBox_ = new FindTextBox("Find");
findTextBox_.setIconVisible(true);
findTextBox_.setOverrideWidth(120);
findTextBox_.getElement().getStyle().setMarginRight(6, Unit.PX);
toolbar.addRightWidget(findTextBox_);
findTextBox_.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// enter key triggers a find
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
event.preventDefault();
event.stopPropagation();
findInTopic(findTextBox_.getValue().trim(), findTextBox_);
findTextBox_.focus();
} else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
findTextBox_.setValue("");
}
}
private void findInTopic(String term, CanFocus findInputSource) {
// get content window
WindowEx contentWindow = previewFrame_.getWindow();
if (contentWindow == null)
return;
if (!contentWindow.find(term, false, false, true, false)) {
RStudioGinjector.INSTANCE.getGlobalDisplay().showMessage(MessageDialog.INFO, "Find in Page", "No occurences found", findInputSource);
}
}
});
refreshButtonSeparator_ = toolbar.addRightSeparator();
refreshButton_ = toolbar.addRightWidget(commands.refreshHtmlPreview().createToolbarButton());
return toolbar;
}
Aggregations