List of usage examples for com.google.gwt.user.client.ui HorizontalPanel setVerticalAlignment
public void setVerticalAlignment(VerticalAlignmentConstant align)
From source file:tv.dyndns.kishibe.qmaclone.client.game.input.InputWidgetClick.java
License:Open Source License
public InputWidgetClick(PacketProblem problem, AnswerView answerView, QuestionPanel questionPanel, SessionData sessionData) {/*from ww w . j a v a 2 s . co m*/ super(problem, answerView, questionPanel, sessionData); HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(ALIGN_MIDDLE); image = new Image(problem.getClickImageUrl()); image.setPixelSize(Constant.CLICK_IMAGE_WIDTH, Constant.CLICK_IMAGE_HEIGHT); panel.add(image); buttonOk.setStyleName("gwt-Button-clickControl"); panel.add(buttonOk); canvas = new MarkedCanvas(image, Constant.CLICK_IMAGE_WIDTH, Constant.CLICK_IMAGE_HEIGHT); canvas.addMouseDownHandler(this); add(panel); }
From source file:tv.dyndns.kishibe.qmaclone.client.game.input.InputWidgetSenmusubi.java
License:Open Source License
public InputWidgetSenmusubi(PacketProblem problem, AnswerView answerView, QuestionPanel questionPanel, SessionData sessionData) {//www. ja v a 2s . c om super(problem, answerView, questionPanel, sessionData); this.numberOfChoice = problem.getNumberOfShuffledChoices(); this.isImageChoice = problem.imageChoice; this.isImageAnswer = problem.imageAnswer; buttonLeft = new Button[numberOfChoice]; buttonRight = new Button[numberOfChoice]; select = new int[numberOfChoice]; HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(ALIGN_MIDDLE); add(panel); for (int i = 0; i < numberOfChoice; ++i) { select[i] = EMPTY; } // ? if (problem.imageChoice) { Grid gridLeft = new Grid(numberOfChoice, 1); for (int i = 0; i < numberOfChoice; ++i) { String imageUrl = problem.getShuffledChoice4SmallAsImageUrl(i); buttonLeft[i] = new Button(TEMPLATE.image(getLetter(ALPHA, i), UriUtils.fromString(imageUrl)), this); buttonLeft[i].setStyleName(BUTTON_SENMUSUBI_IMAGE); mapCol.put(buttonLeft[i], 0); mapRow.put(buttonLeft[i], i); gridLeft.setWidget(i, 0, buttonLeft[i]); } panel.add(gridLeft); } else { Grid gridLeft = new Grid(numberOfChoice, 2); for (int i = 0; i < numberOfChoice; ++i) { Label label = new Label(getLetter(ALPHA, i)); label.addStyleDependentName("buttonIndexSmall"); gridLeft.setWidget(i, 1, label); String choice = problem.shuffledChoices[i]; buttonLeft[i] = new Button( new SafeHtmlBuilder().appendEscapedLines(choice.replaceAll("%n", "\n")).toSafeHtml(), this); buttonLeft[i].setStyleName(BUTTON_SENMUSUBI); mapCol.put(buttonLeft[i], 0); mapRow.put(buttonLeft[i], i); gridLeft.setWidget(i, 0, buttonLeft[i]); } panel.add(gridLeft); } // ? int canvasWidth = 40; if (problem.imageAnswer) { canvasWidth += 40; } if (problem.imageChoice) { canvasWidth += 40; } int canvasHeight = (problem.imageAnswer || problem.imageChoice) ? 360 : 200; spacer.setPixelSize(canvasWidth, canvasHeight); panel.add(spacer); // ?? if (problem.imageAnswer) { Grid gridRight = new Grid(numberOfChoice, 1); for (int i = 0; i < numberOfChoice; ++i) { String imageUrl = problem.getShuffledAnswer4SmallAsImageUrl(i); buttonRight[i] = new Button(TEMPLATE.image(getLetter(DIGIT, i), UriUtils.fromString(imageUrl)), this); buttonRight[i].setStyleName(BUTTON_SENMUSUBI_IMAGE); mapCol.put(buttonRight[i], 1); mapRow.put(buttonRight[i], i); gridRight.setWidget(i, 0, buttonRight[i]); } panel.add(gridRight); } else { Grid gridRight = new Grid(numberOfChoice, 2); for (int i = 0; i < numberOfChoice; ++i) { Label label = new Label(getLetter(DIGIT, i)); label.addStyleDependentName("buttonIndexSmall"); gridRight.setWidget(i, 0, label); String answer = problem.shuffledAnswers[i]; buttonRight[i] = new Button( new SafeHtmlBuilder().appendEscapedLines(answer.replaceAll("%n", "\n")).toSafeHtml(), this); buttonRight[i].setStyleName(BUTTON_SENMUSUBI); mapCol.put(buttonRight[i], 1); mapRow.put(buttonRight[i], i); gridRight.setWidget(i, 1, buttonRight[i]); } panel.add(gridRight); } // OK buttonOk.setStyleName("gwt-Button-senmusubiControl"); add(buttonOk); }
From source file:tv.dyndns.kishibe.qmaclone.client.game.input.InputWidgetTegaki.java
License:Open Source License
public InputWidgetTegaki(PacketProblem problem, AnswerView answerView, QuestionPanel questionPanel, SessionData sessionData) {//from w w w . j a v a2s .co m super(problem, answerView, questionPanel, sessionData); for (int i = 0; i < NUMBER_OF_CANDIDATE; ++i) { buttons[i] = new Button("", this); buttons[i].setStyleName("gwt-Button-tegaki"); } final HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setVerticalAlignment(ALIGN_BOTTOM); { // final VerticalPanel panel = new VerticalPanel(); panel.add(new Label("")); { final Grid grid = new Grid(GRID_ROWS, GRID_COLUMS); int index = 0; for (int row = 0; row < GRID_ROWS; ++row) { for (int column = 0; column < GRID_COLUMS; ++column) { grid.setWidget(row, column, buttons[index++]); } } panel.add(grid); } horizontalPanel.add(panel); } horizontalPanel.add(strokeCanvas); { final VerticalPanel verticalPanel = new VerticalPanel(); buttonClear.setStyleName("gwt-Button-tegakiControl"); buttonDelete.setStyleName("gwt-Button-tegakiControl"); buttonOk.setStyleName("gwt-Button-tegakiControl"); verticalPanel.add(buttonClear); verticalPanel.add(buttonDelete); verticalPanel.add(buttonOk); horizontalPanel.add(verticalPanel); } add(horizontalPanel); }
From source file:tv.dyndns.kishibe.qmaclone.client.link.WidgetLinkData.java
License:Open Source License
public WidgetLinkData(PacketLinkData linkData, PanelLink panelLink) { this.linkData = linkData; this.panelLink = panelLink; add(new HTML(TEMPLATE.messageWithLink(UriUtils.fromString(linkData.url), linkData.homePageName, linkData.authorName, Utility.toDateFormat(new Date(linkData.lastUpdate))))); {//from w w w.j av a2 s . c om final HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(ALIGN_MIDDLE); panel.add(new HTML(TEMPLATE.image(UriUtils.fromString(linkData.url), linkData.bannerUrl))); panel.add(new HTML(SafeHtmlUtils.fromString(linkData.description))); { final VerticalPanel panelButtons = new VerticalPanel(); panelButtons.add(buttonUpdate); panelButtons.add(buttonRemove); panel.add(panelButtons); } add(panel); } }
From source file:tv.dyndns.kishibe.qmaclone.client.PanelMatching.java
License:Open Source License
public void setPlayerList(List<PacketMatchingPlayer> players) { final VerticalPanel verticalPanel = new VerticalPanel(); for (PacketMatchingPlayer player : players) { final HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setVerticalAlignment(ALIGN_MIDDLE); final Image image = new Image(Constant.ICON_URL_PREFIX + player.imageFileName); image.setPixelSize(Constant.ICON_SIZE, Constant.ICON_SIZE); horizontalPanel.add(image);/*from w w w . ja v a 2 s . co m*/ final HTML html = new HTML(player.playerSummary.asSafeHtml()); if (player.isRequestSkip) { html.addStyleDependentName("matchingSkip"); } horizontalPanel.add(html); verticalPanel.add(horizontalPanel); } gridPanel.setWidget(verticalPanel); }
From source file:tv.dyndns.kishibe.qmaclone.client.PanelRatioReport.java
License:Open Source License
public PanelRatioReport() { setWidth("800px"); setHorizontalAlignment(ALIGN_CENTER); add(new HTML( "??????????????????<br/>????????????????<br/>?????????????<br/>??????????")); HorizontalPanel idPanel = new HorizontalPanel(); idPanel.setVerticalAlignment(ALIGN_MIDDLE); textBoxProblemNumber.setWidth("240px"); textBoxProblemNumber.addFocusHandler(focusHandler); idPanel.add(textBoxProblemNumber);//from ww w.j av a2s .c o m idPanel.add(buttonAdd); idPanel.add(buttonRemove); add(idPanel); add(buttonUpdate); add(panelGrid); }
From source file:tv.dyndns.kishibe.qmaclone.client.ui.WidgetMultiItemSelector.java
License:Open Source License
public WidgetMultiItemSelector(String title, T[] items, int columns) { this.items = items; setHorizontalAlignment(ALIGN_CENTER); // //from w w w . j ava 2 s . c om { listBox.setWidth("150px"); for (T item : items) { listBox.addItem(item.toString()); } checkBoxMultiSelect.addClickHandler(this); final HorizontalPanel panel = new HorizontalPanel(); panel.setVerticalAlignment(ALIGN_MIDDLE); panel.add(listBox); panel.add(checkBoxMultiSelect); add(panel); } // { final VerticalPanel[] panels = new VerticalPanel[columns]; for (int i = 0; i < panels.length; ++i) { panels[i] = new VerticalPanel(); panelMultiSelect.add(panels[i]); } checkBoxs = new CheckBox[items.length]; for (int itemIndex = 0; itemIndex < items.length; ++itemIndex) { checkBoxs[itemIndex] = new CheckBox(items[itemIndex].toString()); panels[itemIndex / ((items.length + columns - 1) / columns)].add(checkBoxs[itemIndex]); } add(panelMultiSelect); } checkBoxMultiSelect.setValue(false); listBox.setSelectedIndex(0); set(ImmutableSet.of(items[0])); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.widget.EditorTabBar.java
License:Apache License
public EditorTabBar() { HorizontalPanel wrapper = new HorizontalPanel(); wrapper.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); wrapper.setHeight("100%"); wrapper.setWidth("100%"); panel = new HorizontalPanel(); SimplePanel simple = new SimplePanel(); simple.add(panel);/*from w w w . java 2s .com*/ simple.addStyleName("app-TabBar"); wrapper.add(simple); initWidget(wrapper); }
From source file:uk.ac.ncl.openlab.intake24.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 .ja v a2 s .c o m*/ 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, AddMealPrompt.class.getSimpleName()); }
From source file:uk.ac.ncl.openlab.intake24.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 w w w. j av a2s . com*/ .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(), "saveRecipeYesButton", 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, SaveHomeRecipePrompt.class.getSimpleName()); }