Example usage for org.apache.wicket Application get

List of usage examples for org.apache.wicket Application get

Introduction

In this page you can find the example usage for org.apache.wicket Application get.

Prototype

public static Application get() 

Source Link

Document

Get Application for current thread.

Usage

From source file:ontopoly.OntopolyContext.java

License:Apache License

public static LockManager getLockManager() {
    OntopolyApplication app = (OntopolyApplication) Application.get();
    return app.getLockManager();
}

From source file:ontopoly.validators.DateFormatValidator.java

License:Apache License

@Override
protected void onValidate(IValidatable<String> validatable) {
    final String value = validatable.getValue();
    if (value == null)
        return;//from   www .  ja  va  2  s  . com
    try {
        DateFormat df = createDateFormat();
        df.parse(value);
    } catch (ParseException e) {
        String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(),
                (Component) null, new Model<Serializable>(new Serializable() {
                    @SuppressWarnings("unused")
                    public String getValue() {
                        return value;
                    }
                }));
        component.error(
                AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
    }
}

From source file:ontopoly.validators.IdentityValidator.java

License:Apache License

private void reportError(String resourceKey, final String identity) {
    String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey,
            (Component) null, new Model<Serializable>(new Serializable() {
                @SuppressWarnings("unused")
                public String getIdentity() {
                    return identity;
                }//  w w w  . j av a  2 s  .  c o m
            }));
    component.error(
            AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
}

From source file:ontopoly.validators.RegexValidator.java

License:Apache License

private void reportError(String resourceKey, final String value, final String regex) {
    try {//w  ww. ja v a  2s .  c o  m
        String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey,
                (Component) null, new Model<Serializable>(new Serializable() {
                    @SuppressWarnings("unused")
                    public String getValue() {
                        return value;
                    }

                    @SuppressWarnings("unused")
                    public String getRegex() {
                        return regex;
                    }
                }));
        component.error(
                AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
    } catch (Exception e) {
        component.error(AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel,
                new Model<String>("Regexp validation error (value='" + value + "', regex='" + regex + "')")));
    }
}

From source file:ontopoly.validators.URIValidator.java

License:Apache License

@Override
protected void onValidate(IValidatable<String> validatable) {
    final String value = validatable.getValue();
    if (value == null)
        return;//w w w. j  a  v  a2s. c  o  m
    try {
        new URILocator(value);
    } catch (Exception e) {
        String message = Application.get().getResourceSettings().getLocalizer().getString(resourceKey(),
                (Component) null, new Model<Serializable>(new Serializable() {
                    @SuppressWarnings("unused")
                    public String getValue() {
                        return value;
                    }
                }));
        component.error(
                AbstractFieldInstancePanel.createErrorMessage(fieldInstanceModel, new Model<String>(message)));
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.collectioncontents.ajaxtable.columns.ColumnAbstract.java

License:Apache License

protected ComponentFactoryRegistry getComponentRegistry() {
    final ComponentFactoryRegistryAccessor cfra = (ComponentFactoryRegistryAccessor) Application.get();
    return cfra.getComponentFactoryRegistry();
}

From source file:org.apache.isis.viewer.wicket.ui.components.entity.blocks.action.EntityActionLinkFactory.java

License:Apache License

protected ComponentFactoryRegistry getComponentFactoryRegistry() {
    final ComponentFactoryRegistryAccessor cfra = (ComponentFactoryRegistryAccessor) Application.get();
    return cfra.getComponentFactoryRegistry();
}

From source file:org.apache.isis.viewer.wicket.ui.components.entity.blocks.action.EntityActionLinkFactory.java

License:Apache License

protected PageClassRegistry getPageClassRegistry() {
    final PageClassRegistryAccessor pcra = (PageClassRegistryAccessor) Application.get();
    return pcra.getPageClassRegistry();
}

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

License:Apache License

/**
 * Locates the best IConverter implementation for a given {@link org.apache.isis.core.metamodel.adapter.ObjectAdapter}
 *
 * @param objectAdapter The object adapter to locate converter for
 * @param wicketViewerSettings The date related settings
 * @return The best converter for the object adapter's type
 *//*from  ww  w  . j  av a  2  s.co  m*/
public static IConverter<Object> findConverter(final ObjectAdapter objectAdapter,
        final WicketViewerSettings wicketViewerSettings) {

    final ObjectSpecification objectSpecification = objectAdapter.getSpecification();

    // only use Wicket IConverter for value types, not for domain objects.
    if (!objectSpecification.isValue()) {
        return null;
    }

    // explicitly exclude enums; this will force the titleString
    // to be used from Isis' EnumValueSemanticsProvider
    final Class<?> correspondingClass = objectSpecification.getCorrespondingClass();
    if (Enum.class.isAssignableFrom(correspondingClass)) {
        return null;
    }

    final RenderedAdjustedFacet renderedAdjustedFacet = objectSpecification
            .getFacet(RenderedAdjustedFacet.class);
    final int adjustBy = renderedAdjustedFacet != null ? renderedAdjustedFacet.value() : 0;

    IConverter converter = null;
    if (java.util.Date.class == correspondingClass) {
        converter = new DateConverterForJavaUtilDate(wicketViewerSettings, adjustBy);
    } else if (java.sql.Date.class == correspondingClass) {
        converter = new DateConverterForJavaSqlDate(wicketViewerSettings, adjustBy);
    } else if (org.apache.isis.applib.value.Date.class == correspondingClass) {
        converter = new DateConverterForApplibDate(wicketViewerSettings, adjustBy);
    } else if (org.apache.isis.applib.value.DateTime.class == correspondingClass) {
        converter = new DateConverterForApplibDateTime(wicketViewerSettings, adjustBy);
    } else if (org.joda.time.LocalDate.class == correspondingClass) {
        converter = new DateConverterForJodaLocalDate(wicketViewerSettings, adjustBy);
    } else if (org.joda.time.LocalDateTime.class == correspondingClass) {
        converter = new DateConverterForJodaLocalDateTime(wicketViewerSettings, adjustBy);
    } else if (org.joda.time.DateTime.class == correspondingClass) {
        converter = new DateConverterForJodaDateTime(wicketViewerSettings, adjustBy);
    } else if (java.sql.Timestamp.class == correspondingClass) {
        converter = new DateConverterForJavaSqlTimestamp(wicketViewerSettings, adjustBy);
    } else if (java.math.BigInteger.class == correspondingClass) {
        converter = BigIntegerConverter.INSTANCE;
    } else if (java.math.BigDecimal.class == correspondingClass) {
        final BigDecimalValueFacet facet = objectSpecification.getFacet(BigDecimalValueFacet.class);
        Integer scale = null;
        if (facet != null) {
            scale = facet.getScale();
        }
        converter = new BigDecimalConverterWithScale(scale).forViewMode();
    } else if (Application.exists()) {
        final IConverterLocator converterLocator = Application.get().getConverterLocator();
        converter = converterLocator.getConverter(correspondingClass);
    }

    return converter;
}

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

License:Apache License

protected ComponentFactoryRegistry getComponentFactoryRegistry() {
    return ((ComponentFactoryRegistryAccessor) Application.get()).getComponentFactoryRegistry();
}