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

public Label() 

Source Link

Document

Creates an empty label.

Usage

From source file:bwbv.rlt.client.ui.StatusBarPane.java

License:Apache License

public StatusBarPane() {
    messageLabel = new Label();
    messageLabel.setStyleName("MessageLabel");
    initWidget(messageLabel);//from  w w w.ja v a  2 s  .co m
    setStyleName("StatusBarPane");
}

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

License:Apache License

public ActionProgress(final String id, AsyncCallback<JobTracker> completionCallback) {
    this.id = id;
    this.completionCallback = completionCallback;
    this.fp = new FlowPanel();
    fp.setStyleName("alcina-ActionProgress");
    grid = new Grid(4, 2);
    jobName = new InlineLabel();
    FlowPanel jobNCancel = new FlowPanel();
    jobNCancel.add(jobName);//from  w w w .ja v a2  s  .c o m
    jobName.setStyleName("pad-right-5");
    this.cancelLink = new Link("(Cancel)", new ClickHandler() {
        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            cancelJob();
        }
    });
    jobNCancel.add(cancelLink);
    cancellingStatusMessage = new InlineLabel();
    cancellingStatusMessage.setVisible(false);
    jobNCancel.add(cancellingStatusMessage);
    addToGrid("Job", jobNCancel);
    times = new HTML();
    addToGrid("Time", times);
    message = new Label();
    message.setStyleName("message");
    addToGrid("Status", message);
    progress = new FlowPanel();
    progress.setStyleName("progress");
    bar = new FlowPanel();
    bar.setStyleName("bar");
    bar.add(progress);
    addToGrid("Progress", bar);
    grid.setCellSpacing(2);
    fp.add(grid);
    initWidget(fp);
    updateProgress();
    timer = new Timer() {
        boolean checking = false;

        @Override
        public void run() {
            AsyncCallback<JobTracker> callback = new AsyncCallback<JobTracker>() {
                public void onFailure(Throwable caught) {
                    checking = false;
                    if (maxConnectionFailure-- <= 0) {
                        stopTimer();
                        if (ActionProgress.this.completionCallback != null) {
                            ActionProgress.this.completionCallback.onFailure(caught);
                        }
                        throw new WrappedRuntimeException(caught);
                    }
                }

                public void onSuccess(JobTracker info) {
                    checking = false;
                    if (info == null) {
                        info = new JobTrackerImpl();
                        info.setJobName("Unknown job");
                        info.setComplete(true);
                        info.setProgressMessage("---");
                    }
                    if (info.isComplete()) {
                        stopTimer();
                        if (ActionProgress.this.completionCallback != null) {
                            ActionProgress.this.completionCallback.onSuccess(info);
                        }
                    }
                    setJobInfo(info);
                    fireNullPropertyChange("Updated");
                }
            };
            if (!checking) {
                ClientBase.getCommonRemoteServiceAsyncInstance().pollJobStatus(id, false, callback);
                checking = true;
            }
        }
    };
}

From source file:cc.alcina.framework.gwt.client.util.ClientUtils.java

License:Apache License

public static String trimToWidth(String s, String style, int pxWidth, String ellipsis) {
    if (pxWidth <= 20) {
        return s;
    }/* w  ww. j  a v a 2  s  .  c  o  m*/
    ellipsis = ellipsis == null ? "\u2026" : ellipsis;
    int r0 = 0;
    int r1 = s.length();
    Label l = new Label();
    setElementStyle(l.getElement(), style);
    Style cStyle = l.getElement().getStyle();
    cStyle.setPosition(Position.ABSOLUTE);
    cStyle.setLeft(0, Unit.PX);
    cStyle.setTop(0, Unit.PX);
    cStyle.setDisplay(Display.INLINE_BLOCK);
    cStyle.setProperty("whitespace", "nowrap");
    cStyle.setProperty("visibility", "hidden");
    RootPanel.get().add(l);
    boolean tried = false;
    while (true) {
        int mid = (r1 - r0) / 2 + r0;
        String t = tried ? s.substring(0, mid) + ellipsis : s;
        l.setText(t);
        if (l.getOffsetWidth() <= pxWidth) {
            if (!tried || (r1 - r0) <= 1) {
                RootPanel.get().remove(l);
                return t;
            }
            r0 = mid;
        } else {
            if (!tried) {
                tried = true;
            } else {
                r1 = mid;
            }
        }
    }
}

From source file:cc.kune.common.client.actions.gwtui.GwtMenuGui.java

License:GNU Affero Public License

@Override
public AbstractGuiItem create(final GuiActionDescrip descriptor) {
    super.descriptor = descriptor;
    descriptor.putValue(ParentWidget.PARENT_UI, this);
    // Standalone menus are menus without and associated button in a toolbar
    // (sometimes, a menu showed in a grid, or other special widgets)
    notStandAlone = !((MenuDescriptor) descriptor).isStandalone();
    if (notStandAlone) {
        button = new Button();
        button.removeStyleName("gwt-Button");
        descriptor.putValue(MenuDescriptor.MENU_SHOW_NEAR_TO, button);
        iconLabel = new IconLabel("");
        final ImageResource rightIcon = ((MenuDescriptor) descriptor).getRightIcon();
        if (rightIcon != null) {
            iconLabel.setRightIconResource(rightIcon);
            // iconLabel.addRightIconStyle("k-fr");
        }/*from w w  w .j  a va2  s .  c  o  m*/
        button.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(final ClickEvent event) {
                if (button.isEnabled()) {
                    event.stopPropagation();
                    showRelativeTo(button);
                }
            }
        });
        final String id = descriptor.getId();
        if (id != null) {
            button.ensureDebugId(id);
        }
        if (!descriptor.isChild()) {
            initWidget(button);
        } else {
            child = button;
        }
    } else {
        initWidget(new Label());
    }
    super.create(descriptor);
    configureItemFromProperties();
    descriptor.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(final PropertyChangeEvent event) {
            final Object newValue = event.getNewValue();
            if (event.getPropertyName().equals(MenuDescriptor.MENU_RIGHTICON)) {
                setIconRightResource((ImageResource) newValue);
            }
        }
    });

    return this;
}

From source file:cc.kune.common.client.notify.SimpleUserMessage.java

License:GNU Affero Public License

/**
 * Instantiates a new simple user message.
 *///from   w ww. j a  va2s .  co m
public SimpleUserMessage() {
    msg = new Label();
    msg.addStyleName("oc-user-msg");
    rp = new FlowPanel();
    timer = new Timer() {
        @Override
        public void run() {
            hide();
        }
    };

}

From source file:cc.kune.common.client.tooltip.Tooltip.java

License:GNU Affero Public License

/**
 * Instantiates a new tooltip.//  w w w  .j  a  va 2  s  .  co m
 */
private Tooltip() {
    super.add(uiBinder.createAndBindUi(this));
    super.setStyleName("k-tooltip-no-chrome");
    super.getElement().getStyle().setZIndex(10000);
    super.setAutoHideEnabled(false);
    super.setAnimationEnabled(false);
    final TimerWrapper overTimer = new TimerWrapper();
    final Executer hideExecuter = new Executer() {
        @Override
        public void execute() {
            hide();
        }
    };
    final TimerWrapper outTimer = new TimerWrapper();
    final TimerWrapper securityTimer = new TimerWrapper();
    timers = new TooltipTimers(overTimer, outTimer, securityTimer);
    outTimer.configure(hideExecuter);
    securityTimer.configure(hideExecuter);
    textLabel = new Label();
    content.add(textLabel);
}

From source file:cc.kune.core.client.ui.dialogs.PromptTopDialog.java

License:GNU Affero Public License

/**
 * Instantiates a new prompt top dialog.
 *
 * @param builder//from w  w w . j av  a  2s  .com
 *          the builder
 */
protected PromptTopDialog(final Builder builder) {
    super(builder);
    promptLabel = new Label();
    promptLabel.addStyleName("kune-Margin-Medium-b");
    if (builder.promptLines > 1) {
        textField = new TextArea();
        textField.setHeight(20 * builder.promptLines);
    } else {
        textField = new TextField<String>();
    }
    if (TextUtils.notEmpty(builder.textFieldStyle)) {
        textField.addStyleName(builder.textFieldStyle);
    }
    textField.setRegex(builder.regex);
    textField.getMessages().setRegexText(builder.regexText);
    textField.getMessages().setMinLengthText(builder.minLengthText);
    textField.getMessages().setMaxLengthText(builder.maxLengthText);
    textField.setTabIndex(1);
    textField.setId(builder.textboxId);
    if (TextUtils.notEmpty(builder.emptyText)) {
        textField.setEmptyText(builder.emptyText);
    }
    if (builder.textFieldWidth != 0) {
        textField.setWidth(builder.textFieldWidth);
    }
    if (builder.minLength != 0) {
        textField.setMinLength(builder.minLength);
    }
    if (builder.maxLength != 0) {
        textField.setMaxLength(builder.maxLength);
    }
    if (builder.promptWidth != 0) {
        textField.setWidth(builder.promptWidth);
    }
    textField.setAllowBlank(builder.allowBlank);
    textField.addListener(Events.OnKeyPress, new Listener<FieldEvent>() {
        @Override
        public void handleEvent(final FieldEvent fe) {
            if (fe.getEvent().getKeyCode() == 13) {
                builder.onEnter.onEnter();
            }
        }
    });
    if (TextUtils.notEmpty(builder.promptText)) {
        promptLabel.setText(builder.promptText);
    }
    super.getInnerPanel().add(promptLabel);
    super.getInnerPanel().add(textField);
}

From source file:cc.kune.gspace.client.licensewizard.pages.LicenseWizardFirstForm.java

License:GNU Affero Public License

/**
 * Instantiates a new license wizard first form.
 * /*  w w  w  .j  a  v a 2 s  .  c om*/
 * @param i18n
 *          the i18n
 */
@Inject
public LicenseWizardFirstForm(final I18nTranslationService i18n) {
    super.setFrame(true);
    super.setPadding(10);
    super.setAutoHeight(true);
    // super.setHeight(LicenseWizardView.HEIGHT);

    final Label intro = new Label();
    intro.setText(
            i18n.t("Select the license you prefer using for sharing your group contents with other people:"));
    intro.addStyleName("kune-Margin-10-b");
    final FieldSet fieldSet = new FieldSet();
    // fieldSet.setTitle(i18n.t("license recommended"));
    fieldSet.addStyleName("margin-left: 105px");
    fieldSet.setWidth(250);
    copyleftRadio = DefaultFormUtils.createRadio(fieldSet, i18n.t("Use a copyleft license (recommended)"),
            RADIO_FIELD_NAME, null, RADIO_COPYLEFT_ID);
    anotherLicenseRadio = DefaultFormUtils.createRadio(fieldSet,
            i18n.t("Use another kind of license (advanced)"), RADIO_FIELD_NAME, null, RADIO_ANOTHER_ID);

    final RadioGroup radioGroup = new RadioGroup();
    radioGroup.add(copyleftRadio);
    radioGroup.add(anotherLicenseRadio);
    radioGroup.setOrientation(Orientation.VERTICAL);
    radioGroup.setHideLabel(true);
    radioGroup.addListener(Events.Change, new Listener<BaseEvent>() {
        @Override
        public void handleEvent(final BaseEvent be) {
            onChange.onCallback();
        }
    });

    final FieldSet infoFS = new FieldSet();
    infoFS.setHeadingHtml("Info");
    // infoFS.setFrame(false);
    // infoFS.setIcon("k-info-icon");
    infoFS.setCollapsible(false);
    infoFS.setAutoHeight(true);

    final HTML recommendCopyleft = new HTML();
    final HTML whyALicense = new HTML();
    final HTML youCanChangeTheLicenseLater = new HTML();
    recommendCopyleft.setHTML(POINT + i18n.t("We recommend [%s] licenses, specially for practical works",
            TextUtils.generateHtmlLink("http://en.wikipedia.org/wiki/Copyleft", i18n.t("copyleft"))));
    whyALicense.setHTML(POINT + TextUtils.generateHtmlLink("http://mirrors.creativecommons.org/getcreative/",
            i18n.t("Why do we need a license?")));
    youCanChangeTheLicenseLater.setHTML(POINT + i18n.t("You can change this license later"));

    infoFS.addStyleName("kune-Margin-20-t");
    add(intro);
    add(radioGroup);
    infoFS.add(recommendCopyleft);
    infoFS.add(whyALicense);
    infoFS.add(youCanChangeTheLicenseLater);
    add(infoFS);
}

From source file:cc.kune.gspace.client.licensewizard.pages.LicenseWizardFrdForm.java

License:GNU Affero Public License

/**
 * Instantiates a new license wizard frd form.
 *
 * @param i18n/* w  w  w . ja v  a  2 s.c o m*/
 *          the i18n
 * @param session
 *          the session
 */
@Inject
public LicenseWizardFrdForm(final I18nTranslationService i18n, final Session session) {
    final Label intro = new Label();
    intro.setText(i18n.t("Select other kind of licenses:"));
    intro.addStyleName("kune-Margin-10-b");

    final ChosenOptions options = new ChosenOptions();
    options.setNoResultsText(i18n.t("License not found"));
    options.setPlaceholderText(i18n.t("Select license"));
    options.setSearchContains(true);
    licenseChoose = new ChosenListBox(false, options);
    // First empty
    licenseChoose.addItem("", "");
    for (final LicenseDTO license : session.getLicenses()) {
        if (!license.isCC()) {
            licenseChoose.addItem(license.getLongName(), license.getShortName());
        }
    }
    licenseChoose.addChosenChangeHandler(new ChosenChangeHandler() {
        @Override
        public void onChange(final ChosenChangeEvent event) {
            onChange.onCallback();
        }
    });
    add(licenseChoose);
}

From source file:cc.kune.gspace.client.licensewizard.pages.LicenseWizardSndForm.java

License:GNU Affero Public License

/**
 * Instantiates a new license wizard snd form.
 * //from  w  ww  . j a  va2s.  c  o  m
 * @param i18n
 *          the i18n
 */
@Inject
public LicenseWizardSndForm(final I18nTranslationService i18n) {
    setFrame(true);
    super.setPadding(10);
    // super.setHeight(LicenseWizardView.HEIGHT);
    super.setAutoHeight(true);
    final Label intro = new Label();
    intro.setText(i18n.t("Select the license type:"));
    intro.addStyleName("kune-Margin-10-b");

    final FieldSet fieldSet = new FieldSet();
    // fieldSet.setTitle("license type");
    fieldSet.addStyleName("margin-left: 105px");
    fieldSet.setWidth(250);
    commonLicensesRadio = DefaultFormUtils.createRadio(fieldSet, i18n.t("Common licenses for cultural works"),
            RADIO_FIELD_NAME, i18n.t("Select a Creative Commons license (recommended for cultural works)"),
            COMMON_LICENSES_ID);
    otherLicensesRadio = DefaultFormUtils.createRadio(fieldSet, i18n.t("Other kind of licenses"),
            RADIO_FIELD_NAME,
            i18n.t("Use the GNU licenses (recommended for free software works) and other kind of licenses"),
            OTHER_LICENSES_ID);
    add(intro);
    add(commonLicensesRadio);
    add(otherLicensesRadio);

}