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

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

Introduction

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

Prototype

protected InlineLabel(Element element) 

Source Link

Document

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

Usage

From source file:cc.alcina.framework.common.client.provider.TextProvider.java

License:Apache License

public Label getInlineLabel(String text) {
    return new InlineLabel(text);
}

From source file:cc.alcina.framework.gwt.client.gwittir.widget.ExpandableLabel.java

License:Apache License

@Override
public void setValue(Object o) {
    fp.clear();//from  ww w.j a  v a2  s  . c om
    if (o == null) {
        // fp.add(new InlineLabel("[Undefined]"));
        return;
    }
    boolean hidden = false;
    if (o instanceof Collection) {
        ArrayList l = new ArrayList((Collection) o);
        if (l.size() > 0 && l.get(0) instanceof Comparable) {
            Collections.sort(l);
        }
        int strlen = 0;
        for (Object object : l) {
            InlineLabel comma = new InlineLabel(", ");
            if (strlen > 0) {
                fp.add(comma);
                strlen += 2;
            }
            String name = ClientReflector.get().displayNameForObject(object);
            InlineLabel label = new InlineLabel(name);
            if (strlen > getMaxLength()) {
                comma.setVisible(false);
                label.setVisible(false);
                hiddenWidgets.add(comma);
                hiddenWidgets.add(label);
                hidden = true;
            }
            strlen += name.length();
            fp.add(label);
        }
    } else {
        fullText = renderer == null ? o.toString() : renderer.render(o).toString();
        fullTextNoBrs = fullText;
        if (isShowNewlinesAsBreaks()) {
            fullText = SafeHtmlUtils.htmlEscape(fullText).replace("\n", "<br>\n");
        }
        int maxC = getMaxLength();
        int y1 = fullText.indexOf(">", maxC);
        int y2 = fullText.indexOf("<", maxC);
        int y3 = fullText.indexOf("<");
        if (y1 < y2 && y1 != -1 && y3 < maxC && !escapeHtml) {
            maxC = y1 + 1;
        }
        String vis = CommonUtils.trimToWsChars(fullText, maxC);
        com.google.gwt.user.client.ui.Label label;
        if (fullText.length() == vis.length()) {
            label = isShowNewlinesAsBreaks() ? new InlineHTML(fullText) : new InlineLabel(fullText);
            fp.add(label);
        } else {
            label = isShowNewlinesAsBreaks() ? new InlineHTML(vis) : new InlineLabel(vis);
            fp.add(label);
            hidden = true;
            if (!isShowAsPopup()) {
                String notVis = fullText.substring(vis.length());
                label = isShowNewlinesAsBreaks() ? new InlineHTML(notVis) : new InlineLabel(notVis);
                label.setVisible(false);
                fp.add(label);
                hiddenWidgets.add(label);
            }
        }
    }
    if (hidden) {
        this.dots = new InlineLabel("...");
        this.space = new InlineHTML("&nbsp;");
        fp.add(dots);
        this.hiding = true;
        this.showLink = new Link("[more]");
        this.hideLink = new Link("[less]");
        if (isShowHideAtEnd()) {
            fp.add(space);
            fp.add(hideLink);
        } else {
            fp.insert(hideLink, 0);
            fp.add(space);
        }
        hideLink.setVisible(false);
        space.setVisible(false);
        fp.add(showLink);
        hideLink.addClickHandler(showHideListener);
        showLink.addClickHandler(showHideListener);
    }
}

From source file:cc.alcina.framework.gwt.client.ide.widget.ActionProgress.java

License:Apache License

private void addToGrid(String label, Widget widget) {
    InlineLabel l = new InlineLabel(label + ": ");
    l.setStyleName("caption");
    grid.setWidget(row, 0, l);/*from   w  w w . j  ava  2 s  . c  o m*/
    grid.setWidget(row, 1, widget);
    grid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP);
    grid.getCellFormatter().setVerticalAlignment(row, 1, HasVerticalAlignment.ALIGN_TOP);
    row++;
}

From source file:cc.alcina.framework.gwt.client.widget.RelativePopupValidationFeedback.java

License:Apache License

@Override
public void handleException(Object source, ValidationException exception) {
    final Widget w = (Widget) source;
    resolve(source);/* w  w  w  .ja v a2 s  .com*/
    if (!DomUtils.isVisibleAncestorChain(w.getElement())) {
        return;
    }
    Widget suppressValidationFeedbackFor = RenderContext.get().getSuppressValidationFeedbackFor();
    if (suppressValidationFeedbackFor != null
            && suppressValidationFeedbackFor.getElement().isOrHasChild(w.getElement())) {
        return;
    }
    final RelativePopup p = new RelativePopup();
    p.setVisible(false);
    popups.put(source, p);
    WidgetByElementTracker.get().register(p);
    p.setStyleName("gwittir-ValidationPopup");
    if (getCss() != null) {
        p.addStyleName(getCss());
    }
    if (exception instanceof ProcessingServerValidationException) {
        ProcessingServerValidationException psve = (ProcessingServerValidationException) exception;
        FlowPanel fp = new FlowPanel();
        fp.setStyleName("gwittir-ServerValidation");
        fp.add(new InlineLabel(this.getMessage(exception)));
        p.add(fp);
        psve.setSourceWidget(source);
        psve.setFeedback(this);
    } else {
        p.add(renderExceptionWidget(exception));
    }
    int x = w.getAbsoluteLeft();
    int y = w.getAbsoluteTop();
    Widget pw = WidgetUtils.getPositioningParent(w);
    ComplexPanel cp = WidgetUtils.complexChildOrSelf(pw);
    if (!(pw instanceof RootPanel)) {
        x -= pw.getAbsoluteLeft();
        y -= pw.getAbsoluteTop();
    }
    cp.add(p);
    if (this.position == BOTTOM) {
        y += w.getOffsetHeight();
    } else if (this.position == RIGHT) {
        x += w.getOffsetWidth();
    } else if (this.position == LEFT) {
        x -= p.getOffsetWidth();
    } else if (this.position == TOP) {
        y -= p.getOffsetHeight();
    }
    Element h = p.getElement();
    Style style = h.getStyle();
    style.setPosition(Position.ABSOLUTE);
    style.setLeft(x, Unit.PX);
    style.setTop(y, Unit.PX);
    if (this.position == BOTTOM) {
        style.setWidth(w.getOffsetWidth(), Unit.PX);
    }
    p.setVisible(true);
    if (w instanceof SourcesPropertyChangeEvents) {
        // GWT.log("is PCE", null);
        PropertyChangeListener attachListener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                if (((Boolean) propertyChangeEvent.getNewValue()).booleanValue()) {
                    p.setVisible(true);
                } else {
                    p.setVisible(false);
                }
            }
        };
        listeners.put(w, attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("attached", attachListener);
        ((SourcesPropertyChangeEvents) w).addPropertyChangeListener("visible", attachListener);
    }
}

From source file:cc.kune.core.client.sitebar.ErrorsDialog.java

License:GNU Affero Public License

/**
 * Creates the dialog lazy./*w  w  w.java  2s.c o  m*/
 */
private void createDialogLazy() {
    if (dialog == null) {
        dialog = new BasicTopDialog.Builder(ERROR_LOGGER_ID, true, true, i18n.getDirection())
                .title(i18n.t("Errors info")).autoscroll(true).firstButtonTitle(i18n.t("Ok"))
                .firstButtonId(ERROR_LOGGER_BUTTON_ID).tabIndexStart(1).width("400px").height("400px").build();
        dialog.getTitleText().setText(i18n.t("Info about errors"), i18n.getDirection());
        final InlineLabel subTitle = new InlineLabel(i18n.t("Please copy/paste this info to report problems"));
        dialog.getInnerPanel().add(subTitle);
        dialog.getInnerPanel().add(BINDER.createAndBindUi(this));
        scroll.setHeight("350px");
        // scroll.setAlwaysShowScrollBars(true);
        dialog.getFirstBtn().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                dialog.hide();
            }
        });
    }
}

From source file:cc.kune.core.client.sitebar.SiteUserOptionsPresenter.java

License:GNU Affero Public License

/**
 * Sets the logged user name.//from   w  ww .  j a v  a  2s .  co  m
 *
 * @param username
 *          the new logged user name
 */
private void setLoggedUserName(final String shortname) {
    final InlineLabel username = new InlineLabel(shortname);
    username.addStyleName(Responsiveness.HIDDEN_XS.getCssName());
    //userBtn.setIcon("kune:chat-status");
    userBtn.setInnerHTML(username.getElement().getString());
}

From source file:cc.kune.gspace.client.viewers.AbstractFolderViewerPanel.java

License:GNU Affero Public License

/**
 * Instantiates a new abstract folder viewer panel.
 *
 * @param gsArmor/*from w  w w  .ja v a 2s. c  o m*/
 *          the gs armor
 * @param eventBus
 *          the event bus
 * @param i18n
 *          the i18n
 * @param capabilitiesRegistry
 *          the capabilities registry
 * @param dragController
 *          the drag controller
 * @param contentDropControllerProv
 *          the content drop controller prov
 * @param containerDropControllerProv
 *          the container drop controller prov
 * @param fromInboxDropController
 */
public AbstractFolderViewerPanel(final GSpaceArmor gsArmor, final EventBus eventBus,
        final I18nTranslationService i18n, final ContentCapabilitiesRegistry capabilitiesRegistry,
        final KuneDragController dragController,
        final Provider<FolderContentDropController> contentDropControllerProv,
        final Provider<FolderContainerDropController> containerDropControllerProv,
        final InboxToContainerDropController fromInboxDropController) {
    this.gsArmor = gsArmor;
    this.i18n = i18n;
    this.capabilitiesRegistry = capabilitiesRegistry;
    this.dragController = dragController;
    this.contentDropControllerProv = contentDropControllerProv;
    this.containerDropControllerProv = containerDropControllerProv;
    this.fromInboxDropController = fromInboxDropController;
    emptyPanel = new FlowPanel();
    emptyLabel = new InlineLabel(i18n.t("This is empty."));
    emptyLabel.setStyleName("k-empty-msg");
    emptyPanel.setStyleName("k-empty-folder-panel");
    emptyPanel.add(emptyLabel);
    contentTitle = new ContentTitleWidget(i18n, gsArmor, capabilitiesRegistry.getIconsRegistry());

    fromInboxDropController.init((Widget) gsArmor.getDocHeader());
}

From source file:com.ait.toolkit.ace.examples.client.AceDemo.java

License:Open Source License

/**
 * This method builds the UI. It creates UI widgets that exercise most/all of the AceEditor methods, so it's a bit of a kitchen sink.
 *//*www  .  j a  v  a  2  s  . c  om*/
private void buildUI() {
    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.setWidth("100%");

    mainPanel.add(new Label("Label above!"));

    mainPanel.add(editor1);

    // Label to display current row/column
    rowColLabel = new InlineLabel("");
    mainPanel.add(rowColLabel);

    // Create some buttons for testing various editor APIs
    HorizontalPanel buttonPanel = new HorizontalPanel();

    // Add button to insert text at current cursor position
    Button insertTextButton = new Button("Insert");
    insertTextButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            // Window.alert("Cursor at: " + editor1.getCursorPosition());
            editor1.insertAtCursor("inserted text!");
        }
    });
    buttonPanel.add(insertTextButton);

    // Add check box to enable/disable soft tabs
    final CheckBox softTabsBox = new CheckBox("Soft tabs");
    softTabsBox.setValue(true); // I think soft tabs is the default
    softTabsBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setUseSoftTabs(softTabsBox.getValue());
        }
    });
    buttonPanel.add(softTabsBox);

    // add text box and button to set tab size
    final TextBox tabSizeTextBox = new TextBox();
    tabSizeTextBox.setWidth("4em");
    Button setTabSizeButton = new Button("Set tab size");
    setTabSizeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setTabSize(Integer.parseInt(tabSizeTextBox.getText()));
        }
    });
    buttonPanel.add(new InlineLabel("Tab size: "));
    buttonPanel.add(tabSizeTextBox);
    buttonPanel.add(setTabSizeButton);

    // add text box and button to go to a given line
    final TextBox gotoLineTextBox = new TextBox();
    gotoLineTextBox.setWidth("4em");
    Button gotoLineButton = new Button("Go to line");
    gotoLineButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.gotoLine(Integer.parseInt(gotoLineTextBox.getText()));
        }
    });
    buttonPanel.add(new InlineLabel("Go to line: "));
    buttonPanel.add(gotoLineTextBox);
    buttonPanel.add(gotoLineButton);

    // checkbox to set whether or not horizontal scrollbar is always visible
    final CheckBox hScrollBarAlwaysVisibleBox = new CheckBox("H scrollbar: ");
    hScrollBarAlwaysVisibleBox.setValue(true);
    hScrollBarAlwaysVisibleBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setHScrollBarAlwaysVisible(hScrollBarAlwaysVisibleBox.getValue());
        }
    });
    buttonPanel.add(hScrollBarAlwaysVisibleBox);

    // checkbox to show/hide gutter
    final CheckBox showGutterBox = new CheckBox("Show gutter: ");
    showGutterBox.setValue(true);
    showGutterBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setShowGutter(showGutterBox.getValue());
        }
    });
    buttonPanel.add(showGutterBox);

    // checkbox to set/unset readonly mode
    final CheckBox readOnlyBox = new CheckBox("Read only: ");
    readOnlyBox.setValue(false);
    readOnlyBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setReadOnly(readOnlyBox.getValue());
        }
    });
    buttonPanel.add(readOnlyBox);

    // checkbox to show/hide print margin
    final CheckBox showPrintMarginBox = new CheckBox("Show print margin: ");
    showPrintMarginBox.setValue(true);
    showPrintMarginBox.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            editor1.setShowPrintMargin(showPrintMarginBox.getValue());
        }
    });
    buttonPanel.add(showPrintMarginBox);

    mainPanel.add(buttonPanel);

    mainPanel.add(editor2);
    mainPanel.add(new Label("Label below!"));

    RootPanel.get().add(mainPanel);
}

From source file:com.areahomeschoolers.baconbits.client.content.calendar.agenda.AgendaView.java

License:Open Source License

@Override
public void doLayout() {

    appointmentAdapterList.clear();// w ww  . j  av  a2s . c  om
    appointmentGrid.clear();
    for (int i = appointmentGrid.getRowCount() - 1; i >= 0; i--) {
        appointmentGrid.removeRow(i);
    }

    // Get the start date, make sure time is 0:00:00 AM
    Date startDate = (Date) calendarWidget.getDate().clone();
    Date today = new Date();
    Date endDate = (Date) calendarWidget.getDate().clone();
    endDate = ClientDateUtils.addDays(endDate, 1);
    DateUtils.resetTime(today);
    DateUtils.resetTime(startDate);
    DateUtils.resetTime(endDate);

    int row = 0;

    for (int i = 0; i < calendarWidget.getDays(); i++) {

        // Filter the list by date
        List<Appointment> filteredList = AppointmentUtil.filterListByDate(calendarWidget.getAppointments(),
                startDate, endDate);

        if (filteredList != null && filteredList.size() > 0) {

            appointmentGrid.setText(row, 0, DEFAULT_DATE_FORMAT.format(startDate));

            appointmentGrid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP);
            appointmentGrid.getFlexCellFormatter().setRowSpan(row, 0, filteredList.size());
            appointmentGrid.getFlexCellFormatter().setStyleName(row, 0, "dateCell");
            int startingCell = 1;

            // Row styles will alternate, so we set the style accordingly
            String rowStyle = (i % 2 == 0) ? "row" : "row-alt";

            // If a Row represents the current date (Today) then we style it differently
            if (startDate.equals(today)) {
                rowStyle += "-today";
            }

            for (Appointment appt : filteredList) {
                // add the time range
                String timeSpanString = DEFAULT_TIME_FORMAT.format(appt.getStart()) + " - "
                        + DEFAULT_TIME_FORMAT.format(appt.getEnd());
                DefaultInlineHyperlink timeSpanLink = new DefaultInlineHyperlink(timeSpanString.toLowerCase(),
                        PageUrl.event(Integer.parseInt(appt.getId())));

                appointmentGrid.setWidget(row, startingCell, timeSpanLink);

                // add the title and description
                FlowPanel titleContainer = new FlowPanel();
                DefaultInlineHyperlink titleLink = new DefaultInlineHyperlink(appt.getTitle(),
                        PageUrl.event(Integer.parseInt(appt.getId())));
                titleContainer.add(titleLink);
                InlineLabel descLabel = new InlineLabel(" - " + appt.getDescription());
                descLabel.setStyleName("descriptionLabel");
                titleContainer.add(descLabel);
                appointmentGrid.setWidget(row, startingCell + 1, titleContainer);

                // Format the Cells
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell + 1,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell, "timeCell");
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell + 1, "titleCell");
                appointmentGrid.getRowFormatter().setStyleName(row, rowStyle);

                // increment the row
                // make sure the starting column is reset to 0
                startingCell = 0;
                row++;
            }
        }

        // increment the date
        endDate = ClientDateUtils.addDays(endDate, 1);
        startDate = ClientDateUtils.addDays(startDate, 1);
    }
}

From source file:com.bradrydzewski.gwt.calendar.client.agenda.AgendaView.java

License:Open Source License

@Override
public void doLayout() {

    appointmentAdapterList.clear();//from   w  ww .j  av a 2  s  . co  m
    appointmentGrid.clear();
    for (int i = appointmentGrid.getRowCount() - 1; i >= 0; i--) {
        appointmentGrid.removeRow(i);
    }

    //Get the start date, make sure time is 0:00:00 AM
    Date startDate = (Date) calendarWidget.getDate().clone();
    Date today = new Date();
    Date endDate = (Date) calendarWidget.getDate().clone();
    endDate.setDate(endDate.getDate() + 1);
    DateUtils.resetTime(today);
    DateUtils.resetTime(startDate);
    DateUtils.resetTime(endDate);

    int row = 0;

    for (int i = 0; i < calendarWidget.getDays(); i++) {

        // Filter the list by date
        List<Appointment> filteredList = AppointmentUtil.filterListByDate(calendarWidget.getAppointments(),
                startDate, endDate);

        if (filteredList != null && filteredList.size() > 0) {

            appointmentGrid.setText(row, 0, DEFAULT_DATE_FORMAT.format(startDate));

            appointmentGrid.getCellFormatter().setVerticalAlignment(row, 0, HasVerticalAlignment.ALIGN_TOP);
            appointmentGrid.getFlexCellFormatter().setRowSpan(row, 0, filteredList.size());
            appointmentGrid.getFlexCellFormatter().setStyleName(row, 0, "dateCell");
            int startingCell = 1;

            //Row styles will alternate, so we set the style accordingly
            String rowStyle = (i % 2 == 0) ? "row" : "row-alt";

            //If a Row represents the current date (Today) then we style it differently
            if (startDate.equals(today))
                rowStyle += "-today";

            for (Appointment appt : filteredList) {

                // add the time range
                String timeSpanString = DEFAULT_TIME_FORMAT.format(appt.getStart()) + " - "
                        + DEFAULT_TIME_FORMAT.format(appt.getEnd());
                Label timeSpanLabel = new Label(timeSpanString.toLowerCase());
                appointmentGrid.setWidget(row, startingCell, timeSpanLabel);

                // add the title and description
                FlowPanel titleContainer = new FlowPanel();
                InlineLabel titleLabel = new InlineLabel(appt.getTitle());
                titleContainer.add(titleLabel);
                InlineLabel descLabel = new InlineLabel(" - " + appt.getDescription());
                descLabel.setStyleName("descriptionLabel");
                titleContainer.add(descLabel);
                appointmentGrid.setWidget(row, startingCell + 1, titleContainer);

                SimplePanel detailContainerPanel = new SimplePanel();
                AppointmentDetailPanel detailContainer = new AppointmentDetailPanel(detailContainerPanel, appt);

                appointmentAdapterList.add(new AgendaViewAppointmentAdapter(titleLabel, timeSpanLabel,
                        detailContainerPanel, detailContainer.getMoreDetailsLabel(), appt));

                //add the detail container
                titleContainer.add(detailContainer);

                //add click handlers to title, date and details link
                timeSpanLabel.addClickHandler(appointmentClickHandler);
                titleLabel.addClickHandler(appointmentClickHandler);
                detailContainer.getMoreDetailsLabel().addClickHandler(appointmentClickHandler);

                // Format the Cells
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setVerticalAlignment(row, startingCell + 1,
                        HasVerticalAlignment.ALIGN_TOP);
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell, "timeCell");
                appointmentGrid.getCellFormatter().setStyleName(row, startingCell + 1, "titleCell");
                appointmentGrid.getRowFormatter().setStyleName(row, rowStyle);

                // increment the row
                // make sure the starting column is reset to 0
                startingCell = 0;
                row++;
            }
        }

        // increment the date
        startDate.setDate(startDate.getDate() + 1);
        endDate.setDate(endDate.getDate() + 1);
    }
}