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); }
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); }
@Override public void onModuleLoad() { C3Resources resources = loadResources(); boolean pretty = isPretty(resources); GWT.log("[C3Js] Loading " + (pretty ? "pretty" : "obfuscated") + " resources"); TextResource c3Css = resources.c3Css(); GWT.log("[C3Js] Injecting CSS " + c3Css.getName()); StyleInjector.inject(c3Css.getText()); TextResource c3JavaScript = resources.c3JavaScript(); GWT.log("[C3Js] Injecting JavaScript " + c3JavaScript.getName()); ScriptInjector.fromString(c3JavaScript.getText()).setRemoveTag(pretty).setWindow(getWindow()).inject(); GWT.log("[C3Js] C3 v" + getC3Version() + " (using D3 v" + getD3Version() + ") loaded!"); }
public static LintLine create(String shortMsg, String msg, String sev, Pos line) { StyleInjector.inject( ".CodeMirror-lint-marker-" + sev + " {\n" + " visibility: hidden;\n" + " text-overflow: ellipsis;\n" + " white-space: nowrap;\n" + " overflow: hidden;\n" + " position: relative;\n" + "}\n" + ".CodeMirror-lint-marker-" + sev + ":after {\n" + " content:'" + shortMsg + "';\n" + " visibility: visible;\n" + "}"); return create(msg, sev, line, null); }
@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); }
private static AsyncCallback<?> createGenerateTypedCSSCallBack() { return new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { ClientApplicationContext.getInstance().log("Getting generated CSS Failed", caught.getMessage(), true, true, caught); } @Override public void onSuccess(Object result) { if (result != null) { String generatedCss = (String) result; StyleInjector.injectAtEnd(generatedCss); } } }; }
private void updateBgImage(ImageElement bgImage){ canvas.removeStyleName("newbg"); if(injectedBgCss!=null){ injectedBgCss.removeFromParent(); } if(bgImage!=null){ int w=(int) (bgImage.getWidth()*currentScale); int h=(int) (bgImage.getHeight()*currentScale); String css=".newbg{"+"background-image: url(\""+bgImage.getSrc()+"\");background-size:"+w+"px "+h+"px;"+"}"; injectedBgCss = StyleInjector.injectStylesheet(css); canvas.addStyleName("newbg"); updateCanvas(false); } }
@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(); } }
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(); } }; }
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()); }
@Override public void load() { injectJs(MaterialTableBundle.INSTANCE.jQueryExt()); injectJs(MaterialTableBundle.INSTANCE.stickyth()); injectJs(MaterialTableBundle.INSTANCE.tableSubHeaders()); injectJs(MaterialTableBundle.INSTANCE.greedyScroll()); StyleInjector.inject(MaterialTableBundle.INSTANCE.style().getText()); StyleInjector.inject(MaterialDataPagerClientBundle.INSTANCE.dataPagerCss().getText()); }
@Override public void load() { injectDebugJs(MaterialTableDebugBundle.INSTANCE.jQueryExt()); injectDebugJs(MaterialTableDebugBundle.INSTANCE.stickyth()); injectDebugJs(MaterialTableDebugBundle.INSTANCE.tableSubHeaders()); injectDebugJs(MaterialTableDebugBundle.INSTANCE.greedyScroll()); StyleInjector.inject(MaterialTableDebugBundle.INSTANCE.style().getText()); StyleInjector.inject(MaterialDataPagerClientBundle.INSTANCE.dataPagerDebugCss().getText()); }
/** * Load the specified style file. * * @param css Path to style file. */ public static void load(String css) { if (loadedCss.contains(css)) { return; } StyleInjector.inject(css, true); StyleInjector.flush(); loadedCss.add(css); }
private void createDisplay() { if (MGWT.getOsDetection().isTablet() && isNavigationPanelEnabled()) { StyleInjector.inject(AppBundle.INSTANCE.css().getText()); createTabletDisplay(); } else { createPhoneDisplay(); } }
private void updateBgStyle(){ if(isTransparent()){ canvas.setStylePrimaryName("transparent_bg"); }else{ if(bgElement!=null){ bgElement.removeFromParent(); } String css=".colorbg{margin-left: 8px;padding: 0px;background:"+getBgColor()+";}"; LogUtils.log(css); bgElement = StyleInjector.injectStylesheet(css); canvas.setStylePrimaryName("colorbg"); } }
private static Resources createResources() { if (resources == null) { resources = GWT.create(Resources.class); StyleInjector.injectAtEnd("." + resources.cellTreeStyle().cellTreeItem() + " {padding-top: 2px; padding-bottom: 0px}"); StyleInjector.injectAtEnd("." + resources.cellTreeStyle().cellTreeTopItem() + " {margin-top: 0px;}"); StyleInjector.injectAtEnd("." + resources.cellTreeStyle().cellTreeTopItem() + " {margin-top: 0px;}"); StyleInjector.injectAtEnd("." + resources.cellTreeStyle().cellTreeSelectedItem() + " {background:none !important; color:#4B3E2D;}"); // TODO } return resources; }
/** * 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(); }
private void injectLeftStyle() { if (ie || styleElementForLeft != null) { return; } styleElementForLeft = StyleInjector.injectStylesheetAtEnd("." + STYLE_COL + " { } "); StyleInjector.flush(); }
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); }
/** * This is the entry point method. */ public void onModuleLoad() { StyleInjector.injectAtEnd(resources.taskDetailsCss().getText() + resources.taskListCss().getText() + resources.controlBarCss().getText() + resources.labelMatrixCss().getText()); uiPages = new PageTransitionPanel(Document.get().getBody()); Controller controller = new Controller(); ControlBar.Controls taskListControls = TaskList.createControls(controller, resources); taskList = new TaskList(uiPages, taskListControls, controller, resources); ControlBar.Controls taskDetailsControls = TaskDetails.createControls( controller, resources); taskDetails = new TaskDetails(uiPages, taskDetailsControls, controller, resources); loadEntireTaskList(); uiPages.doResize(); DeferredCommand.defer(new DeferredCommand() { @Override public void onExecute() { uiPages.doResize(); } }, 100); }
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; }
public static void injectCss(TextResource resource) { StyleInjector.inject(resource.getText()); }
@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); }
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."); }
public static void injectStyle(String css) { StyleInjector.inject(css); }
public static void injectStyle(TextResource css) { StyleInjector.inject(css.getText()); }
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 + "; } "); } }
private void showAllResolutionBlocks() { if (styleElementForLeft != null) { StyleInjector.setContents(styleElementForLeft, "." + STYLE_COL + " { position: relative; left: 0px; }"); } fillTimelineForResolution(startDate, endDate, 0); }
private void buildDisplay(final ClientFactory clientFactory, final PhoneGap phoneGap) { ViewPort viewPort = new MGWTSettings.ViewPort(); viewPort.setUserScaleAble(false).setMinimumScale(1.0) .setInitialScale(1.0).setMaximumScale(1.0); MGWTSettings settings = new MGWTSettings(); settings.setViewPort(viewPort); settings.setIconUrl("logo.png"); settings.setFullscreen(true); settings.setFixIOS71BodyBug(true); settings.setPreventScrolling(true); MGWT.applySettings(settings); // Create initial database tables createDatabaseTables(clientFactory); phoneGap.getEvent().getBackButton() .addBackButtonPressedHandler(new BackButtonPressedHandler() { @Override public void onBackButtonPressed(BackButtonPressedEvent event) { Place place = clientFactory.getPlaceController().getWhere(); if (place instanceof HomePlace) { phoneGap.exitApp(); } else { History.back(); } } }); // Start PlaceHistoryHandler with our PlaceHistoryMapper AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); StyleInjector.inject(AppBundle.INSTANCE.css().getText()); createPhoneDisplay(clientFactory); AppHistoryObserver historyObserver = new AppHistoryObserver(); MGWTPlaceHistoryHandler historyHandler = new MGWTPlaceHistoryHandler( historyMapper, historyObserver); historyHandler.register(clientFactory.getPlaceController(), clientFactory.getEventBus(), new HomePlace("home")); historyHandler.handleCurrentHistory(); }
/** * 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); }