Example usage for org.apache.wicket.util.string Strings isEmpty

List of usage examples for org.apache.wicket.util.string Strings isEmpty

Introduction

In this page you can find the example usage for org.apache.wicket.util.string Strings isEmpty.

Prototype

public static boolean isEmpty(final CharSequence string) 

Source Link

Document

Checks whether the string is considered empty.

Usage

From source file:org.apache.isis.viewer.wicket.ui.components.bookmarkedpages.BookmarkedPagesPanel.java

License:Apache License

protected Component addHelpText(final BookmarkedPagesModel bookmarkedPagesModel) {

    IModel<String> helpTextModel = new AbstractReadOnlyModel<String>() {
        @Override/*from   w w  w  .  j a v a2  s.c o m*/
        public String getObject() {
            return bookmarkedPagesModel.isEmpty() ? "You have no bookmarks!" : "";
        }
    };

    Label helpText = new Label(ID_BOOKMARKS_HELP_TEXT, helpTextModel) {
        @Override
        protected void onConfigure() {
            super.onConfigure();

            setVisible(!Strings.isEmpty(getDefaultModelObjectAsString()));
        }
    };
    helpText.setOutputMarkupPlaceholderTag(true);
    return helpText;
}

From source file:org.apache.isis.viewer.wicket.ui.components.scalars.datepicker.DateTimeConfig.java

License:Apache License

/**
 * The earliest date that may be selected; all earlier dates will be disabled.
 *
 * @param value the earliest start date//from  w  w  w . j  av a2s . c om
 * @return this instance for chaining
 */
public DateTimeConfig withStartDate(final DateTime value) {
    String format = getFormat();
    String startDate;
    if (Strings.isEmpty(format)) {
        startDate = value.toString();
    } else {
        DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(format);
        startDate = dateTimeFormatter.print(value);
    }
    put(StartDate, startDate);
    return this;
}

From source file:org.apache.isis.viewer.wicket.ui.components.scalars.datepicker.DateTimeConfig.java

License:Apache License

/**
 * The latest date that may be selected; all later dates will be disabled.
 *
 * @param value the latest end date/*  ww w .  j  a  v a 2  s  .c  om*/
 * @return this instance for chaining
 */
public DateTimeConfig withEndDate(final DateTime value) {
    Args.notNull(value, "value");
    String format = getFormat();
    String endDate;
    if (Strings.isEmpty(format)) {
        endDate = value.toString();
    } else {
        DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(format);
        endDate = dateTimeFormatter.print(value);
    }
    put(EndDate, endDate);
    return this;
}

From source file:org.apache.isis.viewer.wicket.ui.components.scalars.jdkmath.BigIntegerConverter.java

License:Apache License

@Override
public BigInteger convertToObject(String value, Locale locale) throws ConversionException {
    if (Strings.isEmpty(value)) {
        return null;
    }/* w ww  . j  av a  2s  . c  om*/

    final Number number = parse(value, -Double.MAX_VALUE, Double.MAX_VALUE, locale);

    if (number instanceof BigInteger) {
        return (BigInteger) number;
    } else if (number instanceof Long) {
        return BigInteger.valueOf(number.longValue());
    } else if (number instanceof Integer) {
        return BigInteger.valueOf(number.intValue());
    } else {
        return new BigInteger(value);
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.widgets.favicon.Favicon.java

License:Apache License

@Override
protected void onConfigure() {
    super.onConfigure();

    setVisible(!Strings.isEmpty(url));
}

From source file:org.apache.isis.viewer.wicket.ui.components.widgets.favicon.Favicon.java

License:Apache License

@Override
protected void onComponentTag(ComponentTag tag) {
    super.onComponentTag(tag);

    tag.put("href", url);

    if (!Strings.isEmpty(contentType)) {
        tag.put("type", contentType);
    }//from  w w  w . ja  va  2s. c o m
}

From source file:org.apache.isis.viewer.wicket.ui.components.widgets.ObjectAdapterMementoProviderAbstract.java

License:Apache License

/**
 * Filters all choices against a term by using their
 * {@link org.apache.isis.core.metamodel.adapter.ObjectAdapter#titleString(org.apache.isis.core.metamodel.adapter.ObjectAdapter) title string}
 *
 * @param term The term entered by the user
 * @param choicesMementos The collections of choices to filter
 * @return A list of all matching choices
 *//*from   w w w . j  a v  a 2 s.c om*/
protected List<ObjectAdapterMemento> obtainMementos(String term,
        Collection<ObjectAdapterMemento> choicesMementos) {
    List<ObjectAdapterMemento> matches = Lists.newArrayList();
    if (Strings.isEmpty(term)) {
        matches.addAll(choicesMementos);
    } else {
        for (ObjectAdapterMemento candidate : choicesMementos) {
            ObjectAdapter objectAdapter = candidate.getObjectAdapter(ConcurrencyChecking.NO_CHECK);
            String title = objectAdapter.titleString(objectAdapter);
            if (title.toLowerCase().contains(term.toLowerCase())) {
                matches.add(candidate);
            }
        }
    }

    return matches;
}

From source file:org.apache.isis.viewer.wicket.ui.components.widgets.select2.providers.ObjectAdapterMementoProviderAbstract.java

License:Apache License

/**
 * Filters all choices against a term by using their
 * {@link org.apache.isis.core.metamodel.adapter.ObjectAdapter#titleString(org.apache.isis.core.metamodel.adapter.ObjectAdapter) title string}
 *
 * @param term The term entered by the user
 * @param choicesMementos The collections of choices to filter
 * @return A list of all matching choices
 *///from www .j  av  a 2  s  .c  om
protected final List<ObjectAdapterMemento> obtainMementos(String term,
        Collection<ObjectAdapterMemento> choicesMementos) {
    List<ObjectAdapterMemento> matches = Lists.newArrayList();
    if (Strings.isEmpty(term)) {
        matches.addAll(choicesMementos);
    } else {
        for (ObjectAdapterMemento candidate : choicesMementos) {
            ObjectAdapter objectAdapter = candidate.getObjectAdapter(ConcurrencyChecking.NO_CHECK,
                    getPersistenceSession(), getSpecificationLoader());
            String title = objectAdapter.titleString(objectAdapter);
            if (title.toLowerCase().contains(term.toLowerCase())) {
                matches.add(candidate);
            }
        }
    }

    return matches;
}

From source file:org.apache.isis.viewer.wicket.ui.components.widgets.themepicker.ThemeChooser.java

License:Apache License

private void initializeActiveThemeFromCookie() {
    CookieUtils cookieUtils = new CookieUtils();
    String activeTheme = cookieUtils.load(ISIS_THEME_COOKIE_NAME);
    if (!Strings.isEmpty(activeTheme)) {
        setActiveTheme(activeTheme);// w  w  w  . j  av a2 s  .  c o  m
    }
}

From source file:org.apache.isis.viewer.wicket.ui.pages.accmngt.password_reset.PasswordResetPage.java

License:Apache License

@Override
protected void onInitialize() {
    super.onInitialize();

    add(new NotificationPanel("feedback"));

    StringValue uuidValue = getPageParameters().get(0);
    if (uuidValue.isEmpty()) {
        addPasswordResetEmailPanel(ID_CONTENT_PANEL);
    } else {/*  w  w w .j a  v  a2  s . c o  m*/
        String uuid = uuidValue.toString();

        AccountConfirmationMap accountConfirmationMap = getApplication()
                .getMetaData(AccountConfirmationMap.KEY);
        final String email = accountConfirmationMap.get(uuid);
        if (Strings.isEmpty(email)) {
            error(getString("passwordResetExpiredOrInvalidToken"));
            addOrReplace(addPasswordResetEmailPanel(ID_CONTENT_PANEL));
        } else {
            Boolean emailExists = IsisContext.doInSession(new Callable<Boolean>() {
                @Override
                public Boolean call() throws Exception {
                    UserRegistrationService userRegistrationService = IsisContext.getPersistenceSession()
                            .getServicesInjector().lookupService(UserRegistrationService.class);
                    return userRegistrationService.emailExists(email);
                }
            });
            if (!emailExists) {
                error(getString("noUserForAnEmailValidToken"));
                addOrReplace(addPasswordResetEmailPanel(ID_CONTENT_PANEL));
            } else {
                addPasswordResetPanel(ID_CONTENT_PANEL, uuid);
            }
        }
    }
}