List of usage examples for com.google.gwt.user.client.ui Label setText
public void setText(String text)
From source file:info.magnolia.ui.vaadin.gwt.client.dialog.widget.DialogHeaderWidget.java
License:Open Source License
public void setDescription(String description) { final Label content = new Label(); content.setText(description); descriptionPanel.insert(content, 0); hasDescription = !description.isEmpty(); if (hasDescription) { descriptionPanel.setVisible(isDescriptionVisible); if (this.getElement().getParentElement() != null) { this.getElement().getParentElement().setAttribute("role", "dialogDescriptionHeader"); }/* w w w . j a v a 2 s . c om*/ } }
From source file:io.apiman.manager.ui.client.local.pages.consumer.OrganizationList.java
License:Apache License
/** * @param bean/*from w ww. jav a 2s . c o m*/ * @param item */ private void createDescriptionRow(OrganizationBean bean, FlowPanel item) { Label description = new Label(); item.add(description); description.getElement().setClassName("description"); //$NON-NLS-1$ description.setTitle(bean.getDescription()); String d = bean.getDescription(); if (d != null && d.length() >= 70) { d = d.substring(0, 70) + "..."; //$NON-NLS-1$ } description.setText(d); }
From source file:io.apiman.manager.ui.client.local.pages.consumer.ServiceList.java
License:Apache License
/** * @param bean/*from w ww . j av a 2 s .c o m*/ * @param item */ private void createDescriptionRow(ServiceSummaryBean bean, FlowPanel item) { Label description = new Label(); item.add(description); description.getElement().setClassName("description"); //$NON-NLS-1$ description.setTitle(bean.getDescription()); String d = bean.getDescription(); if (d != null && d.length() >= 70) { d = d.substring(0, 70) + "..."; //$NON-NLS-1$ } description.setText(d); }
From source file:it.alexabbi.aproject.client.ui.second.SecondPageImpl.java
License:Open Source License
public SecondPageImpl() { logger.info("SecondPageImpl"); initWidget(binder.createAndBindUi(this)); Storage storage = Storage.getLocalStorageIfSupported(); if (storage != null) { storage.setItem("a", "pippo"); }//www . j a v a2s. c om final String valore = storage.getItem("a"); final Label label = new Label(); label.setText("DRAG ME"); label.getElement().setDraggable("TRUE"); pannello.add(label); label.addDragStartHandler(new DragStartHandler() { @Override public void onDragStart(DragStartEvent event) { event.setData("prova", "DROPPATO"); //event.getDataTransfer().setDragImage(label, 10, 10); } }); final Label label2 = new Label(); label2.setText("DROP HERE"); pannello2.add(label2); label2.addDragOverHandler(new DragOverHandler() { @Override public void onDragOver(DragOverEvent event) { //label2.getElement().setTitle("cicco"); } }); label2.addDropHandler(new DropHandler() { @Override public void onDrop(DropEvent event) { // TODO Auto-generated method stub event.preventDefault(); String data = event.getData("prova"); label2.setText(data); } }); }
From source file:lv.abuzdin.client.simple.SimplePanelExample.java
License:Open Source License
public SimplePanelExample() { HorizontalPanel panel = new HorizontalPanel(); panel.setWidth("100%"); final Button sendButton = new Button(messages.sendButton()); sendButton.addStyleName("sendButton"); panel.add(sendButton);/*from ww w.j a v a 2 s . c o m*/ final TextBox nameField = new TextBox(); nameField.setText(messages.nameField()); nameField.setFocus(true); nameField.selectAll(); panel.add(nameField); final Label errorLabel = new Label(); panel.add(errorLabel); panel.setCellHorizontalAlignment(sendButton, HasHorizontalAlignment.ALIGN_RIGHT); panel.setCellHorizontalAlignment(errorLabel, HasHorizontalAlignment.ALIGN_LEFT); final Button closeButton = new Button("Close"); closeButton.getElement().setId("closeButton"); final Label textToServerLabel = new Label(); final HTML serverResponseLabel = new HTML(); VerticalPanel dialogVPanel = new VerticalPanel(); dialogVPanel.addStyleName("dialogVPanel"); dialogVPanel.add(new HTML("<b>Sending name to the server:</b>")); dialogVPanel.add(textToServerLabel); dialogVPanel.add(new HTML("<br><b>Server replies:</b>")); dialogVPanel.add(serverResponseLabel); dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT); dialogVPanel.add(closeButton); final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); dialogBox.setWidget(dialogVPanel); // Add a handler to close the DialogBox closeButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { dialogBox.hide(); sendButton.setEnabled(true); sendButton.setFocus(true); } }); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler, KeyUpHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendNameToServer(); } /** * Fired when the user types in the nameField. */ public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { sendNameToServer(); } } /** * Send the name from the nameField to the server and wait for a response. */ private void sendNameToServer() { // First, we validate the input. errorLabel.setText(""); String textToServer = nameField.getText(); if (!FieldVerifier.isValidName(textToServer)) { errorLabel.setText("Please enter at least four characters"); return; } // Then, we send the input to the server. sendButton.setEnabled(false); textToServerLabel.setText(textToServer); serverResponseLabel.setText(""); greetingService.greetServer(textToServer, new AsyncCallback<String>() { @Override public void onSuccess(String result) { dialogBox.setText("Remote Procedure Call"); serverResponseLabel.removeStyleName("serverResponseLabelError"); serverResponseLabel.setHTML(result); dialogBox.center(); closeButton.setFocus(true); } @Override public void onFailure(Throwable throwable) { } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); sendButton.addClickHandler(handler); nameField.addKeyUpHandler(handler); initWidget(panel); }
From source file:main.client.ui.RowLayoutPortlet.java
License:Open Source License
public RowLayoutPortlet() { LayoutPanel panel = new LayoutPanel(); initWidget(panel);/* www.j ava 2 s .c om*/ final CheckBox column = new CheckBox("Column"); column.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { getTargetLayout().setColumn(column.getValue()); target.layout(); } }); final TextBox spacing = new TextBox(); spacing.setVisibleLength(4); spacing.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { try { getTargetLayout().setSpacing(Integer.parseInt(spacing.getText())); } catch (NumberFormatException e) { // ignore } target.layout(); } }); final Label bounds = new Label(); target.addLayoutHandler(new LayoutHandler() { public void onLayoutUpdated(LayoutEvent layoutEvent) { bounds.setText(LDOM.getBounds(target).toString()); column.setValue(getTargetLayout().isColumn()); spacing.setText(Integer.toString(getTargetLayout().getSpacing())); } }); demoList.addItem("Buttons & Body"); demoList.addItem("Sidebar & Margin"); demoList.addItem("Border Layout"); demoList.setSelectedIndex(0); Button add = new CssButton("Add Widget", new ClickHandler() { public void onClick(ClickEvent event) { target.add(new Thing("Widget-" + (target.getWidgetCount() + 1))); target.layout(); } }, "Add a new widget to the layout"); final Button go = new CssButton("Go", new ClickHandler() { public void onClick(ClickEvent event) { go(); } }, "Reset the layout to the selected state"); demoList.addChangeHandler(new ChangeHandler() { public void onChange(ChangeEvent event) { go.click(); } }); FormBuilder b = new FormBuilder(); b.add(add).label("Spacing").field(spacing).field(column).add("").field(bounds).wrap().width("100%") .add(demoList).add(go).endRow(); panel.add(b.getForm(), 22); panel.add(target, LayoutConstraints.HIDDEN); go(); }
From source file:net.autosauler.ballance.client.gui.AuthPanel.java
License:Apache License
/** * Construct hello pane./*from w ww . j av a 2s .c om*/ */ private void constructHelloPane() { authPanel.removeAll(); authPanel.getButtonBar().removeAll(); loginText = null; passwordText = null; okButton = null; cancelButton = null; Label helloLabel = new Label(); helloLabel.setText(M.auth.helloUserMsg(Ballance_autosauler_net.sessionId.getUsername())); helloLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); authPanel.add(helloLabel); UserRole userrole = Ballance_autosauler_net.sessionId.getUserrole(); RolesWidget roleswidget = new RolesWidget(userrole); roleswidget.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); authPanel.add(roleswidget); logoutButton = new Button(M.auth.btnLogout()); logoutButton.addSelectionListener(this); authPanel.addButton(logoutButton); if (Ballance_autosauler_net.menu != null) { Ballance_autosauler_net.menu.buildContent(); } }
From source file:net.officefloor.demo.chat.client.ChatWidget.java
License:Open Source License
/** * Initiate.//from w w w . j av a 2 s .c o m */ public ChatWidget() { // Provide means to send a message HorizontalPanel messagePanel = new HorizontalPanel(); // messagePanel.setSpacing(10); messagePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); this.add(messagePanel); // Provide message text box this.messageText.setStylePrimaryName("message"); messagePanel.add(this.messageText); this.messageText.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { ChatWidget.this.ensureHaveUserName(); } }); // Provide send button for message Button sendButton = new Button("send"); sendButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { ChatWidget.this.sendChatMessage(); } }); messagePanel.add(sendButton); // Provide messages in scroll area VerticalPanel messagesPanel = new VerticalPanel(); messagesPanel.setSize("100%", "100%"); ScrollPanel scrollMessagesPanel = new ScrollPanel(messagesPanel); scrollMessagesPanel.setStylePrimaryName("messages"); this.add(scrollMessagesPanel); // Provide label to display typing users final Label typingLabel = new Label(); typingLabel.setStylePrimaryName("typing"); messagesPanel.add(typingLabel); typingLabel.setVisible(false); // initially hidden as no typing users // List to contain chat messages Cell<ChatMessage> chatCell = new AbstractCell<ChatMessage>() { @Override public void render(Context context, ChatMessage value, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<span><b>"); sb.appendEscaped(value.getUserName()); sb.appendHtmlConstant("</b>"); sb.appendEscaped(" > "); sb.appendEscaped(value.getMessage()); sb.appendHtmlConstant("</span>"); } }; CellList<ChatMessage> chatList = new CellList<ChatMessage>(chatCell); messagesPanel.add(chatList); // Add the data final ListDataProvider<ChatMessage> chatEntries = new ListDataProvider<ChatMessage>(); chatEntries.addDataDisplay(chatList); // Handle listening for messages OfficeFloorComet.subscribe(ConversationSubscription.class, new ConversationSubscription() { @Override public void message(ChatMessage message) { // Determine if typing notification String userName = message.getUserName(); if ((ChatWidget.this.userName == null) || (!(ChatWidget.this.userName.equals(userName)))) { // Not user so provide notification of typing if (message.isTyping()) { // Include user as typing if (!(ChatWidget.this.typingUserNames.contains(userName))) { ChatWidget.this.typingUserNames.add(userName); } } else { // User has stopped typing ChatWidget.this.typingUserNames.remove(userName); } } // Display typing notification if (ChatWidget.this.typingUserNames.size() == 0) { // No typing users typingLabel.setVisible(false); } else { // Display the typing users StringBuilder typingUsers = new StringBuilder(); boolean isFirst = true; for (String typingUserName : ChatWidget.this.typingUserNames) { if (!isFirst) { typingUsers.append(", "); } isFirst = false; typingUsers.append(typingUserName); } typingUsers.append(" ... (typing)"); typingLabel.setText(typingUsers.toString()); typingLabel.setVisible(true); } // Add the message (if one provided) String text = message.getMessage(); if (text != null) { List<ChatMessage> list = chatEntries.getList(); if (list.size() == 0) { list.add(message); } else { list.add(0, message); } } } }, null); // Handle submitting a message this.messageText.addKeyDownHandler(new KeyDownHandler() { @Override public void onKeyDown(KeyDownEvent event) { // Obtain the message text and cursor position String message = ChatWidget.this.messageText.getText(); int cursorPosition = ChatWidget.this.messageText.getCursorPos(); // Handle various scenarios of keys for sending/notification switch (event.getNativeKeyCode()) { case KeyCodes.KEY_ENTER: ChatWidget.this.sendChatMessage(); break; case KeyCodes.KEY_BACKSPACE: if (ChatWidget.this.isTyping && (message.length() == 1) && (cursorPosition == 1)) { // No longer typing as deleting last character ChatWidget.this.sendChatMessage(false, null); } break; case KeyCodes.KEY_DELETE: if (ChatWidget.this.isTyping && (message.length() == 1) && (cursorPosition == 0)) { // No longer typing as deleting last character ChatWidget.this.sendChatMessage(false, null); } break; case KeyCodes.KEY_ALT: case KeyCodes.KEY_CTRL: case KeyCodes.KEY_DOWN: case KeyCodes.KEY_END: case KeyCodes.KEY_ESCAPE: case KeyCodes.KEY_HOME: case KeyCodes.KEY_LEFT: case KeyCodes.KEY_PAGEDOWN: case KeyCodes.KEY_PAGEUP: case KeyCodes.KEY_RIGHT: case KeyCodes.KEY_SHIFT: case KeyCodes.KEY_UP: // Do nothing break; default: if ((!ChatWidget.this.isTyping) && (message.length() == 0)) { // Started typing a message ChatWidget.this.sendChatMessage(true, null); } break; } } }); }
From source file:net.officefloor.plugin.gwt.comet.client.OfficeFloorCometEntryPoint.java
License:Open Source License
@Override public void onModuleLoad() { // Create the publishers final MockCometNotificationListener notificationPublisher = OfficeFloorComet .createPublisher(MockCometNotificationListener.class); final MockCometEventListener eventPublisher = OfficeFloorComet .createPublisher(MockCometEventListener.class); final MockCometMatchKeyListener matchKeyPublisher = OfficeFloorComet .createPublisher(MockCometMatchKeyListener.class); final MockCometNullFilterKeyListener nullFilterKeyPublisher = OfficeFloorComet .createPublisher(MockCometNullFilterKeyListener.class); // Provide the widgets Panel root = RootPanel.get("comet"); root.clear();//from w w w .j a va2 s . co m VerticalPanel panel = new VerticalPanel(); root.add(panel); // Provide event text widget HorizontalPanel eventPanel = new HorizontalPanel(); panel.add(eventPanel); eventPanel.add(new Label("Event text: ")); final TextBox eventText = new TextBox(); eventText.setText("TEST"); eventPanel.add(eventText); // Provide match key widget HorizontalPanel matchKeyPanel = new HorizontalPanel(); panel.add(matchKeyPanel); matchKeyPanel.add(new Label("Match key: ")); final TextBox matchKeyText = new TextBox(); matchKeyText.setText("MATCH"); matchKeyPanel.add(matchKeyText); matchKeyPanel.add(new Label("Additional: ")); final TextBox additionalText = new TextBox(); additionalText.setText("additional"); matchKeyPanel.add(additionalText); // Multiple subscriptions OfficeFloorComet.setMultipleSubscriptions(true); // Provide notification subscription HorizontalPanel notificationSubscribePanel = new HorizontalPanel(); panel.add(notificationSubscribePanel); notificationSubscribePanel.add(new Label("Subscribe notification: ")); final CheckBox notificationCheckBox = new CheckBox(); notificationSubscribePanel.add(notificationCheckBox); OfficeFloorComet.subscribe(MockCometNotificationListener.class, new MockCometNotificationListener() { @Override public void handleNotification() { OfficeFloorCometEntryPoint.this.notificationToggle = !OfficeFloorCometEntryPoint.this.notificationToggle; notificationCheckBox.setValue(Boolean.valueOf(OfficeFloorCometEntryPoint.this.notificationToggle)); } }, null); // Provide event subscription HorizontalPanel eventSubscribePanel = new HorizontalPanel(); panel.add(eventSubscribePanel); eventSubscribePanel.add(new Label("Subscribed event: ")); final Label eventSubscribeLabel = new Label("[no event]"); eventSubscribePanel.add(eventSubscribeLabel); OfficeFloorComet.subscribe(MockCometEventListener.class, new MockCometEventListener() { @Override public void handleEvent(String event) { eventSubscribeLabel.setText(event + " (" + (++OfficeFloorCometEntryPoint.this.eventCount) + ")"); } }, null); // Provide filter key subscription HorizontalPanel filterKeySubscribePanel = new HorizontalPanel(); panel.add(filterKeySubscribePanel); filterKeySubscribePanel.add(new Label("Filter Key: ")); final TextBox filterKeyText = new TextBox(); filterKeyText.setText(matchKeyText.getText()); filterKeySubscribePanel.add(filterKeyText); filterKeySubscribePanel.add(new Label("Subscribe filter key: ")); final Label matchKeySubscribeLabel = new Label("[no event]"); filterKeySubscribePanel.add(matchKeySubscribeLabel); OfficeFloorComet.subscribe(MockCometMatchKeyListener.class, new MockCometMatchKeyListener() { @Override public void handleEvent(String event, MockFilterKey matchKey) { matchKeySubscribeLabel.setText(event + "(" + (++OfficeFloorCometEntryPoint.this.filterKeyCount) + ") - " + (matchKey == null ? "NONE" : matchKey.getAdditionalText())); } }, this.filterKey); // Provide null filter key subscription HorizontalPanel nullFilterKeySubscribePanel = new HorizontalPanel(); panel.add(nullFilterKeySubscribePanel); nullFilterKeySubscribePanel.add(new Label("Subscribe null filter key: ")); final Label nullMatchKeySubscribeLabel = new Label("[no event]"); nullFilterKeySubscribePanel.add(nullMatchKeySubscribeLabel); OfficeFloorComet.subscribe(MockCometNullFilterKeyListener.class, new MockCometNullFilterKeyListener() { @Override public void handleEvent(String event, MockFilterKey matchKey) { nullMatchKeySubscribeLabel .setText(event + "(" + (++OfficeFloorCometEntryPoint.this.nullFilterKeyCount) + ") - " + (matchKey == null ? "NONE" : matchKey.getAdditionalText())); } }, null); // Subscribe OfficeFloorComet.subscribe(); // Provide button to trigger publishing Button publishButton = new Button("Publish"); panel.add(publishButton); publishButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { // Specify the filter key (may take two events to update) String filterKey = filterKeyText.getText(); OfficeFloorCometEntryPoint.this.filterKey.setFilterText(filterKey); // Create the match key MockFilterKey matchKey; String matchKeyValue = matchKeyText.getText(); if ((matchKeyValue == null) || (matchKeyValue.trim().length() == 0)) { // No match key matchKey = null; } else { // Provide the match key matchKey = new MockFilterKey(additionalText.getText()); matchKey.setFilterText(matchKeyValue); } // Publish events String event = eventText.getText(); notificationPublisher.handleNotification(); eventPublisher.handleEvent(event); matchKeyPublisher.handleEvent(event, matchKey); nullFilterKeyPublisher.handleEvent(event, matchKey); } }); }
From source file:net.officefloor.tutorial.gwtapp.client.GwtAppEntryPoint.java
License:Open Source License
@Override public void onModuleLoad() { // Provide the time label RootPanel panel = RootPanel.get("timer"); final Label label = new Label("0"); panel.add(label);//from w w w . j a v a 2 s . c om // Increment time each second Timer timer = new Timer() { @Override public void run() { long time = Long.parseLong(label.getText()); time++; label.setText(String.valueOf(time)); } }; timer.scheduleRepeating(1000); }