Example usage for com.google.gwt.i18n.shared AnyRtlDirectionEstimator get

List of usage examples for com.google.gwt.i18n.shared AnyRtlDirectionEstimator get

Introduction

In this page you can find the example usage for com.google.gwt.i18n.shared AnyRtlDirectionEstimator get.

Prototype

public static AnyRtlDirectionEstimator get() 

Source Link

Document

Get an instance of AnyRtlDirectionEstimator.

Usage

From source file:com.google.gwt.sample.showcase.client.content.text.CwBasicText.java

License:Apache License

/**
 * Initialize this example./*from   w w  w.ja v  a2 s  .  c  o m*/
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create a panel to layout the widgets
    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(5);

    // Add a normal and disabled text box
    TextBox normalText = new TextBox();
    normalText.ensureDebugId("cwBasicText-textbox");
    // Set the normal text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL direction
    // iff the text contains at least one RTL character.
    normalText.setDirectionEstimator(AnyRtlDirectionEstimator.get());
    TextBox disabledText = new TextBox();
    disabledText.ensureDebugId("cwBasicText-textbox-disabled");
    disabledText.setText(constants.cwBasicTextReadOnly());
    disabledText.setEnabled(false);
    vpanel.add(new HTML(constants.cwBasicTextNormalLabel()));
    vpanel.add(createTextExample(normalText, true));
    vpanel.add(createTextExample(disabledText, false));

    // Add a normal and disabled password text box
    PasswordTextBox normalPassword = new PasswordTextBox();
    normalPassword.ensureDebugId("cwBasicText-password");
    PasswordTextBox disabledPassword = new PasswordTextBox();
    disabledPassword.ensureDebugId("cwBasicText-password-disabled");
    disabledPassword.setText(constants.cwBasicTextReadOnly());
    disabledPassword.setEnabled(false);
    vpanel.add(new HTML("<br><br>" + constants.cwBasicTextPasswordLabel()));
    vpanel.add(createTextExample(normalPassword, true));
    vpanel.add(createTextExample(disabledPassword, false));

    // Add a text area
    TextArea textArea = new TextArea();
    textArea.ensureDebugId("cwBasicText-textarea");
    textArea.setVisibleLines(5);
    vpanel.add(new HTML("<br><br>" + constants.cwBasicTextAreaLabel()));
    vpanel.add(createTextExample(textArea, true));

    // Return the panel
    return vpanel;
}

From source file:com.vo.search.admin.client.content.widgets.CwQueryIndex.java

License:Apache License

/**
 * Initialize this widget.//from w ww  .j  a v  a2  s  .c  o m
 */
@Override
public Widget onInitialize() {

    // initialize search box
    searchBox = new TextBox();
    searchBox.ensureDebugId("cwBasicText-textbox");
    // Set the text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL
    // direction
    // iff the text contains at least one RTL character.
    searchBox.setDirectionEstimator(AnyRtlDirectionEstimator.get());

    // innitialize label
    label = new Label(constants.cwQueryIndexEnterQuery());
    label.ensureDebugId("cwQueryIndex-label");
    // initialize submit button
    submitButton = new Button(constants.cwQueryIndexButtonSubmit());
    submitButton.ensureDebugId("cwBasicButton-normal");

    // Create the popup dialog box
    final DialogBox dialogBox = new DialogBox();
    dialogBox.setText("Remote Procedure Call");
    dialogBox.setAnimationEnabled(true);

    // Set a key provider that provides a unique key for each content.
    dataGrid = new DataGrid<ContentInfo>(ContentInfo.KEY_PROVIDER);

    // Set the message to display when the table is empty.
    dataGrid.setWidth("100%");
    dataGrid.setEmptyTableWidget(new Label(constants.cwDataGridEmpty()));
    // Initialize data provider
    if (dataProvider == null) {
        dataProvider = new ListDataProvider<ContentInfo>();
    }
    dataProvider.addDataDisplay(dataGrid);

    // Create a Pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {
            sendQueryToServer();
        }

        /**
         * Send the name from the nameField to the server and wait for a
         * response.
         */
        private void sendQueryToServer() {
            String queryToServer = searchBox.getText();
            // Then, we send the input to the server.

            greetingService.queryServer(queryToServer, new AsyncCallback<QueryResult>() {
                public void onFailure(Throwable caught) {
                    // Show the RPC error message to the user
                    dialogBox.setText("Remote Procedure Call - Failure");
                    dialogBox.center();
                    submitButton.setEnabled(false);
                }

                public void onSuccess(QueryResult result) {
                    // Initialize the columns.
                    dataProvider.getList().clear();
                    dataProvider.setList(result.getResults());
                    initTableData(result);

                }
            });
        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    submitButton.addClickHandler(handler);

    // Create the UiBinder.
    Binder uiBinder = GWT.create(Binder.class);
    return uiBinder.createAndBindUi(this);

}

From source file:fr.drop.client.content.about.CwBasicText.java

License:Apache License

/**
 * Initialize this example.//from  w w  w  .  j a v  a 2s  . c  o m
 */
@DropSource
@Override
public Widget onInitialize() {
    // Create a panel to layout the widgets
    VerticalPanel vpanel = new VerticalPanel();
    vpanel.setSpacing(5);

    // Add a normal and disabled text box
    TextBox normalText = new TextBox();
    normalText.ensureDebugId("cwBasicText-textbox");
    // Set the normal text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL direction
    // iff the text contains at least one RTL character.
    normalText.setDirectionEstimator(AnyRtlDirectionEstimator.get());
    TextBox disabledText = new TextBox();
    disabledText.ensureDebugId("cwBasicText-textbox-disabled");
    disabledText.setText(constants.cwBasicTextReadOnly());
    disabledText.setEnabled(false);
    vpanel.add(new HTML(constants.cwBasicTextNormalLabel()));
    vpanel.add(createTextExample(normalText, true));
    vpanel.add(createTextExample(disabledText, false));

    // Add a normal and disabled password text box
    PasswordTextBox normalPassword = new PasswordTextBox();
    normalPassword.ensureDebugId("cwBasicText-password");
    PasswordTextBox disabledPassword = new PasswordTextBox();
    disabledPassword.ensureDebugId("cwBasicText-password-disabled");
    disabledPassword.setText(constants.cwBasicTextReadOnly());
    disabledPassword.setEnabled(false);
    vpanel.add(new HTML("<br><br>" + constants.cwBasicTextPasswordLabel()));
    vpanel.add(createTextExample(normalPassword, true));
    vpanel.add(createTextExample(disabledPassword, false));

    // Add a text area
    TextArea textArea = new TextArea();
    textArea.ensureDebugId("cwBasicText-textarea");
    textArea.setVisibleLines(5);
    vpanel.add(new HTML("<br><br>" + constants.cwBasicTextAreaLabel()));
    vpanel.add(createTextExample(textArea, true));

    // Return the panel
    return vpanel;
}

From source file:fr.drop.client.content.projects.CwProjectCreation.java

License:Apache License

protected void AddTextBox(VerticalPanel vPanel, String description, String identifier) {
    // Project Name
    TextBox normalText = new TextBox();
    normalText.ensureDebugId("cwCreateProjectName-textbox");
    // Set the normal text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL direction
    // iff the text contains at least one RTL character.
    normalText.setDirectionEstimator(AnyRtlDirectionEstimator.get());
    vPanel.add(normalText);/* w  w  w.  j av  a 2s .co  m*/
}

From source file:org.geosdi.maplite.client.model.LegendBuilder.java

private static DialogBox getRefreshDialogBox(final ClientRasterInfo raster, final Map map) {
    // Create a dialog box and set the caption text
    final DialogBox refreshDialogBox = new DialogBox();
    refreshDialogBox.ensureDebugId("cwDialogBox");
    refreshDialogBox.setText("REFRESH TIME");

    // Create a table to layout the content
    VerticalPanel dialogContents = new VerticalPanel();
    dialogContents.setSpacing(4);// ww w.  jav a2s. co  m
    refreshDialogBox.setWidget(dialogContents);

    // Add some text to the top of the dialog
    HTML details = new HTML("seconds");
    dialogContents.add(details);
    dialogContents.setCellHorizontalAlignment(details, HasHorizontalAlignment.ALIGN_CENTER);

    final TextBox normalText = new TextBox();
    normalText.ensureDebugId("cwBasicText-textbox");
    // Set the normal text box to automatically adjust its direction according
    // to the input text. Use the Any-RTL heuristic, which sets an RTL direction
    // iff the text contains at least one RTL character.
    normalText.setDirectionEstimator(AnyRtlDirectionEstimator.get());

    dialogContents.add(normalText);
    dialogContents.setCellHorizontalAlignment(normalText, HasHorizontalAlignment.ALIGN_CENTER);

    // Add a close button at the bottom of the dialog
    Button closeButton = new Button("Apply", new ClickHandler() {

        private java.util.Map<ClientRasterInfo, Timer> timerMap = Maps.<ClientRasterInfo, Timer>newHashMap();

        @Override
        public void onClick(ClickEvent event) {
            String value = normalText.getValue();
            try {
                int seconds = Integer.parseInt(value);
                if (seconds != 0 && seconds < 30) {
                    Window.alert("The time must be greater or equal to 30 seconds");
                } else {
                    Layer layer = map.getLayer(raster.getWmsLayerId());

                    final WMS wms = WMS.narrowToLayer(layer.getJSObject());
                    Timer timer = timerMap.get(raster);
                    if (timer == null) {
                        timer = new Timer() {

                            @Override
                            public void run() {
                                logger.info("Repeat scheduling");
                                wms.redraw(true);
                            }
                        };
                        timerMap.put(raster, timer);
                    }
                    if (seconds == 0) {
                        timer.cancel();
                    } else {
                        timer.scheduleRepeating(seconds * 1000);
                    }
                    refreshDialogBox.hide();
                }
            } catch (NumberFormatException nfe) {
                Window.alert("The passed value is not a valid integer number");
            }
        }
    });
    dialogContents.add(closeButton);
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_LEFT);

    } else {
        dialogContents.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_RIGHT);
    }

    // Return the dialog box
    refreshDialogBox.setGlassEnabled(true);
    refreshDialogBox.setAnimationEnabled(true);
    refreshDialogBox.center();
    return refreshDialogBox;
}