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

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

Introduction

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

Prototype

public static void alert(String msg) 

Source Link

Usage

From source file:burrito.client.crud.widgets.ImagePickerPopup.java

License:Apache License

/**
 * Creates an {@link ImagePickerPopup} that validates uploaded images
 * against a required width and height. If strict is true then the uploaded
 * image will be validated at exactly that size. If strict is false, then
 * the uploaded image will be validated against a maximum size instead.
 * // w  ww  . jav a  2s  . c o  m
 * @param width
 * @param height
 * @param strict
 *            whether or not the uploaded image size must strictly be width
 *            x height
 */
public ImagePickerPopup(int width, int height, boolean strict) {
    super(true);
    setText(labels.uploadImage());
    BlobStoreUploader form = new BlobStoreUploader(new AsyncCallback<String>() {

        @Override
        public void onSuccess(String result) {
            saved(result);
        }

        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Failed to store image. Reason: " + caught.getMessage());
            throw new RuntimeException(caught);
        }
    });

    if (strict) {
        wrapper.add(new Label(
                height == 0 ? labels.requiredImageWidth(width) : labels.requiredImageSize(width, height)));
    } else {
        wrapper.add(new Label(labels.maximumImageSize(width, height)));
    }
    wrapper.add(form);
    setWidget(wrapper);
}

From source file:burrito.client.widgets.blobstore.BlobStoreUploader.java

License:Apache License

public BlobStoreUploader(Integer requiredWidth, Integer requiredHeight, final AsyncCallback<String> callback) {
    FlowPanel inner = new FlowPanel();
    inner.add(file);/*from  w ww.  j av a 2 s .  c  o m*/
    file.setName("file");
    file.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            getUploadURLAndPost();
        }
    });
    form.setEncoding(FormPanel.ENCODING_MULTIPART);
    form.setMethod(FormPanel.METHOD_POST);
    if (requiredWidth != null) {
        inner.add(new Hidden("width", String.valueOf(requiredWidth)));
    }
    if (requiredHeight != null) {
        inner.add(new Hidden("height", String.valueOf(requiredHeight)));
    }
    form.addSubmitHandler(new SubmitHandler() {

        @Override
        public void onSubmit(SubmitEvent event) {
            file.setVisible(false);
            progress.setVisible(true);
        }
    });

    form.addSubmitCompleteHandler(new SubmitCompleteHandler() {

        @Override
        public void onSubmitComplete(SubmitCompleteEvent event) {
            file.setVisible(true);
            progress.setVisible(false);
            String results = event.getResults().replaceAll("<.*?>", ""); // sometime, <pre> tags are added by the browser
            if (results.contains("OK#")) {
                String blobStoreKey = results.replace("OK#", "");
                callback.onSuccess(blobStoreKey);
            } else {
                Window.alert(results);
                callback.onFailure(new RuntimeException("Failure response from server"));
            }
        }
    });
    progress.setVisible(false);
    inner.add(progress);

    form.add(inner);
    initWidget(form);
}

From source file:burrito.client.widgets.inputfield.ListInputField.java

License:Apache License

@Override
public boolean validate() {
    if (required && (model == null || model.isEmpty())) {
        Window.alert("Minst ett vrde mste lggas till");
        return false;
    }//from  w ww.jav  a2  s. c o m
    return true;
}

From source file:bz.davide.dmweb.client.DMWeb.java

License:Open Source License

public static void start(Unmarshaller widgetUnmarshaller) {
    try {/*from  w  w w.j a v a 2  s.  c  o  m*/
        // During de-serialization avoid to create dom elements in default constructors
        AbstractHtmlElementView.clientSide = false;

        JSONObject jsonObject = new JSONObject(readSerializationData());
        GWTStructure gwtStructure = new GWTStructure(jsonObject);

        DMWidgetSerializationData serializationData = (DMWidgetSerializationData) widgetUnmarshaller
                .newInstance("DMWidgetSerializationData");
        widgetUnmarshaller.unmarschall(gwtStructure, serializationData);
        AbstractHtmlElementView.clientSideIdSeq = serializationData.getIdseq();

        AbstractHtmlElementView.clientSide = true;

        for (AttachListener attachHandler : serializationData.getDomReady()) {
            attachHandler.onAttachOrDetach(new AttachEvent(true));
        }
        for (AttachListener attachHandler : serializationData.getAttachHandlers()) {
            attachHandler.onAttachOrDetach(new AttachEvent(true));
        }
    } catch (Exception e) {
        e.printStackTrace();
        Window.alert("Errr");
    }
}

From source file:bz.davide.dmweb.shared.view.AbstractHtmlElementView.java

License:Open Source License

public static String escapeText4url(String title) {
    try {/*from   w w w .j a  va2 s  .co m*/
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < title.length(); i++) {
            String singleChar = title.substring(i, i + 1);
            if (!singleChar.matches("[a-zA-Z0-9]")) {
                byte[] utf8bytes = singleChar.getBytes("UTF-8"); // lower case does not work in gwt compiled code
                singleChar = "%";
                for (byte b : utf8bytes) {
                    String hexDigit = Integer.toHexString(b & 0xFF);
                    while (hexDigit.length() < 2) {
                        hexDigit = "0" + hexDigit;
                    }
                    singleChar += hexDigit;
                }
            }
            result.append(singleChar);
        }
        return result.toString();
    } catch (UnsupportedEncodingException encodingException) {
        Window.alert("UnsupportedEncodingException");
        throw new RuntimeException(encodingException);
    }
}

From source file:bz.davide.dmweb.shared.view.example.SignInViewOnLoginClick.java

License:Open Source License

@Override
public void onClick(DMClickEvent event) {
    event.preventDefault();//from  w  w  w  . ja v  a2 s  .c om
    event.stopPropagation();
    Window.alert("Logged with: " + this.signInView.getUser() + ":" + this.signInView.getPassword());
}

From source file:bz.davide.tnbus.html5.shared.NoRoutingSponsorView.java

License:Open Source License

public NoRoutingSponsorView(AreaList areaList, DMHashNavigationPanel navigationPanel, SASAbusMap map,
        SASAbusI18N i18n) {/*  www  .  j a va 2 s  . co  m*/
    super("route");

    DivView sponsor = new DivView("sponsor");
    DivView silver = new DivView("silver");
    silver.appendChild(new TextNodeView("Routing sponsor of the month"));
    sponsor.appendChild(silver);
    this.appendChild(sponsor);

    SpanView introText = new SpanView("Route calculation");
    introText.setStyleName("intro-text");
    this.appendChild(introText);

    this.appendChild(new BusStationSearchWidget(i18n.getLocalizedText("RouteSearchPanel_start_station"), map,
            areaList, new BusStationSelectedEventHandler() {
                @Override
                public void selected(BusStation busStation) {
                    RouteSearchPanel.start = busStation;
                }
            }, RouteSearchPanel.start, i18n));
    this.appendChild(new BusStationSearchWidget(i18n.getLocalizedText("RouteSearchPanel_end_station"), map,
            areaList, new BusStationSelectedEventHandler() {
                @Override
                public void selected(BusStation busStation) {
                    RouteSearchPanel.end = busStation;
                }
            }, RouteSearchPanel.end, i18n));

    this.appendChild(new SpanView(i18n.getLocalizedText("RouteSearchPanel_when") + ":"));
    this.appendChild(this.dateBox = new SASAbusDateBox());

    this.search = new ButtonView(i18n.getLocalizedText("RouteSearchPanel_search"));
    this.appendChild(this.search);
    this.search.addClickHandler(new DMClickHandler() {

        @Override
        public void onClick(DMClickEvent event) {
            Window.alert("Routing coming soon ...");
        }
    });

    this.appendChild(this.results = new DivView("results"));

}

From source file:ca.farez.sortsomething.client.Sortsomething.java

License:Apache License

public void onModuleLoad() {

    // Boundary panel message on startup
    callNumsHere = new Label("Call Numbers will display here!");
    callNumsHere.addStyleName("callNumsHere");

    // Boundary panel setup
    boundaryPanel.setPixelSize(1000, 200);
    boundaryPanel.addStyleName("boundaryPanel");
    boundaryPanel.getElement().getStyle().setProperty("position", "relative");
    boundaryPanel.add(callNumsHere);/*w  ww  . j a va  2  s .  com*/

    // Call number panel setup   
    cnPanel.addStyleName("cnPanel");

    // Setting up widget drag controller
    final PickupDragController widgetDragController = new PickupDragController(boundaryPanel, false);
    widgetDragController.setBehaviorMultipleSelection(false);
    //widgetDragController.addDragHandler(demoDragHandler);

    // Setting up HP drag controller
    HorizontalPanelDropController widgetDropController = new HorizontalPanelDropController(cnPanel);
    widgetDragController.registerDropController(widgetDropController);

    // scoreMe button setup
    scoreMeButton.setPixelSize(120, 60);
    scoreMeButton.setVisible(false);
    scoreMeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // Clear all of Quiz's data structures to avoid null pointers and index out of bounds
            newQuiz.clean();

            // Finds the position on buttons/callnumbers as arranged by users  
            int numOfButtons = cnPanel.getWidgetCount();
            setUserOrder(numOfButtons);

            // Compute our inter-sorted buckets
            newQuiz.builtInSortQuiz();

            // Set the bucket indices for fine sorting later
            newQuiz.fillBucketCollection(newQuiz.callNums.size());
            newQuiz.printBucketCollection();

            // Compute our and intra-sorted buckets
            newQuiz.callNumberIntraBucketSorting();

            // Compare the two and find mistakes (if any)
            //System.out.println("Mistakes BEFORE compare() = " + newQuiz.getMistakes());
            int mistakes = newQuiz.compare();
            //System.out.println("Mistakes AFTER compare() = " + mistakes);
            if (mistakes > 0) {
                if (mistakes == 1) {
                    mistakeLabel = new Label(mistakes + " mistake");
                } else
                    mistakeLabel = new Label(mistakes + " mistakes!");
                mistakeLabel.addStyleName("yesMistakes");
            } else {
                mistakeLabel = new Label("Correct Solution!");
                mistakeLabel.addStyleName("noMistakes");
            }
            if (bottomPanel.getWidgetCount() == 4) {
                bottomPanel.remove(3);
            }
            bottomPanel.add(mistakeLabel);
        }
    });

    // startQuiz button setup
    startQuizButton.setPixelSize(120, 60);
    startQuizButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            scoreMeButton.setVisible(true);
            String input = inputArea.getText().toUpperCase();

            if (input == null || input.trim().equals("")) { // Checking for empty strings
                Window.alert("Please type something in the text box!");
            } else {
                int newCallNums = newQuiz.populate(input);

                // Reassemble call number panel only if there are NEW call numbers!
                if (newCallNums > 0) {
                    cnPanel.clear();
                    AsyncCallback<Void> callback = autoQuizVoidSetup();
                    // TODO figure out how to switch to next panel if we've reached the right most side
                    Button cnb;
                    for (int i = 0; i < newQuiz.callNums.size(); i++) {
                        // Storing string in db asynchronously
                        autoQuizSvc.addString(newQuiz.callNums.get(i), callback);
                        // Adding call number to the UI                       
                        cnb = new Button(newQuiz.callNums.get(i));
                        cnb.addStyleName("gwt-Button");
                        cnPanel.add(cnb);
                        cnb.setPixelSize(60, 90);
                        widgetDragController.makeDraggable(cnb);
                    }
                }
                callNumsHere.removeFromParent();
                if (bottomPanel.getWidgetCount() == 4)
                    mistakeLabel.removeFromParent();
                if (scoreMeButton.getParent() != bottomPanel)
                    bottomPanel.add(scoreMeButton);
            }
        }
    });

    // generateQuizButton setup
    generateQuizButton.setPixelSize(120, 60);
    generateQuizButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            String input = generateQuizTextBox.getText();
            if (input == null || input.trim().equals("")) { // Checking for empty strings
                Window.alert("Please type something in the text box!");
            } else {
                int size = Integer.parseInt(input);
                if (size <= 0) { // Checking for invalid size
                    Window.alert("Please enter a valid quiz size!");
                } else {
                    AsyncCallback<String> callback = autoQuizStringSetup();
                    // Making the call to the auto quiz generation service
                    autoQuizSvc.getQuiz(size, callback);
                    String randomQuiz = generateRandomQuiz(size);
                    inputArea.setText(randomQuiz);
                }
            }
        }
    });

    // newQuizButton Setup
    newQuizButton.setPixelSize(120, 60);
    newQuizButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            cnPanel.clear();
            newQuiz.clean();
            inputArea.setText("");
            newQuiz.callNums.clear(); // The clean() call above doesn't clear the entered call number list
            if (boundaryPanel.getWidgetCount() > 1) {
                boundaryPanel.remove(1);
            }
            boundaryPanel.add(callNumsHere);
            if (bottomPanel.getWidgetCount() == 4)
                mistakeLabel.removeFromParent();
            scoreMeButton.removeFromParent();
        }
    });

    // inputBox text box setup
    inputArea.setFocus(true);
    inputArea.setText("Enter one call number per line. For example,\n\n" + "A100 TA2 2006\n"
            + "PC2600 Z68 2012\n" + "G53 XN1 2011\n");
    inputArea.addStyleName("inputArea");
    inputArea.setHeight("200px");
    inputArea.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            if (inputAreaOnClickCount == 0) {
                inputArea.setText("");
            }
            inputAreaOnClickCount++;
        }
    });

    // Populating Boundary Panel
    boundaryPanel.add(cnPanel);

    // Top panel setup
    topPanel.add(inputArea);
    topPanel.add(boundaryPanel);

    // Bottom panel setup
    bottomPanel.add(startQuizButton);
    bottomPanel.add(newQuizButton);
    bottomPanel.add(scoreMeButton);
    bottomPanel.addStyleName("bottomPanel");

    // Populating Manual Quiz Panel      
    manualQuizPanel.add(topPanel);
    manualQuizPanel.add(bottomPanel);
    manualQuizPanel.addStyleName("manualQuizPanel");

    // Generate Quiz setup
    generateQuizTextBox.getElement().setPropertyString("placeholder", "Enter the size of the quiz");

    // Populating Generated Quiz Panel
    autoQuizPanel.add(generateQuizTextBox);
    autoQuizPanel.add(generateQuizButton);

    // Populating Main Panel
    tabPanel.add(autoQuizPanel, "Generate Quiz Automatically");
    tabPanel.add(manualQuizPanel, "Create Quiz Manually");
    tabPanel.selectTab(1);

    // Adding panels & buttons to Root
    RootPanel.get().add(tabPanel);
}

From source file:ca.qc.cegepoutaouais.tge.pige.client.ui.widget.CategoryEditor.java

License:Open Source License

protected void configureDND() {
    //Window.alert("Configuring DND...");
    TreeGridDropTarget treeGridDT = new TreeGridDropTarget(treeGrid) {

        @Override//from   w  w w  .j  av  a2s . c  o  m
        protected void onDragMove(DNDEvent e) {
            super.onDragMove(e);
            //Window.alert("GOOD 1");
            TreeNode targetNode = treeGrid.findNode(e.getTarget());
            if (targetNode == null) {
                e.getStatus().setStatus(Boolean.FALSE);
                return;
            }
            BeanModel targetModel = (BeanModel) targetNode.getModel();
            if (targetModel == null) {
                e.getStatus().setStatus(Boolean.FALSE);
                return;
            }
            //Window.alert("GOOD 2");
            Category targetCategory = targetModel.<Category>getBean();
            // Vrifier qu'il n'y pas pas dj une catgorie portant le
            // mme nom.               
            final BeanModel sourceModel = (BeanModel) treeGrid.getSelectionModel().getSelectedItem();
            if (targetModel.get(Category.NAME_REF).equals(sourceModel.get(Category.NAME_REF))) {
                e.getStatus().setStatus(Boolean.FALSE);
                return;
            }
            //Window.alert("GOOD 3");
            if (targetCategory.getId() < 0) {
                e.getStatus().setStatus(Boolean.FALSE);
                return;
            }
            e.getStatus().setStatus(Boolean.TRUE);
            Window.alert("GOOD final");
        }

        @Override
        protected void onDragDrop(DNDEvent e) {
            Window.alert("Dropping target 1");
            super.onDragDrop(e);

            TreeNode targetNode = treeGrid.findNode(e.getTarget());
            if (targetNode == null) {
                return;
            }
            Window.alert("Dropping target 2");
            final BeanModel targetModel = (BeanModel) targetNode.getModel();
            final BeanModel sourceModel = (BeanModel) treeGrid.getSelectionModel().getSelectedItem();
            final Category targetCat = (Category) targetModel.getBean();
            final Category sourceCat = (Category) sourceModel.getBean();

            targetCat.addChild(sourceCat);
            sourceCat.updatePath();
            Window.alert("Dropping target 3");
            ManagementServiceAsync rpcService = Registry.get(PIGE.MANAGEMENT_SERVICE);
            rpcService.updateCategories(Arrays.asList(targetCat, sourceCat), new AsyncCallback() {

                @Override
                public void onSuccess(Object o) {
                    load();
                    StatusBar statusBar = Registry.get(AppWidgets.APP_STATUS_BAR);
                    statusBar.setTimedText(messages.updateSuccessful());
                }

                @Override
                public void onFailure(Throwable caught) {
                    PIGE.handleException(caught);
                }
            });
        }
    };
    treeGridDT.setAllowDropOnLeaf(Boolean.TRUE);
    treeGridDT.setAllowSelfAsSource(Boolean.TRUE);
    treeGridDT.setOperation(Operation.MOVE);
    treeGridDT.setFeedback(Feedback.APPEND);
    treeGridDT.setGroup("cat-only");
    new TreeGridDragSource(treeGrid).setGroup("cat-only");

}

From source file:cc.alcina.framework.gwt.client.ClientNotificationsImpl.java

License:Apache License

@Override
public void notifyOfCompletedSaveFromOffline() {
    ensureLocalisedMessages();
    Window.alert(localisedMessages.get(LT_NOTIFY_COMPLETED_SAVE));
}