List of usage examples for com.google.gwt.user.client.ui Label Label
public Label(String text, boolean wordWrap)
From source file:asquare.gwt.tk.demo.client.DebugPanel.java
License:Apache License
private Widget createControlPanel(final DebugEventListener eventListener) { BasicPanel controls = new BasicPanel(); DOM.setAttribute(controls.getElement(), "id", "debug-controls"); // debug output BasicPanel debug = new BasicPanel("p", BasicPanel.DISPLAY_INLINE); debug.add(new Label("Debug output ", false)); debug.add(new Button("enable", new ClickListener() { public void onClick(Widget sender) { Debug.enable();// w w w. j a v a2s . c om } })); debug.add(new Button("disable", new ClickListener() { public void onClick(Widget sender) { Debug.disable(); } })); controls.add(debug); // console BasicPanel console = new BasicPanel("p", BasicPanel.DISPLAY_INLINE); console.add(new Label("Debug console ", false)); console.add(new Button("enable", new ClickListener() { public void onClick(Widget sender) { DebugConsole.getInstance().enable(); } })); console.add(new Button("disable", new ClickListener() { public void onClick(Widget sender) { DebugConsole.getInstance().disable(); } })); controls.add(console); // event tracing BasicPanel tracing = new BasicPanel("p", BasicPanel.DISPLAY_INLINE); tracing.add(new Label("Event tracing ", false)); tracing.add(new Button("enable", new ClickListener() { public void onClick(Widget sender) { eventListener.enable(true); Debug.println("You can trace any event. Some events are ignored by default"); } })); tracing.add(new Button("disable", new ClickListener() { public void onClick(Widget sender) { eventListener.enable(false); } })); controls.add(tracing); Widget checkBoxes = createCheckBoxes(); controls.add(checkBoxes); DOM.setStyleAttribute(checkBoxes.getElement(), "display", "block"); return controls; }
From source file:com.allen_sauer.gwt.log.client.DivLogger.java
License:Apache License
/** * @deprecated/*w ww.j ava2 s . c o m*/ */ @Deprecated private FocusPanel makeHeader() { FocusPanel header; header = new FocusPanel(); HorizontalPanel masterPanel = new HorizontalPanel(); masterPanel.setWidth("100%"); header.add(masterPanel); final Label titleLabel = new Label("gwt-log", false); titleLabel.setStylePrimaryName(LogClientBundle.INSTANCE.css().logTitle()); HorizontalPanel buttonPanel = new HorizontalPanel(); levelButtons = new Button[levels.length]; for (int i = 0; i < levels.length; i++) { final int level = levels[i]; levelButtons[i] = new Button(LogUtil.levelToString(level)); buttonPanel.add(levelButtons[i]); levelButtons[i].addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.setCurrentLogLevel(level); } }); } Button clearButton = new Button("Clear"); clearButton.addStyleName(LogClientBundle.INSTANCE.css().logClearButton()); DOM.setStyleAttribute(clearButton.getElement(), "color", "#00c"); clearButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.clear(); } }); buttonPanel.add(clearButton); Button aboutButton = new Button("About"); aboutButton.addStyleName(LogClientBundle.INSTANCE.css().logClearAbout()); aboutButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ((Button) event.getSource()).setFocus(false); Log.diagnostic("\n" // + "gwt-log-" + Log.getVersion() // + " - Runtime logging for your Google Web Toolkit projects\n" + // "Copyright 2007 Fred Sauer\n" + // "The original software is available from:\n" + // "\u00a0\u00a0\u00a0\u00a0http://allen-sauer.com/gwt/\n", null); } }); Button closeButton = new Button("X"); closeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { logDockPanel.removeFromParent(); } }); masterPanel.add(titleLabel); masterPanel.add(buttonPanel); masterPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); masterPanel.add(aboutButton); masterPanel.add(closeButton); masterPanel.setCellHeight(titleLabel, "100%"); masterPanel.setCellWidth(titleLabel, "50%"); masterPanel.setCellWidth(aboutButton, "50%"); new MouseDragHandler(titleLabel); return header; }
From source file:com.apress.progwt.client.college.gui.timeline.ProcessTimeLineObjFactory.java
License:Apache License
/** * mea culpa. putting all the instanceof stuff in one place. Is there * a better way to do this when I can't put anything to do with * ConstHolder.images into the real domain objects without fear of * them exploding in a non GWT context?/*from w w w . j a v a 2s. c om*/ * * * @param zoomableTimeline * @param manager * @param tlo * @return */ public TimelineRemembersPosition getWidget(ZoomableTimeline<?> zoomableTimeline, TimelineController controller, TimeLineObj<?> tlo) { // if (tlo.getHasDate() instanceof HippoDate) { // TLORangeWidget tlow = new TLORangeWidget(zoomableTimeline, // tlo); // tlow.addMouseWheelListener(zoomableTimeline); // return tlow; // } else { // Widget mainWidget = null; Label mainLabel = null; TLOWrapper tlow = null; if (tlo.getHasDate() instanceof ProcessTimeLineEntry) { Image dragImage = ConstHolder.images.bullet_blue().createImage(); ProcessTimeLineEntry pte = (ProcessTimeLineEntry) tlo.getHasDate(); ProcessType processType = pte.getProcessType(); String imageName = processType.getImageName(); if (imageName != null) { if (imageName.equals("applying")) { mainWidget = ConstHolder.images.applying().createImage(); } else if (imageName.equals("accepted")) { mainWidget = ConstHolder.images.accepted().createImage(); } else if (imageName.equals("rejected")) { mainWidget = ConstHolder.images.rejected().createImage(); } else if (imageName.equals("applied")) { mainWidget = ConstHolder.images.applied().createImage(); } else if (imageName.equals("considering")) { mainWidget = ConstHolder.images.considering().createImage(); } } else { if (processType.isPercentage()) { mainWidget = new ProcessPercentWidget(controller, processType, pte.getProcessValue()); } else { mainWidget = new ProcessCheckboxWidget(controller, processType, pte.getProcessValue()); } mainLabel = new Label(processType.getName(), false); } tlow = new TLOWrapper(zoomableTimeline, tlo, dragImage, mainWidget, mainLabel); } tlow.addMouseWheelListener(zoomableTimeline); return tlow; }
From source file:com.apress.progwt.client.gui.timeline.TLOWrapper.java
License:Apache License
public TLOWrapper(ZoomableTimeline<T> timeline, final TimeLineObj<T> tlo, Image dragImage, Widget mainWidget, Label mainLabel) {//from w w w. j a va 2s . c o m this.tlo = tlo; this.top = 0; this.dragImage = dragImage; this.mainWidget = mainWidget; HorizontalPanel panel = new HorizontalPanel(); if (mainLabel == null) { label = new Label("", false); } else { label = mainLabel; } TLORangeEdge edge = new TLORangeEdge(timeline, tlo, this, true, dragImage); panel.add(edge); panel.add(label); if (mainWidget != null) { panel.add(mainWidget); } addClickListener(timeline); addDblClickListener(timeline); setWidget(panel); label.setStyleName("H-TLOWrapper"); JSUtil.disableSelect(getElement()); }
From source file:com.dawg6.web.dhcalc.client.DamageTypePanel.java
License:Open Source License
public DamageTypePanel() { CaptionPanel captionPanel = new CaptionPanel("Elemental Damage Modifiers"); initWidget(captionPanel);//from w ww .j a v a2 s . co m flexTable = new FlexTable(); captionPanel.setContentWidget(flexTable); List<DamageType> list = new Vector<DamageType>(DamageType.values().length); listBox = new ListBox(); for (DamageType type : DamageType.values()) { list.add(type); } Collections.sort(list, new Comparator<DamageType>() { @Override public int compare(DamageType o1, DamageType o2) { return o1.getLongName().compareTo(o2.getLongName()); } }); for (DamageType s : list) { listBox.addItem(s.getLongName(), s.name()); } listBox.setSelectedIndex(0); addButton = new Button("Add"); addButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { addType(); } }); flexTable.setWidget(0, 0, new Label("Type:", false)); flexTable.setWidget(0, 1, listBox); flexTable.getFlexCellFormatter().setColSpan(0, 1, 2); flexTable.setWidget(0, 2, addButton); }
From source file:com.dawg6.web.dhcalc.client.DamageTypePanel.java
License:Open Source License
private void addType(DamageType type, int value) { int row = fields.size() + 1; final Holder holder = new Holder(); holder.removeButton = new Button("Remove"); holder.row = row;//from w w w . jav a2 s. c o m holder.spinner = new NumberSpinner(); holder.spinner.setVisibleLength(4); holder.spinner.setTitle("Additional damage done by " + type.getLongName() + " skills, as shown in-game in the Character Details screen, under Offense"); holder.spinner.setValue(value); holder.type = type; holder.removeButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { removeType(holder); } }); fields.put(type, holder); flexTable.setWidget(row, 0, new Label(type.getLongName(), false)); flexTable.setWidget(row, 1, new Label("+ %", false)); flexTable.setWidget(row, 2, holder.spinner); flexTable.setWidget(row, 3, holder.removeButton); }
From source file:com.dawg6.web.dhcalc.client.GemsPanel.java
License:Open Source License
public GemsPanel() { CaptionPanel captionPanel = new CaptionPanel("Legendary Gems"); initWidget(captionPanel);//from w w w . j av a 2s . c o m table = new FlexTable(); captionPanel.setContentWidget(table); List<GemSkill> gems = new Vector<GemSkill>(); for (GemSkill gem : GemSkill.values()) gems.add(gem); Collections.sort(gems, new Comparator<GemSkill>() { @Override public int compare(GemSkill o1, GemSkill o2) { return o1.getDisplayName().toLowerCase().compareTo(o2.getDisplayName().toLowerCase()); } }); for (int i = 0; i < NUM_GEMS; i++) { final int row = i; Anchor anchor = new Anchor("Gem " + (i + 1)); anchor.setWordWrap(false); anchor.setTarget("_blank"); anchor.setHref("javascript:void(0)"); anchors.add(anchor); table.setWidget(row, 0, anchor); ListBox list = new ListBox(); list.addItem("None", ""); list.setWidth("100%"); table.setWidget(row, 1, list); listBoxes.add(list); list.setSelectedIndex(0); selected.add(null); for (GemSkill gem : gems) { list.addItem(gem.getDisplayName(), gem.name()); } list.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { gemChanged(row); } }); Label label = new Label("Level:", false); table.setWidget(row, 2, label); NumberSpinner level = new NumberSpinner(); level.setMax(100); level.setVisibleLength(4); table.setWidget(row, 3, level); levels.add(level); level.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { levelChanged(row); } }); attributes.add(null); } }
From source file:com.dawg6.web.dhcalc.client.GemsPanel.java
License:Open Source License
private boolean setGem(final int i, GemSkill gem, GemAttributeData gd) { if ((gem != null) && (gd == null)) { gd = new GemAttributeData(); gd.level = 0;//from ww w .java 2s .c o m for (GemSkill.Attribute a : gem.getAttributes()) { gd.put(a.getLabel(), 0); } } boolean gemChanged = false; boolean valueChanged = false; ListBox list = listBoxes.get(i); GemSkill prev = selected.get(i); int next = 0; if (gem == null) { next = 0; } else { int num = list.getItemCount(); boolean found = false; for (int n = 1; n < num; n++) { String value = list.getValue(n); if (value.equals(gem.name())) { next = n; found = true; break; } } if (!found) { next = 0; gd = null; } } if (gem != prev) { list.setSelectedIndex(next); selected.set(i, gem); gemChanged = true; } NumberSpinner level = levels.get(i); int prevLevel = level.getValue(); int nextLevel = prevLevel; if (gem == null) { nextLevel = 0; } else { nextLevel = gd.level; } if (nextLevel != prevLevel) { level.setValue(nextLevel); valueChanged = true; } if (gemChanged) { Anchor anchor = anchors.get(i); if (gem == null) { anchor.setHref("javascript:void(0)"); } else { anchor.setHref(gem.getUrl()); } if (attributes.get(i) != null) { table.removeCell(i, 5); table.removeCell(i, 4); attributes.set(i, null); } if ((gem != null) && (gem.getAttributes() != null) && (gem.getAttributes().length > 0)) { // TODO Handle more than 1 Attribute per Gem Label label = new Label("# " + gem.getAttributes()[0].getLabel() + ":", false); NumberSpinner spinner = new NumberSpinner(); spinner.setMax(gem.getAttributes()[0].getMaxValue(gd.level)); spinner.setVisibleLength(4); table.setWidget(i, 4, label); table.setWidget(i, 5, spinner); attributes.set(i, spinner); spinner.setValue(gd.get(gem.getAttributes()[0].getLabel())); spinner.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { attributeChanged(i); } }); } } else { if ((gem == null) || (gem.getAttributes() == null) || (gem.getAttributes().length == 0)) { // nothing changes } else { NumberSpinner a = attributes.get(i); int prevValue = a.getValue(); Integer nextValue = gd.get(gem.getAttributes()[0].getLabel()); if (nextValue != prevValue) { a.setValue(nextValue); valueChanged = true; } } } return gemChanged | valueChanged; }
From source file:com.dawg6.web.dhcalc.client.ItemPanel.java
License:Open Source License
public ItemPanel() { disableListeners = false;//from w ww . j a va 2s . c om CaptionPanel cptnpnlSpecialItems = new CaptionPanel("Items"); initWidget(cptnpnlSpecialItems); table = new FlexTable(); cptnpnlSpecialItems.setContentWidget(table); int row = 0; Label label_1 = new Label("General", false); label_1.addStyleName("boldText"); table.setWidget(row, 0, label_1); row++; Label label_4 = new Label("# Ancient Items:", false); table.setWidget(row, 0, label_4); numAncients = new NumberSpinner(); numAncients.setVisibleLength(4); numAncients.setTitle("# Ancient items worn"); table.setWidget(row, 1, numAncients); row++; Label label_2 = new Label("Area Damage +%:", false); table.setWidget(row, 0, label_2); areaDamageEquipment = new NumberSpinner(); areaDamageEquipment.setMax(100); areaDamageEquipment.setVisibleLength(4); areaDamageEquipment.setTitle("Added Area Damage from Equipment only"); table.setWidget(row, 1, areaDamageEquipment); row++; Label label_3 = new Label("Elite Damage +%:", false); table.setWidget(row, 0, label_3); eliteDamagePercent = new NumberSpinner(); eliteDamagePercent.setVisibleLength(4); eliteDamagePercent.setTitle( "Added Elite Damage from Armor and Weapons only (do not include Bane of the Powerful bonus)"); table.setWidget(row, 1, eliteDamagePercent); row++; Label label_3a = new Label( "Note: subtract 15% from the value displayed in-game if Bane of the Powerful is rank 25 or more.", true); label_3a.addStyleName("boldText"); label_3a.setWidth("350px"); table.setWidget(row, 0, label_3a); table.getFlexCellFormatter().setColSpan(row, 0, 2); row++; Label label_5 = new Label("Set Bonuses", false); label_5.addStyleName("boldText"); table.setWidget(row, 0, label_5); row++; Label label_4b = new Label("Other Set Bonuses?", false); table.setWidget(row, 0, label_4b); this.otherSets = new SimpleCheckBox(); this.otherSets.setTitle("Select if any set bonuses not listed below are in effect."); table.setWidget(row, 1, this.otherSets); row++; for (ItemSet set : ItemSet.values()) { Anchor anchor = new Anchor(set.getName()); anchor.setWordWrap(false); anchor.setTarget("_blank"); anchor.setHref(set.getUrl()); table.setWidget(row, 0, anchor); final ItemSet thisSet = set; if (set.getMaxPieces() > 2) { NumberSpinner number = new NumberSpinner(); number.setMax(set.getMaxPieces()); number.setVisibleLength(2); number.setTitle("# of pieces of this set worn (add 1 if using RoRG)"); table.setWidget(row, 1, number); setCounts.put(thisSet, number); number.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { setChanged(thisSet); } }); } else { SimpleCheckBox checkBox = new SimpleCheckBox(); table.setWidget(row, 1, checkBox); setToggles.put(thisSet, checkBox); checkBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { setChanged(thisSet); } }); } row++; } Label label_4a = new Label("Note: Add 1 to Set Item count if using RROG", true); label_4a.addStyleName("boldText"); label_4a.setWidth("350px"); table.setWidget(row, 0, label_4a); table.getFlexCellFormatter().setColSpan(row, 0, 2); row++; Label label_6 = new Label("Special Item Bonuses", false); label_6.addStyleName("boldText"); table.setWidget(row, 0, label_6); row++; for (Slot slot : Slot.values()) { List<SpecialItemType> types = SpecialItemType.getItemsBySlot(slot); if (!types.isEmpty()) { rows.put(slot, row); Anchor anchor = new Anchor(slot.getName()); anchor.setWordWrap(false); anchor.setHref("javascript:void(0)"); anchor.setTarget("_blank"); table.setWidget(row, 0, anchor); anchors.put(slot, anchor); ListBox list = new ListBox(); list.setWidth("100%"); list.addItem("Other/None", ""); for (SpecialItemType t : types) { list.addItem(t.getName(), t.name()); } list.setSelectedIndex(0); final Slot thisSlot = slot; list.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { itemChanged(thisSlot); } }); listBoxes.put(slot, list); table.setWidget(row, 1, list); attributeSpinners.put(slot, new TreeMap<String, BaseSpinner<?>>()); row += 2; } } }
From source file:com.dawg6.web.dhcalc.client.ItemPanel.java
License:Open Source License
private boolean setItem(final Slot slot, SpecialItemType type, AttributeData data) { boolean changed = false; SpecialItemType prev = selected.get(slot); selected.put(slot, type);/* w w w .ja v a2 s . c o m*/ int row = rows.get(slot); if ((prev != null) && (type != prev)) { table.removeCell(row + 1, 1); attributeSpinners.get(slot).clear(); changed |= true; } if (type != prev) setItem(slot, type); if ((type != null) && (type != prev)) { changed |= true; FlexTable aTable = new FlexTable(); table.setWidget(row + 1, 1, aTable); SpecialItemType.Attribute[] aList = type.getAttributes(); int n = 0; for (SpecialItemType.Attribute a : aList) { String name = a.getLabel(); Label label = new Label(name + ":", false); aTable.setWidget(n, 0, label); double s = a.getScalar(); if (s > 100) { DoubleSpinner spinner = new DoubleSpinner(); spinner.setIncrement(0.1); spinner.setMin(a.getMin() / 10.0); spinner.setMax(a.getMax() / 10.0); spinner.setVisibleLength(6); aTable.setWidget(n, 1, spinner); attributeSpinners.get(slot).put(name, spinner); final SpecialItemType.Attribute thisAttribute = a; spinner.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { attributeValueChanged(slot, thisAttribute); } }); } else { NumberSpinner spinner = new NumberSpinner(); spinner.setMin(a.getMin()); spinner.setMax(a.getMax()); spinner.setVisibleLength(6); aTable.setWidget(n, 1, spinner); attributeSpinners.get(slot).put(name, spinner); final SpecialItemType.Attribute thisAttribute = a; spinner.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { attributeValueChanged(slot, thisAttribute); } }); } n++; } } if (type != null) { SpecialItemType.Attribute[] aList = type.getAttributes(); for (SpecialItemType.Attribute a : aList) { BaseSpinner<?> spinner = attributeSpinners.get(slot).get(a.getLabel()); Integer value = (data != null) ? data.get(a.getLabel()) : null; if (value == null) { if (slot.isCube()) { // TODO Get Min value for others that need min value as default for cube if (type == SpecialItemType.MeticulousBolts) value = a.getMin(); else value = a.getMax(); } else { // TODO Get Min value for others that need max value as default if (type == SpecialItemType.MeticulousBolts) value = a.getMax(); else value = a.getMin(); } } if (spinner instanceof NumberSpinner) { if (value != ((NumberSpinner) spinner).getValue()) { ((NumberSpinner) spinner).setValue(value); changed = true; } } else { if (value != (int) (((DoubleSpinner) spinner).getValue() * 10.0)) { ((DoubleSpinner) spinner).setValue(value / 10.0); changed = true; } } } } return changed; }