List of usage examples for com.google.gwt.user.client.ui Label Label
protected Label(Element element)
From source file:com.alkacon.opencms.v8.dialogs.client.CmsDialogEntryPoint.java
License:Open Source License
/** * @see org.opencms.gwt.client.A_CmsEntryPoint#onModuleLoad() *///from www . ja v a2s . co m @Override public void onModuleLoad() { super.onModuleLoad(); final CmsFrameDialog frame = new CmsFrameDialog(); frame.setContent(new Label("Hello World")); CmsPushButton button = new CmsPushButton(); button.setText("Close"); button.setButtonStyle(ButtonStyle.TEXT, ButtonColor.GREEN); button.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { frame.hide(); } }); frame.addButton(button); frame.show(); }
From source file:com.allen_sauer.gwt.dnd.demo.client.DragStartSensitivityBehaviorPanel.java
License:Apache License
public DragStartSensitivityBehaviorPanel(final DragController dragController) { super("Drag Sensitivity", "getBehaviorDragStartSensitivity() / setBehaviorDragStartSensitivity(int)"); this.dragController = dragController; HorizontalPanel panel = new HorizontalPanel(); panel.setSpacing(5);/*w w w. j a va2 s . c o m*/ Label label = new Label("Number of Pixels"); textBox = new TextBox(); textBox.setWidth("3em"); panel.add(label); panel.add(textBox); panel.setTitle("DragController#setBehaviorDragStartSensitivity(int)"); add(panel); textBox.setText("" + dragController.getBehaviorDragStartSensitivity()); textBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { fix(); } }); textBox.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { fix(); textBox.selectAll(); } }); textBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { fix(); } }); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.insertpanel.InsertPanelExample.java
License:Apache License
public InsertPanelExample(DemoDragHandler demoDragHandler) { addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE); int count = 0; // use the boundary panel as this composite's widget AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setSize("100%", "100%"); setWidget(boundaryPanel);// ww w . java 2 s. co m // initialize our column drag controller PickupDragController columnDragController = new PickupDragController(boundaryPanel, false); columnDragController.setBehaviorMultipleSelection(false); columnDragController.addDragHandler(demoDragHandler); // initialize our widget drag controller PickupDragController widgetDragController = new PickupDragController(boundaryPanel, false); widgetDragController.setBehaviorMultipleSelection(false); widgetDragController.addDragHandler(demoDragHandler); // initialize horizontal panel to hold our columns HorizontalPanel horizontalPanel = new HorizontalPanel(); horizontalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER); horizontalPanel.setSpacing(SPACING); boundaryPanel.add(horizontalPanel); // initialize our column drop controller HorizontalPanelDropController columnDropController = new HorizontalPanelDropController(horizontalPanel); columnDragController.registerDropController(columnDropController); for (int col = 1; col <= COLUMNS; col++) { // initialize a vertical panel to hold the heading and a second vertical // panel VerticalPanel columnCompositePanel = new VerticalPanel(); columnCompositePanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_COLUMN_COMPOSITE); // initialize inner vertical panel to hold individual widgets VerticalPanel verticalPanel = new VerticalPanelWithSpacer(); verticalPanel.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_CONTAINER); verticalPanel.setSpacing(SPACING); horizontalPanel.add(columnCompositePanel); // initialize a widget drop controller for the current column VerticalPanelDropController widgetDropController = new VerticalPanelDropController(verticalPanel); widgetDragController.registerDropController(widgetDropController); // Put together the column pieces Label heading = new Label("Column " + col); heading.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_HEADING); columnCompositePanel.add(heading); columnCompositePanel.add(verticalPanel); // make the column draggable by its heading columnDragController.makeDraggable(columnCompositePanel, heading); for (int row = 1; row <= ROWS; row++) { // initialize a widget HTML widget = new HTML("Draggable #" + ++count); widget.addStyleName(CSS_DEMO_INSERT_PANEL_EXAMPLE_WIDGET); widget.setHeight(Random.nextInt(4) + 2 + "em"); verticalPanel.add(widget); // make the widget draggable widgetDragController.makeDraggable(widget); } } }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.insertpanel.VerticalPanelWithSpacer.java
License:Apache License
public VerticalPanelWithSpacer() { Label spacerLabel = new Label(""); spacerLabel.setStylePrimaryName(CSS_DEMO_INSERT_PANEL_EXAMPLE_SPACER); super.add(spacerLabel); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.palette.PaletteExample.java
License:Apache License
public PaletteExample(DemoDragHandler demoDragHandler) { addStyleName(CSS_DEMO_PALETTE_EXAMPLE); // use the boundary panel as this composite's widget AbsolutePanel boundaryPanel = new AbsolutePanel(); boundaryPanel.setPixelSize(500, 300); setWidget(boundaryPanel);// w w w .j ava 2s . co m dragController = new PickupDragController(boundaryPanel, true); dragController.setBehaviorMultipleSelection(false); dragController.setBehaviorDragProxy(false); dragController.setBehaviorConstrainedToBoundaryPanel(true); dragController.addDragHandler(demoDragHandler); PalettePanel palette = new PalettePanel(dragController); palette.add(new PaletteWidget(new Label("New Label"))); palette.add(new PaletteWidget(new RadioButton("name", "New Radio Button"))); palette.add(new PaletteWidget(new CheckBox("New Check Box"))); boundaryPanel.add(palette, 10, 10); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.palette.PalettePanel.java
License:Apache License
public PalettePanel(PickupDragController dragController) { this.dragController = dragController; addStyleName("demo-PalettePanel"); setSpacing(2);//from w w w . j a v a 2 s .c o m setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); Label header = new Label("Widget Palette"); header.addStyleName("demo-PalettePanel-header"); add(header); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.palette.PaletteWidget.java
License:Apache License
public PaletteWidget cloneWidget() { Widget clone;/* w w w . j a v a 2 s . c om*/ // Clone our internal widget if (widget instanceof Label) { Label label = (Label) widget; clone = new Label(label.getText()); } else if (widget instanceof RadioButton) { RadioButton radioButton = (RadioButton) widget; clone = new RadioButton(radioButton.getName(), radioButton.getHTML(), true); } else if (widget instanceof CheckBox) { CheckBox checkBox = (CheckBox) widget; clone = new CheckBox(checkBox.getHTML(), true); } else { throw new IllegalStateException("Unhandled Widget class " + widget.getClass().getName()); } // Copy a few obvious common widget properties clone.setStyleName(widget.getStyleName()); clone.setTitle(widget.getTitle()); // Wrap the cloned widget in a new PaletteWidget instance return new PaletteWidget(clone); }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.resetcache.ResetCacheExample.java
License:Apache License
public ResetCacheExample(PickupDragController dragController) { super(dragController); addStyleName(CSS_DEMO_CACHE_EXAMPLE); // some colors to go with each tab String[] colors = { "#AAAAFF", "#AAFFAA", "#FFAAAA", "#FFFFAA", "#FFAAFF", "#AAFFFF", }; // use the containing panel as this composite's widget AbsolutePanel containingPanel = new AbsolutePanel(); containingPanel.setPixelSize(600, 300); setWidget(containingPanel);// www .ja v a2s . c o m // create a tab panel and populate with a few tabs TabPanel tabPanel = new TabPanel(); tabPanel.addStyleName(CSS_DEMO_CACHE_EXAMPLE_TAB_PANEL); tabPanel.setPixelSize(300, 200); containingPanel.add(tabPanel, 40, 20); for (int i = 0; i < colors.length; i++) { // create a simple panel for the tab content AbsolutePanel contentPanel = new AbsolutePanel(); contentPanel.setHeight("200px"); contentPanel.getElement().getStyle().setProperty("backgroundColor", colors[i]); // create a tab widget HTML tabWidget = new HTML("Tab #" + (i + 1)); tabWidget.setWordWrap(false); tabWidget.getElement().getStyle().setProperty("backgroundColor", colors[i]); tabPanel.add(contentPanel, tabWidget); // add drop controller to allow automatic tab selection and dropping on tab TabSelectingDropController tabSelectingDropController = new TabSelectingDropController(tabWidget, tabPanel, i); dragController.registerDropController(tabSelectingDropController); // create a sample draggable Widget draggableLabel = new Label("Drag me to another tab"); draggableLabel.getElement().getStyle().setProperty("backgroundColor", colors[i]); draggableLabel.addStyleName(CSS_DEMO_CACHE_EXAMPLE_DRAGGABLE); // make label draggable dragController.makeDraggable(draggableLabel); // determine random location within target panel int left = Random.nextInt(200); int top = Random.nextInt(150); contentPanel.add(draggableLabel, left, top); // create a drop controller for the content panel AbsolutePositionDropController contentPanelDropController = new AbsolutePositionDropController( contentPanel); dragController.registerDropController(contentPanelDropController); } tabPanel.selectTab(0); // create a drop controller for the containing panel containerDropController = new AbsolutePositionDropController(containingPanel); dragController.registerDropController(containerDropController); }
From source file:com.allen_sauer.gwt.dnd.demo.client.ExampleTabPanel.java
License:Apache License
/** * Add another example to demonstrate.// www. j a v a2 s.c o m * * @param example the example panel to add */ public void add(Example example) { VerticalPanel verticalPanel = new VerticalPanel(); verticalPanel.add(describe(example.getInvolvedClasses(), example.getDescription())); verticalPanel.add(example); Label tabLabel = new Label("Demo " + (getTabCount() + 1)); tabLabel.setWordWrap(false); String title = DOMUtil .adjustTitleForBrowser(StringUtil.getShortTypeName(example) + "\n" + example.getDescription()); tabLabel.setTitle(title); add(verticalPanel, tabLabel, example.getHistoryToken(), Window.getTitle() + " - " + example.getHistoryToken()); }
From source file:com.anzsoft.client.ui.UserIndicator.java
License:Open Source License
public UserIndicator(final String nick) { createStatusMenu();//from w ww . j a v a 2 s . c o m setWidth("100%"); setCellPadding(0); setCellSpacing(0); setStyleName("indicator"); FlexCellFormatter formatter = getFlexCellFormatter(); // Setup the links cell /* linksPanel = new HorizontalPanel(); setWidget(0, 0, linksPanel); formatter.setStyleName(0, 0, "indicator-links"); formatter.setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT); formatter.setColSpan(0, 0, 2); */ // Setup the title cell setTitleWidget(null); formatter.setStyleName(0, 0, "indicator-title"); getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP); getRowFormatter().setVerticalAlign(1, HasVerticalAlignment.ALIGN_TOP); final ChatIcons icons = ChatIcons.App.getInstance(); statusImg = new Image(); statusImg.setWidth("16px"); statusImg.setHeight("16px"); icons.online().applyTo(statusImg); avatarImg = new Image("images/default_avatar.png"); avatarImg.setWidth("32px"); avatarImg.setHeight("32px"); avatarImg.setStyleName("handler"); avatarImg.addClickListener(new ClickListener() { public void onClick(Widget sender) { JabberApp.instance().showInfoSelf(); } }); nickName = new Label(nick); nickName.setDirection(Direction.LTR); nickName.setWidth("100%"); statusLabel = new Label(); statusLabel.setStyleName("status_label"); statusLabel.setWidth("100%"); statusEditor = new TextBox(); statusEditor.setVisible(false); statusEditor.setWidth("100%"); statusButton = new Button(); statusButton.setMenu(statusMenu); statusButton.setStyleName("Status-Menu-Button"); //statusMenuLabel = new Label(); //statusMenuLabel.setStyleName("status_menu_label"); //addLink(new HTML("<a href=\"http://samespace.anzsoft.com\">SameSpace</a>")); // Add the title and some images to the title bar HorizontalPanel titlePanel = new HorizontalPanel(); titlePanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); titlePanel.setWidth("100%"); titlePanel.setSpacing(3); VerticalPanel statusPanel = new VerticalPanel(); statusPanel.setWidth("100%"); statusPanel.add(nickName); HorizontalPanel hPanel = new HorizontalPanel(); hPanel.setWidth("100%"); hPanel.setSpacing(2); hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); hPanel.add(statusLabel); hPanel.add(statusEditor); hPanel.add(statusButton); statusPanel.add(hPanel); titlePanel.add(statusImg); titlePanel.add(statusPanel); titlePanel.add(avatarImg); titlePanel.setCellWidth(statusImg, "20px"); titlePanel.setCellWidth(statusPanel, "100%"); titlePanel.setCellWidth(avatarImg, "32px"); setTitleWidget(titlePanel); JabberApp.instance().getSession().getUser().addUserListener(new XmppUserListener() { public void onPresenceChanged(XmppPresence presence) { String show = new String(""); PresenceShow presenceShow = presence.getShow(); if (presenceShow != null) show = presenceShow.toString(); String statusString = presence.getStatus(); int priority = presence.getPriority(); boolean avaiable = true; String type = presence.getType(); if (type != null && !type.isEmpty()) { if (type.equalsIgnoreCase("unavailable")) avaiable = false; } status = new XmppContactStatus(show, statusString, priority, avaiable); statusLabel.setText(status.status()); iconFromStatus(status).applyTo(statusImg); } }); statusLabel.addClickListener(new ClickListener() { public void onClick(Widget sender) { statusLabel.setVisible(false); statusEditor.setVisible(true); statusEditor.setText(statusLabel.getText()); } }); statusEditor.addKeyboardListener(new KeyboardListener() { public void onKeyDown(Widget sender, char keyCode, int modifiers) { } public void onKeyPress(Widget sender, char keyCode, int modifiers) { } public void onKeyUp(Widget sender, char keyCode, int modifiers) { if (keyCode == 13) doneChangeStatusString(); } }); statusEditor.addFocusListener(new FocusListener() { public void onFocus(Widget sender) { } public void onLostFocus(Widget sender) { doneChangeStatusString(); } }); XmppVCardFactory.instance().addVCardListener(new VCardListener() { public void onVCard(XmppID jid, XmppVCard vcard) { if (jid.toStringNoResource().equalsIgnoreCase(JabberApp.instance().getJid().toStringNoResource())) { if (!vcard.nickName().isEmpty()) nickName.setText(vcard.fullName()); else if (!vcard.fullName().isEmpty()) nickName.setText(vcard.fullName()); String photoData = vcard.photo(); if (!photoData.isEmpty() && !GXT.isIE) { ImageElement imgEl = avatarImg.getElement().cast(); imgEl.removeAttribute("src"); imgEl.setSrc("data:image;base64," + photoData); } } } }); }