void initContentOracle() { contentOracle = new MultiWordSuggestOracle(); contentSuggestBox = new SuggestBox(contentOracle); contentSuggestBox.getElement().setId("content-box"); // Some initial content xml strings contentOracle.add(""); contentOracle.add("abcd"); contentSuggestBox.addSelectionHandler(new SelectionHandler<SuggestOracle.Suggestion>() { @Override public void onSelection(SelectionEvent<SuggestOracle.Suggestion> event) { setFromContentBox(); } }); String[] extra = extendSampleContent(); if (extra != null) { for (String content : extra) { contentOracle.add(content); } } }
private void onKey(int key) { if (key == KeyCodes.KEY_ESCAPE) { setText(prevText); Widget p = getParent(); if (p instanceof SuggestBox) { // Since the text was changed, ensure that the SuggestBox is // aware of this change so that it will refresh properly on // the next keystroke. Without this, if the first keystroke // recreates the same string as before ESC was pressed, the // SuggestBox will think that the string has not changed, and // it will not yet provide any Suggestions. ((SuggestBox) p).showSuggestionList(); // The suggestion list lingers if we don't hide it. ((DefaultSuggestionDisplay) ((SuggestBox) p).getSuggestionDisplay()).hideSuggestions(); } setFocus(false); } }
EnumEditorViewImpl(final List<String> enumValues, final List<String> enumDescriptions) { // Sets up a SuggestOracle that, when the textbox has focus, displays the // valid enum values and their descriptions. MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); List<Suggestion> suggestions = Lists.newArrayList(); for (int i = 0; i < enumValues.size(); i++) { suggestions.add(new EnumSuggestion( enumValues.get(i), enumDescriptions == null ? "" : enumDescriptions.get(i))); } oracle.setDefaultSuggestions(suggestions); this.suggestBox = new SuggestBox(oracle); suggestBox.getTextBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { suggestBox.showSuggestionList(); } }); add(suggestBox); this.errorMessage = new Label("This parameter is invalid."); errorMessage.setVisible(false); add(errorMessage); }
public FullView(URLManipulator urlManipulator, AuthManager authManager, AnalyticsManager analytics, SuggestOracle searchKeywords) { this.analytics = analytics; this.presenter = new FullViewPresenter(urlManipulator, this); this.authManager = authManager; PlaceholderTextBox searchBackingTextBox = new PlaceholderTextBox("Search for services, methods, and recent requests..."); this.searchBox = new SuggestBox(searchKeywords, searchBackingTextBox); searchBox.setAutoSelectEnabled(false); initWidget(uiBinder.createAndBindUi(this)); setMenuActions(); // Add a fixed css class name that I can use to be able to style the menu. settingsMenu.setStyleName(SETTINGS_MENU_CSS_RULE + " " + settingsMenu.getStyleName()); // Set the style of the search box. searchBackingTextBox.setPlaceholderTextStyleName(style.searchPlaceholderText()); }
private void init(String value, Collection<String> suggestions, int maxLength) { if (maxLength > 0) { addErrorValidator(new StringMaxLengthValidator(maxLength)); } if (suggestions != null) { oracle.addAll(suggestions); oracle.setDefaultSuggestionsFromText(suggestions); } inititalValue = value; suggBox = new SuggestBox(oracle); suggBox.setText(value); suggBox.getTextBox().addFocusHandler(this); suggBox.getTextBox().addChangeHandler(this); suggBox.getTextBox().addValueChangeHandler(this); suggBox.getTextBox().addMouseUpHandler(this); suggBox.addValueChangeHandler(this); suggBox.addKeyUpHandler(this); suggBox.addSelectionHandler(this); suggBox.setStyleName("suggBox"); suggBox.setSize("300px", "18px"); panel.add(suggBox); }
/** * Initialize this example. */ @ShowcaseSource @Override public Widget onInitialize() { // Define the oracle that finds suggestions MultiWordSuggestOracle oracle = new MultiWordSuggestOracle(); String[] words = constants.cwSuggestBoxWords(); for (int i = 0; i < words.length; ++i) { oracle.add(words[i]); } // Create the suggest box final SuggestBox suggestBox = new SuggestBox(oracle); suggestBox.ensureDebugId("cwSuggestBox"); VerticalPanel suggestPanel = new VerticalPanel(); suggestPanel.add(new HTML(constants.cwSuggestBoxLabel())); suggestPanel.add(suggestBox); // Return the panel return suggestPanel; }
public StringMinLengthValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new IllegalArgumentException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public StringGtValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new IllegalArgumentException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public StringLtValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new IllegalArgumentException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public IntegerMaxValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new RuntimeException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public IntegerMaxValidator(SuggestBox suggest, int min, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new RuntimeException("suggest must not be null"); this.suggest = suggest; this.max = min; this.setCustomMsgKey(customMsgKey); }
public StringMaxLengthValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new IllegalArgumentException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public StringMaxLengthValidator(SuggestBox suggest, int min, int max, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new IllegalArgumentException("suggest must not be null"); this.suggest = suggest; setMax(max); this.setCustomMsgKey(customMsgKey); }
public IntegerMinValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new RuntimeException("suggest must not be null"); this.suggest = suggest; this.setCustomMsgKey(customMsgKey); }
public IntegerMinValidator(SuggestBox suggest, int min, boolean preventsPropagationOfValidationChain, String customMsgKey) { super(); this.setPreventsPropagationOfValidationChain(preventsPropagationOfValidationChain); if (suggest == null) throw new RuntimeException("suggest must not be null"); this.suggest = suggest; this.min = min; this.setCustomMsgKey(customMsgKey); }
private void setHandlerForSuggestBox(final SuggestBox suggestBox) { suggestBox.addSelectionHandler(new SelectionHandler<Suggestion>() { @Override public void onSelection(SelectionEvent<Suggestion> arg0) { String value = suggestBox.getText(); for (int i = 0; i < documentTypes.getItemCount(); i++) { if (documentTypes.getItemText(i).equalsIgnoreCase(value)) { ScreenMaskUtility.maskScreen(); onDocumentTypeChange(documentTypes.getValue(i)); break; } } } }); validatableSuggestBox = new ValidatableWidget<SuggestBox>(suggestBox); validatableSuggestBox.getWidget().addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { validatableSuggestBox.toggleValidDateBox(); } }); List<String> altValues = new ArrayList<String>(); for (int i = 0; i < documentTypes.getItemCount(); i++) { altValues.add(documentTypes.getItemText(i)); } validatableSuggestBox.addValidator(new SuggestBoxValidator(suggestBox, altValues)); validatableSuggestBox.toggleValidDateBox(); }
private void setSuggestBoxEvents(final Column column, final String originalString, final RegExValidatableWidget<SuggestBox> validatableSuggestBox) { int pos = originalString.lastIndexOf(SEPERATOR); int index = 0; String inputString = originalString; if (!(pos < 0)) { index = Integer.parseInt(inputString.substring(pos + ALTERNATE_STRING_VALUE.length() + SEPERATOR.length(), inputString .length())); inputString = inputString.substring(0, pos); } validatableSuggestBox.getWidget().setValue(inputString); validatableSuggestBox.toggleValidDateBox(); CoordinatesList coordinatesList = column.getCoordinatesList(); int count = 0; if (column.getAlternateValues() != null) { List<Field> alternativeFieldList = column.getAlternateValues().getAlternateValue(); for (Field alternateField : alternativeFieldList) { if (pos < 0) { if (alternateField.getValue().equals(inputString)) { TableExtractionView.this.fireEvent(new ValidationFieldChangeEvent(alternateField)); coordinatesList = alternateField.getCoordinatesList(); } } else { if (alternateField.getValue().equals(inputString)) { if (count == index) { TableExtractionView.this.fireEvent(new ValidationFieldChangeEvent(alternateField)); coordinatesList = alternateField.getCoordinatesList(); } count++; } } } } if (column.getValue().equals(originalString)) { TableExtractionView.this.fireEvent(new ValidationFieldChangeEvent(column)); } column.setCoordinatesList(coordinatesList); }
public NewSuggestTestField(AttributeValue v) { super(v.getLabel()); this.value = v; if (value.getCtrl().isReadonly()) { TextBox readOnlyBox = new TextBox(); addField(readOnlyBox); baseField.setStyleName("mdv-form-input-readonly"); setRequired(false); } else { MultiWordStartSuggestOracle oracle = new MultiWordStartSuggestOracle(); if (this.value.getCtrl() instanceof TextAttributeControl) { TextAttributeControl tCtrl = (TextAttributeControl)this.value.getCtrl(); List values = tCtrl.getAvailableValues(); if (values != null) { for (Iterator iter = values.iterator(); iter.hasNext();) { Object suggestValue = iter.next(); oracle.addSuggestion(suggestValue.toString()); } } } suggestBox = new SuggestBox(oracle); suggestBox.setText(value.getStringValue()); suggestBox.addKeyboardListener(this); setRequired(value.getCtrl().isRequiered()); addField(suggestBox); } }
public MoveDialog(Project.NameKey project) { super(Util.C.moveTitle(), Util.C.moveChangeMessage()); ProjectApi.getBranches( project, new GerritCallback<JsArray<BranchInfo>>() { @Override public void onSuccess(JsArray<BranchInfo> result) { branches = Natives.asList(result); } }); newBranch = new SuggestBox( new HighlightSuggestOracle() { @Override protected void onRequestSuggestions(Request request, Callback done) { List<BranchSuggestion> suggestions = new ArrayList<>(); for (BranchInfo b : branches) { if (b.ref().contains(request.getQuery())) { suggestions.add(new BranchSuggestion(b)); } } done.onSuggestionsReady(request, new Response(suggestions)); } }); newBranch.setWidth("100%"); newBranch.getElement().getStyle().setProperty("boxSizing", "border-box"); message.setCharacterWidth(70); FlowPanel mwrap = new FlowPanel(); mwrap.setStyleName(Gerrit.RESOURCES.css().commentedActionMessage()); mwrap.add(newBranch); panel.insert(mwrap, 0); panel.insert(new SmallHeading(Util.C.headingMoveBranch()), 0); }
public CherryPickDialog(Project.NameKey project) { super(Util.C.cherryPickTitle(), Util.C.cherryPickCommitMessage()); ProjectApi.getBranches( project, new GerritCallback<JsArray<BranchInfo>>() { @Override public void onSuccess(JsArray<BranchInfo> result) { branches = Natives.asList(result); } }); newBranch = new SuggestBox( new HighlightSuggestOracle() { @Override protected void onRequestSuggestions(Request request, Callback done) { List<BranchSuggestion> suggestions = new ArrayList<>(); for (BranchInfo b : branches) { if (b.ref().contains(request.getQuery())) { suggestions.add(new BranchSuggestion(b)); } } done.onSuggestionsReady(request, new Response(suggestions)); } }); newBranch.setWidth("100%"); newBranch.getElement().getStyle().setProperty("boxSizing", "border-box"); message.setCharacterWidth(70); final FlowPanel mwrap = new FlowPanel(); mwrap.setStyleName(Gerrit.RESOURCES.css().commentedActionMessage()); mwrap.add(newBranch); panel.insert(mwrap, 0); panel.insert(new SmallHeading(Util.C.headingCherryPickBranch()), 0); }
public SearchWidget(MainWidget master) { this.master = master; panel = new VerticalPanel(); searchbar = new HorizontalPanel(); searchbar.setHeight("100px"); scrollable = new ScrollPanel(); scrollable.setHeight("400px"); oracle = new MultiWordSuggestOracle(); box = new SuggestBox(oracle); b = new Button("Search"); box.setWidth("200px"); lbl = new Label("Enter Search Criteria"); BuildUI(); }
@Override protected void showSuggestions(SuggestBox suggestBox, Collection<? extends Suggestion> suggestions, boolean isDisplayStringHTML, boolean isAutoSelectEnabled, SuggestionCallback callback) { getPopupPanel().getWidget().setWidth(suggestBox.getElement().getScrollWidth() + Unit.PX.getType()); getPopupPanel().getWidget().getElement().getStyle().setProperty("maxHeight", Math.max(DISPLAY_BOX_MIN_HEIGHT, suggestBox.getElement().getAbsoluteTop() - DISPLAY_BOX_TOP_PADDING) + Unit.PX.getType()); super.showSuggestions(suggestBox, suggestions, isDisplayStringHTML, isAutoSelectEnabled, callback); if (isSuggestionListShowing()) { popupHideTimer.cancel(); paletteShouldIgnoreMouseClicks = true; } }
public PlaygroundUI(MultiWordSuggestOracle sourceSuggestions, MultiWordSuggestOracle policySuggestions) { addressField = new SuggestBox(sourceSuggestions); policyAddressField = new SuggestBox(policySuggestions); initWidget(UI_BINDER.createAndBindUi(this)); }
public SuggestBoxItem(String s, String s1, SuggestOracle suggestOracle) { super(s, s1); suggestBoxField = new SuggestBox(suggestOracle); suggestBoxField.setStyleName("gwt-SuggestBox"); suggestBoxField.setHeight(getHeight() + "px"); canvas.setHeight(getHeight()); canvas.setStyleName("gwt-SuggestBoxCanvas"); canvas.addChild(suggestBoxField); setCanvas(canvas); }
Panel createInputPanel(){ Grid inputGrid = new Grid(2, 2); final NpTextBox filterBox = new NpTextBox(); filterBox.getElement().setPropertyString("placeholder", "filter"); inputGrid.setText(0, 0, "Filter: "); inputGrid.setWidget(0, 1, filterBox); // TODO(davido): Remove hard coded start suggest char 3 final ReviewerSuggestOracle oracle = new ReviewerSuggestOracle(3, projectName); final SuggestBox reviewerBox = new SuggestBox(oracle, new NpTextBox()); reviewerBox.getElement().setPropertyString("placeholder", "reviewer"); inputGrid.setText(1, 0, "Reviewer: "); inputGrid.setWidget(1, 1, reviewerBox); Button addButton = new Button("Add"); addButton.setStyleName("reviewers-addButton"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { ReviewerEntry e = new ReviewerEntry(filterBox.getValue(), reviewerBox.getValue()); if (!rEntries.contains(e) && !e.filter.isEmpty() && !e.reviewer.isEmpty()) { doSave(Action.ADD, e); } filterBox.setText(""); reviewerBox.setText(""); } }); filterBox.setEnabled(isOwner); reviewerBox.setEnabled(isOwner); addButton.setEnabled(isOwner); Panel p = new VerticalPanel(); p.setStyleName("reviewers-inputPanel"); p.add(inputGrid); p.add(addButton); return p; }
@Override public void init(SolrCore solrCore) { setActive(solrCore.getConfiguration().isActive(TermsConfig.class)); if (!isActive()) { searchPane.setSearchTextBox(new TextBox()); return; } oracle = new SuggestOracle() { public void requestSuggestions(final Request request, final Callback callback) { findSuggestions(request.getQuery(), new org.apache.solr.explorer.client.util.Callback<List<Suggestion>>() { public void onSuccess(List<Suggestion> suggestions) { callback.onSuggestionsReady(request, new Response(suggestions)); } }); } }; suggestBox = new SuggestBox(oracle); suggestBox.setPopupStyleName("AutoCompletionPopup"); suggestBox.addKeyDownHandler(new EnterKeyHandler() { @Override protected void onEnter(KeyDownEvent keyDownEvent) { if (!suggestBox.isSuggestionListShowing()) { searchPane.executeSearch(); } } }); suggestBox.setAutoSelectEnabled(false); suggestBox.setAnimationEnabled(true); searchPane.setSearchTextBox(suggestBox); }
public AutoSuggestTextEditor(SuggestOracle oracle, String defaultText, boolean enabled) { box = new SuggestBox(oracle); box.setPopupStyleName("AutoCompletionPopup"); box.setAnimationEnabled(true); box.setText(defaultText == null ? "" : defaultText); box.getTextBox().setEnabled(enabled); }
public StringMinLengthValidator(SuggestBox suggest) { this(suggest, false); }
public StringMinLengthValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain) { this(suggest, preventsPropagationOfValidationChain, null); }
public StringGtValidator(SuggestBox suggest) { this(suggest, false); }
public StringGtValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain) { this(suggest, preventsPropagationOfValidationChain, null); }
public StringLtValidator(SuggestBox suggest) { this(suggest, false); }
public StringLtValidator(SuggestBox suggest, boolean preventsPropagationOfValidationChain) { this(suggest, preventsPropagationOfValidationChain, null); }
public IntegerMaxValidator(SuggestBox suggest) { this(suggest, null); }
public IntegerMaxValidator(SuggestBox suggest, String customMsgKey) { this(suggest, false); this.setCustomMsgKey(customMsgKey); }
public IntegerMaxValidator(SuggestBox suggest, int min) { this(suggest, min, false); }