List of usage examples for com.google.gwt.i18n.client LocaleInfo getCurrentLocale
public static final LocaleInfo getCurrentLocale()
From source file:at.ait.dme.yuma.client.image.annotation.ImageAnnotationComposite.java
License:EUPL
/** * show hints and create link to help page *///ww w. j ava 2s . c o m protected Widget createHeader() { // The parent header panel FlowPanel header = new FlowPanel(); // 'Add your Annotation' label Label addAnnotationLabel = new Label(Application.getConstants().addAnnotation()); addAnnotationLabel.setStyleName("imageAnnotation-add-annotation"); header.add(addAnnotationLabel); // 'Help' link HTML help = new HTML( "<a target=\"_blank\" href=\"userguide_" + LocaleInfo.getCurrentLocale().getLocaleName() + ".html\">" + Application.getConstants().help() + "</a>"); help.setStyleName("imageAnnotation-help"); header.add(help); // Instructions text Label addAnnotationHint = new Label(Application.getConstants().addAnnotationHint()); addAnnotationHint.setStyleName("imageAnnotation-add-annotation-hint"); header.add(addAnnotationHint); // Button panel HorizontalPanel buttons = new HorizontalPanel(); // 'Annotate' button annotateButton.setStyleName("imageAnnotation-button"); annotateButton.setText(Application.getConstants().actionCreate()); annotateButton.addClickHandler(new CreateImageAnnotationClickHandler(this, null, false, false)); annotateButton.setEnabled(!Application.getUser().isEmpty()); buttons.add(annotateButton); // 'Annotate Fragment' button annotateFragmentButton.setStyleName("imageAnnotation-button"); annotateFragmentButton.setText(Application.getConstants().actionCreateFragment()); annotateFragmentButton.addClickHandler(new CreateImageAnnotationClickHandler(this, null, true, false)); annotateFragmentButton.setEnabled(!Application.getUser().isEmpty()); buttons.add(annotateFragmentButton); // 'Show on Map' button showOnMapButton.setStyleName("imageAnnotation-button"); showOnMapButton.setText(Application.getConstants().actionShowOnMap()); showOnMapButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { WindowPanel window = MinMaxWindowPanel.createMinMaxWindowPanel(550, 300, 500, 300); window.getHeader().setText("Map"); window.setWidget(new GoogleMapsComposite(annotations)); window.setResizable(false); window.show(); } }); showOnMapButton.setVisible(Application.getBbox() != null || Application.isInTileMode()); buttons.add(showOnMapButton); header.add(buttons); header.add(annotationFormPanel); return header; }
From source file:at.ait.dme.yuma.client.map.annotation.ControlPointComposite.java
License:EUPL
@Override protected Widget createHeader() { // The parent header panel FlowPanel header = new FlowPanel(); // 'Help geo-Reference' label Label addAnnotationLabel = new Label(Application.getConstants().helpGeoreference()); addAnnotationLabel.setStyleName("imageAnnotation-add-annotation"); header.add(addAnnotationLabel);/*from w w w . j ava 2 s. co m*/ // 'Help' link HTML help = new HTML( "<a target=\"_blank\" href=\"userguide_" + LocaleInfo.getCurrentLocale().getLocaleName() + ".html\">" + Application.getConstants().help() + "</a>"); help.setStyleName("imageAnnotation-help"); header.add(help); // Instructions text Label addAnnotationHint = new Label(Application.getConstants().helpGeoreferenceHint()); addAnnotationHint.setStyleName("imageAnnotation-add-annotation-hint"); header.add(addAnnotationHint); // Button panel HorizontalPanel buttons = new HorizontalPanel(); // 'Create Control Point' button createButton = new PushButton(Application.getConstants().actionCreateCP()); createButton.setStyleName("imageAnnotation-button"); createButton.addClickHandler(new CreateImageAnnotationClickHandler(this, null, false, false)); createButton.setEnabled(!Application.getUser().isEmpty()); buttons.add(createButton); header.add(buttons); // Placeholder for the annotation form header.add(annotationFormPanel); return header; }
From source file:at.ait.dme.yuma.suite.apps.core.client.treeview.AnnotationPanel.java
License:EUPL
/** * show hints and create link to help page *///from w w w . j a v a2s .com protected Widget createHeader() { // The parent header panel FlowPanel header = new FlowPanel(); // 'Add your Annotation' label Label addAnnotationLabel = new Label(YUMACoreProperties.getConstants().addAnnotation()); addAnnotationLabel.setStyleName("imageAnnotation-add-annotation"); header.add(addAnnotationLabel); // 'Loading' animation header.add(loadingImage); // 'Help' link HTML help = new HTML( "<a target=\"_blank\" href=\"userguide_" + LocaleInfo.getCurrentLocale().getLocaleName() + ".html\">" + YUMACoreProperties.getConstants().help() + "</a>"); help.setStyleName("imageAnnotation-help"); header.add(help); // Instructions text Label addAnnotationHint = new Label(YUMACoreProperties.getConstants().addAnnotationHint()); addAnnotationHint.setStyleName("imageAnnotation-add-annotation-hint"); header.add(addAnnotationHint); // Button panel HorizontalPanel buttons = new HorizontalPanel(); // 'Annotate' button annotateButton.setStyleName("imageAnnotation-button"); annotateButton.setText(YUMACoreProperties.getConstants().annotate()); annotateButton.addClickHandler(new AnnotateClickHandler(this, null, null, false)); annotateButton.setEnabled(!User.get().isAnonymous()); buttons.add(annotateButton); // 'Annotate Fragment' button annotateFragmentButton.setStyleName("imageAnnotation-button"); annotateFragmentButton.setText(YUMACoreProperties.getConstants().annotateFragment()); annotateFragmentButton.addClickHandler(new AnnotateClickHandler(this, null, null, true)); annotateFragmentButton.setEnabled(!User.get().isAnonymous()); buttons.add(annotateFragmentButton); header.add(buttons); return header; }
From source file:at.ait.dme.yuma.suite.apps.map.client.georeferencing.ControlPointPanel.java
License:EUPL
@Override protected Widget createHeader() { // The parent header panel FlowPanel header = new FlowPanel(); // 'Help geo-Reference' label Label addAnnotationLabel = new Label(YUMACoreProperties.getConstants().helpGeoreference()); addAnnotationLabel.setStyleName("imageAnnotation-add-annotation"); header.add(addAnnotationLabel);/*from w w w .j a v a 2 s . com*/ // 'Help' link HTML help = new HTML( "<a target=\"_blank\" href=\"userguide_" + LocaleInfo.getCurrentLocale().getLocaleName() + ".html\">" + YUMACoreProperties.getConstants().help() + "</a>"); help.setStyleName("imageAnnotation-help"); header.add(help); // Instructions text Label addAnnotationHint = new Label(YUMACoreProperties.getConstants().helpGeoreferenceHint()); addAnnotationHint.setStyleName("imageAnnotation-add-annotation-hint"); header.add(addAnnotationHint); // Button panel HorizontalPanel buttons = new HorizontalPanel(); // 'Create Control Point' button createButton = new PushButton(YUMACoreProperties.getConstants().actionCreateCP()); createButton.setStyleName("imageAnnotation-button"); createButton.addClickHandler(new AnnotateClickHandler(this, null, null, false)); createButton.setEnabled(!User.get().isAnonymous()); buttons.add(createButton); if (YUMACoreProperties.getObjectURI().startsWith("http://georeferencer")) createButton.setEnabled(false); header.add(buttons); // Placeholder for the annotation form header.add(editFormPanel); return header; }
From source file:br.com.artefino.ordermanager.client.data.ContextAreaDataSource.java
License:Open Source License
public void setDataURL(String urlPrefix, String urlSuffix) { String url = urlPrefix;//from w w w . jav a 2s .co m LocaleInfo localeInfo = LocaleInfo.getCurrentLocale(); String localeName = localeInfo.getLocaleName(); if (localeName.length() > 0) { url = url + "_" + localeName; } url = url + urlSuffix; // Log.debug("setDataURL: " + url); setDataURL(url); }
From source file:br.com.artefino.ordermanager.client.data.NavigationPaneSectionDataSource.java
License:Open Source License
public void setDataURL(String urlPrefix, String urlSuffix) { String url = urlPrefix;//from w w w . ja v a2 s.co m LocaleInfo localeInfo = LocaleInfo.getCurrentLocale(); String localeName = localeInfo.getLocaleName(); if (localeName.length() > 0) { url = url + "_" + localeName; } url = url + urlSuffix; // Log.debug("setDataURL: " + url); setDataURL(url); }
From source file:cc.alcina.framework.gwt.client.ide.widget.FilterableTree.java
License:Apache License
private static int standardizeKeycode(int code) { switch (code) { case OTHER_KEY_DOWN: code = KeyCodes.KEY_DOWN;/*from w ww.j av a 2 s .co m*/ break; case OTHER_KEY_RIGHT: code = KeyCodes.KEY_RIGHT; break; case OTHER_KEY_UP: code = KeyCodes.KEY_UP; break; case OTHER_KEY_LEFT: code = KeyCodes.KEY_LEFT; break; } if (LocaleInfo.getCurrentLocale().isRTL()) { if (code == KeyCodes.KEY_RIGHT) { code = KeyCodes.KEY_LEFT; } else if (code == KeyCodes.KEY_LEFT) { code = KeyCodes.KEY_RIGHT; } } return code; }
From source file:cc.alcina.framework.gwt.client.widget.dialog.DecoratorPanel.java
License:Apache License
/** * 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.//from w ww . j ava2 s . c o m * * 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; }
From source file:cc.alcina.framework.gwt.client.widget.dialog.RelativePopupPanel.java
License:Apache License
/** * Positions the popup, called after the offset width and height of the * popup are known.//from www . jav a 2s.c o m * * @param relativeObject * the ui object to position relative to * @param offsetWidth * the drop down's offset width * @param offsetHeight * the drop down's offset height */ private void position(final UIObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out // whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right // edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge // of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space // for the // overflow to the right of the text box, then left-align the // popup. // However, if there is not enough space on either side, stick // with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always // align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Window.getClientWidth() + Window.getScrollLeft(); int windowLeft = Window.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge // of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space // for the // overflow to the left of the text box, then right-align the // popup. // However, if there is not enough space on either side, then // stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Window.getScrollTop(); int windowBottom = Window.getScrollTop() + Window.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then then position the popup above the text box. However, if // there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
From source file:cc.kune.core.client.i18n.I18nUITranslationService.java
License:GNU Affero Public License
/** * Instantiates a new i18n ui translation service. * * @param session/*from ww w . ja v a 2s.c o m*/ * the session * @param i18nService * the i18n service * @param eventBus * the event bus * @param kuneConstants * the kune constants */ @Inject public I18nUITranslationService(final Session session, final I18nServiceAsync i18nService, final EventBus eventBus, final KuneConstants kuneConstants) { this.session = session; this.i18nService = i18nService; this.kuneConstants = kuneConstants; final String locale = WindowUtils.getParameter(SiteParameters.LOCALE); final LocaleInfo currentLocale = LocaleInfo.getCurrentLocale(); Log.info("Workspace starting with language: " + currentLocale.getLocaleName() + ", isRTL: " + LocaleInfo.getCurrentLocale().isRTL() + ", translated langs: " + Arrays.toString(LocaleInfo.getAvailableLocaleNames())); isLangInProperties = isInConstantProperties(currentLocale.getLocaleName()); earlyTexts = new HashSet<Pair<String, String>>(); i18nService.getInitialLanguage(locale, new AsyncCallback<I18nLanguageDTO>() { @Override public void onFailure(final Throwable caught) { Log.error("Workspace adaptation to your language failed: " + caught.getMessage()); } @Override public void onSuccess(final I18nLanguageDTO result) { currentLang = result; currentLanguageCode = currentLang.getCode(); session.setCurrentLanguage(currentLang); isLangInProperties = isInConstantProperties(currentLang.getCode()); i18nService.getLexicon(currentLang.getCode(), new AsyncCallback<HashMap<String, String>>() { @Override public void onFailure(final Throwable caught) { Log.error( "Workspace adaptation to server proposed language failed: " + caught.getMessage()); } @Override public void onSuccess(final HashMap<String, String> result) { lexicon = result; session.setCurrentLanguage(currentLang); Log.info("Workspace adaptation to server proposed language: " + currentLang.getEnglishName() + ", isRTL: " + currentLang.getDirection() + " use properties: " + shouldIuseProperties()); changeToLanguageIfNecessary(getCurrentGWTlanguage(), currentLang.getCode(), currentLang.getEnglishName(), false, new I18nLanguageChangeNeeded() { @Override public void onChangeNeeded() { } @Override public void onChangeNotNeeded() { isCurrentLangRTL = currentLang.getDirection().equals(RTL); eventBus.fireEvent(new I18nReadyEvent()); I18nStyles.setRTL(isCurrentLangRTL); } }); } }); session.onUserSignIn(true, new UserSignInHandler() { @Override public void onUserSignIn(final UserSignInEvent event) { Scheduler.get().scheduleIncremental(new RepeatingCommand() { @Override public boolean execute() { if (!earlyTexts.isEmpty()) { final Pair<String, String> pair = earlyTexts.iterator().next(); save(pair.getLeft(), pair.getRight()); earlyTexts.remove(pair); } return !earlyTexts.isEmpty(); } }); } }); } }); }