Search in sources :

Example 26 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project rstudio by rstudio.

the class CreateBranchDialog method textBox.

private TextBox textBox() {
    TextBox textBox = new TextBox();
    textBox.getElement().getStyle().setProperty("minWidth", "200px");
    return textBox;
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox)

Example 27 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class PerunSearchParametersWidget method rebuild.

/**
	 * Method which rebuild whole searcher widget when number of params changes
	 */
protected void rebuild() {
    ft.clear();
    //ft.setHTML(0, 0, "<h3>" + "Search by parameters:" + "</h3>");
    //ft.getFlexCellFormatter().setColSpan(0, 0, 4);
    int row = 1;
    for (Map.Entry<ListBoxWithObjects<AttributeDefinition>, TextBox> entry : inputs.entrySet()) {
        final ListBoxWithObjects<AttributeDefinition> lb = entry.getKey();
        int selectedItem = lb.getSelectedIndex();
        lb.clear();
        lb.addAllItems(availableAttrDefs);
        lb.setSelectedIndex(selectedItem);
        CustomButton rb = new CustomButton("", SmallIcons.INSTANCE.deleteIcon());
        ft.setWidget(row, 0, lb);
        ft.setText(row, 1, "=");
        ft.setWidget(row, 2, entry.getValue());
        ft.setWidget(row, 3, rb);
        if (inputs.entrySet().size() <= 1) {
            // allow remove if more than 1
            rb.setEnabled(false);
            rb.setTitle("Enabled only when more than 1 parameter is used.");
        }
        rb.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent clickEvent) {
                inputs.keySet().remove(lb);
                rebuild();
            }
        });
        row++;
    }
    ft.setWidget(row, 0, addParameterButton);
    ft.setHTML(row, 1, "");
    ft.setWidget(row, 2, searchButton);
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) TextBox(com.google.gwt.user.client.ui.TextBox) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class PerunSearchParametersWidget method addParameter.

/**
	 * Adds a parameter
	 */
protected void addParameter() {
    TextBox tb = new TextBox();
    final ListBoxWithObjects<AttributeDefinition> lb = new ListBoxWithObjects<AttributeDefinition>();
    inputs.put(lb, tb);
    lb.addAllItems(availableAttrDefs);
    rebuild();
}
Also used : AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) TextBox(com.google.gwt.user.client.ui.TextBox)

Example 29 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project perun by CESNET.

the class GetApplicationForm method createWidget.

/**
	 * Create approval style change widget
	 *
	 * @param form
	 */
private void createWidget(final ApplicationForm form) {
    final CustomButton button = TabMenu.getPredefinedButton(ButtonType.SETTINGS, ButtonTranslation.INSTANCE.changeAppFormSettings());
    if (form != null) {
        // create click handler
        ClickHandler ch = new ClickHandler() {

            public void onClick(ClickEvent event) {
                // layout
                FlexTable ft = new FlexTable();
                ft.setCellSpacing(10);
                ft.setHTML(0, 0, "<strong>INITIAL: </strong>");
                ft.setHTML(1, 0, "<strong>EXTENSION: </strong>");
                ft.setHTML(2, 0, "<strong>Module name: </strong>");
                // widgets
                final ListBox lbInit = new ListBox();
                final ListBox lbExt = new ListBox();
                final TextBox className = new TextBox();
                lbInit.addItem("Automatic", "true");
                lbInit.addItem("Manual", "false");
                lbExt.addItem("Automatic", "true");
                lbExt.addItem("Manual", "false");
                if (form.getAutomaticApproval() == true) {
                    lbInit.setSelectedIndex(0);
                } else {
                    lbInit.setSelectedIndex(1);
                }
                if (form.getAutomaticApprovalExtension() == true) {
                    lbExt.setSelectedIndex(0);
                } else {
                    lbExt.setSelectedIndex(1);
                }
                className.setText(form.getModuleClassName());
                ft.setWidget(0, 1, lbInit);
                ft.setWidget(1, 1, lbExt);
                ft.setWidget(2, 1, className);
                // click on save
                ClickHandler click = new ClickHandler() {

                    public void onClick(ClickEvent event) {
                        // switch and send request
                        UpdateForm request = new UpdateForm(new JsonCallbackEvents() {

                            public void onFinished(JavaScriptObject jso) {
                                // recreate same widget
                                content.clear();
                                ApplicationForm newForm = jso.cast();
                                createWidget(newForm);
                            }

                            ;
                        });
                        form.setAutomaticApproval(Boolean.parseBoolean(lbInit.getValue(lbInit.getSelectedIndex())));
                        form.setAutomaticApprovalExtension(Boolean.parseBoolean(lbExt.getValue(lbExt.getSelectedIndex())));
                        form.setModuleClassName(className.getText().trim());
                        request.updateForm(form);
                    }
                };
                Confirm c = new Confirm("Change application form settings", ft, click, true);
                c.show();
            }
        };
        button.addClickHandler(ch);
        String appStyle = "<strong>Approval style: </strong>";
        String module = "</br><strong>Module name: </strong>" + form.getModuleClassName();
        if (form.getAutomaticApproval() == true) {
            appStyle = appStyle + "<span style=\"color:red;\">Automatic</span> (INITIAL)";
        } else {
            appStyle = appStyle + "<span style=\"color:red;\">Manual</span> (INITIAL)";
        }
        if (form.getAutomaticApprovalExtension() == true) {
            appStyle = appStyle + " <span style=\"color:red;\">Automatic</span> (EXTENSION)";
        } else {
            appStyle = appStyle + " <span style=\"color:red;\">Manual</span> (EXTENSION)";
        }
        if (form.getGroup() == null && !session.isVoAdmin(form.getVo().getId()))
            button.setEnabled(false);
        if (form.getGroup() != null && (!session.isGroupAdmin(form.getGroup().getId()) && !session.isVoAdmin(form.getVo().getId())))
            button.setEnabled(false);
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    } else {
        button.setEnabled(false);
        String appStyle = "<strong>Approval style: </strong> Form doesn't exists.";
        String module = "</br><strong>Module name: </strong> Form doesn't exists.";
        content.setHTML(0, 0, appStyle + module);
        content.setWidget(0, 1, button);
        content.getFlexCellFormatter().getElement(0, 0).setAttribute("style", "padding-right: 10px");
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationForm(cz.metacentrum.perun.webgui.model.ApplicationForm) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) TextBox(com.google.gwt.user.client.ui.TextBox) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 30 with TextBox

use of com.google.gwt.user.client.ui.TextBox in project gerrit by GerritCodeReview.

the class CopyableLabel method copy.

private void copy() {
    TextBox t = new TextBox();
    try {
        t.setText(getText());
        content.add(t);
        t.setFocus(true);
        t.selectAll();
        boolean ok = execCommand("copy");
        Tooltip.setLabel(copier, ok ? CopyableLabelText.I.copied() : CopyableLabelText.I.failed());
        if (!ok) {
            // Disable JavaScript clipboard and try flash movie in another instance.
            UserAgent.disableJavaScriptClipboard();
        }
    } finally {
        t.removeFromParent();
    }
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox)

Aggregations

TextBox (com.google.gwt.user.client.ui.TextBox)31 Test (org.junit.Test)10 Label (com.google.gwt.user.client.ui.Label)9 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 Grid (com.google.gwt.user.client.ui.Grid)4 HashMap (java.util.HashMap)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)2 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)2 CheckBox (com.google.gwt.user.client.ui.CheckBox)2 FlexTable (com.google.gwt.user.client.ui.FlexTable)2 HTML (com.google.gwt.user.client.ui.HTML)2 AttributeDefinition (cz.metacentrum.perun.webgui.model.AttributeDefinition)2 ThemedButton (org.rstudio.core.client.widget.ThemedButton)2 StringListPanel (com.google.gerrit.client.StringListPanel)1 AccessMap (com.google.gerrit.client.access.AccessMap)1