com.google.gwt.dom.client.StyleInjector Java Examples
The following examples show how to use
com.google.gwt.dom.client.StyleInjector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Tooltip.java From jetpad-projectional-open-source with Apache License 2.0 | 6 votes |
private static Registration injectCornerStyle(String id, Cell cell) { Color borderColor = cell.get(Cell.BORDER_COLOR); String border = borderColor == null ? "none" : "1px solid " + borderColor.toCssColor(); Color backgroundColor = cell.get(Cell.BACKGROUND); String background = backgroundColor == null ? Color.WHITE.toCssColor() : backgroundColor.toCssColor(); final StyleElement styleElement = StyleInjector.injectStylesheet("." + id + "::before { border-top: " + border + "; border-left: " + border + "; " + "background: linear-gradient(135deg, " + background + " 0%, " + background + " 70%, rgba(0,0,0,0) 71%, rgba(0,0,0,0) 100%) }"); StyleInjector.flush(); return new Registration() { @Override protected void doRemove() { styleElement.removeFromParent(); } }; }
Example #2
Source File: BasicToolBar.java From geowe-core with GNU General Public License v3.0 | 6 votes |
private void initializew3wPanel() { w3wPanel = new HorizontalPanel(); w3wPanel.setSpacing(5); w3wPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); StyleInjector.inject(".w3wPanel { " + "background: #E0ECF8;" + "border-radius: 5px 10px;" + "opacity: 0.8}"); w3wPanel.setStyleName("w3wPanel"); w3wPanel.setWidth("415px"); wordsLabel = new Label(); w3wAnchor = new AnchorBuilder().setHref("https://what3words.com/") .setText(UIMessages.INSTANCE.what3Words()) .setTitle("https://what3words.com/").build(); w3wAnchor.getElement().getStyle().setColor("#FF0000"); w3wAnchor.setVisible(false); w3wPanel.add(w3wAnchor); w3wPanel.add(wordsLabel); }
Example #3
Source File: FullCalendarEntryPoint.java From gwtbootstrap3-extras with Apache License 2.0 | 6 votes |
@Override public void onModuleLoad() { StyleInjector.injectAtEnd(FullCalendarClientBundle.INSTANCE.fullCalendarCss().getText()); StyleInjector.injectAtEnd("@media print {" + FullCalendarClientBundle.INSTANCE.fullCalendarPrintCss().getText() + "}"); if (!isMomentPresent()) { ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getMomentJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } if (!isCalendarPresent()) { ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getFullCalendarJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } if (!isDragAndResizePresent()) { ScriptInjector.fromString(FullCalendarClientBundle.INSTANCE.getCustomDragResizeJS().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); } }
Example #4
Source File: StatusPanelWidget.java From geowe-core with GNU General Public License v3.0 | 6 votes |
private void initializeStatusPanel() { String comboWidth = "125px"; statusPanel = new VerticalPanel(); StyleInjector.inject(".statusPanelStyle { " + "background: #E0ECF8;" + "border-radius: 5px 10px;" + "opacity: 0.8}"); statusPanel.setStyleName("statusPanelStyle"); statusPanel.setSpacing(5); statusPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); initializeLayerCombo(comboWidth); initializeEpsgCombo(comboWidth); initializeStatusGrid(); statusPanel.add(new FieldLabel(layerCombo, UIMessages.INSTANCE .sbSelectLayerLabel())); statusPanel.add(new FieldLabel(epsgCombo, UIMessages.INSTANCE .sbEpsgLabel())); statusPanel.add(statusGrid); statusPanel.setVisible(false); }
Example #5
Source File: SelectorSliderDisplayerView.java From dashbuilder with Apache License 2.0 | 6 votes |
@Override public void init(SelectorSliderDisplayer presenter) { super.setPresenter(presenter); super.setVisualization(container); // Enlarge the tooltip max width StyleInjector.inject(".slider .tooltip-inner { max-width: 900px; }"); header.setVisible(false); slider.setHandle(HandleType.ROUND); slider.setFormatter(r -> presenter.formatRange(r.getMinValue(), r.getMaxValue())); slider.addSlideStopHandler(e -> presenter.onSliderChange(e.getValue().getMinValue(), e.getValue().getMaxValue())); slider.getElement().getStyle().setWidth(100, Style.Unit.PCT); inputs.getElement().getStyle().setWidth(100, Style.Unit.PCT); body.add(slider); body.getElement().getStyle().setMarginLeft(10, Style.Unit.PX); container.add(header); container.add(body); container.add(inputs); container.add(error); }
Example #6
Source File: DarkThemeLoader.java From gwt-material with Apache License 2.0 | 5 votes |
public void load() { if (injectResource) { if (children != null) { for (DarkThemeLoader child : children) { if (child != null) { child.load(); } } } else { if (styleElement == null) { styleElement = StyleInjector.injectStylesheet(resource.getText()); } } } }
Example #7
Source File: CellContainerToDomMapper.java From jetpad-projectional-open-source with Apache License 2.0 | 5 votes |
private static void ensureIndentInjected() { if (ourIndentInjected) return; StyleInjector.flush(); double width = TextMetricsCalculator.calculate(TextCell.DEFAULT_FONT, "xx").dimension().x; StyleInjector.inject("." + CSS.indented() + "{ padding-left: " + width + "px }", true); ourIndentInjected = true; }
Example #8
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 5 votes |
private void showResolutionBlocksOnView() { double positionLeftSnapshot = positionLeft; double datePos = positionLeftSnapshot; firstWeekBlockHidden = false; int left = (int) positionLeftSnapshot; if (positionLeftSnapshot > 0 && resBlockWidthPx > 0) { double overflow = 0.0; boolean firstResBlockShort = isFirstResBlockShort(); overflow = getScrollOverflowForResolutionBlock(positionLeftSnapshot, left, firstResBlockShort); left = (int) (positionLeftSnapshot - overflow); datePos = adjustLeftPositionForDateDetection(left); } if (datePos < 0.0) { datePos = positionLeftSnapshot; } long leftDate; boolean noticeDst = resolution == Resolution.Hour; leftDate = getDateForLeftPosition(datePos, noticeDst); double containerWidth = GanttUtil.getBoundingClientRectWidth(getElement().getParentElement()); fillTimelineForResolution(leftDate, Math.min(endDate, getDateForLeftPosition(datePos + containerWidth, noticeDst)), left); if (styleElementForLeft != null) { StyleInjector.setContents(styleElementForLeft, "." + STYLE_COL + " { position: relative; left: " + left + "px; }"); } GWT.log(getClass().getSimpleName() + " Updated visible timeline elements for horizontal scroll position " + left); }
Example #9
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 5 votes |
private void injectLeftStyle() { if (ie || styleElementForLeft != null) { return; } styleElementForLeft = StyleInjector.injectStylesheetAtEnd("." + STYLE_COL + " { } "); StyleInjector.flush(); }
Example #10
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 5 votes |
/** * Injects custom stylesheet just for this widget. It helps to update styles * for a big group of elements in the DOM, like resolution blocks. * <p> * Warning, this feature is not working with Internet Explorer reliably * enough. Read more at {@link StyleInjector#injectStylesheetAtEnd(String)}. * This method has no effect when {@link #ie} is set to true. */ private void injectStyle() { if (ie || styleElement != null) { return; } styleElement = StyleInjector.injectStylesheetAtEnd( "." + STYLE_FIRST + " { } ." + STYLE_CENTER + " { } ." + STYLE_LAST + " { } ." + STYLE_COL + " { } "); StyleInjector.flush(); }
Example #11
Source File: LinksWidget.java From geowe-core with GNU General Public License v3.0 | 5 votes |
@Override public Widget asWidget() { if (widget == null) { //String width="320px"; String width="370px"; String height="50px"; widget = new HorizontalLayoutContainer(); widget.getElement().getStyle().setPosition(Position.ABSOLUTE); widget.getElement().getStyle().setRight(5, Unit.PX); widget.getElement().getStyle().setTop(0, Unit.PX); widget.setSize(width, height); hp = new HorizontalPanel(); hp.setSpacing(10); StyleInjector.inject(".linkPanel { " + "background: #FFFFFF;" + "border-radius: 5px 10px;" + "opacity: 0.8}"); hp.setStyleName("linkPanel"); hp.setSize(width, height); ScrollSupport scrollSupport = widget.getScrollSupport(); scrollSupport.setScrollMode(ScrollMode.AUTOX); setDefaultLinks(); widget.add(hp); } return widget; }
Example #12
Source File: VerticalLegend.java From geowe-core with GNU General Public License v3.0 | 5 votes |
private void createContentPanel() { this.contentPanel = new VerticalPanel(); StyleInjector.inject(".mapLegendPanel { " + "background: #FFFFFF;" + "border-radius: 5px 10px;" + "opacity: 0.8}"); contentPanel.setStyleName("mapLegendPanel"); contentPanel.setSize(WIDTH, HEIGHT); contentPanel.add(getHeader()); setData(getData()); }
Example #13
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 4 votes |
/** * <p> * Updates the content of this widget. Builds the time-line and calculates * width and heights for the content (calls in the end * {@link #updateWidths()}). This should be called explicitly. Otherwise the * widget will be empty. * <p> * Date values should always follow specification in {@link Date#getTime()}. * Start and end date is always required. * * @param resolution * Resolution enum (not null) * @param startDate * Time-line's start date in milliseconds. (not null) * @param endDate * Time-line's end date in milliseconds. (not null) * @param firstDayOfRange * First day of the whole range. Allowed values are 1-7. 1 is * Sunday. Required with {@link Resolution#Week}. * @param firstHourOfRange * First hour of the range. Allowed values are 0-23. Required * with {@link Resolution#Hour}. * @param localeDataProvider * Data provider for locale specific data. month names, first day * of week etc. * */ public void update(Resolution resolution, long startDate, long endDate, int firstDayOfRange, int firstHourOfRange, LocaleDataProvider localeDataProvider) { if (localeDataProvider == null) { GWT.log(getClass().getSimpleName() + " requires LocaleDataProvider. Can't complete update(...) operation."); return; } if (isChanged(resolution, startDate, endDate, localeDataProvider.getFirstDayOfWeek(), firstDayOfRange, firstHourOfRange, localeDataProvider.getLocale())) { clear(); GWT.log(getClass().getSimpleName() + " content cleared."); } else { return; } GWT.log(getClass().getSimpleName() + " Updating content."); injectStyle(); injectLeftStyle(); if (styleElementForLeft != null) { StyleInjector.setContents(styleElementForLeft, "." + STYLE_COL + " { position: relative; left: 0px; }"); } this.localeDataProvider = localeDataProvider; locale = localeDataProvider.getLocale(); this.resolution = resolution; this.startDate = startDate; this.endDate = endDate; normalStartDate = toNormalDate(startDate); normalEndDate = toNormalDate(endDate); // Required with Resolution.Week. firstDayOfWeek = localeDataProvider.getFirstDayOfWeek(); lastDayOfWeek = (firstDayOfWeek == 1) ? 7 : Math.max((firstDayOfWeek - 1) % 8, 1); this.firstDayOfRange = firstDayOfRange; this.firstHourOfRange = firstHourOfRange; monthNames = localeDataProvider.getMonthNames(); weekdayNames = localeDataProvider.getWeekdayNames(); resolutionDiv = DivElement.as(DOM.createDiv()); resolutionDiv.setClassName(STYLE_ROW + " " + STYLE_RESOLUTION); if (minResolutionWidth < 0) { minResolutionWidth = calculateResolutionMinWidth(); } if (resolution == Resolution.Day || resolution == Resolution.Week) { prepareTimelineForDayResolution(startDate, endDate); } else if (resolution == Resolution.Hour) { prepareTimelineForHourResolution(startDate, endDate); } else { GWT.log(getClass().getSimpleName() + " resolution " + (resolution != null ? resolution.name() : "null") + " is not supported"); return; } if (isYearRowVisible()) { appendTimelineBlocks(yearRowData, STYLE_YEAR); } if (isMonthRowVisible()) { appendTimelineBlocks(monthRowData, STYLE_MONTH); } if (isDayRowVisible()) { appendTimelineBlocks(dayRowData, STYLE_DAY); } getElement().appendChild(resolutionDiv); GWT.log(getClass().getSimpleName() + " Constructed content."); updateWidths(); GWT.log(getClass().getSimpleName() + " is updated for resolution " + resolution.name() + "."); }
Example #14
Source File: HighlighterInjector.java From lumongo with Apache License 2.0 | 4 votes |
public static void inject() { ScriptInjector.fromString(HighlightBundle.INSTANCE.highlight().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject(); StyleInjector.injectStylesheetAtStart(HighlightBundle.INSTANCE.style().getText()); GWT.log("Injected highlighter."); }
Example #15
Source File: GeocodingPanelWidget.java From geowe-core with GNU General Public License v3.0 | 4 votes |
@Override public Widget asWidget() { if (panel == null) { panel = new ContentPanel(); panel.setBorders(true); panel.setPixelSize(490, 47); panel.setHeaderVisible(false); panel.setPosition(300, 0); panel.getElement().getStyle().setPosition(Position.ABSOLUTE); StyleInjector.inject(".statusBarStyle { " + "position: absolute; " + "bottom: 35 px;" + "background: #E0ECF8;" + "border-radius: 5px 10px;" + "opacity: 0.8}"); panel.setStyleName("geocodingPanelStyle"); final HorizontalPanel horizontalGroup = new HorizontalPanel(); horizontalGroup.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE); horizontalGroup.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalGroup.setSpacing(5); horizontalGroup.getElement().getStyle().setBackgroundColor("#E0ECF8"); addressTextField.setWidth("320px"); addressTextField.setEmptyText(UIMessages.INSTANCE.gcAddressTextField()); addressTextField.getElement().setId("autocompletar"); addressTextField.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(final KeyDownEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { searchGeocoding(addressTextField.getText()); } } }); horizontalGroup.add(addressTextField); horizontalGroup.add(getSearchButton()); horizontalGroup.add(getW3WLocationButton()); horizontalGroup.add(getLocationMenuButton()); panel.setWidget(horizontalGroup); panel.setVisible(false); } return panel; }
Example #16
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 4 votes |
private void updateResolutionBlockWidths(String pct) { if (styleElement == null) { if (!isTimelineOverflowingHorizontally()) { resolutionDiv.getStyle().setProperty("display", "flex"); } else { resolutionDiv.getStyle().clearProperty("display"); } boolean firstResBlockIsShort = isFirstResBlockShort(); boolean lastResBlockIsShort = isLastResBlockShort(); // styleElement is not set, set width for each block explicitly. int count = resolutionDiv.getChildCount(); if (containsResBlockSpacer()) { count--; } int lastIndex = count - 1; int i; Element resBlock; for (i = 0; i < count; i++) { resBlock = Element.as(resolutionDiv.getChild(i)); // first and last week blocks may be thinner than other // resolution blocks. if (firstResBlockIsShort && i == 0) { setWidth(resBlock, firstResBlockCount); } else if (lastResBlockIsShort && i == lastIndex) { setWidth(resBlock, lastResBlockCount); } else { setWidth(resBlockWidthPx, pct, resBlock); } } } else { // set widths by updating injected styles in one place. Faster than // setting widths explicitly for each element. String center = getWidthStyleValue(pct); String first = center; String last = center; if (isFirstResBlockShort()) { first = getWidth(firstResBlockCount); } if (isLastResBlockShort()) { last = getWidth(lastResBlockCount); } StyleInjector.setContents(styleElement, "." + STYLE_CENTER + " { width: " + center + "; } ." + STYLE_FIRST + " { width: " + first + "; } ." + STYLE_LAST + " { width: " + last + "; } "); } }
Example #17
Source File: TimelineWidget.java From gantt with Apache License 2.0 | 4 votes |
private void showAllResolutionBlocks() { if (styleElementForLeft != null) { StyleInjector.setContents(styleElementForLeft, "." + STYLE_COL + " { position: relative; left: 0px; }"); } fillTimelineForResolution(startDate, endDate, 0); }
Example #18
Source File: Animate.java From gwtbootstrap3-extras with Apache License 2.0 | 4 votes |
/** * Styles element with animation class. New class name is generated to customize count, duration and delay. * Style is removed on animation end (if not set to infinite). * * @param element Element to apply animation to. * @param animation Type of animation to apply. * @param count Number of animation repeats. 0 disables animation, any negative value set repeats to infinite. * @param duration Animation duration in ms. 0 disables animation, any negative value keeps default of original animation. * @param delay Delay before starting the animation loop in ms. Value <= 0 means no delay. * @param <T> Any object extending UIObject class (typically Widget). * @return Animation's CSS class name, which can be removed to stop animation. */ private static <T extends UIObject> String styleElement(Element element, String animation, int count, int duration, int delay) { if (!usedStyles.contains(animation + " " + getStyleNameFromAnimation(animation,count,duration,delay))) { String styleSheet = "." + getStyleNameFromAnimation(animation, count, duration, delay) + " {"; // 1 is default, 0 disable animation, any negative -> infinite loop if (count >= 0) { styleSheet += "-webkit-animation-iteration-count: " + count + ";" + "-moz-animation-iteration-count:" + count + ";" + "-ms-animation-iteration-count:" + count + ";" + "-o-animation-iteration-count:" + count + ";" + "animation-iteration-count:" + count + ";"; } else { styleSheet += "-webkit-animation-iteration-count: infinite;" + "-moz-animation-iteration-count: infinite;" + "-ms-animation-iteration-count: infinite;" + "-o-animation-iteration-count: infinite;" + "animation-iteration-count: infinite;"; } // if not default (any negative -> use default) if (duration >= 0) { styleSheet += "-webkit-animation-duration: " + duration + "ms;" + "-moz-animation-duration:" + duration + "ms;" + "-ms-animation-duration:" + duration + "ms;" + "-o-animation-duration:" + duration + "ms;" + "animation-duration:" + duration + "ms;"; } // if not default (any negative -> use default) if (delay >= 0) { styleSheet += "-webkit-animation-delay: " + delay + "ms;" + "-moz-animation-delay:" + delay + "ms;" + "-ms-animation-delay:" + delay + "ms;" + "-o-animation-delay:" + delay + "ms;" + "animation-delay:" + delay + "ms;"; } styleSheet += "}"; // inject new style StyleInjector.injectAtEnd(styleSheet, true); usedStyles.add(animation + " " + getStyleNameFromAnimation(animation, count, duration, delay)); } // start animation element.addClassName(animation + " " + getStyleNameFromAnimation(animation,count,duration,delay)); // remove animation on end so we could start it again // removeAnimationOnEnd(element, animation + " anim-"+count+"-"+duration+"-"+delay); return animation + " " + getStyleNameFromAnimation(animation,count,duration,delay); }
Example #19
Source File: Game.java From shortyz with GNU General Public License v3.0 | 4 votes |
@Inject public Game(RootPanel rootPanel, PuzzleServiceProxy service, Resources resources, final PuzzleListView plv, Renderer renderer) { this.service = service; this.plv = plv; this.renderer = renderer; this.css = resources.css(); History.newItem("list", false); History.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { if (event.getValue().equals("list")) { if (closingRegistration != null) { closingRegistration.removeHandler(); closingRegistration = null; } if (autoSaveTimer != null) { autoSaveTimer.cancel(); autoSaveTimer.run(); autoSaveTimer = null; } mainPanel.setWidget(plv); keyboardIntercept.removeKeyboardListener(l); getDisplayChangeListener().onDisplayChange(); } else if (event.getValue().startsWith("play=")) { Long id = Long.parseLong(event.getValue().split("=")[1]); loadPuzzle(id); } } }); verticalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.setWidth("100%"); StyleInjector.inject(resources.css().getText()); keyboardIntercept.setWidth("1px"); keyboardIntercept.setHeight("1px"); keyboardIntercept.setStyleName(css.keyboardIntercept()); rootPanel.add(keyboardIntercept); verticalPanel.add(status); verticalPanel.setCellHorizontalAlignment(status, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.add(mainPanel); verticalPanel.setCellHorizontalAlignment(mainPanel, HasHorizontalAlignment.ALIGN_CENTER); verticalPanel.add(below); display.add(verticalPanel); display.setWidth("97%"); rootPanel.add(display); }
Example #20
Source File: MaterialDesignBase.java From gwt-material with Apache License 2.0 | 4 votes |
public static void injectCss(TextResource resource) { StyleInjector.inject(resource.getText()); }