List of usage examples for com.google.gwt.user.client.ui SuggestOracle SuggestOracle
public SuggestOracle()
From source file:org.freemedsoftware.gwt.client.widget.PatientTagWidget.java
License:Open Source License
public PatientTagWidget() { // Log.setUncaughtExceptionHandler(); map = new HashMap<String, String>(); layout = new VerticalPanel(); textBox = new TextBox(); searchBox = new SuggestBox(new SuggestOracle() { public void requestSuggestions(Request r, Callback cb) { loadSuggestions(r.getQuery(), r, cb); }/*w w w . jav a2s .c om*/ }, textBox); searchBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { // Window.alert("Here be the new value:" + event.getValue()); } }); searchBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { int keyCode = event.getNativeKeyCode(); switch (keyCode) { case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_BACKSPACE: // Clear any current values searchBox.setText(""); searchBox.setTitle(""); setValue(""); textBox.cancelKey(); break; default: // Ignore any other keystroke break; } } }); searchBox.addSelectionHandler(new SelectionHandler<Suggestion>() { @Override public void onSelection(SelectionEvent<Suggestion> event) { Suggestion s = (Suggestion) event.getSelectedItem(); value = s.getDisplayString(); setTitle(s.getDisplayString()); onSelected(); } }); searchBox.setLimit(10); searchBox.setAnimationEnabled(true); layout.add(searchBox); initWidget(layout); }
From source file:org.rstudio.core.client.widget.FilterWidget.java
License:Open Source License
public FilterWidget(String placeholder) { SuggestOracle oracle = new SuggestOracle() { @Override//from www . j a va 2s . c o m public void requestSuggestions(Request request, Callback callback) { } }; searchWidget_ = new SearchWidget(oracle); searchWidget_.setPlaceholderText(placeholder); searchWidget_.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { filter(event.getValue()); } }); initWidget(searchWidget_); }
From source file:org.rstudio.core.client.widget.ModifyKeyboardShortcutsWidget.java
License:Open Source License
public ModifyKeyboardShortcutsWidget(String filterText) { RStudioGinjector.INSTANCE.injectMembers(this); initialFilterText_ = filterText;//from ww w. j av a2s . c o m shortcuts_ = ShortcutManager.INSTANCE; changes_ = new HashMap<KeyboardShortcutEntry, KeyboardShortcutEntry>(); buffer_ = new KeySequence(); table_ = new DataGrid<KeyboardShortcutEntry>(1000, RES, KEY_PROVIDER); FlowPanel emptyWidget = new FlowPanel(); Label emptyLabel = new Label("No bindings available"); emptyLabel.getElement().getStyle().setMarginTop(20, Unit.PX); emptyLabel.getElement().getStyle().setColor("#888"); emptyWidget.add(emptyLabel); table_.setEmptyTableWidget(emptyWidget); table_.setWidth("700px"); table_.setHeight("400px"); // Add a 'global' click handler that performs a row selection regardless // of the cell clicked (it seems GWT clicks can be 'fussy' about whether // you click on the contents of a cell vs. the '<td>' element itself) table_.addDomHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { Element el = event.getNativeEvent().getEventTarget().cast(); Element rowEl = DomUtils.findParentElement(el, new ElementPredicate() { @Override public boolean test(Element el) { return el.getTagName().toLowerCase().equals("tr"); } }); if (rowEl == null) return; if (rowEl.hasAttribute("__gwt_row")) { int row = StringUtil.parseInt(rowEl.getAttribute("__gwt_row"), -1); if (row != -1) { event.stopPropagation(); event.preventDefault(); table_.setKeyboardSelectedRow(row); table_.setKeyboardSelectedColumn(0); } } } }, ClickEvent.getType()); table_.setKeyboardSelectionHandler(new CellPreviewEvent.Handler<KeyboardShortcutEntry>() { private final AbstractCellTable.CellTableKeyboardSelectionHandler<KeyboardShortcutEntry> handler_ = new AbstractCellTable.CellTableKeyboardSelectionHandler<KeyboardShortcutEntry>( table_); @Override public void onCellPreview(CellPreviewEvent<KeyboardShortcutEntry> preview) { NativeEvent event = preview.getNativeEvent(); int code = event.getKeyCode(); // Don't let arrow keys change the selection when a shortcut cell // has been selected. if (preview.getColumn() == 1) { if (code == KeyCodes.KEY_UP || code == KeyCodes.KEY_DOWN || code == KeyCodes.KEY_LEFT || code == KeyCodes.KEY_RIGHT) { return; } } // Also disable 'left', 'right' keys as they can 'navigate' the widget // into an unusable state. if (code == KeyCodes.KEY_LEFT || code == KeyCodes.KEY_RIGHT) { return; } handler_.onCellPreview(preview); } }); dataProvider_ = new ListDataProvider<KeyboardShortcutEntry>(); dataProvider_.addDataDisplay(table_); addColumns(); addHandlers(); setText("Keyboard Shortcuts"); addOkButton(new ThemedButton("Apply", new ClickHandler() { @Override public void onClick(ClickEvent event) { applyChanges(); } })); addCancelButton(); radioAll_ = radioButton("All", new ClickHandler() { @Override public void onClick(ClickEvent event) { filter(); } }); radioCustomized_ = radioButton("Customized", new ClickHandler() { @Override public void onClick(ClickEvent event) { filter(); } }); filterWidget_ = new SearchWidget(new SuggestOracle() { @Override public void requestSuggestions(Request request, Callback callback) { callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); filterWidget_.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { filter(); } }); filterWidget_.setPlaceholderText("Filter..."); addLeftWidget(new ThemedButton("Reset...", new ClickHandler() { @Override public void onClick(ClickEvent event) { globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Reset Keyboard Shortcuts", "Are you sure you want to reset keyboard shortcuts to their default values? " + "This action cannot be undone.", new ProgressOperation() { @Override public void execute(final ProgressIndicator indicator) { indicator.onProgress("Resetting Keyboard Shortcuts..."); appCommands_.resetBindings(new CommandWithArg<EditorKeyBindings>() { @Override public void execute(EditorKeyBindings appBindings) { editorCommands_.resetBindings(new Command() { @Override public void execute() { addins_.resetBindings(new Command() { @Override public void execute() { indicator.onCompleted(); ShortcutManager.INSTANCE.resetAppCommandBindings(); resetState(); } }); } }); } }); } }, false); } })); }
From source file:org.rstudio.studio.client.dataviewer.DataTable.java
License:Open Source License
public void initToolbar(Toolbar toolbar) { filterButton_ = new LatchingToolbarButton("Filter", DataViewerResources.INSTANCE.filterIcon(), new ClickHandler() { public void onClick(ClickEvent event) { boolean newFilterState = !filtered_; // attempt to apply the new filter state, and update state // if we succeed (might fail if the filter UI is not // ready/table is not initialized) if (setFilterUIVisible(newFilterState)) { filtered_ = newFilterState; filterButton_.setLatched(filtered_); }/*w w w . ja v a 2 s .c o m*/ } }); toolbar.addLeftWidget(filterButton_); searchWidget_ = new SearchWidget(new SuggestOracle() { @Override public void requestSuggestions(Request request, Callback callback) { // no suggestions callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); searchWidget_.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { applySearch(getWindow(), event.getValue()); } }); toolbar.addRightWidget(searchWidget_); }
From source file:org.rstudio.studio.client.workbench.views.connections.ui.ConnectionsPane.java
License:Open Source License
@Override protected Toolbar createMainToolbar() { toolbar_ = new Toolbar(); searchWidget_ = new SearchWidget(new SuggestOracle() { @Override//ww w . j a v a2s.co m public void requestSuggestions(Request request, Callback callback) { // no suggestions callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); backToConnectionsButton_ = new ToolbarButton(commands_.helpBack().getImageResource(), (ClickHandler) null); backToConnectionsButton_.setTitle("View all connections"); // connect meuu ToolbarPopupMenu connectMenu = new ToolbarPopupMenu(); connectMenu.addItem(connectMenuItem(commands_.historySendToConsole().getImageResource(), "R Console", ConnectionOptions.CONNECT_R_CONSOLE)); connectMenu.addSeparator(); connectMenu.addItem(connectMenuItem(commands_.newSourceDoc().getImageResource(), "New R Script", ConnectionOptions.CONNECT_NEW_R_SCRIPT)); connectMenu.addItem(connectMenuItem(commands_.newRNotebook().getImageResource(), "New R Notebook", ConnectionOptions.CONNECT_NEW_R_NOTEBOOK)); if (BrowseCap.INSTANCE.canCopyToClipboard()) { connectMenu.addSeparator(); connectMenu.addItem(connectMenuItem(commands_.copyPlotToClipboard().getImageResource(), "Copy to Clipboard", ConnectionOptions.CONNECT_COPY_TO_CLIPBOARD)); } connectMenuButton_ = new ToolbarButton("Connect", commands_.newConnection().getImageResource(), connectMenu); // manage connect menu visibility connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible()); commands_.disconnectConnection().addVisibleChangedHandler(new VisibleChangedHandler() { @Override public void onVisibleChanged(AppCommand command) { connectMenuButton_.setVisible(!commands_.disconnectConnection().isVisible()); } }); installConnectionsToolbar(); return toolbar_; }
From source file:org.rstudio.studio.client.workbench.views.environment.EnvironmentPane.java
License:Open Source License
@Override protected SecondaryToolbar createSecondaryToolbar() { SecondaryToolbar toolbar = new SecondaryToolbar(); environmentMenu_ = new EnvironmentPopupMenu(); environmentButton_ = new ToolbarButton(friendlyEnvironmentName(), imageOfEnvironment(environmentName_, environmentIsLocal_), environmentMenu_); toolbar.addLeftWidget(environmentButton_); SearchWidget searchWidget = new SearchWidget(new SuggestOracle() { @Override/*w w w . ja v a 2s.co m*/ public void requestSuggestions(Request request, Callback callback) { // no suggestions callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); searchWidget.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { objects_.setFilterText(event.getValue()); } }); searchWidget.getElement().getStyle().setMarginTop(1, Unit.PX); toolbar.addRightWidget(searchWidget); return toolbar; }
From source file:org.rstudio.studio.client.workbench.views.history.view.HistoryPane.java
License:Open Source License
@Override protected Toolbar createMainToolbar() { searchWidget_ = new SearchWidget(new SuggestOracle() { @Override//from w w w. j a va 2 s .c o m public void requestSuggestions(Request request, Callback callback) { callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); searchWidget_.addKeyDownHandler(new KeyDownHandler() { public void onKeyDown(KeyDownEvent event) { getActiveHistory().getKeyTarget().fireEvent(event); } }); searchWidget_.addSelectionCommitHandler(new SelectionCommitHandler<String>() { public void onSelectionCommit(SelectionCommitEvent<String> event) { if (mode_ == Mode.SearchResults) fireEvent(event); } }); searchWidget_.addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { commandList_.getFocusTarget().addClassName(styles_.fakeFocus()); searchResults_.getFocusTarget().addClassName(styles_.fakeFocus()); contextResults_.getFocusTarget().addClassName(styles_.fakeFocus()); } }); searchWidget_.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { commandList_.getFocusTarget().removeClassName(styles_.fakeFocus()); searchResults_.getFocusTarget().removeClassName(styles_.fakeFocus()); contextResults_.getFocusTarget().removeClassName(styles_.fakeFocus()); } }); Toolbar toolbar = new Toolbar(); toolbar.addLeftWidget(commands_.loadHistory().createToolbarButton()); toolbar.addLeftWidget(commands_.saveHistory().createToolbarButton()); toolbar.addLeftSeparator(); toolbar.addLeftWidget(commands_.historySendToConsole().createToolbarButton()); toolbar.addLeftSeparator(); toolbar.addLeftWidget(commands_.historySendToSource().createToolbarButton()); toolbar.addLeftSeparator(); toolbar.addLeftWidget(commands_.historyRemoveEntries().createToolbarButton()); toolbar.addLeftWidget(commands_.clearHistory().createToolbarButton()); toolbar.addRightWidget(searchWidget_); return toolbar; }
From source file:org.rstudio.studio.client.workbench.views.packages.PackagesPane.java
License:Open Source License
@Override protected Toolbar createMainToolbar() { Toolbar toolbar = new Toolbar(); // install packages toolbar.addLeftWidget(commands_.installPackage().createToolbarButton()); toolbar.addLeftSeparator();//from w ww . j ava 2s. c o m // update packages toolbar.addLeftWidget(commands_.updatePackages().createToolbarButton()); prePackratSeparator_ = toolbar.addLeftSeparator(); // packrat (all packrat UI starts out hidden and then appears // in response to changes in the packages state) // create packrat bootstrap button packratBootstrapButton_ = commands_.packratBootstrap().createToolbarButton(false); toolbar.addLeftWidget(packratBootstrapButton_); packratBootstrapButton_.setVisible(false); // create packrat menu + button ToolbarPopupMenu packratMenu = new ToolbarPopupMenu(); packratMenu.addItem(commands_.packratHelp().createMenuItem(false)); packratMenu.addSeparator(); packratMenu.addItem(commands_.packratClean().createMenuItem(false)); packratMenu.addItem(commands_.packratBundle().createMenuItem(false)); packratMenu.addSeparator(); packratMenu.addItem(commands_.packratOptions().createMenuItem(false)); packratMenuButton_ = new ToolbarButton("Packrat", commands_.packratBootstrap().getImageResource(), packratMenu); toolbar.addLeftWidget(packratMenuButton_); packratMenuButton_.setVisible(false); packratSeparator_ = toolbar.addLeftSeparator(); packratSeparator_.setVisible(false); toolbar.addLeftWidget(commands_.refreshPackages().createToolbarButton()); searchWidget_ = new SearchWidget(new SuggestOracle() { @Override public void requestSuggestions(Request request, Callback callback) { // no suggestions callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); searchWidget_.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> event) { observer_.onPackageFilterChanged(event.getValue().trim()); } }); toolbar.addRightWidget(searchWidget_); return toolbar; }
From source file:org.rstudio.studio.client.workbench.views.source.editors.explorer.view.ObjectExplorerEditingTargetWidget.java
License:Open Source License
public ObjectExplorerEditingTargetWidget(ObjectExplorerHandle handle, SourceDocument document) { RStudioGinjector.INSTANCE.injectMembers(this); mainWidget_ = new DockLayoutPanel(Unit.PX); toolbar_ = new EditingTargetToolbar(commands_, true); grid_ = new ObjectExplorerDataGrid(handle, document); resizePanel_ = new ResizeLayoutPanel(); cbAttributes_ = new CheckBox(); refreshButton_ = new ToolbarButton(RES.refresh2x(), new ClickHandler() { @Override/* w w w .j a va2 s. c o m*/ public void onClick(ClickEvent event) { grid_.refresh(); } }); filterWidget_ = new SearchWidget(new SuggestOracle() { @Override public void requestSuggestions(Request request, Callback callback) { } }); initToolbar(); initMainWidget(); PanelWithToolbars panel = new PanelWithToolbars(toolbar_, mainWidget_); initWidget(panel); }
From source file:org.rstudio.studio.client.workbench.views.workspace.dataimport.ImportGoogleSpreadsheetDialog.java
License:Open Source License
@Override protected Widget createMainWidget() { Resources res = GWT.create(Resources.class); Styles styles = res.styles();//from w w w. ja v a2s. c om // initialize list box table_ = new GoogleSpreadsheetTable(styles.selected(), styles.date(), styles.spreadsheetIcon(), styles.iconCell()); table_.setStyleName(styles.table()); table_.setWidth("100%"); table_.addSelectionChangedHandler(new SelectionChangedHandler() { public void onSelectionChanged(SelectionChangedEvent e) { maybeUpdateVarName(); } }); // disable controls until we get the list enableControls(false); // return list box scrollPanel_ = new ScrollPanel(table_); scrollPanel_.setStyleName(styles.scrollPanel()); scrollPanel_.setSize("100%", "100%"); progressPanel_ = new SimplePanelWithProgress(); progressPanel_.setStyleName(styles.progressPanel()); progressPanel_.showProgress(1); progressPanel_.setSize("500px", "300px"); final SearchWidget search = new SearchWidget(new SuggestOracle() { @Override public void requestSuggestions(Request request, Callback callback) { callback.onSuggestionsReady(request, new Response(new ArrayList<Suggestion>())); } }); search.addStyleName(styles.googleSpreadsheetSearch()); search.addValueChangeHandler(new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> stringValueChangeEvent) { progressPanel_.showProgress(1); searchInvalidator_.invalidate(); final Token token = searchInvalidator_.getInvalidationToken(); new Timer() { @Override public void run() { if (token.isInvalid()) return; listSpreadsheets(search.getText(), token); } }.schedule(500); } }); VerticalPanel vpanel = new VerticalPanel(); vpanel.add(search); vpanel.setCellHorizontalAlignment(search, VerticalPanel.ALIGN_RIGHT); vpanel.add(progressPanel_); overflow_ = new Label("Showing the first " + MAX_SHOWN + " spreadsheets"); overflow_.setStyleName(styles.overflowWarning()); showOverflow(false); vpanel.add(overflow_); FlowPanel varNamePanel = new FlowPanel(); Label varNameLabel = new Label("Name:"); varNameLabel.setStyleName(styles.varNameLabel()); varNamePanel.add(varNameLabel); varname_ = new TextBox(); varname_.setStyleName(styles.varName()); varNamePanel.add(varname_); addLeftWidget(varNamePanel); listSpreadsheets(null, null); return vpanel; }