Example usage for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel HorizontalPanel

Introduction

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

Prototype

public HorizontalPanel() 

Source Link

Document

Creates an empty horizontal panel.

Usage

From source file:com.fullmetalgalaxy.client.chat.MAppChat.java

License:Open Source License

public MAppChat() {
    m_panel.setSize("100%", "100%");

    scrollPanel.setHeight("400px");
    m_msgList.setStyleName("msglist");
    scrollPanel.add(m_msgList);/*  www .  j  a va  2  s . c om*/
    m_panel.add(scrollPanel);

    Panel hpanel = new HorizontalPanel();
    hpanel.setSize("100%", "100%");
    hpanel.add(m_text);
    m_text.setWidth("100%");
    m_text.addKeyDownHandler(this);
    hpanel.add(m_btnOk);
    m_btnOk.addClickHandler(this);
    m_panel.add(hpanel);

    initWidget(m_panel);
}

From source file:com.fullmetalgalaxy.client.chat.MAppPresences.java

License:Open Source License

@Override
public void onChannelMessage(Object p_message) {
    // redraw widget according to new presenceRoom
    PresenceRoom newPresenceRoom = (PresenceRoom) p_message;
    m_panel.clear();/*w w w  .  j  a v  a  2 s. c  o m*/
    Set<String> pseudoList = new HashSet<String>();
    for (Presence presence : newPresenceRoom) {
        if (!pseudoList.contains(presence.getPseudo())) {
            pseudoList.add(presence.getPseudo());
            Panel panel = new HorizontalPanel();
            Image image = new Image(presence.getAvatarUrl());
            image.setPixelSize(32, 32);
            image.setAltText(presence.getPseudo());
            image.setTitle(presence.getPseudo());
            panel.add(image);
            panel.add(new Label(presence.getPseudo()));
            m_panel.add(panel);
        }
    }
}

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

License:Open Source License

public WgtEditAdmin() {
    m_panel.add(new Label("current turn:"));
    m_panel.add(m_intCurrentTurn);/*  w ww  .ja va  2s  . co  m*/
    m_intCurrentTurn.addValueChangeHandler(new ValueChangeHandler<Integer>() {
        @Override
        public void onValueChange(ValueChangeEvent<Integer> p_event) {
            int delta = m_intCurrentTurn.getValue() - GameEngine.model().getGame().getCurrentTimeStep();
            GameEngine.model().getGame()
                    .setLastTideChange(GameEngine.model().getGame().getLastTideChange() + delta);
            GameEngine.model().getGame().setCurrentTimeStep(m_intCurrentTurn.getValue());
        }
    });

    m_panel.add(new Label("game status:"));
    for (GameStatus status : GameStatus.values()) {
        m_lstStatus.addItem(status.toString());
    }
    m_lstStatus.setVisibleItemCount(1);
    m_lstStatus.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            GameEngine.model().getGame()
                    .setStatus(GameStatus.valueOf(m_lstStatus.getItemText(m_lstStatus.getSelectedIndex())));
        }
    });
    m_panel.add(m_lstStatus);

    m_panel.add(new Label("creator pseudo:"));
    m_panel.add(m_txtCreatorPseudo);
    m_txtCreatorPseudo.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            GameEngine.model().getGame().getAccountCreator().setPseudo(m_txtCreatorPseudo.getText());
        }
    });
    m_panel.add(new Label("creator ID:"));
    m_panel.add(m_txtCreatorId);
    m_txtCreatorId.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            GameEngine.model().getGame().getAccountCreator().setId(Long.parseLong(m_txtCreatorId.getText()));
        }
    });

    m_panel.add(new HTML("<hr>"));
    // ===================

    m_lstReg.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            m_wgtOneReg.loadRegistration(m_mapReg.get(m_lstReg.getItemText(m_lstReg.getSelectedIndex())));

        }
    });
    m_lstReg.setVisibleItemCount(10);
    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.add(m_lstReg);
    hpanel.add(m_wgtOneReg);
    m_panel.add(hpanel);

    m_panel.add(new HTML("<hr>"));
    // ===================
    m_panel.add(m_wgtConfigGameTime);

    initWidget(m_panel);
}

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

License:Open Source License

/**
 * //from w w w .  ja va  2s.c om
 */
public WgtEditTriggers() {
    VerticalPanel vpanel = new VerticalPanel();
    m_lstTrigger.addChangeListener(this);
    m_lstTrigger.setVisibleItemCount(10);
    vpanel.add(m_lstTrigger);
    m_btnNewTrigger.addClickHandler(this);
    vpanel.add(m_btnNewTrigger);

    HorizontalPanel panel = new HorizontalPanel();
    panel.add(vpanel);
    panel.add(m_wgtTrigger);

    initWidget(panel);
}

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

License:Open Source License

/**
 * /* w  ww .  j a v a  2 s  .com*/
 */
public WgtToolsEditLands(WgtBoardEditLand p_wgtlayerEditLand) {
    assert p_wgtlayerEditLand != null;
    m_wgtlayerEditLand = p_wgtlayerEditLand;
    m_lstPlanet.addChangeListener(this);
    m_lstPlanet.setVisibleItemCount(1);
    for (PlanetType planet : PlanetType.values()) {
        m_lstPlanet.addItem(Messages.getPlanetString(0, planet));
        m_planets.add(planet);
    }
    m_panel.add(m_lstPlanet);

    for (MapShape shape : MapShape.values()) {
        m_lstMapShape.addItem(shape.toString());
    }
    m_lstMapShape.setVisibleItemCount(1);
    m_lstMapShape.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            GameEngine.model().getGame()
                    .setMapShape(MapShape.valueOf(m_lstMapShape.getValue(m_lstMapShape.getSelectedIndex())));
        }
    });
    m_panel.add(m_lstMapShape);

    m_panel.add(new Label("taille de carte"));
    Panel hpanel = new HorizontalPanel();
    m_txtLandWidth.setWidth("30px");
    m_txtLandHeight.setWidth("30px");
    hpanel.add(m_txtLandWidth);
    hpanel.add(m_txtLandHeight);
    m_panel.add(hpanel);
    m_btnClear.addClickHandler(this);
    m_panel.add(m_btnClear);
    m_btnGenerate.addClickHandler(this);
    m_panel.add(m_btnGenerate);

    m_lstAlgo.addItem("Lakes", "" + Boolean.TRUE);
    m_lstAlgo.addItem("Islands", "" + Boolean.FALSE);
    m_lstAlgo.setSelectedIndex(0);
    m_lstAlgo.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            GameGenerator.setLakeBoard(Boolean.parseBoolean(m_lstAlgo.getValue(m_lstAlgo.getSelectedIndex())));
        }
    });
    m_panel.add(m_lstAlgo);

    hpanel = new HorizontalPanel();
    hpanel.add(new Label("terre en %"));
    m_txtLandPercent.addChangeListener(this);
    hpanel.add(m_txtLandPercent);
    m_txtLandPercent.setText("" + GameGenerator.getLandPercent());
    m_txtLandPercent.setMaxLength(3);
    m_txtLandPercent.setWidth("30px");
    m_panel.add(hpanel);
    hpanel = new HorizontalPanel();
    hpanel.add(new Label("Hexagonale"));
    hpanel.add(m_chkRoundMap);
    m_chkRoundMap.setChecked(GameGenerator.isHexagonMap());
    m_panel.add(hpanel);

    m_btnLoadMap.addClickHandler(this);
    m_panel.add(m_btnLoadMap);

    m_panel.add(new HTML("<hr>"));

    hpanel = new HorizontalPanel();
    hpanel.add(new Label("Brush "));
    m_lstBrush.addItem("1");
    m_lstBrush.addItem("3");
    m_lstBrush.addItem("7");
    m_lstBrush.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            try {
                m_wgtlayerEditLand
                        .setBrushSize(Integer.parseInt(m_lstBrush.getValue(m_lstBrush.getSelectedIndex())));
            } catch (NumberFormatException e) {
            }
        }
    });
    m_lstBrush.setSelectedIndex(0);
    hpanel.add(m_lstBrush);
    m_panel.add(hpanel);

    hpanel = new HorizontalPanel();
    hpanel.add(m_leftLand);
    hpanel.add(m_rightLand);
    m_panel.add(hpanel);
    m_btnNone.addMouseListener(this);
    m_panel.add(m_btnNone);
    m_btnSea.addMouseListener(this);
    m_panel.add(m_btnSea);
    m_btnReef.addMouseListener(this);
    m_panel.add(m_btnReef);
    m_btnMarsh.addMouseListener(this);
    m_panel.add(m_btnMarsh);
    m_btnPlain.addMouseListener(this);
    m_panel.add(m_btnPlain);
    m_btnMontain.addMouseListener(this);
    m_panel.add(m_btnMontain);

    setClicTool(Event.BUTTON_LEFT, LandType.Sea);
    setClicTool(Event.BUTTON_RIGHT, LandType.Montain);

    initWidget(m_panel);
    redraw();
}

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

License:Open Source License

protected void redraw() {
    m_tools.clear();/*from w  ww  .  j a v a 2s .  c o  m*/
    m_panel.clear();

    HorizontalPanel hpanel = new HorizontalPanel();
    hpanel.add(new Label("Minerai en mer"));
    hpanel.add(m_chkOreInSea);
    m_panel.add(hpanel);
    hpanel = new HorizontalPanel();
    hpanel.add(new Label("Tous les minerais"));
    hpanel.add(m_chkUseAllOre);
    m_panel.add(hpanel);
    hpanel = new HorizontalPanel();
    hpanel.add(new Label("Generateurs"));
    hpanel.add(m_chkUseOreGenerator);
    m_panel.add(hpanel);

    m_panel.add(m_btnOre);
    m_panel.add(m_currentTool);
    AbstractImagePrototype
            .create(TokenImages.getTokenImage(m_wgtBoardEditTokens.getColor(), EnuZoom.Medium,
                    m_wgtBoardEditTokens.getTokenType(), m_wgtBoardEditTokens.getSector()))
            .applyTo(m_currentTool);
    m_panel.add(m_lblUnit);
    m_lblUnit.setText(Messages.getTokenString(0, m_wgtBoardEditTokens.getTokenType()));
    m_panel.add(m_lstColor);

    if (m_wgtBoardEditTokens.getColor().getValue() == EnuColor.None) {
        addTokenBtn(TokenType.Ore0);
        addTokenBtn(TokenType.Ore);
        addTokenBtn(TokenType.Ore3);
        addTokenBtn(TokenType.Ore5);
        addTokenBtn(TokenType.Ore2Generator);
        addTokenBtn(TokenType.Ore3Generator);
        addTokenBtn(TokenType.Warp);
        addTokenBtn(TokenType.Pontoon);
        addTokenBtn(TokenType.Sluice);
    }
    addTokenBtn(TokenType.Crab);
    addTokenBtn(TokenType.Tank);
    addTokenBtn(TokenType.Heap);
    addTokenBtn(TokenType.Tarask);
    addTokenBtn(TokenType.Hovertank);
    addTokenBtn(TokenType.Speedboat);
    addTokenBtn(TokenType.Crayfish);
    addTokenBtn(TokenType.Barge);
    addTokenBtn(TokenType.Destroyer);
    addTokenBtn(TokenType.WeatherHen);
    addTokenBtn(TokenType.Teleporter);
    addTokenBtn(TokenType.Freighter);
    addTokenBtn(TokenType.Turret);

}

From source file:com.fullmetalgalaxy.client.game.board.DlgAIJoinGame.java

License:Open Source License

@Override
public void show() {
    m_panel.clear();/*from   ww  w.j  a  v a  2s .c  o  m*/

    m_panel.add(new HTML("Add an automatic player<hr/>Action point bonus:"));

    intAPBonus.setValue(0);
    m_panel.add(intAPBonus);

    m_panel.add(new HTML("Select avaliable player"));

    m_panel.add(listAI);

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(m_btnCancel);
    hPanel.add(m_btnOk);
    m_panel.add(hPanel);

    super.show();
}

From source file:com.fullmetalgalaxy.client.game.board.DlgJoinChooseColor.java

License:Open Source License

/**
 * /*from w ww. j a va 2  s  . c  o m*/
 */
public DlgJoinChooseColor() {
    // auto hide / modal
    super(false, true);

    // Set the dialog box's caption.
    setText(MAppBoard.s_messages.unitsTitle());

    // add company list widget
    // =======================
    List<Company> freeCompany = new ArrayList<Company>();
    for (Company company : Company.values()) {
        if (company != Company.Freelancer) {
            freeCompany.add(company);
        }
    }
    if (!GameEngine.model().getGame().isTeamAllowed()) {
        // remove already chosen company
        for (EbTeam team : GameEngine.model().getGame().getTeams()) {
            if (team.getCompany() != null && team.getCompany() != Company.Freelancer) {
                freeCompany.remove(team.getCompany());
            }
        }
        freeCompany.add(0, Company.Freelancer);
    } else {
        m_panel.add(new HTML("<b>" + MAppBoard.s_messages.warningTeamAllowed() + "</b>"));
        if (GameEngine.model().getGame().getMaxTeamAllowed() <= GameEngine.model().getGame().getTeams()
                .size()) {
            // player shouldn't choose other team
            freeCompany.clear();
            for (EbTeam team : GameEngine.model().getGame().getTeams()) {
                freeCompany.add(team.getCompany());
            }
        }
    }

    for (Company company : freeCompany) {
        m_companySelection.addItem(company.getFullName(), company.toString());
    }
    m_companySelection.setSelectedIndex(Random.nextInt(m_companySelection.getItemCount()));
    Company company = Company.valueOf(m_companySelection.getValue(m_companySelection.getSelectedIndex()));
    m_companyPreview.setUrl("/images/avatar/" + company + ".jpg");
    m_companySelection.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            Company company = Company
                    .valueOf(m_companySelection.getValue(m_companySelection.getSelectedIndex()));
            m_companyPreview.setUrl("/images/avatar/" + company + ".jpg");
        }
    });
    Panel hpanel = new HorizontalPanel();
    hpanel.add(m_companySelection);
    hpanel.add(m_companyPreview);
    m_panel.add(new HTML("<b>" + MAppBoard.s_messages.chooseCompany() + "</b>"));
    m_panel.add(hpanel);

    // add color list widget
    // =====================
    Set<EnuColor> freeColors = null;
    if (GameEngine.model().getGame().getSetRegistration().size() >= GameEngine.model().getGame()
            .getMaxNumberOfPlayer()) {
        // this is a player replacement: don't allow company selection
        m_companySelection.setVisible(false);
        freeColors = GameEngine.model().getGame().getFreeRegistrationColors();
    } else {
        freeColors = GameEngine.model().getGame().getFreePlayersColors();
    }
    for (EnuColor color : freeColors) {
        if (color.getValue() != EnuColor.None) {
            m_colorSelection.addItem(Messages.getColorString(0, color.getValue()), "" + color.getValue());
        }
    }
    m_colorSelection.setSelectedIndex(Random.nextInt(m_colorSelection.getItemCount()));
    // initialize company icon
    int colorValue = Integer.parseInt(m_colorSelection.getValue(m_colorSelection.getSelectedIndex()));
    EbRegistration registration = GameEngine.model().getGame().getRegistrationByColor(colorValue);
    if (registration != null && registration.getTeam(GameEngine.model().getGame()) != null) {
        m_companyPreview.setUrl(
                "/images/avatar/" + registration.getTeam(GameEngine.model().getGame()).getCompany() + ".jpg");
    }
    // initialize color icon
    m_colorPreview.setUrl("/images/board/" + (new EnuColor(colorValue)).toString() + "/preview.jpg");
    m_colorSelection.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent p_event) {
            int colorValue = Integer.parseInt(m_colorSelection.getValue(m_colorSelection.getSelectedIndex()));
            EnuColor color = new EnuColor(colorValue);
            m_colorPreview.setUrl("/images/board/" + color.toString() + "/preview.jpg");
            m_btnOk.setEnabled(true);
            // for replacement: search corresponding team
            EbRegistration registration = GameEngine.model().getGame().getRegistrationByColor(colorValue);
            if (registration != null && registration.getTeam(GameEngine.model().getGame()) != null) {
                m_companyPreview.setUrl("/images/avatar/"
                        + registration.getTeam(GameEngine.model().getGame()).getCompany() + ".jpg");
            }
        }
    });
    hpanel = new HorizontalPanel();
    hpanel.add(m_colorSelection);
    hpanel.add(m_colorPreview);
    m_panel.add(new HTML("<b>" + MAppBoard.s_messages.chooseColor() + "</b>"));
    m_panel.add(hpanel);

    // add buttons
    // ===========
    hpanel = new HorizontalPanel();
    // add cancel button
    m_btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent p_event) {
            hide();
        }
    });
    hpanel.add(m_btnCancel);

    // add OK button
    m_btnOk.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent p_event) {
            int colorValue = Integer.parseInt(m_colorSelection.getValue(m_colorSelection.getSelectedIndex()));
            EnuColor color = new EnuColor(colorValue);
            EbGameJoin action = new EbGameJoin();
            Company company = Company.Freelancer;
            try {
                company = Company.valueOf(m_companySelection.getValue(m_companySelection.getSelectedIndex()));
            } catch (Exception e) {
            }
            action.setCompany(company);
            action.setGame(GameEngine.model().getGame());
            action.setAccountId(AppMain.instance().getMyAccount().getId());
            action.setAccount(AppMain.instance().getMyAccount());
            action.setColor(color.getValue());
            GameEngine.model().runSingleAction(action);
            hide();
        }
    });
    hpanel.add(m_btnOk);
    m_panel.add(hpanel);

    setWidget(m_panel);
}

From source file:com.fullmetalgalaxy.client.game.board.DlgJoinDisplayVariant.java

License:Open Source License

/**
 * // w  w  w.  j  av  a2s  . co m
 */
public DlgJoinDisplayVariant() {
    // auto hide / modal
    super(false, true);

    // Set the dialog box's caption.
    setText(MAppBoard.s_messages.variantTitle());

    // display common construction reserve
    m_panel.add(new HTML("<b>" + MAppBoard.s_messages.commonConstructReserve() + "</b>"));
    m_panel.add(createTokenList(GameEngine.model().getGame().getConstructReserve()));

    // display initial hold
    m_panel.add(new HTML("<b>" + MAppBoard.s_messages.initialHold() + "</b>"));
    m_panel.add(createTokenList(GameEngine.model().getGame().getInitialHolds()));

    // add buttons
    HorizontalPanel hpanel = new HorizontalPanel();
    // add cancel button
    m_btnCancel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent p_event) {
            hide();
        }
    });
    hpanel.add(m_btnCancel);

    // add OK button
    m_btnOk.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent p_event) {
            hide();
            DlgJoinChooseColor.instance().show();
            DlgJoinChooseColor.instance().center();
        }
    });
    hpanel.add(m_btnOk);
    m_panel.add(hpanel);

    setWidget(m_panel);
}

From source file:com.fullmetalgalaxy.client.game.board.DlgJoinGame.java

License:Open Source License

@Override
public void show() {
    m_panel.clear();/* www . j a v a  2  s . co m*/

    m_panel.add(new HTML(ClientUtil.formatUserMessage(GameEngine.model().getGame().getDescription())));
    m_panel.add(new HTML("<hr/>"));

    WgtGameTime wgtGameTime = new WgtGameTime();
    wgtGameTime.setReadOnly(true);
    m_panel.add(wgtGameTime);
    m_panel.add(new HTML("<hr/>"));

    if (GameEngine.model().getGame().isPasswordProtected()) {
        HorizontalPanel hPanel = new HorizontalPanel();
        hPanel.add(new Label(MAppBoard.s_messages.pasword()));
        hPanel.add(m_txtPassword);
        m_panel.add(hPanel);
    } else {
        m_panel.add(new HTML(MAppBoard.s_messages.joinWarning()));
    }

    HorizontalPanel hPanel = new HorizontalPanel();
    hPanel.add(m_btnCancel);
    hPanel.add(m_btnOk);
    m_panel.add(hPanel);

    super.show();
}