List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:org.geomajas.hammergwt.example.client.PanelsSample.java
License:Open Source License
public PanelsSample() { layout = new FlowPanel(); final AbsolutePanel pinkPanel = new AbsolutePanel(); pinkPanel.setSize("100px", "200px"); pinkPanel.getElement().setId("pinkPanel"); pinkPanel.getElement().getStyle().setBackgroundColor("pink"); pinkPanel.getElement().getStyle().setLeft(0, Style.Unit.PX); pinkPanel.getElement().getStyle().setTop(0, Style.Unit.PX); final Label pinkPanelLabel = new Label("Drag"); pinkPanelLabel.getElement().getStyle().setPadding(5, Style.Unit.PX); pinkPanel.add(pinkPanelLabel);// w w w . jav a 2 s .c om final AbsolutePanel orangePanel = new AbsolutePanel(); AbsolutePanel blackPanel = new AbsolutePanel(); //panel.getElement().getStyle().setTop(100, Style.Unit.PX); orangePanel.getElement().setId("orangePanel"); orangePanel.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); orangePanel.getElement().getStyle().setBackgroundColor("orange"); orangePanel.getElement().getStyle().setLeft(105, Style.Unit.PX); orangePanel.getElement().getStyle().setTop(0, Style.Unit.PX); orangePanel.setSize("100px", "200px"); orangePanel.add(new Label("Pinch")); blackPanel.getElement().setId("notDraggable"); blackPanel.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); blackPanel.getElement().getStyle().setBackgroundColor("black"); blackPanel.getElement().getStyle().setLeft(210, Style.Unit.PX); blackPanel.getElement().getStyle().setTop(0, Style.Unit.PX); blackPanel.setSize("100px", "200px"); final Label blackPanelLabel = new Label("Hold"); blackPanelLabel.getElement().getStyle().setPadding(5, Style.Unit.PX); blackPanelLabel.getElement().getStyle().setColor("white"); blackPanel.add(blackPanelLabel); //Hammer GWT widget example final HammerGWTExampleWidget hammerGWTWidget = new HammerGWTExampleWidget(); layout.add(orangePanel); layout.add(blackPanel); layout.add(hammerGWTWidget); layout.add(pinkPanel); // add hammer gwt events HammerGwt.on(HammerGwt.create(pinkPanel), new HammerHandler() { @Override public void onHammerEvent(NativeHammerEvent event) { log(event); event.preventDefault(); event.preventNativeDefault(); switch (event.getType()) { case TAP: //return to start position pinkPanel.getElement().getStyle().setLeft(0, Style.Unit.PX); pinkPanel.getElement().getStyle().setTop(0, Style.Unit.PX); pinkPanelLabel.setText("Drag"); break; case DRAG: default: pinkPanelLabel.setText("Tap to move to start position"); int left = event.getPageX() - 50; int top = event.getPageY() - 100; pinkPanel.getElement().getStyle().setLeft(left, Style.Unit.PX); pinkPanel.getElement().getStyle().setTop(top, Style.Unit.PX); break; } } }, EventType.TAP, EventType.DRAG); // add hammer gwt events HammerGwt.on(HammerGwt.create(orangePanel), new HammerHandler() { @Override public void onHammerEvent(NativeHammerEvent event) { log(event); switch (event.getType()) { case DRAG: int left = event.getPageX() - 50; int top = event.getPageY() - 100; orangePanel.getElement().getStyle().setLeft(left, Style.Unit.PX); orangePanel.getElement().getStyle().setTop(top, Style.Unit.PX); break; case PINCH: default: double w = (event.getScale() * orangePanel.getElement().getClientWidth()); double h = (event.getScale() * orangePanel.getElement().getClientHeight()); orangePanel.setPixelSize((int) w, (int) h); break; } } }, EventType.DRAG, EventType.PINCH); HammerTime hammerTime3 = HammerGwt.create(blackPanel.getElement()); // Set hammer gwt options hammerTime3.setOption(GestureOptions.HOLD_TIMEOUT, 2); hammerTime3.setOption(GestureOptions.DRAG, false); // add hammer gwt events NativeHammmerHandler sb3 = HammerGwt.on(HammerGwt.create(blackPanel), new HammerHandler() { @Override public void onHammerEvent(NativeHammerEvent event) { log(event); Timer timer = new Timer() { public void run() { // Timer expired blackPanelLabel.setText("Hold"); } }; switch (event.getType()) { case HOLD: blackPanelLabel.setText("Holding..."); timer.cancel(); break; case RELEASE: blackPanelLabel.setText("Released"); // Execute the timer to expire 1 second in the future timer.schedule(1000); break; } } }, EventType.HOLD, EventType.RELEASE); //HammerGWT.off(hammerTime3, EventType.DRAG, sb3); }
From source file:org.glom.web.client.ui.details.SingleLineText.java
License:Open Source License
public SingleLineText(final String text) { Widget dataWidget;/*from w ww. ja v a 2s . c om*/ if (text.startsWith("http://") || text.startsWith("ftp://")) { dataWidget = new Anchor(text, text, "_blank"); dataWidget.setStyleName("dataLink"); } else if (text.startsWith("www.")) { dataWidget = new Anchor(text, "http://" + text, "_blank"); dataWidget.setStyleName("dataLink"); } else { final Label dataLabel = new Label(); dataLabel.setText(text); dataWidget = dataLabel; } final Style style = dataWidget.getElement().getStyle(); style.setOverflow(Overflow.HIDDEN); style.setProperty("textOverflow", "ellipsis"); initWidget(dataWidget); }
From source file:org.gwtcmis.sample.client.application.SampleForm.java
License:Open Source License
/** * @param eventBus//from w ww. j a v a 2 s . com */ public SampleForm(final HandlerManager eventBus) { setWidth("100%"); setHeight("100%"); mainPanel = new VerticalPanel(); mainPanel.setSpacing(20); repositoryInfoPanel = new VerticalPanel(); Label title = new Label(); title.setText("REPOSITORIES:"); repositoryInfoPanel.add(title); mainPanel.add(repositoryInfoPanel); toolBarPanel = new HorizontalPanel(); toolBarPanel.setSpacing(10); createFolderButton = createButton("Add Folder"); createDocumentButton = createButton("Add Document"); deleteButton = createButton("Delete"); mainPanel.add(toolBarPanel); createTabPanel(); add(mainPanel); RootPanel.get().add(this); presenter = new SamplePresenter(eventBus); presenter.bindDisplay(this); }
From source file:org.gwtcmis.sample.client.application.SampleForm.java
License:Open Source License
/** * Creates one property panel with property name and value * // w ww .j a v a2 s.c o m * @param name * @param value * @return {@link HorizontalPanel} */ private HorizontalPanel createPropertyPanel(String name, String value) { HorizontalPanel hPanel = new HorizontalPanel(); Label label = new Label(); label.setText(name); label.setWidth("250px"); TextBox propertyBox = new TextBox(); propertyBox.setWidth("300px"); propertyBox.setText(value); hPanel.add(label); hPanel.add(propertyBox); return hPanel; }
From source file:org.gwtcmis.sample.client.application.SampleForm.java
License:Open Source License
/** * @see org.gwtcmis.sample.client.application.SamplePresenter.Display#displayRepository(org.xcmis.gwtframework.client.model.repository.CmisRepositoryInfo) *///from w ww . j av a 2s .c om public void displayRepository(CmisRepositoryInfo repositoryInfo) { Label label = new Label(); label.setText("- " + repositoryInfo.getRepositoryName()); repositoryInfoPanel.add(label); }
From source file:org.gwtopenmaps.demo.openlayers.client.examples.format.xml.XMLFormatExample.java
License:Apache License
@Override public void buildPanel() { contentPanel.add(new HTML("Shows the use of the OpenLayers XML format class<br/>" + "OpenLayers has a very simple XML format class (OpenLayers.Format.XML) " + "that can be used to read/write XML docs. The methods available on the " + "XML format (or parser if you like) allow for reading and writing of " + "the various XML flavors used by the library - in particular the vector " + "data formats. It is by no means intended to be a full-fledged XML toolset. " + "Additional methods will be added only as needed elsewhere in the library.<br/>" + "This page loads an XML document and demonstrates a few of the methods available in the parser.")); final Label outputValue = new Label(); HorizontalPanel panel = new HorizontalPanel(); Label statusLabel = new Label("Status : "); final InlineHTML statusLabelValue = new InlineHTML(); statusLabelValue.setHTML("<strong>XML document loaded</strong>."); panel.add(statusLabel);//from w w w. ja va 2 s . c o m panel.add(statusLabelValue); contentPanel.add(panel); contentPanel.add(new HTML("<p>After the XML document loads, see the result " + "of a few of the methods below. Assume that you start with the " + "following code: <br/>" + "var format = new OpenLayers.Format.XML();</p>" + "Sample methods")); VerticalPanel vp = new VerticalPanel(); GwtOpenLayersULComponent uLComponent = new GwtOpenLayersULComponent(); HorizontalPanel wp = new HorizontalPanel(); Anchor write = new Anchor(); write.setHTML("format.write()"); wp.add(write); wp.add(new Label(" - write the XML doc as text")); write.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(wp); HorizontalPanel ebyTagNames = new HorizontalPanel(); Anchor tagNames = new Anchor(); tagNames.setHTML("format.getElementsByTagNameNS()"); ebyTagNames.add(tagNames); ebyTagNames.add(new Label(" - get all gml:MultiPolygon")); tagNames.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { NodeList elements = xmlFormat.getElementsByTagNameNS(baseEl.getDocumentElement(), "http://www.opengis.net/gml", "MultiPolygon"); StringBuilder builder = new StringBuilder(); for (int i = 0; i < elements.getLength(); i++) { builder.append(xmlFormat.write(elements.getItem(i))); } outputValue.setText(builder.toString()); } }); uLComponent.add(ebyTagNames); HorizontalPanel hasAttributePanel = new HorizontalPanel(); Anchor hasAttAnchor = new Anchor(); hasAttAnchor.setHTML("format.hasAttributeNS()"); hasAttributePanel.add(hasAttAnchor); hasAttributePanel.add(new Label(" - test to see schemaLocation " + "attribute exists in the http://www.w3.org/2001/XMLSchema-instance namespace")); hasAttAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(String.valueOf(xmlFormat.hasAttributeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"))); } }); uLComponent.add(hasAttributePanel); vp.add(uLComponent); HorizontalPanel getAttrNodeNSPanel = new HorizontalPanel(); Anchor getAttrNodeNSAnchor = new Anchor(); getAttrNodeNSAnchor.setHTML("format.getAttributeNodeNS()"); getAttrNodeNSPanel.add(getAttrNodeNSAnchor); getAttrNodeNSPanel.add(new Label( " - get schemaLocation attribute in " + "the http://www.w3.org/2001/XMLSchema-instance namespace")); getAttrNodeNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.getAttributeNodeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"); outputValue.setText(e.getNodeName() + " = " + e.getNodeValue()); } }); uLComponent.add(getAttrNodeNSPanel); HorizontalPanel getAttrNSHorizontalPanel = new HorizontalPanel(); Anchor getAttrNSAnchor = new Anchor(); getAttrNSAnchor.setHTML("format.getAttributeNS()"); getAttrNSHorizontalPanel.add(getAttrNSAnchor); getAttrNSHorizontalPanel.add(new Label(" - get schemaLocation " + "attribute value in the http://www.w3.org/2001/" + "XMLSchema-instance namespace")); getAttrNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { outputValue.setText(xmlFormat.getAttributeNS(baseEl.getDocumentElement(), "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation")); } }); uLComponent.add(getAttrNSHorizontalPanel); HorizontalPanel createElNSPanel = new HorizontalPanel(); Anchor createElNSAnchor = new Anchor(); createElNSAnchor.setHTML("format.createElementNS()"); createElNSPanel.add(createElNSAnchor); createElNSPanel.add(new Label(" - create a foo:TestNode element" + " (and append it to the doc)")); createElNSAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.createElementNS("http://bar.com/foo", "foo:TestNode"); baseEl.getDocumentElement().appendChild(e); outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(createElNSPanel); HorizontalPanel createTextNodePanel = new HorizontalPanel(); Anchor createTextNodeAnchor = new Anchor(); createTextNodeAnchor.setHTML("format.createTextNode()"); createTextNodePanel.add(createTextNodeAnchor); createTextNodePanel.add(new Label(" - create a text node" + " (and append it to the doc)")); createTextNodeAnchor.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Element e = xmlFormat.createTextNode("test text "); baseEl.getDocumentElement().appendChild(e); outputValue.setText(xmlFormat.write(baseEl)); } }); uLComponent.add(createTextNodePanel); contentPanel.add(vp); contentPanel.add(new InlineHTML("<strong>Output</strong> :")); contentPanel.add(outputValue); initWidget(contentPanel); }
From source file:org.idwebmail.client.LeftPanel.java
public LeftPanel() { this.setSize("200px", "100%"); final Label labelMessage = new Label() { {//from ww w . j a va2 s. c o m setWidth("300"); } }; arbol = new Arbol() { { addSelectionHandler(new SelectionHandler() { @Override public void onSelection(SelectionEvent event) { labelMessage.setText("Seleccin: " + getSelectedItem().getText()); if (!getSelectedItem().getText().isEmpty()) { if (getSelectedItem().getText().toUpperCase().compareTo("NUEVO") == 0) { onNuevo(); } if (getSelectedItem().getText().toUpperCase().compareTo("RECIBIDOS") == 0) { onRecibidos(); } if (getSelectedItem().getText().toUpperCase().compareTo("BORRADORES") == 0) { onBorradores(); } if (getSelectedItem().getText().toUpperCase().compareTo("ENVIADOS") == 0) { onEnviados(); } if (getSelectedItem().getText().toUpperCase().compareTo("PAPELERA") == 0) { onPapelera(); } } } }); } }; VerticalPanel vpanel_00 = new VerticalPanel() { { add(arbol); add(labelMessage); } }; add(vpanel_00, "Correo ", false); add(new Label("Mis Contactos"), "Contactos", false); this.addStyleName("demo-panel"); }
From source file:org.iplantc.phyloviewer.viewer.client.Phyloviewer.java
License:Creative Commons License
private void displayTrees() { final PopupPanel displayTreePanel = new PopupPanel(); displayTreePanel.setModal(true);/* www . ja va 2s. c o m*/ displayTreePanel.setPopupPositionAndShow(new PopupPanel.PositionCallback() { public void setPosition(int offsetWidth, int offsetHeight) { int left = (Window.getClientWidth() - offsetWidth) / 2; int top = (Window.getClientHeight() - offsetHeight) / 2 - 100; displayTreePanel.setPopupPosition(left, top); } }); final VerticalPanel vPanel = new VerticalPanel(); displayTreePanel.add(vPanel); Label messageLabel = new Label("Select a tree to load:"); vPanel.add(messageLabel); final Label label = new Label("Retrieving tree list..."); vPanel.add(label); final ListBox lb = new ListBox(); lb.setVisible(false); vPanel.add(lb); final HorizontalPanel hPanel = new HorizontalPanel(); hPanel.add(new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent arg0) { label.setText("Loading..."); label.setVisible(true); lb.setVisible(false); hPanel.setVisible(false); int index = lb.getSelectedIndex(); if (index >= 0 && trees != null) { final ITree data = trees.get(index); if (data != null) { loadTree(displayTreePanel, ((RemoteTree) data), layoutType); } } } })); hPanel.add(new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent arg0) { displayTreePanel.hide(); } })); vPanel.add(hPanel); displayTreePanel.show(); treeList.getTreeList(new AsyncCallback<List<ITree>>() { @Override public void onFailure(Throwable arg0) { Window.alert(arg0.getMessage()); } @Override public void onSuccess(List<ITree> trees) { Phyloviewer.this.trees = new ArrayList<ITree>(); for (ITree tree : trees) { if (((RemoteTree) tree).isPublic()) { lb.addItem(tree.getName()); Phyloviewer.this.trees.add(tree); } } label.setVisible(false); lb.setVisible(true); } }); }
From source file:org.jboss.as.console.client.administration.accesscontrol.ui.AssignmentDialog.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public Widget asWidget() { ProvidesKey<Role> keyProvider = Role::getId; AbstractCell<Role> roleCell = new AbstractCell<Role>() { @Override/*from w w w. ja v a 2 s . c o m*/ public void render(final Context context, final Role value, final SafeHtmlBuilder sb) { sb.append(Templates.roleItem("navigation-column-item", value)); } }; DefaultCellList<Role> list = new DefaultCellList<>(roleCell, keyProvider); list.setPageSize(30); list.setKeyboardPagingPolicy(INCREASE_RANGE); list.setKeyboardSelectionPolicy(BOUND_TO_SELECTION); ListDataProvider<Role> dataProvider = new ListDataProvider<>(keyProvider); dataProvider.setList( Roles.orderedByType().compound(Roles.orderedByName()).immutableSortedCopy(unassignedRoles)); dataProvider.addDataDisplay(list); SingleSelectionModel<Role> selectionModel = new SingleSelectionModel<>(keyProvider); list.setSelectionModel(selectionModel); selectionModel.setSelected(dataProvider.getList().get(0), true); Scheduler.get().scheduleDeferred(() -> list.setFocus(true)); Label errorMessage = new Label(); errorMessage.setVisible(false); errorMessage.getElement().getStyle().setColor("#c82e2e"); errorMessage.getElement().getStyle().setPadding(7, PX); VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); layout.add(errorMessage); layout.add(list); DialogueOptions options = new DialogueOptions(event -> { if (selectionModel.getSelectedObject() == null) { errorMessage.setText(Console.CONSTANTS.pleaseSelectRole()); errorMessage.setVisible(true); } else { Assignment assignment = new Assignment(principal, selectionModel.getSelectedObject(), include); circuit.dispatch(new AddAssignment(assignment, PRINCIPAL_TO_ROLE)); presenter.closeWindow(); } }, event -> presenter.closeWindow()); return new WindowContentBuilder(layout, options).build(); }
From source file:org.jboss.as.console.client.administration.accesscontrol.ui.MemberDialog.java
License:Open Source License
@Override @SuppressWarnings("unchecked") public Widget asWidget() { ProvidesKey<Principal> keyProvider = Principal::getId; AbstractCell<Principal> roleCell = new AbstractCell<Principal>() { @Override/*from w w w. j a v a 2 s.c om*/ public void render(final Context context, final Principal value, final SafeHtmlBuilder sb) { sb.append(Templates.memberItem("navigation-column-item", value)); } }; DefaultCellList<Principal> list = new DefaultCellList<>(roleCell, keyProvider); list.setPageSize(30); list.setKeyboardPagingPolicy(INCREASE_RANGE); list.setKeyboardSelectionPolicy(BOUND_TO_SELECTION); ListDataProvider<Principal> dataProvider = new ListDataProvider<>(keyProvider); dataProvider.setList(Principals.orderedByType().compound(Principals.orderedByName()) .immutableSortedCopy(unassignedPrincipals)); dataProvider.addDataDisplay(list); SingleSelectionModel<Principal> selectionModel = new SingleSelectionModel<>(keyProvider); list.setSelectionModel(selectionModel); selectionModel.setSelected(dataProvider.getList().get(0), true); Scheduler.get().scheduleDeferred(() -> list.setFocus(true)); Label errorMessage = new Label(); errorMessage.setVisible(false); errorMessage.getElement().getStyle().setColor("#c82e2e"); errorMessage.getElement().getStyle().setPadding(7, PX); VerticalPanel layout = new VerticalPanel(); layout.setStyleName("window-content"); layout.add(errorMessage); layout.add(list); DialogueOptions options = new DialogueOptions(event -> { if (selectionModel.getSelectedObject() == null) { errorMessage.setText(Console.CONSTANTS.pleaseSelectPrincipal()); errorMessage.setVisible(true); } else { Assignment assignment = new Assignment(selectionModel.getSelectedObject(), role, include); circuit.dispatch(new AddAssignment(assignment, ROLE_TO_PRINCIPAL)); presenter.closeWindow(); } }, event -> presenter.closeWindow()); return new WindowContentBuilder(layout, options).build(); }