Search in sources :

Example 21 with TextBox

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

the class CreateKeyDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    Styles styles = RESOURCES.styles();
    VerticalPanel panel = new VerticalPanel();
    panel.addStyleName(styles.mainWidget());
    VerticalPanel namePanel = new VerticalPanel();
    namePanel.setWidth("100%");
    // path
    CaptionWithHelp pathCaption = new CaptionWithHelp("The RSA key will be created at:", "SSH/RSA key management", "rsa_key_help");
    pathCaption.setIncludeVersionInfo(false);
    pathCaption.setWidth("100%");
    namePanel.add(pathCaption);
    TextBox txtKeyPath = new TextBox();
    txtKeyPath.addStyleName(styles.keyPathTextBox());
    txtKeyPath.setReadOnly(true);
    txtKeyPath.setText(rsaSshKeyPath_.getPath());
    txtKeyPath.setWidth("100%");
    namePanel.add(txtKeyPath);
    panel.add(namePanel);
    HorizontalPanel passphrasePanel = new HorizontalPanel();
    passphrasePanel.addStyleName(styles.newSection());
    VerticalPanel passphrasePanel1 = new VerticalPanel();
    Label passphraseLabel1 = new Label("Passphrase (optional):");
    passphraseLabel1.addStyleName(styles.entryLabel());
    passphrasePanel1.add(passphraseLabel1);
    txtPassphrase_ = new PasswordTextBox();
    txtPassphrase_.addStyleName(styles.passphrase());
    passphrasePanel1.add(txtPassphrase_);
    passphrasePanel.add(passphrasePanel1);
    VerticalPanel passphrasePanel2 = new VerticalPanel();
    passphrasePanel2.addStyleName(styles.lastSection());
    Label passphraseLabel2 = new Label("Confirm:");
    passphraseLabel2.addStyleName(styles.entryLabel());
    passphrasePanel2.add(passphraseLabel2);
    txtConfirmPassphrase_ = new PasswordTextBox();
    txtConfirmPassphrase_.addStyleName(styles.passphraseConfirm());
    passphrasePanel2.add(txtConfirmPassphrase_);
    passphrasePanel.add(passphrasePanel2);
    panel.add(passphrasePanel);
    return panel;
}
Also used : VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Label(com.google.gwt.user.client.ui.Label) CaptionWithHelp(org.rstudio.core.client.widget.CaptionWithHelp) TextBox(com.google.gwt.user.client.ui.TextBox) PasswordTextBox(com.google.gwt.user.client.ui.PasswordTextBox) PasswordTextBox(com.google.gwt.user.client.ui.PasswordTextBox)

Example 22 with TextBox

use of com.google.gwt.user.client.ui.TextBox 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 23 with TextBox

use of com.google.gwt.user.client.ui.TextBox 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 24 with TextBox

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

the class ChunkOptionsPopupPanel method makeInputBox.

private TextBox makeInputBox(final String option, final boolean enquote) {
    final TextBox box = new TextBox();
    box.getElement().setAttribute("placeholder", "Default");
    box.setWidth("40px");
    DomUtils.addKeyHandlers(box, new NativeEventHandler() {

        @Override
        public void onNativeEvent(NativeEvent event) {
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    String text = box.getText().trim();
                    boolean isEmpty = StringUtil.isNullOrEmpty(text);
                    if (enquote && !isEmpty) {
                        text = StringUtil.ensureQuoted(text);
                        text = text.replaceAll("\\\\", "\\\\\\\\");
                    }
                    if (isEmpty)
                        unset(option);
                    else
                        set(option, text);
                    synchronize();
                }
            });
        }
    });
    return box;
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) NativeEventHandler(org.rstudio.core.client.dom.DomUtils.NativeEventHandler) TextBox(com.google.gwt.user.client.ui.TextBox) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Example 25 with TextBox

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

the class AddRemoteDialog method textBox.

private TextBox textBox() {
    TextBox textBox = new TextBox();
    textBox.setWidth("260px");
    textBox.getElement().getStyle().setMarginBottom(6, Unit.PX);
    return textBox;
}
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