Example usage for com.google.gwt.user.client Window prompt

List of usage examples for com.google.gwt.user.client Window prompt

Introduction

In this page you can find the example usage for com.google.gwt.user.client Window prompt.

Prototype

public static String prompt(String msg, String initialValue) 

Source Link

Usage

From source file:com.google.gwt.sample.feedreader.client.ConfigurationPanel.java

License:Apache License

public ConfigurationPanel(final Configuration configuration, final ManifestPanel parent) {
    super("Configuration", parent);
    this.configuration = configuration;
    this.parent = parent;
    final List feeds = configuration.getFeeds();

    setEditCommand("Reset", "Delete all application settings", new Command() {
        public void execute() {
            if (!Window.confirm("Do you wish to reset the application?")) {
                return;
            }//from   w  ww. j  a v  a  2  s  .com
            configuration.reset();
            parent.setDirty();
            exit();
        }
    });

    add(new PanelLabel("About...", new Command() {
        public void execute() {
            History.newItem("about");
        }
    }));

    // Create the search option
    {
        UnsunkLabel title = new UnsunkLabel("Search for new feeds...");
        title.addStyleName("title");
        UnsunkLabel info = new UnsunkLabel("Add feeds by searching.");
        info.addStyleName("snippit");

        FlowPanel vp = new FlowPanel();
        vp.add(title);
        vp.add(info);

        add(new PanelLabel(vp, new Command() {
            public void execute() {
                final String query = Window.prompt("Search query", "");
                if ((query != null) && (query.length() > 0)) {
                    History.newItem("search||" + URL.encodeComponent(query));
                }
            }
        }));
    }

    // Add all of the feeds to the panel.
    for (Iterator i = feeds.iterator(); i.hasNext();) {
        final Configuration.Feed feed = (Configuration.Feed) i.next();
        addFeed(feed);
    }
}

From source file:com.googlecode.gwtphonegap.client.notification.NotificationBrowserImpl.java

License:Apache License

@Override
public void prompt(String message, PromptCallback callback) {
    String enteredValue = Window.prompt(message, "OK");
    PromptResults results;/*www .  j av  a  2 s .  c om*/
    if (enteredValue == null) {
        results = new PromptResultsBrowserImpl(1, null);
    } else {
        results = new PromptResultsBrowserImpl(0, enteredValue);
    }
    callback.onPrompt(results);
}

From source file:com.qualogy.qafe.gwt.client.ui.renderer.events.EventFactory.java

License:Apache License

public static void createMenuCloseEvent(final String uuid, final WindowPanel sender) {
    sender.addWindowClosingHandler(new ClosingHandler() {
        public void onWindowClosing(ClosingEvent event) {
            if (Window.confirm("Are you sure you want to close the application and all of its windows ?")) {
                MainFactoryActions.remove(uuid);
                ComponentRepository.getInstance().removeAllItemsForWindow(uuid, null);
                // ClientApplicationContext.getInstance().closeAllWindowsForUUID(uuid);
                // return true;
            } else {
                // return false;
            }// w w w .j  a v a2s  .c  o m
            Window.prompt("Are you sure you want to close the application and all of its windows ?", "X");
        }
    });
}

From source file:com.sencha.gxt.widget.core.client.form.HtmlEditor.java

License:sencha.com license

protected void initToolBar() {
    if (!showToolBar) {
        return;//  w ww  . ja  va 2  s .c o m
    }

    buttonHandler = new SelectHandler() {

        @Override
        public void onSelect(SelectEvent event) {
            Widget button = (Widget) event.getSource();

            if (button == fontIncrease) {
                int i = fontSizesConstants.indexOf(activeFontSize);
                if (i < (fontSizesConstants.size() - 1)) {
                    i++;
                    activeFontSize = fontSizesConstants.get(i);
                    textArea.getFormatter().setFontSize(activeFontSize);
                } else {
                    // brings focus back to the editor
                    focus();
                }
            } else if (button == fontDecrease) {
                int i = fontSizesConstants.indexOf(activeFontSize);
                if (i > 0) {
                    i--;
                    activeFontSize = fontSizesConstants.get(i);
                    textArea.getFormatter().setFontSize(activeFontSize);
                } else {
                    // brings focus back to the editor
                    focus();
                }
            } else if (button == bold) {
                textArea.getFormatter().toggleBold();
            } else if (button == italic) {
                textArea.getFormatter().toggleItalic();
            } else if (button == underline) {
                textArea.getFormatter().toggleUnderline();
            } else if (button == justifyLeft) {
                textArea.getFormatter().setJustification(Justification.LEFT);
            } else if (button == justifyCenter) {
                textArea.getFormatter().setJustification(Justification.CENTER);
            } else if (button == justifyRight) {
                textArea.getFormatter().setJustification(Justification.RIGHT);
            } else if (button == ol) {
                textArea.getFormatter().insertOrderedList();
            } else if (button == ul) {
                textArea.getFormatter().insertUnorderedList();
            } else if (button == link) {
                String link = Window.prompt(getMessages().createLinkText(), "http://");
                if (link != null && link.length() > 0) {
                    textArea.getFormatter().createLink(link);
                } else {
                    textArea.getFormatter().removeLink();
                }
            }
        }
    };

    HtmlEditorMessages m = getMessages();

    if (enableFont) {
        final SimpleComboBox<String> fonts = new SimpleComboBox<String>(new StringLabelProvider<String>());
        fonts.setEditable(false);
        fonts.setTriggerAction(TriggerAction.ALL);
        fonts.setForceSelection(true);
        fonts.add("Arial");
        fonts.add("Courier New");
        fonts.add("Times New Roman");
        fonts.add("Verdana");
        fonts.setValue(fonts.getStore().get(0));

        fonts.addSelectionHandler(new SelectionHandler<String>() {
            @Override
            public void onSelection(SelectionEvent<String> event) {
                textArea.getFormatter().setFontName(event.getSelectedItem());
            }
        });

        toolBar.add(fonts);
        toolBar.add(new SeparatorToolItem());
    }

    if (enableFontSize) {
        fontIncrease = new TextButton();
        configureButton(fontIncrease, appearance.fontIncrease(), m.increaseFontSizeTipTitle(),
                m.increaseFontSizeTipText());
        fontIncrease.addSelectHandler(buttonHandler);
        toolBar.add(fontIncrease);

        fontDecrease = new TextButton();
        configureButton(fontDecrease, appearance.fontDecrease(), m.decreaseFontSizeTipTitle(),
                m.decreaseFontSizeTipText());
        fontDecrease.addSelectHandler(buttonHandler);
        toolBar.add(fontDecrease);

        toolBar.add(new SeparatorToolItem());
    }

    if (enableFormat) {
        bold = new ToggleButton();
        configureButton(bold, appearance.bold(), m.boldTipTitle(), m.boldTipText());
        bold.addSelectHandler(buttonHandler);
        toolBar.add(bold);

        italic = new ToggleButton();
        configureButton(italic, appearance.italic(), m.italicTipTitle(), m.italicTipText());
        italic.addSelectHandler(buttonHandler);
        toolBar.add(italic);

        underline = new ToggleButton();
        configureButton(underline, appearance.underline(), m.underlineTipTitle(), m.underlineTipText());
        underline.addSelectHandler(buttonHandler);
        toolBar.add(underline);

        toolBar.add(new SeparatorToolItem());
    }

    if (enableAlignments) {
        justifyLeft = new TextButton();
        configureButton(justifyLeft, appearance.justifyLeft(), m.justifyLeftTipTitle(), m.justifyLeftTipText());
        justifyLeft.addSelectHandler(buttonHandler);
        toolBar.add(justifyLeft);

        justifyCenter = new TextButton();
        configureButton(justifyCenter, appearance.justifyCenter(), m.justifyCenterTipTitle(),
                m.justifyCenterTipText());
        justifyCenter.addSelectHandler(buttonHandler);
        toolBar.add(justifyCenter);

        justifyRight = new TextButton();
        configureButton(justifyRight, appearance.justifyRight(), m.justifyRightTipTitle(),
                m.justifyRightTipText());
        justifyRight.addSelectHandler(buttonHandler);
        toolBar.add(justifyRight);

        toolBar.add(new SeparatorToolItem());
    }

    if (enableLists) {
        ol = new TextButton();
        configureButton(ol, appearance.ol(), m.olTipTitle(), m.olTipText());
        ol.addSelectHandler(buttonHandler);
        toolBar.add(ol);

        ul = new TextButton();
        configureButton(ul, appearance.ul(), m.ulTipTitle(), m.ulTipText());
        ul.addSelectHandler(buttonHandler);
        toolBar.add(ul);

        toolBar.add(new SeparatorToolItem());
    }

    if (enableLinks) {
        link = new TextButton();
        configureButton(link, appearance.link(), m.linkTipTitle(), m.linkTipText());
        link.addSelectHandler(buttonHandler);
        toolBar.add(link);

        toolBar.add(new SeparatorToolItem());
    }

    if (enableColors) {
        fontColor = new TextButton();
        configureButton(fontColor, appearance.fontColor(), m.foreColorTipTitle(), m.foreColorTipText());
        final ColorMenu fontColorMenu = new ColorMenu();
        fontColorMenu.setFocusOnShow(false);
        fontColorMenu.getPalette().addValueChangeHandler(new ValueChangeHandler<String>() {

            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                fontColorMenu.hide();
                textArea.getFormatter().setForeColor(event.getValue());
            }
        });

        fontColor.setMenu(fontColorMenu);

        toolBar.add(fontColor);

        fontHighlight = new TextButton();
        configureButton(fontHighlight, appearance.fontHighlight(), m.backColorTipTitle(), m.backColorTipText());

        final ColorMenu fontHighlightMenu = new ColorMenu();
        fontHighlightMenu.setFocusOnShow(false);
        fontHighlightMenu.getPalette().addValueChangeHandler(new ValueChangeHandler<String>() {
            @Override
            public void onValueChange(ValueChangeEvent<String> event) {
                fontHighlightMenu.hide();
                textArea.getFormatter().setBackColor(event.getValue());
            }
        });
        fontHighlight.setMenu(fontHighlightMenu);

        toolBar.add(fontHighlight);
    }

    if (enableSourceEditMode) {
        toolBar.add(new SeparatorToolItem());
        sourceEdit = new ToggleButton();
        configureButton(sourceEdit, appearance.source(), m.sourceEditTipTitle(), m.sourceEditTipText());

        sourceEdit.addSelectHandler(new SelectHandler() {
            @Override
            public void onSelect(SelectEvent event) {
                toggleSourceEditMode();
            }
        });
        toolBar.add(sourceEdit);

    }
}

From source file:com.vaadin.tests.widgetset.client.helloworldfeature.HelloWorldExtensionConnector.java

License:Apache License

private void greet() {
    String msg = getState().getGreeting() + " from " + Util.getConnectorString(this) + " attached to "
            + Util.getConnectorString(getParent());
    VConsole.log(msg);//from  w ww .  j a  va 2  s .com

    String response = Window.prompt(msg, "");
    getRpcProxy(HelloWorldRpc.class).onMessageSent(response);
}

From source file:de.decidr.workflowmodeleditor.client.DebugStandAloneApp.java

License:Apache License

private String getSampleProcess() {
    // dilettante's approach
    String dwdl = Window.prompt("Enter DWDL (or leave empty for default)", "");
    if (dwdl.isEmpty()) {
        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <workflow name=\"HumanTaskTest\" id=\"1\" targetNamespace=\"http://decidr.de/DefaultTenant/processes/302\" xmlns=\"http://decidr.de/model/schema/Dwdl\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://decidr.de/model/schema/Dwdl Dwdl.xsd\"> <description>This is a test process for human task testing</description> <variables> <variable name=\"L1260445451575\" label=\"my_faultMesssage\" type=\"string\" configurationVariable=\"no\"> <initialValue>This fault message is created by the fault handler of the corresponding BPEL process</initialValue> </variable> <variable name=\"L1260445559543\" label=\"my_successMessage\" type=\"string\" configurationVariable=\"no\"> <initialValue>BPEL process successfully completed.</initialValue> </variable> <variable name=\"L1260455349758\" label=\"my_taskname\" type=\"string\" configurationVariable=\"no\"> <initialValue>doIT</initialValue> </variable> <variable name=\"L1260455377884\" label=\"my_form\" type=\"form\" configurationVariable=\"no\" /> <variable name=\"L1260455400647\" label=\"my_taskdescription\" type=\"string\" configurationVariable=\"no\"> <initialValue>This is a simple human task</initialValue> </variable> <variable name=\"L1260455508986\" label=\"favorite_food\" type=\"string\" configurationVariable=\"no\"> <initialValue>a</initialValue> </variable> </variables> <roles> <role configurationVariable=\"no\" label=\"my_recipient\" name=\"L1260445287013\"> <actor userId=\"1\" /> </role> <role configurationVariable=\"yes\" label=\"my_user\" name=\"L1260445515504\" /> </roles> <faultHandler> <setProperty name=\"message\" variable=\"L1260445451575\" /> <recipient> <setProperty name=\"name\" variable=\"L1260445287013\" /> </recipient> </faultHandler> <nodes> <startNode name=\"de.decidr.modelingtoolbase.client.model.StartNodeModel\" id=\"4815162342\"> <description></description> <graphics x=\"45\" y=\"45\" width=\"52\" height=\"32\" /> <sources> <source arcId=\"1260445316022\" /> </sources> </startNode> <endNode name=\"de.decidr.modelingtoolbase.client.model.EndNodeModel\" id=\"108\"> <description></description> <graphics x=\"246\" y=\"376\" width=\"52\" height=\"32\" /> <targets> <target arcId=\"1260445316024\" /> </targets> <notificationOfSuccess> <setProperty name=\"successMessage\" variable=\"L1260445559543\" /> <setProperty name=\"recipient\" variable=\"L1260445287013\" /> </notificationOfSuccess> </endNode> <invokeNode name=\"de.decidr.modelingtoolbase.client.model.humantask.HumanTaskInvokeNodeModel\" id=\"1260445316025\" activity=\"Decidr-HumanTask\"> <description></description> <graphics x=\"170\" y=\"128\" width=\"102\" height=\"62\" /> <targets> <target arcId=\"1260445316022\" /> </targets> <sources> <source arcId=\"1260445316024\" /> </sources> <setProperty name=\"wfmID\" variable=\"L302\" /> <setProperty name=\"user\" variable=\"L1260445515504\" /> <setProperty name=\"name\" variable=\"L1260455349758\" /> <setProperty name=\"description\" variable=\"L1260455349758\" /> <setProperty name=\"userNotification\"> <propertyValue>no</propertyValue> </setProperty> <getProperty name=\"taskResult\" variable=\"L1260455377884\" /> <parameter> <humanTaskData> <taskItem name=\"ID1260455508987\" variable=\"L1260455508986\" type=\"string\"> <label>Food</label> <hint>What is your favorite food?</hint> <value>a</value> </taskItem> </humanTaskData> </parameter> </invokeNode> </nodes> <arcs> <arc name=\"de.decidr.modelingtoolbase.client.model.ConnectionModel\" id=\"1260445316022\" source=\"4815162342\" target=\"1260445316025\" /> <arc name=\"de.decidr.modelingtoolbase.client.model.ConnectionModel\" id=\"1260445316024\" source=\"1260445316025\" target=\"108\" /> </arcs> </workflow>";
    } else {/*  w  w  w.java 2  s. com*/
        return dwdl;
    }

}

From source file:eu.riscoss.client.riskanalysis.RASSelectionPanel.java

License:Apache License

protected void onNewSessionRequested() {
    String name = Window.prompt("Session name (leave empty for auto-generated name)",
            selectedRC + " - " + selectedEntity);
    if (name == null)
        return;/*  w ww  .j ava  2  s . c o m*/
    name = name.trim();
    if ("".equals(name))
        return;

    //      new Resource( GWT.getHostPageBaseURL() + "api/analysis/" + RiscossJsonClient.getDomain() + "/session/new" )
    //         .addQueryParam( "target", selectedEntity ).addQueryParam( "rc", selectedRC ).addQueryParam( "name", name )
    RiscossJsonClient.creteRiskAnalysisSession(name, selectedRC, selectedEntity, new JsonCallback() {
        @Override
        public void onFailure(Method method, Throwable exception) {
            Window.alert(exception.getMessage());
        }

        @Override
        public void onSuccess(Method method, JSONValue response) {
            JRASInfo info = codec.decode(response);
            dataProvider.getList().add(info);
            //               dataProvider.getList().add( 
            //                     new RASInfo( response ) );
        }
    });
}

From source file:eu.riscoss.client.riskconfs.RiskConfsModule.java

License:Apache License

public void onModuleLoad() {

    exportJS();/*  w  w  w . j a v  a 2s  .  c om*/
    tablePanel = new VerticalPanel();
    spTable = new SimplePanel();

    RiscossJsonClient.listRCs(new JsonCallback() {
        public void onSuccess(Method method, JSONValue response) {
            riskconfsList = response;
            loadRiskConfsTable(response);
        }

        public void onFailure(Method method, Throwable exception) {
            Window.alert(exception.getMessage());
        }
    });

    rightPanel2 = new SimplePanel();

    rightPanel2.setSize("100%", "100%");

    mainView.setStyleName("mainViewLayer");
    mainView.setWidth("100%");
    leftPanel.setStyleName("leftPanelLayer");
    leftPanel.setWidth("400px");
    //leftPanel.setHeight("100%");
    rightPanel.setStyleName("rightPanelLayer");

    Label title = new Label("Risk configuration management");
    title.setStyleName("title");
    page.add(title);

    HorizontalPanel data = new HorizontalPanel();
    data.setStyleName("layerData");
    Label name = new Label("Name");
    name.setStyleName("text");
    data.add(name);
    riskConfName.setWidth("120px");
    riskConfName.setStyleName("layerNameField");
    data.add(riskConfName);
    leftPanel.add(data);

    Button newRisk = new Button("New configuration");
    newRisk.setStyleName("button");
    newRisk.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            String name = riskConfName.getText().trim();
            for (int i = 0; i < riskconfsList.isArray().size(); i++) {
                JSONObject o = (JSONObject) riskconfsList.isArray().get(i);
                if (name.equals(o.get("name").isString().stringValue())) {
                    //info: firefox has some problem with this window, and fires assertion errors in dev mode
                    Window.alert("Model name already in use.\nPlease rename file.");
                    return;
                }
            }
            if (name == null || "".equals(name))
                return;
            while (!RiscossUtil.sanitize(name).equals(name)) {
                name = Window.prompt("Name contains prohibited characters (##,@,\") \nRe-enter name:", "");
                if (name == null || "".equals(name))
                    return;
            }

            RiscossJsonClient.createRC(name, new JsonCallback() {
                @Override
                public void onFailure(Method method, Throwable exception) {
                    Window.alert(exception.getMessage());
                }

                @Override
                public void onSuccess(Method method, JSONValue response) {
                    dataProvider.getList()
                            .add(new RCInfo(response.isObject().get("name").isString().stringValue()));
                    //Window.Location.reload();
                }
            });
            onRCSelected(name);
            riskConfName.setText("");
        }
    });
    leftPanel.add(newRisk);
    leftPanel.add(searchFields());
    leftPanel.add(spTable);

    mainView.add(leftPanel);
    mainView.add(rightPanel);
    page.add(mainView);
    page.setWidth("100%");

    save = new Button("Save");
    save.setStyleName("button");
    save.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            saveRiskConfData();
        }
    });

    RootPanel.get().add(page);
}

From source file:eu.riscoss.client.riskconfs.RiskConfsModule.java

License:Apache License

protected void onAddNew() {
    //String name = Window.prompt( "Name:", "" );
    String name = riskConfName.getText().trim();
    if (name == null || "".equals(name))
        return;/*from  www.j  ava  2 s.c  o m*/

    /**Button bOk = new Button( "Ok" ); //, new ClickHandler() {
            
    bOk.addClickHandler( new ClickWrapper<JSONArray>( (JSONArray)response.isArray() ) {
       @Override
       public void onClick(ClickEvent event) {
    String name = txt.getText().trim();
            
    if (name == null || name.equals("") ) 
       return;
            
    //String s = RiscossUtil.sanitize(txt.getText().trim());//attention:name sanitation is not directly notified to the user
    if (!RiscossUtil.sanitize(name).equals(name)){
       //info: firefox has some problem with this window, and fires asssertion errors in dev mode
       Window.alert("Name contains prohibited characters (##,@,\") \nPlease re-enter name");
       return;
    }
            
    for(int i=0; i<getValue().size(); i++){
       JSONObject o = (JSONObject)getValue().get(i);
       if (name.equals(o.get( "name" ).isString().stringValue())){
          //info: firefox has some problem with this window, and fires asssertion errors in dev mode
          Window.alert("Layer name already in use.\nPlease re-enter name.");
          return;
       }
    }
            
    RiscossJsonClient.createEntity( getChosenName(), getChosenLayer(), getChosenParent(), new JsonCallback() {
       @Override
       public void onFailure(Method method, Throwable exception) {
          Window.alert( exception.getMessage() );
       }
       @Override
       public void onSuccess(Method method, JSONValue response) {
          String entity = response.isObject().get( "name" ).isString().stringValue();
          EntityInfo info = new EntityInfo( entity );
          info.setLayer( JsonUtil.getValue( response, "layer", "" ) );
          insertEntityIntoTable( info );
          dialog.hide();
       }
    } );
       }
    });
    grid.setWidget( 3, 1, bOk);   
            
    grid.setWidget( 3, 2, new Button( "Cancel", new ClickHandler() {
       @Override
       public void onClick(ClickEvent event) {
    //Window.Location.reload();
    dialog.hide();
       }
    } )) ; */

    while (!RiscossUtil.sanitize(name).equals(name)) {
        name = Window.prompt("Name contains prohibited characters (##,@,\") \nRe-enter name:", "");
        if (name == null || "".equals(name))
            return;
    }

    RiscossJsonClient.createRC(name, new JsonCallback() {
        @Override
        public void onFailure(Method method, Throwable exception) {
            Window.alert(exception.getMessage());
        }

        @Override
        public void onSuccess(Method method, JSONValue response) {
            dataProvider.getList().add(new RCInfo(response.isObject().get("name").isString().stringValue()));
        }
    });
}

From source file:ilarkesto.gwt.client.Gwt.java

License:Open Source License

public static String prompt(String message, String value) {
    return Window.prompt(message, value);
}