List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE
VerticalAlignmentConstant ALIGN_MIDDLE
To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.
Click Source Link
From source file:net.officefloor.demo.chat.client.ChatWidget.java
License:Open Source License
/** * Ensures that have user name.//from ww w . j a v a2 s. co m */ private void ensureHaveUserName() { // Determine if user name already specified if ((this.userName != null) && (this.userName.trim().length() > 0)) { return; // user name specified } // No user name so obtain the user name final DialogBox userDialog = new DialogBox(false, true); HorizontalPanel userPanel = new HorizontalPanel(); userPanel.setSpacing(10); userPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); userDialog.add(userPanel); userPanel.add(new Label("Enter name for chat")); final TextBox nameText = new TextBox(); nameText.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { if (KeyCodes.KEY_ENTER == event.getNativeKeyCode()) { ChatWidget.this.enterChatName(nameText, userDialog); } } }); userPanel.add(nameText); Button okButton = new Button("ok"); userPanel.add(okButton); okButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ChatWidget.this.enterChatName(nameText, userDialog); } }); userDialog.center(); nameText.setFocus(true); }
From source file:net.s17fabu.vip.gwt.showcase.client.content.lists.CwStackPanel.java
License:Apache License
/** * Get a string representation of the header that includes an image and some * text./*w ww .ja v a 2 s . c o m*/ * * @param text the header text * @param image the {@link AbstractImagePrototype} to add next to the header * @return the header as a string */ private String getHeaderString(String text, AbstractImagePrototype image) { // Add the image and text to a horizontal panel HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setSpacing(0); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); hPanel.add(image.createImage()); HTML headerText = new HTML(text); headerText.setStyleName("cw-StackPanelHeader"); hPanel.add(headerText); // Return the HTML string for the panel return hPanel.getElement().getString(); }
From source file:net.s17fabu.vip.gwt.showcase.client.Showcase.java
License:Apache License
/** * Create the title bar at the top of the application. * /*from ww w . ja v a 2 s .com*/ * @param constants the constant values to use */ private void setupTitlePanel(ShowcaseConstants constants) { // Get the title from the internationalized constants String pageTitle = "<h1>" + constants.mainTitle() + "</h1><h2>" + constants.mainSubTitle() + "</h2>"; // Add the title and some images to the title bar HorizontalPanel titlePanel = new HorizontalPanel(); titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); titlePanel.add(images.gwtLogo().createImage()); titlePanel.add(new HTML(pageTitle)); app.setTitleWidget(titlePanel); }
From source file:net.scran24.user.client.survey.prompts.AddMealPrompt.java
@Override public SurveyStageInterface getInterface(final Callback1<SurveyOperation> onComplete, final Callback1<Function1<Survey, Survey>> onIntermediateStateChange) { SafeHtml promptText = SafeHtmlUtils.fromSafeConstant(messages.addMeal_promptText()); HorizontalPanel mealNamePanel = new HorizontalPanel(); mealNamePanel.setSpacing(5);//from ww w .j ava 2s .com mealNamePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); HorizontalPanel mealListPanel = new HorizontalPanel(); mealListPanel.setSpacing(5); mealListPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); final TextBox text = new TextBox(); text.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { text.selectAll(); } }); text.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (!text.getText().isEmpty()) onComplete.call(SurveyOperation.update(new Function1<Survey, Survey>() { @Override public Survey apply(Survey argument) { return argument.plusMeal(Meal.empty(text.getText())) .withSelection(new Selection.SelectedMeal(argument.meals.size(), SelectionMode.AUTO_SELECTION)); } })); } } }); final ListBox list = new ListBox(); for (String s : PredefinedMeals.getSuggestedMealNamesForCurrentLocale()) list.addItem(s); list.setSelectedIndex(selectedIndex); text.setText(list.getItemText(list.getSelectedIndex())); list.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { text.setText(list.getItemText(list.getSelectedIndex())); } }); mealListPanel.add(new Label(messages.addMeal_predefLabel())); mealListPanel.add(list); mealListPanel.getElement().setId("intake24-predef-meal-name"); ShepherdTour.makeShepherdTarget(mealListPanel); mealNamePanel.add(new Label(messages.addMeal_customLabel())); mealNamePanel.add(text); mealNamePanel.getElement().setId("intake24-custom-meal-name"); ShepherdTour.makeShepherdTarget(mealNamePanel); Button acceptButton = WidgetFactory.createButton(messages.addMeal_addButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!text.getText().isEmpty()) onComplete.call(SurveyOperation.update(new Function1<Survey, Survey>() { @Override public Survey apply(Survey argument) { return argument.plusMeal(Meal.empty(text.getText())) .withSelection(new Selection.SelectedMeal(argument.meals.size(), SelectionMode.AUTO_SELECTION)); } })); } }); acceptButton.getElement().setId("intake24-accept-button"); Button cancelButton = WidgetFactory.createButton(messages.addMeal_cancelButtonLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(SurveyOperation.noChange); } }); cancelButton.getElement().setId("intake24-cancel-button"); ShepherdTour.makeShepherdTarget(acceptButton, cancelButton); FlowPanel contents = new FlowPanel(); contents.add(WidgetFactory.createPromptPanel(promptText, ShepherdTour.createTourButton(tour, AddMealPrompt.class.getSimpleName()))); contents.add(mealListPanel); contents.add(mealNamePanel); contents.add(WidgetFactory.createButtonsPanel(acceptButton, cancelButton)); return new SurveyStageInterface.Aligned(contents, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS); }
From source file:net.scran24.user.client.survey.prompts.SaveHomeRecipePrompt.java
@Override public SurveyStageInterface getInterface(final Callback1<MealOperation> onComplete, final Callback1<Function1<Pair<FoodEntry, Meal>, Pair<FoodEntry, Meal>>> onIntermediateStateChange) { SafeHtml promptText = SafeHtmlUtils/*from ww w. ja v a2s. c om*/ .fromSafeConstant(messages.homeRecipe_savePromptText(SafeHtmlUtils.htmlEscape(food.description()))); HorizontalPanel recipeNamePanel = new HorizontalPanel(); recipeNamePanel.setSpacing(5); recipeNamePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); recipeName.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recipeName.selectAll(); } }); recipeName.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { if (!recipeName.getText().isEmpty()) onComplete.call(MealOperation.update(saveRecipeFunction)); } } }); recipeNamePanel.add(new Label(messages.homeRecipe_recipeNameLabel())); recipeNamePanel.add(recipeName); Button yesButton = WidgetFactory.createGreenButton(messages.yesNoQuestion_defaultYesLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!recipeName.getText().isEmpty()) onComplete.call(MealOperation.update(saveRecipeFunction)); } }); Button noButton = WidgetFactory.createButton(messages.yesNoQuestion_defaultNoLabel(), new ClickHandler() { @Override public void onClick(ClickEvent event) { onComplete.call(MealOperation.update(dontSaveRecipeFunction)); } }); FlowPanel contents = new FlowPanel(); contents.add(WidgetFactory.createPromptPanel(promptText)); contents.add(recipeNamePanel); contents.add(WidgetFactory.createButtonsPanel(yesButton, noButton)); return new SurveyStageInterface.Aligned(contents, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP, SurveyStageInterface.DEFAULT_OPTIONS); }
From source file:next.common.ui.ui.kbd.KeyboardTextBox.java
License:Apache License
public KeyboardTextBox(boolean isPasswordBox) { super(1, 3);/*from w w w. j av a 2 s. c o m*/ setStyleName("b_textBox"); if (isPasswordBox) { textBox = new PasswordTextBox(); } else { textBox = new TextBox(); } textBox.setStyleName("text"); imgClear = new Image(RES.t_box_clear()); imgClear.getElement().getStyle().setOpacity(0); imgClear.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { textBox.setText(""); } }); getCellFormatter().setStyleName(0, 0, "left"); getCellFormatter().setStyleName(0, 1, "middle"); getCellFormatter().setStyleName(0, 2, "right"); getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); getCellFormatter().setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_MIDDLE); setWidget(0, 0, new HTML(" ")); setWidget(0, 1, textBox); setWidget(0, 2, imgClear); }
From source file:next.i.view.widgets.XButton.java
License:Apache License
private void XButton_(XButtonType buttonType, boolean iconOrientationLeft, String imageUrl, String imagePressedUrl) { _item = new FlexTable(); _item.setCellPadding(0);//w w w. j a v a 2 s. c o m _item.setCellSpacing(0); initWidget(_item); sinkEvents(Event.ONCLICK | Event.ONTOUCHCANCEL | Event.ONTOUCHEND | Event.ONTOUCHMOVE | Event.ONTOUCHSTART); setStyleName(XStyle.xbutton.name()); _item.setHTML(0, 0, " "); _item.setHTML(0, 1, "<div> </div>"); FlexCellFormatter cf = _item.getFlexCellFormatter(); cf.setStyleName(0, 0, "body"); cf.setStyleName(0, 1, "right"); cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); if (buttonType == XButtonType.NavigationRed || buttonType == XButtonType.NavigationBlue || buttonType == XButtonType.NavigationBlack) { addStyleName(XButtonType.Navigation.css() + " " + buttonType.css()); } else { addStyleName(buttonType.css()); } if (buttonType == XButtonType.Image) { Style s = _item.getElement().getStyle(); // TODO fix pressed state s.setProperty("backgroundImage", "url(" + imageUrl + ")"); if (iconOrientationLeft) { s.setProperty("paddingLeft", "30px"); s.setProperty("backgroundPosition", "left center"); } else { s.setProperty("paddingRight", "30px"); s.setProperty("backgroundPosition", "right center"); } } }
From source file:next.i.view.XBarItem.java
License:Apache License
private void BarItem_(Type type) { _item = new FlexTable(); _item.setCellPadding(0);/*from ww w. j a v a 2 s. c om*/ _item.setCellSpacing(0); initWidget(_item); sinkEvents(Event.ONCLICK | Event.ONTOUCHCANCEL | Event.ONTOUCHEND | Event.ONTOUCHMOVE | Event.ONTOUCHSTART); setStyleName(XStyle.navBarItem.name()); _item.setHTML(0, 0, " "); if (type != Type.LABEL) { _item.setHTML(0, 1, "<div> </div>"); } FlexCellFormatter cf = _item.getFlexCellFormatter(); cf.setStyleName(0, 0, "body"); if (type != Type.LABEL) { cf.setStyleName(0, 1, "right"); } cf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); if (type == Type.BACK_BUTTON) { addStyleName(XStyle.navBarItemBack.name()); } }
From source file:next.i.view.XNavigationBar.java
License:Apache License
/** * Private// w ww .j a v a 2s.c o m */ private void NavigationBar_() { _bar = new FlexTable(); initWidget(_bar); // _bar.setStyleName(XStyle.navigationBar.name()); _barTitle = new XBarItem(Type.LABEL); _barTitle.setStyleName(XStyle.navBarTitle.name()); _bar.setWidget(0, 1, _barTitle); _bar.setWidth("100%"); FlexCellFormatter fcf = _bar.getFlexCellFormatter(); fcf.setWidth(0, 0, "15%"); fcf.setWidth(0, 1, "70%"); fcf.setWidth(0, 2, "15%"); fcf.setHeight(0, 0, "100%"); fcf.setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER); fcf.setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_RIGHT); fcf.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE); fcf.setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE); fcf.setVerticalAlignment(0, 2, HasVerticalAlignment.ALIGN_MIDDLE); fcf.setWordWrap(0, 1, false); }
From source file:next.i.view.XTableCell.java
License:Apache License
private void XTableCell_(CellData cellData) { FlexTable xt = new FlexTable(); _panel = xt;/* w w w . ja va 2 s . c om*/ initWidget(_panel); _panel.setStyleName(XStyle.tableCell.name()); FlexCellFormatter fcf = xt.getFlexCellFormatter(); Widget[] westW = cellData.getWestWidgets(); Widget[] eastW = cellData.getEastWidgets(); Widget[] textW = cellData.getTextWidgets(); int colInx = 0; int westLen = 0; if (westW != null) { westLen = westW.length; for (Widget w : westW) { xt.setWidget(0, colInx, w); if (textW != null) { fcf.setRowSpan(0, colInx, textW.length); fcf.setHorizontalAlignment(0, colInx, HasHorizontalAlignment.ALIGN_LEFT); fcf.setVerticalAlignment(0, colInx, HasVerticalAlignment.ALIGN_MIDDLE); } colInx++; } } if (textW != null) { for (int i = 0; i < textW.length; i++) { if (i == 0) { xt.setWidget(i, colInx, textW[i]); fcf.setWidth(i, colInx, "99%"); } else { xt.setWidget(i, colInx - westLen, textW[i]); } } colInx++; } if (eastW != null) { for (Widget w : eastW) { xt.setWidget(0, colInx, w); if (textW != null) { fcf.setRowSpan(0, colInx, textW.length); fcf.setHorizontalAlignment(0, colInx, HasHorizontalAlignment.ALIGN_RIGHT); } colInx++; } } // TODO toggle state if (!_isFromController) { addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { _panel.addStyleName(XStyle.selected.name()); new Timer() { public void run() { removeStyleName(XStyle.selected.name()); } }.schedule(300); } }); } }