Example usage for com.google.gwt.user.client.ui DirectionalTextHelper DirectionalTextHelper

List of usage examples for com.google.gwt.user.client.ui DirectionalTextHelper DirectionalTextHelper

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui DirectionalTextHelper DirectionalTextHelper.

Prototype

public DirectionalTextHelper(Element element, boolean isElementInline) 

Source Link

Usage

From source file:com.github.gwtbootstrap.client.ui.CheckBox.java

License:Apache License

protected CheckBox(Element elem) {
    super(DOM.createLabel());

    assert elem.hasAttribute("type") : "The elem should has type attributes";

    //TODO 2012/05/06 ohashi keisuke. ugly code......
    if (Constants.CHECKBOX.toLowerCase().equals(elem.getAttribute("type").toLowerCase())) {
        this.setStyleName(Constants.CHECKBOX);
    } else if (Constants.RADIO.toLowerCase().equals(elem.getAttribute("type").toLowerCase())) {
        this.setStyleName(Constants.RADIO);
    }//from   w w  w  . j ava  2  s . co  m

    inputElem = InputElement.as(elem);
    spanElem = Document.get().createSpanElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(spanElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    asLabel().setHtmlFor(uid);
    directionalTextHelper = new DirectionalTextHelper(spanElem, false);
    setTabIndex(0);
}

From source file:com.github.gwtbootstrap.client.ui.ControlLabel.java

License:Apache License

/**
 * Creates a widget with  the html set..
 * @param html content html/*from  w  w  w .  ja va 2s .  c o  m*/
 */
public ControlLabel(String html) {
    super(html);
    setStyleName(Constants.CONTROL_LABEL);
    directionalTextHelper = new DirectionalTextHelper(getElement(), true);
}

From source file:com.qualogy.qafe.gwt.client.component.QCheckBox.java

License:Apache License

public QCheckBox(Element elem, String displaynamePosition) {
    inputElem = (InputElement) this.getElement().getChild(0);
    labelElem = (LabelElement) this.getElement().getChild(1);
    if (displaynamePosition.equals(DISPLAYNAME_POSITION_LEFT)) {
        getElement().appendChild(labelElem);
        getElement().appendChild(inputElem);
    } else {/*from   ww w  .j a  v  a  2  s . co  m*/
        getElement().appendChild(inputElem);
        getElement().appendChild(labelElem);
    }
    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    labelElem.setHtmlFor(uid);
    directionalTextHelper = new DirectionalTextHelper(labelElem, true);

    // Accessibility: setting tab index to be 0 by default, ensuring element
    // appears in tab sequence. FocusWidget's setElement method already
    // calls setTabIndex, which is overridden below. However, at the time
    // that this call is made, inputElem has not been created. So, we have
    // to call setTabIndex again, once inputElem has been created.
    setTabIndex(0);
}

From source file:gwt.material.design.client.base.BaseCheckBox.java

License:Apache License

protected BaseCheckBox(Element elem) {
    super(elem);//from w  ww.  j  av a2 s.co  m

    inputElem = InputElement.as(DOM.createInputCheck());
    labelElem = Document.get().createLabelElement();

    getElement().appendChild(inputElem);
    getElement().appendChild(labelElem);

    String uid = DOM.createUniqueId();
    inputElem.setPropertyString("id", uid);
    labelElem.setHtmlFor(uid);

    directionalTextHelper = new DirectionalTextHelper(labelElem, true);

    // Accessibility: setting tab index to be 0 by default, ensuring element
    // appears in tab sequence. FocusWidget's setElement method already
    // calls setTabIndex, which is overridden below. However, at the time
    // that this call is made, inputElem has not been created. So, we have
    // to call setTabIndex again, once inputElem has been created.
    setTabIndex(0);
}

From source file:org.jahia.ajax.gwt.client.widget.content.FileUploader.java

License:Open Source License

public FileUploader(final Linker linker, final GWTJahiaNode location, String defaultUploadOption) {
    super();/*from  w ww . j a v  a2s  .  c o m*/
    if ("rename".equalsIgnoreCase(defaultUploadOption)) {
        uploadOption = UploadOption.RENAME;
    } else if ("version".equalsIgnoreCase(defaultUploadOption)) {
        uploadOption = UploadOption.VERSION;
    } else {
        uploadOption = UploadOption.AUTO;
    }
    setHeadingHtml(Messages.get("uploadFile.label"));
    setSize(500, 500);
    setResizable(false);

    ButtonBar buttons = new ButtonBar();
    final ProgressBar bar = new ProgressBar();
    bar.setWidth(200);
    form = new FormPanel();
    String entryPoint = JahiaGWTParameters.getServiceEntryPoint();
    if (entryPoint == null) {
        entryPoint = "/gwt/";
    }
    form.setHeaderVisible(false);
    form.setBorders(false);
    form.setBodyBorder(false);
    form.setAction(entryPoint + "fileupload");
    form.setEncoding(FormPanel.Encoding.MULTIPART);
    form.setMethod(FormPanel.Method.POST);

    form.setLabelWidth(200);
    setModal(true);

    // upload location
    Hidden dest = new Hidden();
    dest.setName("uploadLocation");

    // unzip parameter
    final CheckBox unzip = new CheckBox();
    unzip.setFieldLabel(Messages.get("autoUnzip.label"));
    unzip.setName("unzip");

    String parentPath = location.getPath();
    if (location.isFile().booleanValue()) {
        int index = parentPath.lastIndexOf("/");
        if (index > 0) {
            parentPath = parentPath.substring(0, index);
        }
    }
    dest.setValue(parentPath);

    form.add(dest);
    form.add(unzip);

    form.addListener(Events.Submit, new Listener<FormEvent>() {
        public void handleEvent(FormEvent ce) {
            String r = ce.getResultHtml();
            if (r == null) {
                return;
            }
            if (r.contains("UPLOAD-SIZE-ISSUE:")) {
                MessageBox
                        .alert(Messages.get("label.error"),
                                new DirectionalTextHelper(
                                        (new HTML(r.replace("UPLOAD-SIZE-ISSUE:", ""))).getElement(), true)
                                                .getTextOrHtml(false),
                                null);
            } else if (r.contains("UPLOAD-ISSUE:")) {
                unmask();
                final Dialog dl = new Dialog();
                dl.setModal(true);
                dl.setHeadingHtml(Messages.get("label.error"));
                dl.setHideOnButtonClick(true);
                dl.setLayout(new FlowLayout());
                dl.setWidth(300);
                dl.setScrollMode(Style.Scroll.NONE);
                dl.add(new HTML(
                        new DirectionalTextHelper((new HTML(r.replace("UPLOAD-ISSUE:", ""))).getElement(), true)
                                .getTextOrHtml(false)));
                dl.setHeight(150);
                dl.show();
            }
        }
    });
    Button cancel = new Button(Messages.get("label.cancel"), new SelectionListener<ButtonEvent>() {
        public void componentSelected(ButtonEvent event) {
            hide();
        }
    });
    final Button submit = new Button(Messages.get("label.ok"), new SelectionListener<ButtonEvent>() {
        public void componentSelected(ButtonEvent event) {
            try {
                mask(Messages.get("message.uploading", "Uploading..."), "x-mask-loading");
                form.submit();
            } catch (Exception e) {
                unmask();
                bar.reset();
                bar.setVisible(false);
                com.google.gwt.user.client.Window.alert(Messages.get("checkUploads.label"));
            }
        }
    });

    buttons.add(submit);
    buttons.add(cancel);
    setButtonAlign(Style.HorizontalAlignment.CENTER);
    setBottomComponent(buttons);

    final UploadPanel p = new UploadPanel();
    form.add(p);

    form.addListener(Events.BeforeSubmit, new Listener<FormEvent>() {
        public void handleEvent(FormEvent formEvent) {
            bar.setVisible(true);
            bar.auto();

        }
    });
    form.addListener(Events.Submit, new Listener<FormEvent>() {
        public void handleEvent(FormEvent formEvent) {
            bar.reset();
            String selectFileAfterDataUpdate = null;
            String result = formEvent.getResultHtml();

            removeAll();
            String[] results = result.split("\n");

            final List<Field[]> exists = new ArrayList<Field[]>();

            for (int i = 0; i < results.length; i++) {
                String s = new HTML(results[i]).getText();
                if (s.startsWith("OK:")) {
                    if (selectFileAfterDataUpdate == null) {
                        selectFileAfterDataUpdate = URL.decode(s.substring("OK: ".length()));
                    }
                } else if (s.startsWith("EXISTS:")) {
                    int i1 = s.indexOf(' ');
                    int i2 = s.indexOf(' ', i1 + 1);
                    int i3 = s.indexOf(' ', i2 + 1);
                    final String key = URL.decode(s.substring(i1 + 1, i2));
                    final String tmp = URL.decode(s.substring(i2 + 1, i3));
                    final String name = URL.decode(s.substring(i3 + 1));

                    addExistingToForm(exists, key, tmp, name, submit);
                }
            }
            if (!exists.isEmpty()) {
                submit.removeAllListeners();
                submit.addSelectionListener(new SelectionListener<ButtonEvent>() {
                    public void componentSelected(ButtonEvent event) {
                        mask(Messages.get("message.uploading", "Uploading..."), "x-mask-loading");
                        submit.setEnabled(false);
                        final List<Field[]> list = new ArrayList<Field[]>(exists);
                        exists.clear();
                        removeAll();
                        List<String[]> uploadeds = new ArrayList<String[]>();
                        for (final Field[] exist : list) {
                            final String tmpName = (String) exist[0].getValue();
                            // selected index correspond to the action: ie. 3=versioning
                            final int operation = ((SimpleComboBox) exist[1]).getSelectedIndex();
                            final String newName = (String) exist[2].getValue();
                            uploadeds.add(new String[] { location.getPath(), tmpName,
                                    Integer.toString(operation), newName });
                        }
                        JahiaContentManagementService.App.getInstance().uploadedFile(uploadeds,
                                new BaseAsyncCallback() {
                                    public void onSuccess(Object result) {
                                        endUpload(unzip, linker);
                                    }

                                    @Override
                                    public void onFailure(Throwable caught) {
                                        super.onFailure(caught);
                                        MessageBox.alert(Messages.get("label.error", "error"),
                                                caught.getLocalizedMessage(), null);
                                        Map<String, Object> data = new HashMap<String, Object>();
                                        data.put(Linker.REFRESH_ALL, true);
                                        linker.refresh(data);
                                        unmask();
                                        hide();
                                    }
                                });
                    }
                });

                layout();
            } else {
                if (selectFileAfterDataUpdate != null) {
                    linker.setSelectPathAfterDataUpdate(
                            Arrays.asList(location.getPath() + "/" + selectFileAfterDataUpdate));
                }
                endUpload(unzip, linker);
            }
        }
    });

    add(form);
    setScrollMode(Style.Scroll.AUTO);
    show();
}