use of com.google.gwt.dom.client.Style in project rstudio by rstudio.
the class ModalDialogBase method addProgressIndicator.
protected ProgressIndicator addProgressIndicator(final boolean closeOnCompleted) {
final SlideLabel label = new SlideLabel(true);
Element labelEl = label.getElement();
Style labelStyle = labelEl.getStyle();
labelStyle.setPosition(Style.Position.ABSOLUTE);
labelStyle.setLeft(0, Style.Unit.PX);
labelStyle.setRight(0, Style.Unit.PX);
labelStyle.setTop(-12, Style.Unit.PX);
mainPanel_.add(label);
return new ProgressIndicator() {
public void onProgress(String message) {
onProgress(message, null);
}
public void onProgress(String message, Operation onCancel) {
if (message == null) {
label.setText("", true);
if (showing_)
clearProgress();
} else {
label.setText(message, false);
if (!showing_) {
enableControls(false);
label.show();
showing_ = true;
}
}
label.onCancel(onCancel);
}
public void onCompleted() {
clearProgress();
if (closeOnCompleted)
closeDialog();
}
public void onError(String message) {
clearProgress();
RStudioGinjector.INSTANCE.getGlobalDisplay().showErrorMessage("Error", message);
}
@Override
public void clearProgress() {
if (showing_) {
enableControls(true);
label.hide();
showing_ = false;
}
}
private boolean showing_;
};
}
use of com.google.gwt.dom.client.Style in project rstudio by rstudio.
the class WebApplicationHeader method createCommandSeparator.
private Widget createCommandSeparator() {
ToolbarSeparator sep = new ToolbarSeparator();
Style style = sep.getElement().getStyle();
style.setMarginTop(2, Unit.PX);
style.setMarginLeft(3, Unit.PX);
return sep;
}
use of com.google.gwt.dom.client.Style in project rstudio by rstudio.
the class WebApplicationHeader method initialize.
@Inject
public void initialize(final Commands commands, EventBus eventBus, GlobalDisplay globalDisplay, ThemeResources themeResources, final Session session, Provider<CodeSearch> pCodeSearch) {
commands_ = commands;
eventBus_ = eventBus;
globalDisplay_ = globalDisplay;
overlay_ = new WebApplicationHeaderOverlay();
// Use the outer panel to just aggregate the menu bar/account area,
// with the logo. The logo can't be inside the HorizontalPanel because
// it needs to overflow out of the top of the panel, and it was much
// easier to do this with absolute positioning.
outerPanel_ = new FlowPanel();
outerPanel_.getElement().getStyle().setPosition(Position.RELATIVE);
// large logo
logoLarge_ = new Image(new ImageResource2x(ThemeResources.INSTANCE.rstudio2x()));
((ImageElement) logoLarge_.getElement().cast()).setAlt("RStudio");
logoLarge_.getElement().getStyle().setBorderWidth(0, Unit.PX);
// small logo
logoSmall_ = new Image(new ImageResource2x(ThemeResources.INSTANCE.rstudio_small2x()));
((ImageElement) logoSmall_.getElement().cast()).setAlt("RStudio");
logoSmall_.getElement().getStyle().setBorderWidth(0, Unit.PX);
// link target for logo
logoAnchor_ = new Anchor();
Style style = logoAnchor_.getElement().getStyle();
style.setPosition(Position.ABSOLUTE);
style.setTop(5, Unit.PX);
style.setLeft(18, Unit.PX);
style.setTextDecoration(TextDecoration.NONE);
style.setOutlineWidth(0, Unit.PX);
// header container
headerBarPanel_ = new HorizontalPanel();
headerBarPanel_.setStylePrimaryName(themeResources.themeStyles().header());
headerBarPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
headerBarPanel_.setWidth("100%");
if (BrowseCap.INSTANCE.suppressBrowserForwardBack())
suppressBrowserForwardBack();
// override Cmd+W keybaord shortcut for Chrome
if (BrowseCap.isChrome()) {
int modifiers = (BrowseCap.hasMetaKey() ? KeyboardShortcut.META : KeyboardShortcut.CTRL) | KeyboardShortcut.ALT;
AppCommand closeSourceDoc = commands.closeSourceDoc();
closeSourceDoc.setShortcut(new KeyboardShortcut(modifiers, 'W'));
ShortcutManager.INSTANCE.register(modifiers, 'W', closeSourceDoc, "", "", "");
}
// main menu
advertiseEditingShortcuts(globalDisplay, commands);
WebMenuCallback menuCallback = new WebMenuCallback();
commands.mainMenu(menuCallback);
mainMenu_ = menuCallback.getMenu();
mainMenu_.setAutoHideRedundantSeparators(false);
fixup(mainMenu_);
mainMenu_.addStyleName(themeResources.themeStyles().mainMenu());
AppMenuBar.addSubMenuVisibleChangedHandler(new SubMenuVisibleChangedHandler() {
public void onSubMenuVisibleChanged(SubMenuVisibleChangedEvent event) {
// so that mouse clicks can make the menus disappear
if (event.isVisible())
eventBus_.fireEvent(new GlassVisibilityEvent(true));
else
eventBus_.fireEvent(new GlassVisibilityEvent(false));
}
});
headerBarPanel_.add(mainMenu_);
// commands panel (no widgets added until after session init)
headerBarCommandsPanel_ = new HorizontalPanel();
headerBarCommandsPanel_.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
headerBarCommandsPanel_.setWidth("100%");
headerBarPanel_.add(headerBarCommandsPanel_);
headerBarPanel_.setCellWidth(headerBarCommandsPanel_, "100%");
headerBarPanel_.setCellHorizontalAlignment(headerBarCommandsPanel_, HorizontalPanel.ALIGN_RIGHT);
eventBus.addHandler(SessionInitEvent.TYPE, new SessionInitHandler() {
public void onSessionInit(SessionInitEvent sie) {
SessionInfo sessionInfo = session.getSessionInfo();
// complete toolbar initialization
toolbar_.completeInitialization(sessionInfo);
// add project tools to main menu
projectMenuSeparator_ = createCommandSeparator();
headerBarPanel_.add(projectMenuSeparator_);
projectMenuButton_ = new ProjectPopupMenu(sessionInfo, commands).getToolbarButton();
projectMenuButton_.addStyleName(ThemeStyles.INSTANCE.webHeaderBarCommandsProjectMenu());
headerBarPanel_.add(projectMenuButton_);
showProjectMenu(!toolbar_.isVisible());
// record logo target url (if any)
logoTargetUrl_ = sessionInfo.getUserHomePageUrl();
if (logoTargetUrl_ != null) {
logoAnchor_.setHref(logoTargetUrl_);
logoAnchor_.setTitle("RStudio Server Home");
logoLarge_.setResource(new ImageResource2x(ThemeResources.INSTANCE.rstudio_home2x()));
logoSmall_.setResource(new ImageResource2x(ThemeResources.INSTANCE.rstudio_home_small2x()));
} else {
// no link, so ensure this doesn't get styled as clickable
logoAnchor_.getElement().getStyle().setCursor(Cursor.DEFAULT);
}
// init commands panel in server mode
if (!Desktop.isDesktop())
initCommandsPanel(sessionInfo);
// notify overlay of global toolbar state
overlay_.setGlobalToolbarVisible(WebApplicationHeader.this, toolbar_.isVisible());
}
});
// create toolbar
toolbar_ = new GlobalToolbar(commands, eventBus, pCodeSearch);
toolbar_.addStyleName(themeResources.themeStyles().webGlobalToolbar());
// create host for project commands
projectBarCommandsPanel_ = new HorizontalPanel();
toolbar_.addRightWidget(projectBarCommandsPanel_);
// initialize widget
initWidget(outerPanel_);
}
use of com.google.gwt.dom.client.Style in project rstudio by rstudio.
the class DocumentOutlineWidget method updateStyles.
private void updateStyles(Widget widget, Style computed) {
Style outlineStyles = widget.getElement().getStyle();
outlineStyles.setBackgroundColor(computed.getBackgroundColor());
outlineStyles.setColor(computed.getColor());
}
use of com.google.gwt.dom.client.Style in project rstudio by rstudio.
the class ChunkOutputStream method showHtmlOutput.
@Override
public void showHtmlOutput(String url, NotebookHtmlMetadata metadata, int ordinal, final Command onRenderComplete) {
// flush any queued errors
initializeOutput(RmdChunkOutputUnit.TYPE_HTML);
flushQueuedErrors();
// persist metadata
metadata_.put(ordinal, metadata);
final boolean knitrFigure = metadata.getSizingPolicyKnitrFigure();
// sizing policy
if (url.indexOf('?') > 0)
url += "&";
else
url += "?";
if (knitrFigure) {
url += "viewer_pane=1";
}
final ChunkOutputFrame frame = new ChunkOutputFrame();
if (chunkOutputSize_ == ChunkOutputSize.Default) {
if (knitrFigure) {
final FixedRatioWidget fixedFrame = new FixedRatioWidget(frame, ChunkOutputUi.OUTPUT_ASPECT, ChunkOutputUi.MAX_HTMLWIDGET_WIDTH);
addWithOrdinal(fixedFrame, ordinal);
} else {
// reduce size of html widget as much as possible and add scroll,
// once it loads, we will adjust the height appropriately.
frame.getElement().getStyle().setHeight(25, Unit.PX);
frame.getElement().getStyle().setOverflow(Overflow.SCROLL);
frame.getElement().getStyle().setWidth(100, Unit.PCT);
addWithOrdinal(frame, ordinal);
}
} else if (chunkOutputSize_ == ChunkOutputSize.Full) {
frame.getElement().getStyle().setPosition(Position.ABSOLUTE);
frame.getElement().getStyle().setWidth(100, Unit.PCT);
frame.getElement().getStyle().setHeight(100, Unit.PCT);
addWithOrdinal(frame, ordinal);
}
Element body = frame.getDocument().getBody();
Style bodyStyle = body.getStyle();
bodyStyle.setPadding(0, Unit.PX);
bodyStyle.setMargin(0, Unit.PX);
frame.loadUrlDelayed(url, 250, new Command() {
@Override
public void execute() {
onRenderComplete.execute();
if (!knitrFigure) {
int contentHeight = frame.getWindow().getDocument().getBody().getOffsetHeight();
frame.getElement().getStyle().setHeight(contentHeight, Unit.PX);
frame.getElement().getStyle().setOverflow(Overflow.HIDDEN);
frame.getWindow().getDocument().getBody().getStyle().setOverflow(Overflow.HIDDEN);
}
onHeightChanged();
}
;
});
themeColors_ = ChunkOutputWidget.getEditorColors();
afterRender_ = new Command() {
@Override
public void execute() {
if (themeColors_ != null) {
Element body = frame.getDocument().getBody();
Style bodyStyle = body.getStyle();
bodyStyle.setColor(themeColors_.foreground);
}
}
};
frame.runAfterRender(afterRender_);
}
Aggregations