Search in sources :

Example 26 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project rstudio by rstudio.

the class EditSnippetsDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    panel_ = new DockLayoutPanel(Unit.PX);
    // compute the widget size and set it
    Size size = new Size(900, 900);
    size = DomMetrics.adjustedElementSize(size, null, // pad
    70, // client margin
    100);
    panel_.setWidth(size.width + "px");
    panel_.setHeight(size.height + "px");
    // snippet types
    snippetTypes_ = new WidgetListBox<EditableSnippets>();
    snippetTypes_.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            updateEditor(snippetTypes_.getSelectedItem());
        }
    });
    snippetTypes_.addItem(new EditableSnippets("R", FileTypeRegistry.R));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.CPP));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.MARKDOWN));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.TEX));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.JS));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.HTML));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.CSS));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.SQL));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.JAVA));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.PYTHON));
    snippetTypes_.addItem(new EditableSnippets(FileTypeRegistry.STAN));
    panel_.addWest(snippetTypes_, 150);
    // editor
    docDisplay_ = new AceEditor();
    docDisplay_.setUseSoftTabs(false);
    docDisplay_.setTabSize(uiPrefs_.numSpacesForTab().getValue());
    docDisplay_.addValueChangeHandler(new ValueChangeHandler<Void>() {

        @Override
        public void onValueChange(ValueChangeEvent<Void> event) {
            editorDirty_ = true;
        }
    });
    docDisplay_.setFileType(FileTypeRegistry.SNIPPETS);
    SimplePanel panel = new SimplePanel();
    panel.addStyleName("EditDialog");
    panel.getElement().getStyle().setMarginLeft(8, Unit.PX);
    panel.setWidget(docDisplay_.asWidget());
    panel_.add(panel);
    TextEditingTarget.syncFontSize(releaseOnDismiss_, events_, this, fontSizeManager_);
    snippetTypes_.setSelectedIndex(0, true);
    return panel_;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) DockLayoutPanel(com.google.gwt.user.client.ui.DockLayoutPanel) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Size(org.rstudio.core.client.Size) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) AceEditor(org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor) Void(org.rstudio.studio.client.server.Void)

Example 27 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent 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 ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent 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 ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project rstudio by rstudio.

the class DataImportOptionsUiCsv method initEvents.

void initEvents() {
    ValueChangeHandler<String> valueChangeHandler = new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ChangeHandler changeHandler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ChangeHandler delimChangeHandler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            if (delimiterListBox_.getSelectedValue() == "other") {
                globalDisplay_.promptForTextWithOption("Other Delimiter", "Please enter a single character delimiter.", "", false, "", false, new ProgressOperationWithInput<PromptWithOptionResult>() {

                    private void dismissAndUpdate(ProgressIndicator indicator, int newSelectIndex) {
                        lastDelimiterListBoxIndex_ = newSelectIndex;
                        delimiterListBox_.setSelectedIndex(newSelectIndex);
                        indicator.onCompleted();
                        updateEnabled();
                        triggerChange();
                    }

                    @Override
                    public void execute(PromptWithOptionResult result, ProgressIndicator indicator) {
                        String otherDelimiter = result.input;
                        if (otherDelimiter.length() != 1) {
                            globalDisplay_.showErrorMessage("Incorrect Delimiter", "The specified delimiter is not valid.");
                        } else {
                            for (int idxDelimiter = 0; idxDelimiter < delimiterListBox_.getItemCount(); idxDelimiter++) {
                                if (delimiterListBox_.getValue(idxDelimiter) == otherDelimiter) {
                                    dismissAndUpdate(indicator, idxDelimiter);
                                    return;
                                }
                            }
                            int selectedIndex = delimiterListBox_.getSelectedIndex();
                            delimiterListBox_.insertItem("Character " + otherDelimiter, otherDelimiter, selectedIndex - 1);
                            dismissAndUpdate(indicator, selectedIndex - 1);
                        }
                    }
                }, new Operation() {

                    @Override
                    public void execute() {
                        delimiterListBox_.setSelectedIndex(lastDelimiterListBoxIndex_);
                        updateEnabled();
                        triggerChange();
                    }
                });
            } else {
                lastDelimiterListBoxIndex_ = delimiterListBox_.getSelectedIndex();
                updateEnabled();
                triggerChange();
            }
        }
    };
    ValueChangeHandler<Boolean> booleanValueChangeHandler = new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    nameTextBox_.addValueChangeHandler(valueChangeHandler);
    delimiterListBox_.addChangeHandler(delimChangeHandler);
    quotesListBox_.addChangeHandler(changeHandler);
    escapeListBox_.addChangeHandler(changeHandler);
    columnNamesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    trimSpacesCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    openDataViewerCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
    naListBox_.addChangeHandler(changeHandler);
    commentListBox_.addChangeHandler(changeHandler);
    skipTextBox_.addValueChangeHandler(valueChangeHandler);
    localeButton_.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            new DataImportOptionsUiCsvLocale(new OperationWithInput<DataImportOptionsCsvLocale>() {

                @Override
                public void execute(final DataImportOptionsCsvLocale result) {
                    localeInfo_ = result;
                    updateEnabled();
                    triggerChange();
                }
            }, localeInfo_).showModal();
        }
    });
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) Operation(org.rstudio.core.client.widget.Operation) PromptWithOptionResult(org.rstudio.core.client.MessageDisplay.PromptWithOptionResult) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator)

Example 30 with ChangeEvent

use of com.google.gwt.event.dom.client.ChangeEvent in project rstudio by rstudio.

the class DataImportOptionsUiSav method initEvents.

void initEvents() {
    ValueChangeHandler<String> valueChangeHandler = new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(ValueChangeEvent<String> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ChangeHandler changeHandler = new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    ValueChangeHandler<Boolean> booleanValueChangeHandler = new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> arg0) {
            updateEnabled();
            triggerChange();
        }
    };
    nameTextBox_.addValueChangeHandler(valueChangeHandler);
    formatListBox_.addChangeHandler(changeHandler);
    openDataViewerCheckBox_.addValueChangeHandler(booleanValueChangeHandler);
}
Also used : ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler)

Aggregations

ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)58 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)58 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)31 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)31 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)31 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)28 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ArrayList (java.util.ArrayList)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)20 PerunError (cz.metacentrum.perun.webgui.model.PerunError)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 HashMap (java.util.HashMap)10 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)8 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)8 Map (java.util.Map)7 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)6 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)6 SetNewAttributeTabItem (cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem)6 ListBox (com.google.gwt.user.client.ui.ListBox)5