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.fountainhead.client.presenter.ReportPresenter.java

License:Apache License

@Override
public void loadTree() {
    final JSONTreeLoader loader = new JSONTreeLoader(getView().getTree());
    getDispatcher().execute(new LoadTreeAction("/WEB-INF/tree-data.json"), new AsyncCallback<LoadTreeResult>() {

        @Override/*from ww w.  ja v  a  2  s  .co  m*/
        public void onFailure(Throwable caught) {
            // fatal error . log it
            if (Log.isDebugEnabled())
                Log.debug("loadTree()-Caught unexpected Error:\n" + caught.toString());

            loader.populateTreeError(caught.getMessage());
            Window.alert("Caught unexpected Error!\n+" + caught.toString()
                    + "\n Refer to Log for more info about this error");

        }

        @Override
        public void onSuccess(LoadTreeResult result) {
            if (Log.isDebugEnabled())
                Log.debug("loadTree() -OnSucces()- " + result.getResponse());
            JSONValue jsonValue = JSONParser.parse(result.getResponse());
            loader.populateTree(jsonValue);
        }
    });
}

From source file:com.fountainhead.client.presenter.SignInPagePresenter.java

License:Open Source License

private void sendCredentialsToServer() {
    String login = getView().getUserName();
    String password = getView().getPassword();
    getView().setError("");
    System.out.println(login + "-" + password);

    getDispatcher().execute(new LoginAction(login, password), new AsyncCallback<LoginResult>() {

        @Override//  ww  w .jav a 2s.  c  o m
        public void onFailure(Throwable caught) {
            if (caught instanceof LoginException) {
                getView().setError(caught.getMessage());
                getView().resetAndFocus();
            } else {
                // Fatal Unexpected error will be logged with
                // gwt-log
                if (Log.isDebugEnabled())
                    Log.debug("Sign In-Caught unexpected Error!\n" + caught.toString());
                Window.alert("Caught unexpected Error!\n+" + caught.toString()
                        + "\n Refer to Log for more info about this error");
            }
        }

        @Override
        public void onSuccess(LoginResult result) {
            // CurrentUser currentUser = new CurrentUser();
            user.setLogin(result.getResponse().getLogin());
            user.setLoggedIn(result.getResponse().isLoggedIn());
            user.setAdministrator(result.getResponse().isAdministrator());
            LoginAuthenticatedEvent.fire(eventBus, user);

            PlaceRequest placeRequest = new PlaceRequest(NameTokens.settingsPage);

            getPlaceManager().revealPlace(placeRequest);

            Log.debug("sign in onSuccess() - username: " + result.getResponse().getLogin());
        }
    });
}

From source file:com.fujitsu.gwt.bewebapp.client.content.text.RichTextToolbar.java

License:Open Source License

private void changeHtmlElement(String startTag, String stopTag) {
    JsArrayString tx = getSelection(styleText.getElement());
    if (tx.get(0).length() == 0) {
        Window.alert("Please select a text to change style before using this button.");
        return;/*from www. j ava2s  .c o  m*/
    }
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = startTag + tx.get(0) + stopTag;

    styleTextFormatter.insertHTML(selectedText);
}

From source file:com.fujitsu.gwt.bewebapp.client.content.text.RichTextToolbar.java

License:Open Source License

private void changeHtm(String startTag, String stopTag) {
    styleTextFormatter.removeFormat();/*  w  w  w  .  j  a va 2  s. c o m*/
    JsArrayString tx = getSelection(styleText.getElement());
    String txbuffer = styleText.getHTML();
    Window.alert("txbuffer:" + txbuffer);
    Integer startpos = Integer.parseInt(tx.get(1));
    String selectedText = tx.get(0);
    styleText.setHTML(txbuffer.substring(0, startpos) + startTag + selectedText + stopTag
            + txbuffer.substring(startpos + selectedText.length()));
}

From source file:com.fullmetalgalaxy.client.AppMain.java

License:Open Source License

@Override
public void onModuleLoad() {
    super.onModuleLoad();

    // start engines, ie none graphical components
    if (RootPanel.get(GameEngine.HISTORY_ID) != null) {
        new GameEngine().onModuleLoad();
    }//from w  ww .j  a v  a  2  s .c  o m
    if (RootPanel.get(ChatEngine.HISTORY_ID) != null) {
        m_chatEngine = new ChatEngine();
        m_chatEngine.onModuleLoad();
    }

    // call all entry point involve in this application
    if (RootPanel.get(MAppContext.HISTORY_ID) != null) {
        new MAppContext().onModuleLoad();
    }
    if (RootPanel.get(MAppGameCreation.HISTORY_ID) != null) {
        GWT.runAsync(MAppGameCreation.class, new RunAsyncCallback() {
            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Error while downloading script: " + caught.getLocalizedMessage());
            }

            @Override
            public void onSuccess() {
                new MAppGameCreation().onModuleLoad();
            }
        });
    }
    if (RootPanel.get(MAppStatusBar.HISTORY_ID) != null) {
        new MAppStatusBar().onModuleLoad();
    }
    if (RootPanel.get(MAppMessagesStack.HISTORY_ID) != null) {
        new MAppMessagesStack().onModuleLoad();
    }
    if (RootPanel.get(MAppBoard.HISTORY_ID) != null) {
        new MAppBoard().onModuleLoad();
    }
    if (RootPanel.get(MAppTabMenu.HISTORY_ID) != null) {
        new MAppTabMenu().onModuleLoad();
    }
    if (RootPanel.get(MAppLittlePresences.HISTORY_ID) != null) {
        new MAppLittlePresences().onModuleLoad();
    }
    if (RootPanel.get(MAppPresences.HISTORY_ID) != null) {
        new MAppPresences().onModuleLoad();
    }
    if (RootPanel.get(MAppChat.HISTORY_ID) != null) {
        new MAppChat().onModuleLoad();
    }
    AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));

    onChannelDisconnected();
}

From source file:com.fullmetalgalaxy.client.creation.MAppGameCreation.java

License:Open Source License

public MAppGameCreation() {
    m_btnCreateGame.addClickHandler(this);
    m_btnCancel.addClickHandler(this);

    // m_form.setBean( ModelFmpMain.model().getGame() );

    m_tabPanel.add(m_simpleForm, s_messages.simpleCreation());
    m_tabPanel.setSize("100%", "90%");
    m_tabPanel.selectTab(0);// w w w  .j a v a2s .c  o  m
    m_tabPanel.addBeforeSelectionHandler(new BeforeSelectionHandler<Integer>() {
        @Override
        public void onBeforeSelection(BeforeSelectionEvent<Integer> p_event) {
            if (p_event.getItem() == 5 // tab admin
                    && !AppMain.instance().iAmAdmin()) {
                Window.alert("Vous n'avez pas les droits pour cet onglet");
                p_event.cancel();
            }
        }
    });
    m_tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
        @Override
        public void onSelection(SelectionEvent<Integer> p_event) {
            // Let the user know what they just did.
            switch (p_event.getSelectedItem()) {
            case 0:
                break;
            case 1: // map
                m_wgtEditLand.setPixelSize(m_tabPanel.getOffsetWidth(), m_tabPanel.getOffsetHeight() - 20);
                if (m_isLandGenerated == false) {
                    GameGenerator.generLands();
                    m_isLandGenerated = true;
                }
                AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
                break;
            case 2: // tokens
                m_wgtEditTokens.onTabSelected();
                // I never understand this bug but... the second call IS needed :(
                m_wgtEditTokens.onTabSelected();
                m_wgtEditTokens.setPixelSize(m_tabPanel.getOffsetWidth(), m_tabPanel.getOffsetHeight() - 20);
                if (m_isOreGenerated == false) {
                    if (m_isLandGenerated == false) {
                        GameGenerator.generLands();
                        m_isLandGenerated = true;
                    }
                    GameGenerator.populateOres();
                    m_isOreGenerated = true;
                }
                AppRoot.getEventBus().fireEvent(new ModelUpdateEvent(GameEngine.model()));
                break;
            case 3: // rserve
                m_wgtEditReserve.onTabSelected();
                break;
            case 4: // initial holds
                m_wgtEditIntialHolds.onTabSelected();
                break;
            case 5: // Admin
                m_wgtEditAdmin.onTabSelected();
                break;
            default:
                break;
            }
        }
    });

    m_tabPanel.add(m_wgtEditLand, s_messages.map());
    m_tabPanel.add(m_wgtEditTokens, s_messages.tokens());
    m_tabPanel.add(m_wgtEditReserve, s_messages.reserve());
    m_tabPanel.add(m_wgtEditIntialHolds, s_messages.initialHolds());
    m_tabPanel.add(m_wgtEditAdmin, "Admin");

    m_panel.setSize("100%", "100%");
    m_panel.add(m_tabPanel);
    m_panel.add(m_btnCreateGame);
    m_panel.add(m_btnCancel);

    initWidget(m_panel);

    AppMain.getEventBus().addHandler(ModelUpdateEvent.TYPE, this);
}

From source file:com.fullmetalgalaxy.client.creation.MAppGameCreation.java

License:Open Source License

public void createGame() {
    Game game = GameEngine.model().getGame();
    if (game.getName().compareTo("") == 0) {
        Window.alert(s_messages.errorName());
        return;//  w ww  .  ja v a 2s .  com
    }
    if ((game.getEbConfigGameTime().estimateTotalActionPoint() < 250)
            || (game.getEbConfigGameTime().estimateTotalActionPoint() > 450)) {
        Window.alert(s_messages.errorActionPt());
        return;
    }
    if ((game.getLandWidth() > 70) || (game.getLandHeight() > 50)) {
        Window.alert(s_messages.errorMapTooLarge(70, 50));
        return;
    }
    if (game.getMaxNumberOfPlayer() < 2) {
        Window.alert("Il faut au moins deux joueurs pour crer une partie");
        return;
    }

    game.setAccountCreator(AppMain.instance().getMyAccount());

    if (GameEngine.model().getGame().isTrancient()) {
        // lands creation
        if (m_isLandGenerated == false) {
            GameGenerator.generLands();
        }
        if (m_isOreGenerated == false) {
            GameGenerator.populateOres();
        }
        GameGenerator.cleanToken();
    }

    // (3) Create an asynchronous callback to handle the result.
    FmpCallback<EbBase> callback = new FmpCallback<EbBase>() {
        @Override
        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());
            // this was in the old time where we had only one html page for
            // everything
            // AppMain.instance().gotoGame( p_result.getId() );
            // MAppMessagesStack.s_instance.showMessage(
            // s_messages.gameCreationSuccess() );
            ClientUtil.gotoUrl("/game.jsp?id=" + p_result.getId());
        }

        @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.
    AppMain.getRpcService().saveGame(GameEngine.model().getGame(), callback);

}

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// w  w w . java2s.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.fullmetalgalaxy.client.creation.MAppGameCreation.java

License:Open Source License

@Override
public void onModelUpdate(GameEngine p_modelSender) {
    if (!GameEngine.model().isLogged()) {
        Window.alert("Pour diter une partie vous devez etre logg");
        ClientUtil.gotoUrl("/");
        return;/*from w  ww  .  j  a va 2 s  .  c  om*/
    }

    if (!GameEngine.model().getGame().isTrancient()) {
        m_isLandGenerated = true;
        m_isOreGenerated = true;
    }
    // TODO check we don't have to do anything
    /*
    if( !AppRoot.instance().getHistoryState().containsKey( s_TokenIdGame ) 
        || AppRoot.instance().getHistoryState().getLong( s_TokenIdGame ) == 0 )
    {
      // create a new game
      p_modelSender.reinitGame();
      initNewGame();
    }
    else
    {
      // game is loaded... nothing to do !
    }*/
}

From source file:com.fullmetalgalaxy.client.FmpCallback.java

License:Open Source License

@Override
public void onFailure(Throwable p_caught) {
    // AppMain.instance().stopLoading();

    if (p_caught != null) {
        RpcUtil.logError(p_caught.getMessage(), p_caught);
    }//w w  w  .  j  ava2  s . com

    if (p_caught instanceof RpcFmpException) {
        MAppMessagesStack.s_instance.showWarning(((RpcFmpException) p_caught).getLocalizedMessage());
    } else if (p_caught instanceof SerializationException
            || p_caught instanceof IncompatibleRemoteServiceException) {
        Window.alert(MAppBoard.s_messages.wrongGameVersion());
        ClientUtil.reload();
    } else {
        // lets try it: don't display error to not confuse user...
        MAppMessagesStack.s_instance.showWarning(MAppBoard.s_messages.unknownError());
    }

}