Search in sources :

Example 1 with SuggestBox

use of com.google.gwt.user.client.ui.SuggestBox in project opennms by OpenNMS.

the class VSearchBox method onLoad.

@Override
public void onLoad() {
    m_componentHolder.clear();
    this.setStyleName("topology-search");
    final TextBoxBase textField = new TextBox();
    textField.setWidth("245px");
    textField.setStyleName("topology-search-box");
    textField.getElement().setAttribute("placeholder", "Search...");
    textField.setFocus(true);
    RemoteSuggestOracle oracle = new RemoteSuggestOracle();
    m_suggestBox = new SuggestBox(oracle, textField);
    m_suggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() {

        @Override
        public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) {
            SearchSuggestion selectedItem = (SearchSuggestion) event.getSelectedItem();
            textField.setText("");
            m_connector.addToFocus(selectedItem);
        }
    });
    if (m_isMultiValued) {
        m_suggestBox.setStyleName("multivalue");
    }
    m_suggestBox.addStyleName("wideTextField");
    m_suggestBox.addSelectionHandler(this);
    m_suggestBox.addKeyUpHandler(this);
    m_componentHolder.setWidth("245px");
    m_componentHolder.add(m_suggestBox);
    if (m_focusedContainer == null) {
        m_focusedContainer = new VerticalPanel();
        m_scrollContainer = new FlowPanel();
        m_scrollContainer.add(m_focusedContainer);
    }
    m_focusedContainer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    m_focusedContainer.setTitle("Focused Vertices");
    m_componentHolder.add(m_scrollContainer);
    Timer timer = new Timer() {

        @Override
        public void run() {
            updateScrollPanelSize();
        }
    };
    timer.schedule(1000);
    m_windowResizeRegistration = Window.addResizeHandler(new ResizeHandler() {

        @Override
        public void onResize(ResizeEvent event) {
            updateScrollPanelSize();
        }
    });
}
Also used : TextBox(com.google.gwt.user.client.ui.TextBox) TextBoxBase(com.google.gwt.user.client.ui.TextBoxBase) ResizeEvent(com.google.gwt.event.logical.shared.ResizeEvent) SuggestBox(com.google.gwt.user.client.ui.SuggestBox) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) Timer(com.google.gwt.user.client.Timer) ResizeHandler(com.google.gwt.event.logical.shared.ResizeHandler) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 2 with SuggestBox

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

the class InstallPackageDialog method createMainWidget.

@Override
protected Widget createMainWidget() {
    // vertical panel
    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.setSpacing(2);
    mainPanel.setStylePrimaryName(RESOURCES.styles().mainWidget());
    // source type
    reposCaption_ = new CaptionWithHelp("Install from:", "Configuring Repositories", "configuring_repositories");
    reposCaption_.setIncludeVersionInfo(false);
    reposCaption_.setWidth("100%");
    mainPanel.add(reposCaption_);
    packageSourceListBox_ = new ListBox();
    packageSourceListBox_.setStylePrimaryName(RESOURCES.styles().packageSourceListBox());
    packageSourceListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString repos = installContext_.selectedRepositoryNames();
    if (repos.length() == 1) {
        packageSourceListBox_.addItem("Repository (" + repos.get(0) + ")");
    } else {
        StringBuilder reposItem = new StringBuilder();
        reposItem.append("Repository (");
        for (int i = 0; i < repos.length(); i++) {
            if (i != 0)
                reposItem.append(", ");
            reposItem.append(repos.get(i));
        }
        reposItem.append(")");
        packageSourceListBox_.addItem(reposItem.toString());
    }
    packageSourceListBox_.addItem("Package Archive File (" + installContext_.packageArchiveExtension() + ")");
    mainPanel.add(packageSourceListBox_);
    // source panel container
    sourcePanel_ = new SimplePanel();
    sourcePanel_.setStylePrimaryName(RESOURCES.styles().packageSourcePanel());
    // repos source panel
    reposSourcePanel_ = new FlowPanel();
    Label packagesLabel = new Label("Packages (separate multiple with space or comma):");
    packagesLabel.setStylePrimaryName(RESOURCES.styles().packagesLabel());
    reposSourcePanel_.add(packagesLabel);
    packagesTextBox_ = new MultipleItemSuggestTextBox();
    packagesSuggestBox_ = new SuggestBox(new PackageOracle(), packagesTextBox_);
    packagesSuggestBox_.setWidth("100%");
    packagesSuggestBox_.setLimit(20);
    packagesSuggestBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    reposSourcePanel_.add(packagesSuggestBox_);
    sourcePanel_.setWidget(reposSourcePanel_);
    mainPanel.add(sourcePanel_);
    // archive source panel
    packageArchiveFile_ = new TextBoxWithButton("Package archive:", "Browse...", browseForArchiveClickHandler_);
    // create check box here because manageUIState accesses it
    installDependenciesCheckBox_ = new CheckBox();
    if (defaultInstallOptions_.getInstallFromRepository())
        packageSourceListBox_.setSelectedIndex(0);
    else
        packageSourceListBox_.setSelectedIndex(1);
    manageUIState();
    packageSourceListBox_.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            manageUIState();
            if (!installFromRepository())
                packageArchiveFile_.click();
        }
    });
    mainPanel.add(new Label("Install to Library:"));
    // library list box
    libraryListBox_ = new ListBox();
    libraryListBox_.setWidth("100%");
    libraryListBox_.addStyleName(RESOURCES.styles().extraBottomPad());
    JsArrayString libPaths = installContext_.getWriteableLibraryPaths();
    int selectedIndex = 0;
    for (int i = 0; i < libPaths.length(); i++) {
        String libPath = libPaths.get(i);
        if (!installContext_.isDevModeOn()) {
            if (defaultInstallOptions_.getLibraryPath().equals(libPath))
                selectedIndex = i;
        }
        if (libPath.equals(installContext_.getDefaultLibraryPath()))
            libPath = libPath + " [Default]";
        libraryListBox_.addItem(libPath);
    }
    libraryListBox_.setSelectedIndex(selectedIndex);
    mainPanel.add(libraryListBox_);
    // install dependencies check box
    installDependenciesCheckBox_.addStyleName(RESOURCES.styles().installDependenciesCheckBox());
    installDependenciesCheckBox_.setText("Install dependencies");
    installDependenciesCheckBox_.setValue(defaultInstallOptions_.getInstallDependencies());
    mainPanel.add(installDependenciesCheckBox_);
    mainPanel.add(new HTML("<br/>"));
    return mainPanel;
}
Also used : MultipleItemSuggestTextBox(org.rstudio.core.client.widget.MultipleItemSuggestTextBox) Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) HTML(com.google.gwt.user.client.ui.HTML) JsArrayString(com.google.gwt.core.client.JsArrayString) JsArrayString(com.google.gwt.core.client.JsArrayString) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) SuggestBox(com.google.gwt.user.client.ui.SuggestBox) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) TextBoxWithButton(org.rstudio.core.client.widget.TextBoxWithButton) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) CaptionWithHelp(org.rstudio.core.client.widget.CaptionWithHelp) ListBox(com.google.gwt.user.client.ui.ListBox)

Example 3 with SuggestBox

use of com.google.gwt.user.client.ui.SuggestBox in project opentsdb by OpenTSDB.

the class MetricForm method assembleUi.

private void assembleUi() {
    setWidth("100%");
    {
        // Left hand-side panel.
        final HorizontalPanel hbox = new HorizontalPanel();
        final InlineLabel l = new InlineLabel();
        l.setText("Metric:");
        hbox.add(l);
        final SuggestBox suggest = RemoteOracle.newSuggestBox("metrics", metric);
        suggest.setLimit(40);
        hbox.add(suggest);
        hbox.setWidth("100%");
        metric.setWidth("100%");
        tagtable.setWidget(0, 0, hbox);
        tagtable.getFlexCellFormatter().setColSpan(0, 0, 3);
        addTag();
        tagtable.setText(1, 0, "Tags");
        add(tagtable);
    }
    {
        // Right hand-side panel.
        final VerticalPanel vbox = new VerticalPanel();
        {
            final HorizontalPanel hbox = new HorizontalPanel();
            hbox.add(rate);
            hbox.add(rate_counter);
            hbox.add(x1y2);
            vbox.add(hbox);
        }
        {
            final HorizontalPanel hbox = new HorizontalPanel();
            final InlineLabel l = new InlineLabel("Rate Ctr Max:");
            hbox.add(l);
            hbox.add(counter_max);
            vbox.add(hbox);
        }
        {
            final HorizontalPanel hbox = new HorizontalPanel();
            final InlineLabel l = new InlineLabel("Rate Ctr Reset:");
            hbox.add(l);
            hbox.add(counter_reset_value);
            vbox.add(hbox);
        }
        {
            final HorizontalPanel hbox = new HorizontalPanel();
            final InlineLabel l = new InlineLabel();
            l.setText("Aggregator:");
            hbox.add(l);
            hbox.add(aggregators);
            vbox.add(hbox);
        }
        vbox.add(downsample);
        {
            final HorizontalPanel hbox = new HorizontalPanel();
            hbox.add(downsampler);
            hbox.add(interval);
            hbox.add(fill_policy);
            vbox.add(hbox);
        }
        add(vbox);
    }
}
Also used : SuggestBox(com.google.gwt.user.client.ui.SuggestBox) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel)

Example 4 with SuggestBox

use of com.google.gwt.user.client.ui.SuggestBox in project opentsdb by OpenTSDB.

the class MetricForm method autoSuggestTag.

public void autoSuggestTag(final String tag) {
    // First try to see if the tag is already in the table.
    final int nrows = tagtable.getRowCount();
    int unused_row = -1;
    for (int row = 1; row < nrows; row++) {
        final SuggestBox tagname = ((SuggestBox) tagtable.getWidget(row, 1));
        final SuggestBox tagvalue = ((SuggestBox) tagtable.getWidget(row, 2));
        final String thistag = tagname.getValue();
        if (thistag.equals(tag)) {
            // This tag is already in the table.
            return;
        }
        if (thistag.isEmpty() && tagvalue.getValue().isEmpty()) {
            unused_row = row;
            break;
        }
    }
    if (unused_row >= 0) {
        ((SuggestBox) tagtable.getWidget(unused_row, 1)).setValue(tag);
    } else {
        addTag(tag);
    }
}
Also used : SuggestBox(com.google.gwt.user.client.ui.SuggestBox)

Example 5 with SuggestBox

use of com.google.gwt.user.client.ui.SuggestBox in project opentsdb by OpenTSDB.

the class MetricForm method addTag.

private void addTag(final String default_tagname, final String default_value, final boolean is_groupby) {
    final int row = tagtable.getRowCount();
    final ValidatedTextBox tagname = new ValidatedTextBox();
    final SuggestBox suggesttagk = RemoteOracle.newSuggestBox("tagk", tagname);
    final ValidatedTextBox tagvalue = new ValidatedTextBox();
    final SuggestBox suggesttagv = RemoteOracle.newSuggestBox("tagv", tagvalue);
    final CheckBox groupby = new CheckBox();
    groupby.setValue(is_groupby);
    groupby.setTitle("Group by");
    groupby.addClickHandler(events_handler);
    tagname.setValidationRegexp(TSDB_ID_RE);
    tagvalue.setValidationRegexp(TSDB_TAGVALUE_RE);
    tagname.setWidth("100%");
    tagvalue.setWidth("100%");
    tagname.addBlurHandler(recompact_tagtable);
    tagname.addBlurHandler(events_handler);
    tagname.addKeyPressHandler(events_handler);
    tagvalue.addBlurHandler(recompact_tagtable);
    tagvalue.addBlurHandler(events_handler);
    tagvalue.addKeyPressHandler(events_handler);
    tagtable.setWidget(row, 1, suggesttagk);
    tagtable.setWidget(row, 2, suggesttagv);
    tagtable.setWidget(row, 3, groupby);
    if (row > 2) {
        final Button remove = new Button("x");
        remove.addClickHandler(removetag);
        tagtable.setWidget(row - 1, 0, remove);
    }
    if (default_tagname != null) {
        tagname.setText(default_tagname);
        if (default_value == null) {
            tagvalue.setFocus(true);
        }
    }
    if (default_value != null) {
        tagvalue.setText(default_value);
    }
}
Also used : SuggestBox(com.google.gwt.user.client.ui.SuggestBox) Button(com.google.gwt.user.client.ui.Button) CheckBox(com.google.gwt.user.client.ui.CheckBox)

Aggregations

SuggestBox (com.google.gwt.user.client.ui.SuggestBox)7 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)3 CheckBox (com.google.gwt.user.client.ui.CheckBox)2 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 ResizeEvent (com.google.gwt.event.logical.shared.ResizeEvent)1 ResizeHandler (com.google.gwt.event.logical.shared.ResizeHandler)1 Timer (com.google.gwt.user.client.Timer)1 Button (com.google.gwt.user.client.ui.Button)1 HTML (com.google.gwt.user.client.ui.HTML)1 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)1 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)1 Label (com.google.gwt.user.client.ui.Label)1 ListBox (com.google.gwt.user.client.ui.ListBox)1 SimplePanel (com.google.gwt.user.client.ui.SimplePanel)1 DefaultSuggestionDisplay (com.google.gwt.user.client.ui.SuggestBox.DefaultSuggestionDisplay)1 TextBox (com.google.gwt.user.client.ui.TextBox)1 TextBoxBase (com.google.gwt.user.client.ui.TextBoxBase)1