Example usage for com.google.gwt.user.client.ui Label Label

List of usage examples for com.google.gwt.user.client.ui Label Label

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Label Label.

Prototype

protected Label(Element element) 

Source Link

Document

This constructor may be used by subclasses to explicitly use an existing element.

Usage

From source file:ch.sebastienzurfluh.swissmuseum.core.client.view.tilemenu.Tile.java

License:Open Source License

public Tile(MenuData menuData) {
    this.menuReference = menuData.getReference();
    this.priority = menuData.getPriorityNumber();

    tileImage = new Image(menuData.getSquareImgURL());
    tileImage.setStyleName(stylePrimaryName + "-" + "tileImage");
    tileImage.setAltText(menuData.getTitle());
    tilePanel.add(tileImage);/*from w  ww.  j  av  a2  s  . com*/

    details = new FlowPanel();
    details.setStyleName(stylePrimaryName + "-" + "tileDetails");
    Label titleLabel = new Label(menuData.getTitle());
    titleLabel.setStyleName(stylePrimaryName + "-" + "tileTitle");
    details.add(titleLabel);
    Label descriptionLabel = new Label(menuData.getDescription());
    descriptionLabel.setStyleName(stylePrimaryName + "-" + "tileDescription");
    details.add(descriptionLabel);
    tilePanel.add(details);

    setWidget(tilePanel);

    // Choose default
    setIconOnlyMode();
}

From source file:ch.sebastienzurfluh.swissmuseum.core.client.view.tilemenu.TileMenu.java

License:Open Source License

public TileMenu(String title, PageRequestClickHandler pageRequestHandler) {
    this.pageRequestHandler = pageRequestHandler;

    setStyleName(stylePrimaryName);/*from   w w w. j  av a  2  s .  c  o  m*/

    HorizontalPanel firstLine = new HorizontalPanel();

    button = new ModeSwapButton(this);
    button.setStyleName(stylePrimaryName + "-" + "detailButton");
    firstLine.add(button);

    Label titleLabel = new Label(title);
    titleLabel.setStyleName(stylePrimaryName + "-" + "title");
    firstLine.add(titleLabel);

    add(firstLine);

    tilePanel = new FlowPanel();
    tileOrderList = new LinkedList<Tile>();

    tilePanel.setStyleName(stylePrimaryName + "-" + "tileList");
    add(tilePanel);
}

From source file:ch.sebastienzurfluh.swissmuseum.parcours.client.view.bookletnavigator.LoadOnDemandPageWidget.java

License:Open Source License

public LoadOnDemandPageWidget(MenuData menuData, EventBus pageChangeEventBus, Model model,
        TextParser textParser) {/*from  ww  w. j  a  v a  2 s  .c  o m*/
    this.model = model;
    this.menuData = menuData;
    this.eventBus = pageChangeEventBus;
    this.parser = textParser;

    title = new HTML("");

    header = new Label("");

    content = new FlowPanel();

    mainContainer = new RoundPanel();
    mainContainer.add(title);
    mainContainer.add(header);
    mainContainer.add(content);

    scrollPanel = new ScrollPanel();
    scrollPanel.setScrollingEnabledX(false);
    scrollPanel.setWidget(mainContainer);

    title.setStyleName(primaryStyleName + "-title");
    header.setStyleName(primaryStyleName + "-header");
    content.setStyleName(primaryStyleName + "-content");
    mainContainer.setStyleName(primaryStyleName);

    add(scrollPanel);
    // Needed for the panel to show properly!
    setHeight(CLIENT_WINDOW_HEIGHT_PX);

    if (model.getCurrentPageData().getReference().equals(menuData.getReference()))
        load();
    else
        postponeLoad();
}

From source file:ch.sebastienzurfluh.swissmuseum.parcours.client.view.infos.InfoMenubar.java

License:Open Source License

public InfoMenubar(final AnimationHelper animationHelper, final Widget goBackTo) {
    this.setStyleName("infoMenuBar");

    final AppInfoPanel appInfo = new AppInfoPanel(goBackTo, animationHelper);
    final InstitutInfoPanel institutInfo = new InstitutInfoPanel(goBackTo, animationHelper);

    Label benvenon = new Label("Bienvenue au Muse des Suisses dans le Monde");
    benvenon.setStyleName("infoMenuBar-title");
    this.add(benvenon);

    MenuBar menu = new MenuBar();

    menu.addItem("<img src='resources/images/generic_tiles/logo_parcours.png' class='infoMenuBar-button' />",
            true, new ScheduledCommand() {
                @Override//w  w w .  java  2s.  c o  m
                public void execute() {
                    animationHelper.goTo(appInfo, Animation.SLIDE_UP_REVERSE);
                }
            });
    menu.addItem("<img src='resources/images/generic_tiles/logo_penthes.png' class='infoMenuBar-button' />",
            true, new ScheduledCommand() {
                @Override
                public void execute() {
                    animationHelper.goTo(institutInfo, Animation.SLIDE_UP_REVERSE);
                }
            });

    this.add(menu);
}

From source file:ch.sebastienzurfluh.swissmuseum.parcours.client.view.infos.InfoPanel.java

License:Open Source License

public InfoPanel(String title, final Widget returnToIt, final AnimationHelper animationHelper) {

    setStyleName("infoPanel");

    HorizontalPanel titleLine = new HorizontalPanel();

    Label returnLabel = new Label("Retourner");
    returnLabel.setStyleName("infoPanel-returnButton");

    returnLabel.addClickHandler(new ClickHandler() {

        @Override//from   ww  w  . j a va2 s  .  c  o  m
        public void onClick(ClickEvent event) {
            animationHelper.goTo(returnToIt, Animation.SLIDE_UP);
        }
    });

    titleLine.add(returnLabel);

    Label titleLabel = new Label(title);
    titleLabel.setStyleName("infoPanel-title");
    titleLine.add(titleLabel);

    this.add(titleLine);

    setContent(new Label("loading..."));
    this.add(contentPanel);
}

From source file:ch.unifr.pai.ice.client.dragNdrop.DND4users4spaces.java

License:Apache License

/******************************************
 * Set the drop panels with the grid/*  w ww .j ava2s  . c o m*/
 ******************************************/

private void setDropPanels() {

    for (int row = 0; row < 4; ++row) {
        for (int col = 0; col < 10; ++col) {

            dropGrid.getColumnFormatter().setWidth(col, "10%");
            dropPanel = new FocusPanel();
            dropPanel.setSize("100%", "100%");

            Label l = new Label(String.valueOf(col));
            l.getElement().getStyle().setBackgroundColor(colors[row]);
            l.getElement().getStyle().setFontSize(18, Unit.PX);
            l.getElement().getStyle().setFontWeight(FontWeight.BOLD);

            if (colors[row].equals("black"))
                l.getElement().getStyle().setColor("white");

            final DropAbsolutePanel absDropPanel = new DropAbsolutePanel((row * 10) + col);
            absDropPanel.add(l);
            absDropPanel.setTitle(String.valueOf(row) + String.valueOf(col));
            absDropPanel.setSize("100%", "100%");

            dropPanel.add(absDropPanel);
            dropGrid.setWidget(row, col, dropPanel);

            /**************************
             * Set the drop handler
             *************************/

            DragNDrop.setDropHandler(dropPanel, new DropTargetHandlerAdapter() {

                @Override
                public boolean onDrop(String deviceId, Widget widget, Element dragProxy, Event event,
                        Double intersectionPercentage, Double intersectionPercentageWithTarget) {

                    if (((DraggableLabelledBlob) widget).getBlobNumber() == absDropPanel.getPanelID()) {

                        absDropPanel.clear();
                        absDropPanel.add(widget);

                        ((DraggableLabelledBlob) widget).setDropTime(System.currentTimeMillis());
                        ((DraggableLabelledBlob) widget).setDragStarted(false);
                        ((DraggableLabelledBlob) widget).setDropTime(System.currentTimeMillis());

                        resultVector.add(

                                new String("user" + widget.getTitle().charAt(0) + ";" + "blob"
                                        + ((DraggableLabelledBlob) widget).getBlobName() + ";"
                                        + ((DraggableLabelledBlob) widget).getDragNdropTime())

                        );

                        if (--blobsToDrop == 0) {
                            // log the results if all blobs are dropped!!!
                            log();
                        }
                        return true;
                    } else
                        return false;
                }

            }, false);
        }
    }
}

From source file:ch.unifr.pai.ice.client.textedit.TextEditor.java

License:Apache License

public TextEditor(TextEntry1Space parentWidget, int userNo, int nbTextEntry) {
    super();/*w w  w. j  av  a 2 s.  c  om*/
    parent = parentWidget;
    logVector = new Vector<String>();
    this.userNo = userNo;
    this.nbTextEntry = nbTextEntry;
    if (parentWidget instanceof AbsolutePanel)
        isAPanel = true;

    if (nbTextEntry == 1) // if it's training
    {
        wordlist = traininglist;
    }

    text = new Label(wordlist[0]);
    text.getElement().getStyle().setColor("#fff");
    text.getElement().getStyle().setFontSize(20, Unit.PT);
    text.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    hPanel.setWidth("100%");
    hPanel.add(text);
    this.add(hPanel);

    MultiFocus.setVisible(true);
    MultiFocus.setWidth("100%");
    MultiFocus.setHeight("100px");
    MultiFocus.setWidth("250px");

    MultiFocus.getElement().getStyle().setBackgroundColor("#fff");

    // this.add(ta);
    this.add(MultiFocus);
    this.setBorderWidth(1);

    MultiFocus.addDomHandler(new KeyPressHandler() { //Listen for KeyPress events on MultiFocusTextBox
        @Override
        public void onKeyPress(KeyPressEvent event) {

            if (!isStarted) {
                startTime = System.currentTimeMillis();

                if (!isSetStarted) {
                    setStartTime = startTime; // set experiment start time
                    isSetStarted = true;
                }

                isStarted = true;
            }
            typedText = typedText + event.getCharCode();

        }
    }, KeyPressEvent.getType());

    MultiFocus.addDomHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {

            if (event.getNativeEvent().getKeyCode() == 13) {

                if (isSetFinished && !isLast) { // for the second set

                    log(typedText, ta.getText());
                    parent.setLoggedData(logVector, false, true); // done with experiment

                    iteration++;
                    text.setText(secondwordlist[iteration]);

                    typedText = "";
                    isStarted = false;
                }

                if (isLast) {
                    log(typedText, ta.getText());
                    parent.setLoggedData(logVector, true, true); // done with experiment

                    text.setText(secondwordlist[0]);
                    typedText = "";
                    isStarted = false;

                    iteration = 0;
                    isLast = false;
                }

                if (!isSetFinished) {

                    if (!isLast) {
                        iteration++;
                        text.setText(wordlist[iteration]);

                        log(typedText, ta.getText()); // log for wordlist[iteration-1]
                        typedText = "";
                        isStarted = false;

                        if ((iteration == (wordlist.length - 1))) { //last element
                            isSetFinished = true;
                            isLast = true;
                        }
                    }

                }

            }

            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_BACKSPACE) {

                typedText = typedText + "~";
            }

        }
    }, KeyUpEvent.getType());
}

From source file:ch.unifr.pai.twice.comm.serverPush.standalone.client.ServerPushStandalone.java

License:Apache License

/**
 * This is the entry point method./*from   w  w  w .j  a v a2 s .  c  o m*/
 */
/*
 * (non-Javadoc)
 * @see com.google.gwt.core.client.EntryPoint#onModuleLoad()
 */
@Override
public void onModuleLoad() {

    //
    //
    //
    //
    FlexTable table = new FlexTable();
    final TextBox message = new TextBox();
    table.setWidget(0, 0, new Label("Message"));
    table.setWidget(0, 1, message);
    table.setWidget(1, 0, new Label("Event date"));
    final DatePicker datePicker = new DatePicker();
    table.setWidget(1, 1, datePicker);

    Button undoable = new Button("Send as undoable event", new ClickHandler() {

        /**
         * Creates an {@link UndoableTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            UndoableTestEvent e = GWT.create(UndoableTestEvent.class);
            e.setFoo(message.getText());
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    Button blocking = new Button("Send as blocking event", new ClickHandler() {

        /**
         * Creates an {@link BlockingTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            BlockingTestEvent e = GWT.create(BlockingTestEvent.class);
            e.foo = message.getText();
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    Button discarding = new Button("Send as discarding event", new ClickHandler() {

        /**
         * Creates an {@link DiscardingTestEvent} and fires it on the event bus.
         * 
         * @see com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event.dom.client.ClickEvent)
         */
        @Override
        public void onClick(ClickEvent event) {
            DiscardingTestEvent e = GWT.create(DiscardingTestEvent.class);
            e.setInstanceId("eventTests");
            e.setFoo(message.getText());
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    final HTML html = new HTML("");
    final HTML value = new HTML("");
    eventBus.addHandler(BlockingTestEvent.TYPE, new BlockingTestHandler() {

        /**
         * listens for blocking test events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(BlockingTestEvent event) {
            html.setHTML(html.getHTML() + " [BLOCKING " + event.getTimestamp() + "] " + event.foo);
            value.setHTML(event.foo);
        }
    });
    eventBus.addHandler(UndoableTestEvent.TYPE, new UndoableTestHandler() {

        /**
         * undo the event in case of a conflict by resetting the display to the values valid before the event has been applied
         * 
         * @param event
         */
        @Override
        public void undo(UndoableTestEvent event) {
            html.setHTML(event.getOldHistory());
            value.setHTML(event.getOldValue());
        }

        /**
         * listens for undoable events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(UndoableTestEvent event) {
            html.setHTML(html.getHTML() + " [UNDOABLE " + event.getTimestamp() + "] " + event.getFoo());
            value.setHTML(event.getFoo());
        }

        /**
         * stores the state of the display before the newly arrived event has arrived
         * 
         * @param event
         */
        @Override
        public void saveState(UndoableTestEvent event) {
            event.setOldHistory(html.getHTML());
            event.setOldValue(value.getHTML());
        }
    });

    eventBus.addHandler(DiscardingTestEvent.TYPE, new DiscardingTestHandler() {

        /**
         * listens for discarding test events and adds their message to the display
         * 
         * @param event
         */
        @Override
        public void onEvent(DiscardingTestEvent event) {
            html.setHTML(html.getHTML() + " [DISCARDING " + event.getTimestamp() + "] " + event.getFoo());
            value.setHTML(event.getFoo());
        }
    });

    table.setWidget(2, 0, undoable);
    table.setWidget(2, 1, blocking);
    table.setWidget(2, 2, discarding);
    table.setWidget(3, 0, new Label("Current value: "));
    table.setWidget(3, 1, value);
    table.setWidget(4, 0, new Label("Event history: "));
    table.setWidget(4, 1, html);

    Button ping = new Button("Send ping", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            PingEvent e = GWT.create(PingEvent.class);
            e.setInstanceId("eventTests");
            if (datePicker.getValue() != null)
                e.setTimestamp(datePicker.getValue().getTime());
            eventBus.fireEvent(e);
        }
    });

    RootPanel.get().add(table);
    RootPanel.get().add(ping);

    RootPanel.get().add(new Label("GWTEvent wrapper"));
    FlexTable table2 = new FlexTable();

    final TextBox box = new TextBox();
    table2.setWidget(0, 0, new Label("Textbox"));
    table2.setWidget(0, 1, box);

    eventBus.addHandlerToSource(RemoteKeyPressEvent.TYPE, "test",
            new RemoteKeyPressEvent.RemoteKeyPressHandler() {

                @Override
                public void onEvent(RemoteKeyPressEvent event) {
                    box.setValue(box.getValue() + event.getCharCode());
                }
            });
    box.addKeyPressHandler(new KeyPressHandler() {

        @Override
        public void onKeyPress(KeyPressEvent event) {
            RemoteKeyPressEvent e = GWT.create(RemoteKeyPressEvent.class);
            e.wrap(event);
            eventBus.fireEventFromSource(e, "test");
            event.preventDefault();
        }
    });

    final MyNewTextBox box4 = new MyNewTextBox(eventBus, "myNewTextBox");
    table2.setWidget(1, 0, new Label("My new textbox"));
    table2.setWidget(1, 1, box4);

    final RemoteKeyRecorder recorder = new RemoteKeyRecorder("multiFocus", eventBus);
    RootPanel.get().add(recorder);

    // final RemoteTextBox box3 = new RemoteTextBox("multiFocus", eventBus);
    // box3.setValue("");
    // RootPanel.get().add(box3);
    // table2.setWidget(2, 0, new Label("Textbox (undoable - other resource)"));
    // table2.setWidget(2,1,box3);
    // RootPanel.get().add(table2);
    //
    MultiFocusTextBox multiFocus = new RemoteMultiFocusTextBox("multiFocus", eventBus);
    RootPanel.get().add(multiFocus);

}

From source file:ch.unifr.pai.twice.widgets.mpproxy.client.ProxyBody.java

License:Apache License

/**
 * Register required listeners and set up the basic objects
 *///ww  w .j  av  a 2s.  c  o m
public void initialize() {
    Event.addNativePreviewHandler(new NativePreviewHandler() {

        /**
         * Rewrites the URLs on mouse down if somebody clicks on an anchor element
         * 
         * @see com.google.gwt.user.client.Event.NativePreviewHandler#onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)
         */
        @Override
        public void onPreviewNativeEvent(NativePreviewEvent event) {
            if (event.getTypeInt() == Event.ONMOUSEDOWN) {
                EventTarget t = event.getNativeEvent().getEventTarget();
                Element e = (Element) Element.as(t);
                if (e != null && e.getTagName().equalsIgnoreCase("a"))
                    rewriteUrls(e);

            }
        }
    });
    Storage s = Storage.getSessionStorageIfSupported();
    if (s != null) {
        RootPanel.get().add(new Label("Multicursor: " + s.getItem("ch.unifr.pai.mice.deviceType")));
    }
    publishInterfaces();
    rewriteUrls((Element) Document.get().getDocumentElement());
    addDomChangeEvents();
    // screenShot.start();
    if (!isParentFrame()) {
        Element e = DOM.getElementById("miceNavigation");
        if (e != null)
            e.removeFromParent();
    }
}

From source file:cimav.client.view.catalogos.tabulador.NivelesUi.java

private void buildGrid() {
    // super.onLoad(); //To change body of generated methods, choose Tools | Templates.

    /*//w ww  . j a  v a 2  s  .co m
     * Set a key provider that provides a unique key for each contact. If key is
     * used to identify contacts when fields (such as the name and address)
     * change.
     */
    dataGrid = new CellTable<>(NivelesProvider.get().getDataProvider());
    //cellTable.setWidth("100%");
    //cellTable.setHeight("100%");

    /*
     * Do not refresh the headers every time the data is updated. The footer
     * depends on the current data, so we do not disable auto refresh on the
     * footer.
     */
    dataGrid.setAutoHeaderRefreshDisabled(true);

    // Set the message to display when the table is empty.
    dataGrid.setEmptyTableWidget(new Label("No hay Niveles"));

    // Attach a column sort handler to the ListDataProvider to sort the list.
    ColumnSortEvent.ListHandler<Tabulador> sortHandler = new ColumnSortEvent.ListHandler<>(
            NivelesProvider.get().getDataProvider().getList());
    dataGrid.addColumnSortHandler(sortHandler);

    // Create a Pager to control the table.
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    pager = new SimplePager(SimplePager.TextLocation.CENTER, pagerResources, false, 0, true);
    pager.setDisplay(dataGrid);

    dataGrid.setPageSize(50);

    // Add a selection model so we can select cells.
    final SelectionModel<Tabulador> selectionModel = new SingleSelectionModel<>(
            NivelesProvider.get().getDataProvider());
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            //System.out.println("123> " + event.getSource() + " - " + event.getAssociatedType());
            if (event.getSource() instanceof SingleSelectionModel) {

                SingleSelectionModel selecter = (SingleSelectionModel) event.getSource();
                Tabulador sel = (Tabulador) selecter.getSelectedObject();

                GWT.log("Sel>> " + sel);
            }
        }
    });
    dataGrid.setSelectionModel(selectionModel);

    dataGrid.addDomHandler(new DoubleClickHandler() {
        @SuppressWarnings("unchecked")
        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            //                DataGrid<Departamento> grid = (DataGrid<Departamento>) event.getSource();
            //                int row = grid.getKeyboardSelectedRow();
            //                Departamento item = grid.getVisibleItem(row);
        }
    }, DoubleClickEvent.getType());

    initTableColumns(sortHandler);

    // Add the CellList to the adapter in the database.
    NivelesProvider.get().getDataProvider().addDataDisplay(dataGrid);

}