Search in sources :

Example 26 with Grid

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

the class ProjectTemplateWidget method textInput.

private ProjectTemplateWidgetItem textInput(final ProjectTemplateWidgetDescription description) {
    final TextBox primaryWidget = new TextBox();
    primaryWidget.setWidth("180px");
    String defaultValue = description.getDefault();
    if (!StringUtil.isNullOrEmpty(defaultValue))
        primaryWidget.setText(defaultValue);
    Grid grid = new Grid(1, 2);
    primaryWidget.getElement().setAttribute("spellcheck", "false");
    grid.setWidget(0, 0, new Label(ensureEndsWithColon(description.getLabel())));
    grid.setWidget(0, 1, primaryWidget);
    return new ProjectTemplateWidgetItem(grid, new Collector() {

        @Override
        public void collectInput(JsObject receiver) {
            String value = primaryWidget.getValue();
            receiver.setString(description.getParameter(), value);
        }
    });
}
Also used : JsObject(org.rstudio.core.client.js.JsObject) Grid(com.google.gwt.user.client.ui.Grid) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) FileChooserTextBox(org.rstudio.core.client.widget.FileChooserTextBox) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 27 with Grid

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

the class NewConnectionSnippetDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    SimplePanel wrapper = new SimplePanel();
    wrapper.setStyleName(RES.styles().wrapper());
    Grid connGrid = new Grid(initialConfig_.size(), 2);
    connGrid.addStyleName(RES.styles().grid());
    for (int idxParams = 0; idxParams < initialConfig_.size(); idxParams++) {
        final String key = initialConfig_.get(idxParams).getKey();
        Label label = new Label(key + ":");
        label.addStyleName(RES.styles().label());
        connGrid.setWidget(idxParams, 0, label);
        connGrid.getRowFormatter().setVerticalAlign(idxParams, HasVerticalAlignment.ALIGN_TOP);
        final TextBox textbox = new TextBox();
        textbox.setText(initialConfig_.get(idxParams).getValue());
        textbox.addStyleName(RES.styles().textbox());
        connGrid.setWidget(idxParams, 1, textbox);
        textbox.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent arg0) {
                partsKeyValues_.put(key, textbox.getValue());
            }
        });
    }
    wrapper.add(connGrid);
    return wrapper;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Grid(com.google.gwt.user.client.ui.Grid) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) TextBox(com.google.gwt.user.client.ui.TextBox)

Example 28 with Grid

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

the class NewConnectionSnippetHost method createParameterizedUI.

private Grid createParameterizedUI(final NewConnectionInfo info) {
    final ArrayList<NewConnectionSnippetParts> snippetParts = parseSnippet(info.getSnippet());
    int visibleRows = snippetParts.size();
    int visibleParams = Math.min(visibleRows, maxRows_);
    // If we have a field that shares the first row, usually port:
    boolean hasSecondaryHeaderField = false;
    if (visibleParams >= 2 && snippetParts.get(0).getOrder() == snippetParts.get(1).getOrder()) {
        visibleRows--;
        visibleParams++;
        hasSecondaryHeaderField = true;
    }
    boolean showAdvancedButton = visibleRows > maxRows_;
    visibleRows = Math.min(visibleRows, maxRows_);
    final ArrayList<NewConnectionSnippetParts> secondarySnippetParts = new ArrayList<NewConnectionSnippetParts>(snippetParts.subList(visibleParams, snippetParts.size()));
    final Grid connGrid = new Grid(visibleRows + (showAdvancedButton ? 1 : 0), 4);
    connGrid.addStyleName(RES.styles().grid());
    connGrid.getCellFormatter().setWidth(0, 0, "150px");
    connGrid.getCellFormatter().setWidth(0, 1, "180px");
    connGrid.getCellFormatter().setWidth(0, 2, "60px");
    connGrid.getCellFormatter().setWidth(0, 3, "74px");
    for (int idxParams = 0, idxRow = 0; idxRow < visibleRows; idxParams++, idxRow++) {
        connGrid.getRowFormatter().setStyleName(idxRow, RES.styles().gridRow());
        final String key = snippetParts.get(idxParams).getKey();
        Label label = new Label(key + ":");
        label.addStyleName(RES.styles().label());
        connGrid.setWidget(idxRow, 0, label);
        connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
        String textboxStyle = RES.styles().textbox();
        if (idxRow == 0 && hasSecondaryHeaderField) {
            textboxStyle = RES.styles().firstTextbox();
        } else {
            connGrid.getCellFormatter().getElement(idxRow, 1).setAttribute("colspan", "4");
        }
        final TextBoxBase textboxBase;
        if (key.toLowerCase() == "parameters") {
            TextArea textarea = new TextArea();
            textarea.setVisibleLines(7);
            textarea.addStyleName(RES.styles().textarea());
            connGrid.setWidget(idxRow, 1, textarea);
            textboxBase = textarea;
        } else {
            TextBox textbox = new TextBox();
            textbox.setText(snippetParts.get(idxParams).getValue());
            textbox.addStyleName(textboxStyle);
            textboxBase = textbox;
        }
        connGrid.setWidget(idxRow, 1, textboxBase);
        textboxBase.addChangeHandler(new ChangeHandler() {

            @Override
            public void onChange(ChangeEvent arg0) {
                partsKeyValues_.put(key, textboxBase.getValue());
                updateCodePanel();
            }
        });
        if (idxRow == 0 && hasSecondaryHeaderField) {
            idxParams++;
            final String secondKey = snippetParts.get(idxParams).getKey();
            Label secondLabel = new Label(secondKey + ":");
            secondLabel.addStyleName(RES.styles().secondLabel());
            connGrid.setWidget(idxRow, 2, secondLabel);
            connGrid.getRowFormatter().setVerticalAlign(idxRow, HasVerticalAlignment.ALIGN_TOP);
            final TextBox secondTextbox = new TextBox();
            secondTextbox.setText(snippetParts.get(idxParams).getValue());
            secondTextbox.addStyleName(RES.styles().secondTextbox());
            connGrid.setWidget(idxRow, 3, secondTextbox);
            connGrid.getCellFormatter().getElement(idxRow, 3).setAttribute("colspan", "2");
            secondTextbox.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent arg0) {
                    partsKeyValues_.put(secondKey, secondTextbox.getValue());
                    updateCodePanel();
                }
            });
        }
    }
    if (showAdvancedButton) {
        ThemedButton pushButton = new ThemedButton("Advanced Options...", new ClickHandler() {

            public void onClick(ClickEvent event) {
                new NewConnectionSnippetDialog(new OperationWithInput<HashMap<String, String>>() {

                    @Override
                    public void execute(final HashMap<String, String> result) {
                        for (String key : result.keySet()) {
                            partsKeyValues_.put(key, result.get(key));
                        }
                        updateCodePanel();
                    }
                }, secondarySnippetParts, info).showModal();
            }
        });
        connGrid.getRowFormatter().setStyleName(visibleRows, RES.styles().lastRow());
        connGrid.getCellFormatter().getElement(visibleRows, 1).setAttribute("colspan", "4");
        connGrid.setWidget(visibleRows, 1, pushButton);
    }
    return connGrid;
}
Also used : TextArea(com.google.gwt.user.client.ui.TextArea) HashMap(java.util.HashMap) Grid(com.google.gwt.user.client.ui.Grid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) TextBox(com.google.gwt.user.client.ui.TextBox) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase) ThemedButton(org.rstudio.core.client.widget.ThemedButton) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler)

Example 29 with Grid

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

the class NewConnectionShinyHost method createWidget.

private Widget createWidget() {
    VerticalPanel container = new VerticalPanel();
    // create iframe for miniUI
    frame_ = new RStudioFrame();
    frame_.setSize("100%", "140px");
    container.add(frame_);
    // add the code panel     
    codePanel_ = new ConnectionCodePanel();
    codePanel_.addStyleName(RES.styles().dialogCodePanel());
    final Command updateCodeCommand = new Command() {

        @Override
        public void execute() {
            codePanel_.setCode("", null);
        }
    };
    updateCodeCommand.execute();
    Grid codeGrid = new Grid(1, 1);
    codeGrid.addStyleName(RES.styles().codeGrid());
    codeGrid.setCellPadding(0);
    codeGrid.setCellSpacing(0);
    codeGrid.setWidget(0, 0, codePanel_);
    container.add(codeGrid);
    return container;
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Command(com.google.gwt.user.client.Command) Grid(com.google.gwt.user.client.ui.Grid) RStudioFrame(org.rstudio.core.client.widget.RStudioFrame)

Example 30 with Grid

use of com.google.gwt.user.client.ui.Grid in project zxing by zxing.

the class WifiGenerator method getWidget.

@Override
public Grid getWidget() {
    if (table != null) {
        // early termination if the table has already been constructed
        return table;
    }
    table = new Grid(4, 2);
    table.setText(0, 0, "SSID");
    table.setWidget(0, 1, ssid);
    table.setText(1, 0, "Password");
    table.setWidget(1, 1, password);
    table.setText(2, 0, "Network Type");
    table.setWidget(2, 1, networkType);
    table.setText(3, 0, "Hidden?");
    table.setWidget(3, 1, hidden);
    ssid.addStyleName(StylesDefs.INPUT_FIELD_REQUIRED);
    return table;
}
Also used : Grid(com.google.gwt.user.client.ui.Grid)

Aggregations

Grid (com.google.gwt.user.client.ui.Grid)38 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)10 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)9 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)9 Label (com.google.gwt.user.client.ui.Label)7 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)7 Button (com.google.gwt.user.client.ui.Button)6 CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)6 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)5 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)5 ColumnFormatter (com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter)4 Image (com.google.gwt.user.client.ui.Image)4 CheckBox (com.google.gwt.user.client.ui.CheckBox)3 TextBox (com.google.gwt.user.client.ui.TextBox)3 GerritUiExtensionPoint (com.google.gerrit.client.GerritUiExtensionPoint)2 NativeString (com.google.gerrit.client.rpc.NativeString)2 HintTextBox (com.google.gerrit.client.ui.HintTextBox)2 OnEditEnabler (com.google.gerrit.client.ui.OnEditEnabler)2 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)2