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:com.dotweblabs.friendscube.app.client.local.widgets.connections.ConnectionsWidget.java

License:Apache License

private void loadUser(Long friendUserId, final ConnectionsRowWidget row) {
    String clientToken = loggedInUser.getUser().getClientToken();
    ProfileResourceProxy proxy = GWT.create(ProfileResourceProxy.class);
    proxy.getClientResource().setReference(
            ClientProxyHelper.restRootPath() + ProfileResourceProxy.PROFILE_URI + "/" + friendUserId);
    proxy.getClientResource().addQueryParameter("client_token", clientToken);
    proxy.retrieve(new Result<Profile>() {
        @Override// w  ww  .j a  va2s . c  o m
        public void onFailure(Throwable throwable) {
            Window.alert("Cannot retrieve user profile..");
        }

        @Override
        public void onSuccess(Profile profile) {
            ConnectionsThumbnailWidget thumbnail = connectionsThumbnailWidget.get();
            thumbnail.setModel(profile);
            row.getConnectionRowContainer().add(thumbnail);
        }
    });
}

From source file:com.dotweblabs.friendscube.app.client.local.widgets.messages.MessageFriendWidget.java

License:Apache License

public void setMessage(User message) {
    Window.alert("1");
    //  this.message= message;
    msg.setText("Awu!!.. Awu!!..");
    profileName.setText(profile.getFirstName() + " " + profile.getMiddleName() + " " + profile.getLastName());
    timeSent.setText(DateTimeFormat.getFormat("h:mm a").format(new Date()));
    Window.alert("2");
}

From source file:com.dotweblabs.friendscube.app.client.local.widgets.messages.MessageFriendWidget.java

License:Apache License

@EventHandler
public void alert(ClickEvent event) {
    event.preventDefault();
    Window.alert(profileName.getText());
}

From source file:com.dotweblabs.friendscube.app.client.local.widgets.ProfileInfoWidget.java

License:Apache License

private void sendProfileInfo(String field, String value) {
    ProfileResourceProxy profileResourceProxy = GWT.create(ProfileResourceProxy.class);
    profileResourceProxy.getClientResource()
            .setReference(ClientProxyHelper.restRootPath() + ProfileResourceProxy.PROFILE_URI);
    profileResourceProxy.getClientResource().addQueryParameter("client_token",
            loggedInUser.getUser().getClientToken());

    final Profile profile = loggedInUser.getUser().getProfile();
    String firstName = field.equals("firstName") ? value : profileFirstName.getText();
    String middleName = field.equals("middleName") ? value : profileMiddleName.getText();
    String lastName = field.equals("lastName") ? value : profileLastName.getText();
    String jobTitle = field.equals("jobTitle") ? value : profileJobTitle.getText();
    String phoneNumber = field.equals("phoneNumber") ? value : profilePhone.getText();
    String email = field.equals("email") ? value : profileEmail.getText();
    String aboutMe = field.equals("aboutMe") ? value : profileAboutMe.getText();

    profile.setFirstName(firstName);/*from  w ww .j  av  a 2s .co  m*/
    profile.setMiddleName(middleName);
    profile.setLastName(lastName);
    profile.setJobTitle(jobTitle);
    profile.setPhoneNumber(phoneNumber);
    profile.setEmail(email);
    profile.setAboutMe(aboutMe);

    profileResourceProxy.store(profile, new Result<Void>() {
        @Override
        public void onFailure(Throwable throwable) {
            Window.alert("Cannot update profile");
        }

        @Override
        public void onSuccess(Void result) {
            // do nothing
        }
    });
}

From source file:com.dushyant.sample.ui.gwt.GwtRpcPortletEntryPoint.java

License:Apache License

/**
 * This method is invoked when GWT Module is loaded on the page
 *///from ww w . j a va2  s .c  o m
public void onModuleLoad() {
    // This is just a sample entry point method for this portlet. In real world you would probably use MVP
    // pattern with UiBinder files instead of adding stuff to a div like this and directly making RPC calls from
    // here.
    // The "gwtRpcPortlet" here is the ID of an empty div used in "view.jsp" file
    RootPanel mainPanel = RootPanel.get("gwtRpcPortlet");

    final TextBox inputName = new TextBox();
    mainPanel.add(inputName);

    Button serviceCallButton = new Button("Make GWT RPC Call");
    mainPanel.add(serviceCallButton);

    serviceCallButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            ServiceInput serviceInput = new ServiceInput(inputName.getText());
            // Making the RPC call here
            getGwtRpcService().doSomeStuff(serviceInput, new AsyncCallback<ServiceOutput>() {
                @Override
                public void onFailure(Throwable caught) {
                    Window.alert("Service call failed " + caught.getMessage());
                }

                @Override
                public void onSuccess(ServiceOutput result) {
                    Window.alert("Successfully called GWT RPC service. Server says ---- " + result);
                }
            });
        }
    });
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEInsertTableDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row;/*from w  w  w .  j  a  va2  s .  c o  m*/
    int col;
    String borderColor = "", bgColor = "", borderWidth = "", cellpadding = "", cellspacing = "", clz;
    StringBuilder styleBuf = new StringBuilder();
    String hasTitleB = "false";
    if (asGrid.getValue()) {
        row = NumberUtil.toInt(gridRows.getText(), -1);
        col = NumberUtil.toInt(gridCols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        styleBuf.append("border-width:0px;width:100%;");
        //!!!please note: this size has same value in MceInsertTableMacro.java, please keep consist.
        cellpadding = "5";
        cellspacing = "5";
        clz = "macroGrid";
    } else {
        clz = "macroTable";
        row = NumberUtil.toInt(rows.getText(), -1);
        col = NumberUtil.toInt(cols.getText(), -1);
        if (row <= 0 || col <= 0) {
            Window.alert(Msg.consts.error_input_number_only());
            return;
        }
        hasTitleB = Boolean.valueOf(hasTitle.getValue()).toString();
        int borderN = NumberUtil.toInt(border.getText(), -1);
        if (borderN == -1) {
            border.setText("0");
            borderN = 0;
        }
        //according to TinyMCE, style string is for creating table, hidden is for update use 
        //although style=border-color is useless as it must put into td/th level,but it is useful to 
        //get back this value when editing table properties
        if (!SharedConstants.TABLE_BORDER_DEFAULT_COLOR.equalsIgnoreCase(borderPicker.getColor())) {
            borderColor = borderPicker.getColor();
            styleBuf.append("border-color:").append(borderColor);
        }
        if (!SharedConstants.TABLE_BG_DEFAULT_COLOR.equalsIgnoreCase(bkPicker.getColor())) {
            //only background color is not white.
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            bgColor = bkPicker.getColor();
            styleBuf.append("background-color:").append(bgColor);
        }
        if (!StringUtil.isBlank(width)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("width:").append(width);
        }
        if (!StringUtil.isBlank(height)) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");
            styleBuf.append("height:").append(height);
        }

        //border also pass to client even it is default size, this makes "1px solid #121212" valid 
        borderWidth = borderN + "px";
        if (borderN != DEFAULT_BORDER_SIZE) {
            if (styleBuf.length() > 0)
                styleBuf.append(";");

            styleBuf.append("border-width:").append(borderWidth);
        }
    }
    //Original design is use form.elements['name'].value to retrieve values. But fuck IE, it does work:
    //http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/5144115ec715ce1a/78507fc52fab2429?lnk=gst&q=setName+ie#78507fc52fab2429
    //It means pure javascript can not get value by name. So I collect them into list then pass it to javascript. Fuck IE again.
    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, String.valueOf(row));
    input.set(1, String.valueOf(col));
    input.set(2, bgColor);
    input.set(3, borderColor);
    input.set(4, hasTitleB);
    input.set(5, borderWidth);
    input.set(6, styleBuf.toString());
    input.set(7, cellpadding);
    input.set(8, cellspacing);
    input.set(9, clz);

    tiny.restoreEditorBookmark();
    if (update) {
        updateTable(input);
    } else {
        //insert table
        insertTable(input);
    }
    close();

}

From source file:com.edgenius.wiki.gwt.client.editor.MCEMacroDialog.java

License:Open Source License

@Override
protected void okEvent() {
    if (TYPE_USER.equalsIgnoreCase(type)) {
        String filter = hbox.getText();
        if (!StringUtil.isBlank(filter)) {
            StringBuffer macro = new StringBuffer("@");
            macro.append(filter).append("@");
            MacroRequester.buildMacroFromServer(tiny.getSpaceUname(), tiny.getPageUuid(), macro.toString(),
                    null, null, this);
        }/*from w  ww. java  2s  .co m*/
    } else if (TYPE_GALLERY.equalsIgnoreCase(type)) {
        String filter = hbox.getText();

        StringBuffer macro = new StringBuffer("{gallery");
        if (!StringUtil.isBlank(filter)) {
            macro.append(":filter=").append(filter);
        }
        macro.append("}");

        MacroRequester.buildMacroFromServer(tiny.getSpaceUname(), tiny.getPageUuid(), macro.toString(), null,
                tiny.getEditor().getAttachmentNodeUuidList(), this);
    } else if (TYPE_ATTACH.equalsIgnoreCase(type)) {
        String filter = hbox.getText();

        StringBuffer macro = new StringBuffer("{attach");
        if (!StringUtil.isBlank(filter)) {
            macro.append(":filter=").append(filter);
        }
        macro.append("}");
        MacroRequester.buildMacroFromServer(tiny.getSpaceUname(), tiny.getPageUuid(), macro.toString(), null,
                tiny.getEditor().getAttachmentNodeUuidList(), this);
    } else if (TYPE_HTML.equalsIgnoreCase(type)) {
        this.tiny.insertContent(area.getText());
    } else if (TYPE_PANEL.equalsIgnoreCase(type)) {

        String title = hbox.getText();
        StringBuffer buffer = new StringBuffer();
        MacroMaker.buildPanel(HTMLPanel.createUniqueId(), buffer, title, "<br>", true);
        this.tiny.insertContent(buffer.toString());

    } else if (TYPE_TOC.equalsIgnoreCase(type)) {
        StringBuffer macro = new StringBuffer("{toc");

        String levelStr = hbox.getText();
        boolean dirty = false;
        if (!StringUtil.isBlank(levelStr)) {
            int level = NumberUtil.toInt(levelStr, -1);
            if (level < 1 || level > 6) {
                Window.alert(Msg.consts.toc_levels_exceed_scope());
                return;
            }
            macro.append(":level=").append(level);
            dirty = true;
        }
        if (radio2.isChecked()) {
            macro.append(dirty ? "|" : ":").append("ordered=false");
        }
        macro.append("}");
        MacroRequester.buildMacroFromServer(tiny.getSpaceUname(), tiny.getPageUuid(), macro.toString(),
                tiny.getEditor().getText(), null, this);
    }

    this.hidebox();
}

From source file:com.edgenius.wiki.gwt.client.editor.MCEMergeCellsDialog.java

License:Open Source License

@Override
protected void okEvent() {
    int row = NumberUtil.toInt(rowBox.getText(), -1);
    int col = NumberUtil.toInt(colBox.getText(), -1);
    if (row <= 0 || col <= 0) {
        Window.alert(Msg.consts.error_input_number_only());
        return;//  w  w  w  .  j a v  a2  s  . co  m
    }

    JsArrayString input = (JsArrayString) JavaScriptObject.createArray();
    input.set(0, rowBox.getText());
    input.set(1, colBox.getText());

    mergeCells(input);
    close();

}

From source file:com.edgenius.wiki.gwt.client.GwtClientUtils.java

License:Open Source License

/**
 * @param obj error object/*ww w  .  j av  a  2  s.  c  o  m*/
 * @return true, online exception, false, system is current offline. 
 */
public static boolean processError(Throwable obj) {
    if (obj instanceof IncompatibleRemoteServiceException) {
        if (!obsoleteVerWin) {
            //only popup this message once, until user refresh page, otherwise, each RPC call will popup on, Dashboard may contain large 
            //amount RCP call....
            Window.alert(((IncompatibleRemoteServiceException) obj).getMessage());
            obsoleteVerWin = true;
        }
        return true;
    } else if (obj instanceof ClientAuthenticationException) {
        String loginUrl = ((ClientAuthenticationException) obj).getLoginUrl();
        if (AbstractEntryPoint.isOffline()) {
            Window.alert("auth exp");
        } else {
            //append webcontext before loginURL
            gotoLogin(getRediectURL(loginUrl), getLocation());
        }
        //return withError flag
        return true;
    } else if (obj instanceof ClientAccessDeniedException) {
        String errorUrl = ((ClientAccessDeniedException) obj).getErrorUrl();

        if (AbstractEntryPoint.isOffline()) {
            Window.alert("Access denied.");
        } else {
            redirectByForm(errorUrl);
        }
        return true;
    } else if (obj instanceof InvocationException) {
        //IE, Opera, Safari will throw InvocationException if server is not available (or offline model)

        return false;
    } else if (obj instanceof RuntimeException) {
        //???Firefox will throw RuntimeException if server is not available (or offline model)

        return false;
    }

    Window.alert("Unexpected error " + obj);

    return true;
}

From source file:com.edgenius.wiki.gwt.client.login.LoginEntryPoint.java

License:Open Source License

public void onPreviewNativeEvent(NativePreviewEvent event) {
    int type = event.getTypeInt();

    //IE only work for Event.ONKEYDOWN but not Event.ONKEYPRESS (FF is OK)
    if (!event.isCanceled() && type == Event.ONKEYDOWN) {
        int keyCode = event.getNativeEvent().getKeyCode();
        if (keyCode == ClientConstants.KEY_F1) {
            Window.alert(Msg.params.login_for_help(SharedConstants.APP_NAME));
            //in FF, it block the FF help window.
            event.cancel();/*from   w ww.  j  av a 2  s .  com*/
        }

    }
}