private boolean shouldAddToLogicalRightOfTable(DockLayoutConstant widgetDirection) { // See comments for shouldAddToLogicalLeftOfTable for clarification assert (widgetDirection == LINE_START || widgetDirection == LINE_END || widgetDirection == EAST || widgetDirection == WEST); if (widgetDirection == LINE_END) { return true; } if (LocaleInfo.getCurrentLocale().isRTL()) { return (widgetDirection == WEST); } return (widgetDirection == EAST); } }
private int getStartOfLinePos() { return (LocaleInfo.getCurrentLocale().isRTL() ? RIGHT : LEFT); } }
private int getEndOfLinePos() { return (LocaleInfo.getCurrentLocale().isRTL() ? LEFT : RIGHT); }
/** * Resolve the specified direction based on the current locale. If the * direction is {@link Direction#LINE_START} or {@link Direction#LINE_END}, * the return value will be one of {@link Direction#EAST} or * {@link Direction#WEST} depending on the RTL mode of the locale. For all * other directions, the specified value is returned. * * @param direction the specified direction * @return the locale */ protected Direction getResolvedDirection(Direction direction) { if (direction == Direction.LINE_START) { return LocaleInfo.getCurrentLocale().isRTL() ? Direction.EAST : Direction.WEST; } else if (direction == Direction.LINE_END) { return LocaleInfo.getCurrentLocale().isRTL() ? Direction.WEST : Direction.EAST; } return direction; }
private boolean shouldAddToLogicalLeftOfTable(DockLayoutConstant widgetDirection) { assert (widgetDirection == LINE_START || widgetDirection == LINE_END || widgetDirection == EAST || widgetDirection == WEST); // In a bidi-sensitive environment, adding a widget to the logical left // column (think DOM order) means that it will be displayed at the start // of the line direction for the current layout. This is because HTML // tables are bidi-sensitive; the column order switches depending on // the line direction. if (widgetDirection == LINE_START) { return true; } if (LocaleInfo.getCurrentLocale().isRTL()) { // In an RTL layout, the logical left columns will be displayed on the right hand // side. When the direction for the widget is EAST, adding the widget to the logical // left columns will have the desired effect of displaying the widget on the 'eastern' // side of the screen. return (widgetDirection == EAST); } // In an LTR layout, the logical left columns are displayed on the left hand // side. When the direction for the widget is WEST, adding the widget to the // logical left columns will have the desired effect of displaying the widget on the // 'western' side of the screen. return (widgetDirection == WEST); }
/** * Factory for creating an instance of BidiFormatter whose context direction * matches the current locale's direction, and given the desired span wrapping * behavior (see below). * * @param alwaysSpan Whether {@link #spanWrap} (and its variations) should * always use a 'span' tag, even when the input direction is neutral * or matches the context, so that the DOM structure of the output * does not depend on the combination of directions */ public static BidiFormatter getInstanceForCurrentLocale(boolean alwaysSpan) { return getInstance(LocaleInfo.getCurrentLocale().isRTL(), alwaysSpan); }
double vertDirection = isAnimationVertical ? direction : 0.0; double horizDirection = isAnimationVertical ? 0.0 : LocaleInfo.getCurrentLocale().isRTL() ? -direction : direction;
/** * Factory for creating an instance of SafeHtmlBidiFormatter whose context * direction matches the current locale's direction, and given the desired * span wrapping behavior (see below). * * @param alwaysSpan Whether {@link #spanWrap} (and its variations) should * always use a 'span' tag, even when the input direction is neutral * or matches the context, so that the DOM structure of the output * does not depend on the combination of directions */ public static SafeHtmlBidiFormatter getInstanceForCurrentLocale( boolean alwaysSpan) { return getInstance(LocaleInfo.getCurrentLocale().isRTL(), alwaysSpan); }
/** * This constructor may be used by subclasses to explicitly use an existing * element. This element must be an <input> element whose type is * 'text'. * * @param element the element to be used */ protected ValueBox(Element element, Renderer<T> renderer, Parser<T> parser) { super(element, renderer, parser); // BiDi input is not expected - disable direction estimation. setDirectionEstimator(false); if (LocaleInfo.getCurrentLocale().isRTL()) { setDirection(Direction.LTR); } assert InputElement.as(element).getType().equalsIgnoreCase("text"); }
/** * Called only from {@link TreeItem}: Shows the leaf image on a tree item. * * @param treeItem the tree item */ void showLeafImage(TreeItem treeItem) { if (useLeafImages || treeItem.isFullNode()) { showImage(treeItem, images.treeLeaf()); } else if (LocaleInfo.getCurrentLocale().isRTL()) { treeItem.getElement().getStyle().setProperty("paddingRight", indentValue); } else { treeItem.getElement().getStyle().setProperty("paddingLeft", indentValue); } }
break; case ONE_WAY_CORNER: if (LocaleInfo.getCurrentLocale().isRTL()) { left = offsetWidth - width;
@Override protected void onBrowserEvent2(Event event) { super.onBrowserEvent2(event); // Handle keyboard navigation between lists. String eventType = event.getType(); if (BrowserEvents.KEYDOWN.equals(eventType) && !isKeyboardNavigationSuppressed()) { int keyCode = event.getKeyCode(); boolean isRtl = LocaleInfo.getCurrentLocale().isRTL(); keyCode = KeyCodes.maybeSwapArrowKeysForRtl(keyCode, isRtl); switch (keyCode) { case KeyCodes.KEY_LEFT: keyboardNavigateShallow(); return; case KeyCodes.KEY_RIGHT: keyboardNavigateDeep(); return; } } }
/** * Get the HTML representation of an image. * * @param res the {@link ImageResource} to render as HTML * @param isTop true if the image is for a top level element. * @return the rendered HTML */ private SafeHtml getImageHtml(ImageResource res, boolean isTop) { // Build the classes. StringBuilder classesBuilder = new StringBuilder(style.cellTreeItemImage()); if (isTop) { classesBuilder.append(" ").append(style.cellTreeTopItemImage()); } // Build the css. SafeStylesBuilder cssBuilder = new SafeStylesBuilder(); if (LocaleInfo.getCurrentLocale().isRTL()) { cssBuilder.appendTrustedString("right: 0px;"); } else { cssBuilder.appendTrustedString("left: 0px;"); } cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;"); cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;"); AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = proto.getSafeHtml(); return template .imageWrapper(classesBuilder.toString(), cssBuilder.toSafeStyles(), image); }
void scrollToEnd() { Element elem = getElement(); targetScrollLeft = elem.getScrollWidth() - elem.getClientWidth(); if (LocaleInfo.getCurrentLocale().isRTL()) { targetScrollLeft *= -1; } if (isAnimationEnabled()) { // Animate the scrolling. startScrollLeft = elem.getScrollLeft(); run(250, elem); } else { // Scroll instantly. onComplete(); } } }
private void keyboardNavigation(Event event) { // Handle keyboard events if keyboard navigation is enabled if (isKeyboardNavigationEnabled(curSelection)) { int code = event.getKeyCode(); switch (KeyCodes.maybeSwapArrowKeysForRtl(code, LocaleInfo.getCurrentLocale().isRTL())) { case KeyCodes.KEY_UP: { moveSelectionUp(curSelection); break; } case KeyCodes.KEY_DOWN: { moveSelectionDown(curSelection, true); break; } case KeyCodes.KEY_LEFT: { maybeCollapseTreeItem(); break; } case KeyCodes.KEY_RIGHT: { maybeExpandTreeItem(); break; } default: { return; } } } }
public void init(HorizontalSplitPanel panel) { this.panel = panel; panel.getElement().getStyle().setProperty("position", "relative"); expandToFitParentHorizontally(panel.getElement(LEFT)); expandToFitParentHorizontally(panel.getElement(RIGHT)); expandToFitParentHorizontally(panel.getSplitElement()); expandToFitParentUsingCssOffsets(panel.container); // Right now, both panes are stacked on top of each other // on either the left side or the right side of the containing // panel. This happens because both panes have position:absolute // and no left/top values. The panes will be on the left side // if the directionality is LTR, and on the right side if the // directionality is RTL. In the LTR case, we need to snap the // right pane to the right of the container, and in the RTL case, // we need to snap the left pane to the left of the container. if (LocaleInfo.getCurrentLocale().isRTL()) { setLeft(panel.getElement(LEFT), "0px"); } else { setRight(panel.getElement(RIGHT), "0px"); } }
@Override public void init(HorizontalSplitPanel panel) { this.panel = panel; final Element elem = panel.getElement(); // Prevents inherited text-align settings from interfering with the // panel's layout. The setting we choose must be bidi-sensitive, // as left-alignment is the default with LTR directionality, and // right-alignment is the default with RTL directionality. if (LocaleInfo.getCurrentLocale().isRTL()) { elem.getStyle().setTextAlign(TextAlign.RIGHT); } else { elem.getStyle().setTextAlign(TextAlign.LEFT); } elem.getStyle().setProperty("position", "relative"); /* * Technically, these are snapped to the top and bottom, but IE doesn't * provide a reliable way to make that happen, so a resize listener is * wired up to control the height of these elements. */ addAbsolutePositoning(panel.getElement(LEFT)); addAbsolutePositoning(panel.getElement(RIGHT)); addAbsolutePositoning(panel.getSplitElement()); expandToFitParentUsingPercentages(panel.container); if (LocaleInfo.getCurrentLocale().isRTL()) { // Snap the left pane to the left edge of the container. We // only need to do this when layout is RTL; if we don't, the // left pane will overlap the right pane. setLeft(panel.getElement(LEFT), "0px"); } }
/** * Get the HTML representation of an image. * * @param res the {@link ImageResource} to render as HTML * @return the rendered HTML */ private SafeHtml getImageHtml(ImageResource res) { // Right-justify image if LTR, left-justify if RTL AbstractImagePrototype proto = AbstractImagePrototype.create(res); SafeHtml image = proto.getSafeHtml(); SafeStylesBuilder cssBuilder = new SafeStylesBuilder(); if (LocaleInfo.getCurrentLocale().isRTL()) { cssBuilder.appendTrustedString("left:0px;"); } else { cssBuilder.appendTrustedString("right:0px;"); } cssBuilder.appendTrustedString("width: " + res.getWidth() + "px;"); cssBuilder.appendTrustedString("height: " + res.getHeight() + "px;"); return template.imageWrapper(cssBuilder.toSafeStyles(), image); }
/** * Create a new row with a specific style name. The row will contain three * cells (Left, Center, and Right), each prefixed with the specified style * name. * * This method allows Widgets to reuse the code on a DOM level, without * creating a DecoratorPanel Widget. * * @param styleName the style name * @return the new row {@link Element} */ static Element createTR(String styleName) { Element trElem = DOM.createTR(); setStyleName(trElem, styleName); if (LocaleInfo.getCurrentLocale().isRTL()) { DOM.appendChild(trElem, createTD(styleName + "Right")); DOM.appendChild(trElem, createTD(styleName + "Center")); DOM.appendChild(trElem, createTD(styleName + "Left")); } else { DOM.appendChild(trElem, createTD(styleName + "Left")); DOM.appendChild(trElem, createTD(styleName + "Center")); DOM.appendChild(trElem, createTD(styleName + "Right")); } return trElem; }
scrollLock.getStyle().setZIndex(-32767); scrollLock.getStyle().setTop(0, Unit.PX); if (LocaleInfo.getCurrentLocale().isRTL()) { scrollLock.getStyle().setRight(0, Unit.PX); } else {