List of usage examples for com.google.gwt.user.client Window prompt
public static String prompt(String msg, String initialValue)
From source file:burrito.client.crud.widgets.CrudRichTextArea.java
License:Apache License
private Widget createCommandsArea() { HorizontalPanel hp = new HorizontalPanel(); this.bold = new ToggleButton(new Image(GWT.getModuleBaseURL() + "images/format-text-bold.png"), new ClickHandler() { public void onClick(ClickEvent event) { formatter.toggleBold(); }//from w w w . ja va 2 s . c o m }); bold.setTitle(labels.bold()); hp.add(bold); this.italics = new ToggleButton(new Image(GWT.getModuleBaseURL() + "images/format-text-italic.png"), new ClickHandler() { public void onClick(ClickEvent event) { formatter.toggleItalic(); } }); italics.setTitle(labels.italic()); hp.add(italics); this.strikethrough = new ToggleButton( new Image(GWT.getModuleBaseURL() + "images/format-text-strikethrough.png"), new ClickHandler() { public void onClick(ClickEvent event) { formatter.toggleStrikethrough(); } }); strikethrough.setTitle(labels.strikethrough()); hp.add(strikethrough); this.underline = new ToggleButton(new Image(GWT.getModuleBaseURL() + "images/format-text-underline.png"), new ClickHandler() { public void onClick(ClickEvent event) { formatter.toggleUnderline(); } }); underline.setTitle(labels.underline()); hp.add(underline); PushButton image = new PushButton(new Image(GWT.getModuleBaseURL() + "images/image-x-generic.png"), new ClickHandler() { public void onClick(ClickEvent event) { imagePicker.center(); imagePicker.show(); } }); image.setTitle(labels.insertImage()); hp.add(image); PushButton link = new PushButton(labels.link(), new ClickHandler() { public void onClick(ClickEvent event) { formatter.createLink(Window.prompt(labels.pasteLinkHere(), null)); } }); link.setTitle(labels.insertLink()); hp.add(link); for (CrudRichTextPlugin control : PLUGGED_IN_CONTROLLERS) { hp.add(control.getWidget(formatter)); } return hp; }
From source file:ch.unifr.pai.twice.authentication.client.Authentication.java
License:Apache License
/** * Returns the user name for the identification and the signature of triggered messages within the collaborative session * /*from w w w . jav a 2s. c om*/ * @return the user name */ public static String getUserName() { if (username == null) { String s = Window.prompt("What's your name?", ""); if ((s != null) && !s.isEmpty()) { username = s; } } return username; }
From source file:com.appspot.ast.client.editor.doodad.my.MyDoodad.java
License:Apache License
static void promptNewRef(ContentElement element) { String newRef = Window.prompt("New Ref", element.getAttribute(REF_ATTR)); if (newRef != null) { // Get the document view for mutating the persistent state, then update it element.getMutableDoc().setElementAttribute(element, REF_ATTR, newRef); }//w ww. j a v a 2 s. com }
From source file:com.axlight.gbrain.client.MainPane.java
License:Apache License
private void showPromptDialog(String message, final PromptHandler promptHandler) { if (GBrain.isIPhone) { String input = Window.prompt(message, ""); if (input != null) { promptHandler.handleResult(input); }/*w w w . j a va 2 s . co m*/ } else { final DialogBox dialog = new DialogBox(); dialog.setModal(true); dialog.setGlassEnabled(true); dialog.setText("Prompt"); Label label = new Label(message); final TextBox textBox = new TextBox(); HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(5); Button ok = new Button("OK"); buttonPanel.add(ok); Button cancel = new Button("Cancel"); buttonPanel.add(cancel); VerticalPanel basePanel = new VerticalPanel(); basePanel.setSpacing(10); basePanel.add(label); basePanel.add(textBox); basePanel.add(buttonPanel); dialog.add(basePanel); ok.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { promptHandler.handleResult(textBox.getText()); dialog.hide(); } }); cancel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialog.hide(); } }); dialog.center(); } }
From source file:com.bramosystems.oss.player.showcase.client.PlaylistPane.java
License:Apache License
@UiHandler("addButton") public void onAddClicked(ClickEvent event) { String res = Window.prompt( "Type the URL of the media to add to the playlist. Separate multiple URLs of the same media with a comma", "");/*w w w . j a v a 2 s . co m*/ if (res != null && !res.isEmpty()) { String[] r = res.split(","); for (String x : r) { x.trim(); } addEntry(r); fireEvent(new PlaylistChangeEvent(new MRL(r), list.getItemCount(), true)); } }
From source file:com.extjs.gxt.ui.client.widget.form.HtmlEditor.java
License:Open Source License
protected void setupToolbar() { if (showToolbar) { btnListener = new SelectionListener<ButtonEvent>() { @Override/*from w ww . j a va 2 s . co m*/ public void componentSelected(ButtonEvent ce) { Component item = ce.getComponent(); if (item == bold) { getBasicFormatter().toggleBold(); } else if (item == italic) { getBasicFormatter().toggleItalic(); } else if (item == underline) { getBasicFormatter().toggleUnderline(); } else if (item == sourceEdit) { toggleSourceEditMode(); focus(); } else if (item == ol) { getExtendedFormatter().insertOrderedList(); } else if (item == ul) { getExtendedFormatter().insertUnorderedList(); } else if (item == link) { String link = Window.prompt(getMessages().getCreateLinkText(), "http://"); if (link != null && link.length() > 0) { getExtendedFormatter().createLink(link); } else { getExtendedFormatter().removeLink(); } } else if (item == justifyLeft) { getBasicFormatter().setJustification(Justification.LEFT); } else if (item == justifyCenter) { getBasicFormatter().setJustification(Justification.CENTER); } else if (item == justifyRight) { getBasicFormatter().setJustification(Justification.RIGHT); } else if (item == increasefontsize) { int i = fontSizesConstants.indexOf(activeFontSize); if (i < (fontSizesConstants.size() - 1)) { i++; activeFontSize = fontSizesConstants.get(i); getBasicFormatter().setFontSize(activeFontSize); } else { // brings focus back to the editor focus(); } } else if (item == decreasefontsize) { int i = fontSizesConstants.indexOf(activeFontSize); if (i > 0) { i--; activeFontSize = fontSizesConstants.get(i); getBasicFormatter().setFontSize(activeFontSize); } else { // brings focus back to the editor focus(); } } } }; toolbar = new ToolBar(); if (sourceEditMode) { toolbar.add(sourceEdit = createToggleButton(getImages().getSource(), getMessages().getSourceEditTipText(), getMessages().getSourceEditTipTitle())); toolbar.add(new SeparatorToolItem()); } if (impl.isBasicEditingSupported()) { if (enableFont) { SimpleComboBox<String> scbf = new SimpleComboBox<String>(); scbf.setTabIndex(-1); scbf.add("Arial"); scbf.add("Times New Roman"); scbf.add("Verdana"); scbf.setEditable(false); scbf.addListener(Events.Select, new Listener<FieldEvent>() { @SuppressWarnings("unchecked") public void handleEvent(FieldEvent be) { SimpleComboBox<String> field = (SimpleComboBox<String>) be.getField(); getBasicFormatter().setFontName(field.getSimpleValue()); } }); toolbar.add(scbf); toolbar.add(new SeparatorToolItem()); } if (enableFontSize) { toolbar.add(increasefontsize = createButton(getImages().getFontIncrease(), getMessages().getIncreaseFontSizeTipText(), getMessages().getIncreaseFontSizeTipTitle())); toolbar.add(decreasefontsize = createButton(getImages().getFontDecrease(), getMessages().getDecreaseFontSizeTipText(), getMessages().getDecreaseFontSizeTipTitle())); toolbar.add(new SeparatorToolItem()); } if (enableFormat) { toolbar.add(bold = createToggleButton(getImages().getBold(), getMessages().getBoldTipText(), getMessages().getBackColorTipTitle())); toolbar.add(italic = createToggleButton(getImages().getItalic(), getMessages().getItalicTipText(), getMessages().getItalicTipTitle())); toolbar.add(underline = createToggleButton(getImages().getUnderline(), getMessages().getUnderlineTipText(), getMessages().getUnderlineTipTitle())); toolbar.add(new SeparatorToolItem()); } if (enableAlignments) { toolbar.add(justifyLeft = createButton(getImages().getJustifyLeft(), getMessages().getJustifyLeftTipText(), getMessages().getJustifyLeftTipTitle())); toolbar.add(justifyCenter = createButton(getImages().getJustifyCenter(), getMessages().getJustifyCenterTipText(), getMessages().getJustifyCenterTipTitle())); toolbar.add(justifyRight = createButton(getImages().getJustifyRight(), getMessages().getJustifyRightTipText(), getMessages().getJustifyRightTipTitle())); } } if (impl.isExtendedEditingSupported()) { if (enableLists) { toolbar.add(new SeparatorToolItem()); toolbar.add(ol = createButton(getImages().getOl(), getMessages().getOlTipText(), getMessages().getOlTipTitle())); toolbar.add(ul = createButton(getImages().getUl(), getMessages().getUlTipText(), getMessages().getUlTipTitle())); toolbar.add(new SeparatorToolItem()); } if (enableLinks) { toolbar.add(link = createButton(getImages().getLink(), getMessages().getLinkTipText(), getMessages().getLinkTipTitle())); toolbar.add(new SeparatorToolItem()); } if (enableColors) { toolbar.add(forecolor = createColorButton(getImages().getFontColor(), getMessages().getForeColorTipText(), getMessages().getForColorTipTitle(), new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent be) { getBasicFormatter().setForeColor(((ColorPalette) be.getComponent()).getValue()); } })); toolbar.add(backcolor = createColorButton(getImages().getFontHighlight(), getMessages().getBackColorTipText(), getMessages().getBackColorTipTitle(), new Listener<ComponentEvent>() { public void handleEvent(ComponentEvent be) { getBasicFormatter().setBackColor(((ColorPalette) be.getComponent()).getValue()); } })); } } Element e = DOM.createDiv(); e.setClassName("x-html-editor-tb"); el().insertFirst(e); toolbar.render(e); } }
From source file:com.fullmetalgalaxy.client.creation.MAppGameCreation.java
License:Open Source License
public void saveGame() { String comment = Window.prompt("Un commentaire pour cette modif ?", ""); // (3) Create an asynchronous callback to handle the result. FmpCallback<EbBase> callback = new FmpCallback<EbBase>() { @Override/*from w w w . ja v a 2 s . c o m*/ public void onSuccess(EbBase p_result) { super.onSuccess(p_result); // load newly created game to show it GameEngine.model().getGame().updateFrom(p_result); GameEngine.model().getActionBuilder().setGame(GameEngine.model().getGame()); ClientUtil.gotoUrl("/game.jsp?id=" + p_result.getId()); MAppMessagesStack.s_instance.showMessage("Modif sauvegardes"); } @Override public void onFailure(Throwable p_caught) { super.onFailure(p_caught); Window.alert(p_caught.getMessage()); } }; // (4) Make the call. Control flow will continue immediately and later // 'callback' will be invoked when the RPC completes. Game game = GameEngine.model().getGame(); GameEventStack stack = game.getGameEventStack(); game.setGameEventStack(game); // as stack may be client specific class AppMain.getRpcService().saveGame(GameEngine.model().getGame(), comment, callback); game.setGameEventStack(stack); }
From source file:com.google.api.gwt.samples.calendar.client.CalendarEntryPoint.java
License:Apache License
/** Update an event that was previously retrieved. */ private void updateEvent(EventsContext ctx, Event event, final String calendarId, final String eventId) { String newSummary = ""; while (newSummary.isEmpty()) { newSummary = Window.prompt("Provide a new name for the event", ""); }/*w w w . j ava 2 s .c om*/ Event editableEvent = ctx.edit(event); // Don't forget to call edit() editableEvent.setSummary(newSummary); ctx.update(calendarId, eventId, editableEvent).fire(new Receiver<Event>() { @Override public void onSuccess(Event updated) { // The event has been updated. Now we'll delete it. deleteEvent(calendarId, eventId); } }); }
From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java
License:Apache License
/** Demonstrates expanding a short URL by requesting its information. */ private void expand() { String shortUrl = Window.prompt("Enter a short URL", "http://goo.gl/xwrT5"); // Get a new RequestContext which we will execute. UrlContext urlContext = urlShortener.url(); // Fire a get() request with the short URL we want to expand. urlContext.get(shortUrl).fire(new Receiver<Url>() { @Override// w ww.j av a2s . c o m public void onSuccess(Url response) { Window.alert("Long URL: " + response.getLongUrl() + "\n" // + "Short URL: " + response.getId() + "\n" // + "Status: " + response.getStatus()); shorten(); } @Override public void onFailure(ServerFailure error) { Window.alert("Error expanding a URL\n" + error.getMessage()); } }); }
From source file:com.google.api.gwt.samples.urlshortener.client.UrlshortenerEntryPoint.java
License:Apache License
/** Demonstrates shortening a URL by inserting a new {@link Url} object. */ private void shorten() { String longUrl = Window.prompt("Enter a long URL", "http://gwt-google-apis.googlecode.com/svn/trunk/apis/samples/urlshortener/demo/" + "urlshortener.html"); // Get a new RequestContext which we will execute. UrlContext urlContext = urlShortener.url(); // Create a new Url instance with the longUrl we want to insert. Url url = urlContext.create(Url.class).setLongUrl(longUrl); // Fire an insert() request with the Url to insert. urlContext.insert(url).fire(new Receiver<Url>() { @Override/*from w w w. j a va2 s. c o m*/ public void onSuccess(Url response) { Window.alert("Long URL: " + response.getLongUrl() + "\n" // + "Short URL: " + response.getId() + "\n" // + "Status: " + response.getStatus()); } @Override public void onFailure(ServerFailure error) { Window.alert("Error shortening a URL\n" + error.getMessage()); } }); }