List of usage examples for com.google.gwt.user.client.ui HorizontalPanel add
@Override public void add(Widget w)
From source file:com.controlj.addon.gwttree.client.TreeOptions.java
License:Open Source License
public void showDialog() { VerticalPanel dialogContents = new VerticalPanel(); dialogContents.setSpacing(4);/*www . j a v a2s . c om*/ // Add the tree type radio buttons RadioButton dynamicChoice = createTreeChoice("treeTypeGroup", "Dynamic Tree", false); RadioButton staticChoice = createTreeChoice("treeTypeGroup", "Static Tree", true); if (state.isStaticTree) staticChoice.setValue(true); else dynamicChoice.setValue(true); dialogContents.add(dynamicChoice); dialogContents.add(staticChoice); // Add filtering support dialogContents.add(new Label("Filter by trend name (leave empty to not filter)")); HorizontalPanel sourcesPanel = new HorizontalPanel(); sourcesPanel.setSpacing(10); final ListBox sourceListBox = new ListBox(true); sourceListBox.setSize("10em", "5em"); for (String sourceName : state.sourceNames) sourceListBox.addItem(sourceName); sourcesPanel.add(sourceListBox); VerticalPanel sourcesButtonPanel = new VerticalPanel(); sourcesButtonPanel.add(new Button("Add...", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { final TextBox textBox = new TextBox(); Dialog.showInputDialog("Add Filter", textBox, new Dialog.Handler() { @Override public void setupButtons(final Button ok, final Button cancel) { textBox.addKeyPressHandler(new KeyPressHandler() { @Override public void onKeyPress(KeyPressEvent keyPressEvent) { if (keyPressEvent.getCharCode() == (char) 13) ok.click(); else if (keyPressEvent.getCharCode() == (char) 27) cancel.click(); } }); } @Override public void dialogClosed(boolean wasCancelled) { String name = textBox.getText().trim(); if (!wasCancelled && !name.isEmpty()) { state.sourceNames.add(name); sourceListBox.addItem(name); } } }); textBox.setFocus(true); } })); sourcesButtonPanel.add(new Button("Remove", new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { int count = sourceListBox.getItemCount(); for (int i = count - 1; i >= 0; i--) if (sourceListBox.isItemSelected(i)) { state.sourceNames.remove(sourceListBox.getItemText(i)); sourceListBox.removeItem(i); } } })); sourcesPanel.add(sourcesButtonPanel); dialogContents.add(sourcesPanel); final State originalState = state.copy(); Dialog.showInputDialog("Tree Options", dialogContents, new Dialog.Handler() { @Override public void setupButtons(Button ok, Button cancel) { } @Override public void dialogClosed(boolean wasCancelled) { if (wasCancelled) state = originalState; else if (!state.equals(originalState)) handler.optionsChanged(TreeOptions.this); } }); }
From source file:com.controlj.addon.gwttree.client.TreeOptions.java
License:Open Source License
private Widget createButtonPanel(DialogBox dialogBox, State originalState) { HorizontalPanel buttonPanel = new HorizontalPanel(); buttonPanel.setSpacing(15);/*from w w w . j av a2 s . c om*/ Button okButton = createButton("OK", dialogBox, false, originalState); buttonPanel.add(okButton); Button cancelButton = createButton("Cancel", dialogBox, true, null); buttonPanel.add(cancelButton); return buttonPanel; }
From source file:com.cristal.storm.prototype.client.mvp.view.MainPageView.java
License:Apache License
@Inject public MainPageView() { MCECell.Images images = GWT.create(MCECell.Images.class); MCECell textCell = new MCECell(images.icon()); ProvidesKey<MCE> keyProvider = new ProvidesKey<MCE>() { public Object getKey(MCE item) { // Always do a null check. return (item == null) ? null : item.getURI(); }/* w w w. ja va2s. co m*/ }; mceCollectionDraggable = new DragAndDropCellList<MCE>(textCell, DEFAULT_RESOURCES, keyProvider); mceSelectionModel = new SingleSelectionModel<MCE>(keyProvider); mceCollectionDraggable.setSelectionModel(mceSelectionModel); // mceCollectionDraggable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); widget = uiBinder.createAndBindUi(this); HorizontalPanel horzPanel = new HorizontalPanel(); // Push the data into the widget. // TODO Remove this hardcoded definition of tags Set<String> mcetags1 = new TreeSet<String>(); mcetags1.add("search"); mcetags1.add("mail"); mcetags1.add("travel"); // TODO Remove this hardcoded definition of MCE MCE mce = new MCE("kayak.com", mcetags1); // MCE mce3 = new MCE("kayak.com", mcetags2); mceListVisible = new Vector<MCE>(); mceListVisible.add(mce); mceCollectionDraggable.setRowData(0, mceListVisible); mceSelectionModel.setSelected(mce, true); // The cell of this CellList are only draggable mceCollectionDraggable.setCellDraggableOnly(); // setup the drag operation DraggableOptions options = new DraggableOptions(); // use a clone of the original cell as drag helper options.setHelper(HelperType.CLONE); // set the opacity of the drag helper options.setOpacity((float) 0.9); // append the drag helper to the body element options.setAppendTo("body"); // configure the drag operations of the cell list with this options mceCollectionDraggable.setDraggableOptions(options); /** * Create a droppable CellList */ final FlowPanel aGwtPanel = new FlowPanel(); aGwtPanel.add(new Label("test")); DroppableWidget<FlowPanel> droppablePanel = new DroppableWidget<FlowPanel>(aGwtPanel); // configure the drop behaviour (see next paragraph) droppablePanel.setTolerance(DroppableTolerance.POINTER); droppablePanel.getOriginalWidget(); droppablePanel.addDropHandler(new DropEventHandler() { public void onDrop(DropEvent event) { // retrieve the droppable widget DroppableWidget<FlowPanel> droppableLabel = (DroppableWidget<FlowPanel>) event.getDroppableWidget(); // retrieve the dropped draggable widget (we assume it is a // draggable label) DraggableWidget<Label> draggableLabel = (DraggableWidget<Label>) event.getDraggableWidget(); Label toto = (Label) (droppableLabel.getOriginalWidget().getWidget(0)); Label toto2 = (Label) (droppableLabel.getOriginalWidget().getWidget(0)); aGwtPanel.add(toto2); // toto.setText("Let's eat!!!!"); // remove the draggabeLable // draggableLabel.removeFromParent(); // aGwtPanel.add( new // Label(event.getDraggableWidget().toString())); // event.getDraggableWidget().removeFromParent(); aGwtPanel.add(new Label("just dragged item1")); aGwtPanel.add(new Label("just dragged item2")); } }); horzPanel.add(droppablePanel); centerAbsPanel.add(horzPanel); }
From source file:com.dawg6.gwt.client.ApplicationPanel.java
License:Open Source License
public static DialogBox showDialogBox(String title, IsWidget component, int buttons, final DialogBoxResultHandler handler) { // Create the popup dialog box final DialogBox dialogBox = createDialogBox(); dialogBox.setText(title);//from ww w .ja v a2 s. co m dialogBox.setAnimationEnabled(true); dialogBox.setModal(false); FlexTable table = new FlexTable(); table.setWidget(0, 0, component); dialogBox.setWidget(table); HorizontalPanel row = new HorizontalPanel(); row.setSpacing(5); row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); row.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); table.setWidget(1, 0, row); boolean firstButton = true; if (buttons == 0) buttons = OK; for (final ButtonInfo b : allButtons) { if ((buttons > 0) && ((buttons & b.id) != 0)) { final Button button = createDialogBoxButton(b.label); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { dialogBox.hide(); if (handler != null) handler.dialogBoxResult(b.id); } }); row.add(button); if (firstButton) { button.setFocus(true); firstButton = false; } } } dialogBox.center(); return dialogBox; }
From source file:com.dawg6.gwt.client.ApplicationPanel.java
License:Open Source License
public static AsyncTaskHandler showWaitDialogBox(String title, String message) { VerticalPanel panel = new VerticalPanel(); HorizontalPanel row = new HorizontalPanel(); row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); row.setSpacing(5);/*from w w w .j a v a 2 s . c o m*/ panel.add(row); Image image = new Image("images/Progressbar.gif"); image.setSize("64px", "16px"); row.add(image); if (message != null) { Label label = new Label(message); row.add(label); } final DialogBox dialogBox = showDialogBox(title, panel, -1, null); return new AsyncTaskHandler() { @Override public void taskCompleted() { dialogBox.hide(); } }; }
From source file:com.dawg6.gwt.client.widgets.AbstractSearchable.java
License:Open Source License
protected AbstractSearchable(ValueFactory<T> factory, Comparator<T> sorter) { captionPanel = new CaptionPanel("Caption"); initWidget(captionPanel);/*from ww w . j a v a 2s .co m*/ VerticalPanel verticalPanel_5 = new VerticalPanel(); captionPanel.setContentWidget(verticalPanel_5); verticalPanel_5.setSize("5cm", "3cm"); HorizontalPanel row = new HorizontalPanel(); row.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); row.setSpacing(5); verticalPanel_5.add(row); Label label = new Label("Filter:"); row.add(label); suggestBox = new TextBox(); row.add(suggestBox); suggestBox.setVisibleLength(20); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { setFilter(); } }); Button button = new Button("Clear"); row.add(button); button.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { suggestBox.setText(""); setFilter(); } }); listBox = new CellList<T>(getCell()); scroll = new ScrollPanel(); scroll.setWidget(listBox); this.list = new Vector<T>(); this.dataProvider = new ListDataProvider<T>(); this.dataProvider.addDataDisplay(listBox); verticalPanel_5.add(scroll); listBox.setPageSize(Integer.MAX_VALUE); listBox.setSize("300px", "300px"); selectionModel = new SingleSelectionModel<T>(); listBox.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { selectionChanged(getSelectedValue()); } }); this.factory = factory; this.sorter = sorter; }
From source file:com.dawg6.web.dhcalc.client.AboutDialog.java
License:Open Source License
public AboutDialog() { flexTable = new FlexTable(); flexTable.setBorderWidth(0);//w ww.ja v a 2s . c om flexTable.setCellPadding(5); initWidget(flexTable); Label lblNewLabel = new Label("DH DPS Calculator"); lblNewLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); lblNewLabel.setStyleName("boldText"); lblNewLabel.setWordWrap(false); flexTable.setWidget(0, 0, lblNewLabel); flexTable.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP); flexTable.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setSpacing(5); horizontalPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); flexTable.setWidget(1, 0, horizontalPanel); Label lblNewLabel_1 = new Label("Version:"); horizontalPanel.add(lblNewLabel_1); versionLabel = new Label(Version.getVersionString()); horizontalPanel.add(versionLabel); flexTable.getCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel horizontalPanel_1 = new HorizontalPanel(); horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_1.setSpacing(5); horizontalPanel_1.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); flexTable.setWidget(3, 0, horizontalPanel_1); Label lblWritteByDawg = new Label("Written By:"); horizontalPanel_1.add(lblWritteByDawg); Anchor label_1 = new Anchor("New label"); label_1.setTarget("_blank"); label_1.setText("dawg6"); label_1.setHref("http://us.battle.net/d3/en/profile/Dawg6-1416/"); horizontalPanel_1.add(label_1); Label lblNewLabel_2 = new Label("("); horizontalPanel_1.add(lblNewLabel_2); Anchor anchor_1 = new Anchor("New label"); anchor_1.setText("scott@dawg6.com"); anchor_1.setTarget("_blank"); anchor_1.setHref("mailto:scott@dawg6.com"); horizontalPanel_1.add(anchor_1); Label lblNewLabel_3 = new Label(")"); horizontalPanel_1.add(lblNewLabel_3); flexTable.getCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel horizontalPanel_2 = new HorizontalPanel(); horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_2.setSpacing(5); horizontalPanel_2.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); flexTable.setWidget(5, 0, horizontalPanel_2); Label lblRedditThread = new Label("Reddit Thread:"); horizontalPanel_2.add(lblRedditThread); Anchor anchor = new Anchor("New label"); anchor.setTarget("_blank"); anchor.setText("http://redd.it/2jiynj"); anchor.setHref("http://redd.it/2jiynj"); horizontalPanel_2.add(anchor); flexTable.getCellFormatter().setHorizontalAlignment(5, 0, HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel horizontalPanel_3 = new HorizontalPanel(); horizontalPanel_3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_3.setSpacing(5); horizontalPanel_3.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); flexTable.setWidget(6, 0, horizontalPanel_3); Label lblBlizzardThread = new Label("Blizzard Thread:"); horizontalPanel_3.add(lblBlizzardThread); Anchor anchor_2 = new Anchor("New label"); anchor_2.setText("http://us.battle.net/d3/en/forum/topic/18706673688"); anchor_2.setTarget("_blank"); anchor_2.setHref("http://us.battle.net/d3/en/forum/topic/18706673688"); horizontalPanel_3.add(anchor_2); flexTable.getCellFormatter().setHorizontalAlignment(6, 0, HasHorizontalAlignment.ALIGN_CENTER); HorizontalPanel horizontalPanel_4 = new HorizontalPanel(); horizontalPanel_4.setSpacing(5); horizontalPanel_4.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); flexTable.setWidget(7, 0, horizontalPanel_4); Anchor anchor_3 = new Anchor("New label"); anchor_3.setText("Change Log"); anchor_3.setTarget("_blank"); anchor_3.setHref("changeLog.txt?v2"); horizontalPanel_4.add(anchor_3); Anchor anchor_4 = new Anchor("New label"); anchor_4.setText("To-do List"); anchor_4.setTarget("_blank"); anchor_4.setHref("https://github.com/dawg6/dhcalc/issues"); horizontalPanel_4.add(anchor_4); flexTable.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_CENTER); Anchor anchor_5 = new Anchor("Source Code"); anchor_5.setTarget("_blank"); anchor_5.setHref("https://github.com/dawg6/dhcalc"); horizontalPanel_4.add(anchor_5); flexTable.getCellFormatter().setHorizontalAlignment(7, 0, HasHorizontalAlignment.ALIGN_CENTER); }
From source file:com.dawg6.web.dhcalc.client.BaseSpinner.java
License:Open Source License
/** * @wbp.parser.constructor/*from ww w. j a v a 2 s. c o m*/ */ protected BaseSpinner(ValueBox<T> box, String text, T min, T max, T increment) { this.box = box; this.min = min; this.max = max; this.increment = increment; box.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { keyPressed(); } }); box.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { normalize(); } }); box.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { normalize(); } }); box.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { normalize(); } }); HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setStyleName("spinner"); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); initWidget(horizontalPanel); down = new Button(); down.setText("-"); down.setStyleName("spinnerDownButton"); horizontalPanel.add(down); down.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { increment(-1); } }); box.setStyleName("spinnerBox"); box.setText(text); horizontalPanel.add(box); box.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { BaseSpinner.this.box.selectAll(); } }); up = new Button(); up.setText("+"); up.setStyleName("spinnerUpButton"); horizontalPanel.add(up); up.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { increment(1); } }); }
From source file:com.dawg6.web.dhcalc.client.BPData.java
License:Open Source License
public BPData() { VerticalPanel panel = new VerticalPanel(); initWidget(panel);/*from w w w. j a v a 2s .com*/ HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setSpacing(5); panel.add(horizontalPanel); Label lblNewLabel = new Label("Skill:"); lblNewLabel.setStyleName("boldText"); horizontalPanel.add(lblNewLabel); skills = new ListBox(); horizontalPanel.add(skills); Label lblNewLabel2 = new Label("Weapon Type:"); lblNewLabel2.setStyleName("boldText"); horizontalPanel.add(lblNewLabel2); weaponType = new ListBox(); horizontalPanel.add(weaponType); for (WeaponType t : WeaponType.values()) { weaponType.addItem(t.getName(), t.name()); } CaptionPanel cptnpnlNewPanel = new CaptionPanel("Skill Break Point Data"); panel.add(cptnpnlNewPanel); table = new FlexTable(); cptnpnlNewPanel.setContentWidget(table); table.setSize("5cm", "3cm"); table.setStyleName("breakpointTable"); table.setCellPadding(5); table.setBorderWidth(1); table.getRowFormatter().addStyleName(0, "headerRow"); int col = 0; Label bp = new Label("BP"); bp.setWordWrap(false); table.setWidget(0, col++, bp); Label fpa = new Label("FPA"); fpa.setWordWrap(false); table.setWidget(0, col++, fpa); Label minAps = new Label("Min APS"); minAps.setWordWrap(false); table.setWidget(0, col++, minAps); Label actualAps = new Label("Actual APS"); actualAps.setWordWrap(false); table.setWidget(0, col++, actualAps); List<Pair<String, String>> list = new Vector<Pair<String, String>>(); for (ActiveSkill s : ActiveSkill.values()) { if (DamageFunction.hasDamage(s) && (s.getFrames() != 0)) list.add(new Pair<String, String>(s.getLongName(), s.name())); } Collections.sort(list, new Comparator<Pair<String, String>>() { @Override public int compare(Pair<String, String> o1, Pair<String, String> o2) { return o1.getA().toLowerCase().compareTo(o2.getA().toLowerCase()); } }); for (Pair<String, String> p : list) { skills.addItem(p.getA(), p.getB()); } skills.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { skillChanged(); } }); weaponType.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { skillChanged(); } }); skills.setSelectedIndex(0); weaponType.setSelectedIndex(0); skillChanged(); }
From source file:com.dawg6.web.dhcalc.client.BuffPanel.java
License:Open Source License
public BuffPanel() { CaptionPanel cptnpnlNewPanel = new CaptionPanel("Follower Buffs"); initWidget(cptnpnlNewPanel);//from w ww. j a va 2 s . c o m FlexTable flexTable = new FlexTable(); cptnpnlNewPanel.setContentWidget(flexTable); HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.setSpacing(5); flexTable.setWidget(0, 0, horizontalPanel); Label lblNewLabel = new Label("Enchantress"); horizontalPanel.add(lblNewLabel); Anchor anchor = new Anchor("Focused Mind:"); anchor.setTarget("_blank"); anchor.setHref("http://us.battle.net/d3/en/follower/enchantress/skill/focused-mind"); horizontalPanel.add(anchor); Label lblNewLabel_1 = new Label((String) null); horizontalPanel.add(lblNewLabel_1); focusedMind = new SimpleCheckBox(); flexTable.setWidget(0, 1, focusedMind); HorizontalPanel horizontalPanel_1 = new HorizontalPanel(); horizontalPanel_1.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_1.setSpacing(5); flexTable.setWidget(1, 0, horizontalPanel_1); Label lblScoundrel = new Label("Scoundrel"); horizontalPanel_1.add(lblScoundrel); Anchor anchor_1 = new Anchor("Anatomy:"); anchor_1.setTarget("_blank"); anchor_1.setHref("http://us.battle.net/d3/en/follower/scoundrel/skill/anatomy"); horizontalPanel_1.add(anchor_1); anatomy = new SimpleCheckBox(); flexTable.setWidget(1, 1, anatomy); HorizontalPanel horizontalPanel_2 = new HorizontalPanel(); horizontalPanel_2.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_2.setSpacing(5); flexTable.setWidget(2, 0, horizontalPanel_2); Label label = new Label("Scoundrel"); horizontalPanel_2.add(label); Anchor anchor_2 = new Anchor("Hysteria:"); anchor_2.setTarget("_blank"); anchor_2.setHref("http://us.battle.net/d3/en/follower/scoundrel/skill/hysteria"); horizontalPanel_2.add(anchor_2); hysteria = new SimpleCheckBox(); flexTable.setWidget(2, 1, hysteria); HorizontalPanel horizontalPanel_3 = new HorizontalPanel(); horizontalPanel_3.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); horizontalPanel_3.setSpacing(5); flexTable.setWidget(3, 0, horizontalPanel_3); Label lblTemplar = new Label("Templar"); horizontalPanel_3.add(lblTemplar); Anchor anchor_3 = new Anchor("Hysteria:"); anchor_3.setHTML("Inspire:"); anchor_3.setText("Inspire:"); anchor_3.setTarget("_blank"); anchor_3.setHref("http://us.battle.net/d3/en/follower/templar/skill/inspire"); horizontalPanel_3.add(anchor_3); inspire = new SimpleCheckBox(); flexTable.setWidget(3, 1, inspire); }