Example usage for org.apache.wicket Component isEnabledInHierarchy

List of usage examples for org.apache.wicket Component isEnabledInHierarchy

Introduction

In this page you can find the example usage for org.apache.wicket Component isEnabledInHierarchy.

Prototype

public boolean isEnabledInHierarchy() 

Source Link

Document

Calculates enabled state of the component taking its hierarchy into account.

Usage

From source file:com.googlecode.londonwicket.ComponentExpression.java

License:Apache License

private static final boolean evaluateConditions(Collection<Condition> conditions, Component component) {
    boolean result = true;
    for (Condition condition : conditions) {
        switch (condition.getAttr()) {
        case ENABLED: {
            result = result && (component.isEnabledInHierarchy() == condition.getCondition());
            break;
        }// w w w  .j av a  2  s  .  c  o  m
        case VISIBLE: {
            result = result && (component.isVisibleInHierarchy() == condition.getCondition());
        }
        }
        if (!result) {
            break;
        }
    }
    return result;
}

From source file:com.googlecode.wicket.kendo.ui.form.autocomplete.AutoCompleteBehavior.java

License:Apache License

@Override
public boolean isEnabled(Component component) {
    return component.isEnabledInHierarchy();
}

From source file:com.premiumminds.webapp.wicket.bootstrap.datepicker.BootstrapDatePickerBehaviour.java

License:Open Source License

@Override
public void renderHead(Component component, IHeaderResponse response) {
    super.renderHead(component, response);
    Collection<SpecialDate> specialDates = getSpecialDates();

    if (component.isEnabledInHierarchy()) {
        response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
        response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
        response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
        if (!component.getLocale().getLanguage().equals("en")) {
            response.render(JavaScriptHeaderItem
                    .forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class,
                            "locales/bootstrap-datepicker." + component.getLocale().getLanguage() + ".js")));
        }//from w ww.j a  v  a 2s . c o  m

        if (null != specialDates && !specialDates.isEmpty()) {
            StringBuilder sb = new StringBuilder();
            sb.append("[");
            DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
            for (int i = 0; i < specialDates.size(); ++i) {
                SpecialDate sd = sdArray[i];
                sb.append("{dt:new Date('" + df.format(sd.getDt()) + "'), css:'" + sd.getCssClass()
                        + "', tooltip:'" + sd.getTooltip() + "'}");
                if (i < specialDates.size() - 1) {
                    sb.append(",");
                }
            }
            sb.append("]");

            response.render(OnDomReadyHeaderItem.forScript(
                    "$(\"#" + component.getMarkupId() + "\").datepicker(null, " + sb.toString() + ")"));
        } else {
            response.render(
                    OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").datepicker()"));
        }
    }
}

From source file:com.premiumminds.webapp.wicket.bootstrap.datepicker.BootstrapDatePickerBehaviour.java

License:Open Source License

@Override
public void onComponentTag(Component component, ComponentTag tag) {
    super.onComponentTag(component, tag);

    if (component.isEnabledInHierarchy()) {
        tag.put("data-date-language", component.getLocale().getLanguage());
    }/*from  ww  w .j  a v a 2s .c  o m*/
}

From source file:com.premiumminds.webapp.wicket.datepicker.DatePicker.java

License:Open Source License

@Override
public void renderHead(Component component, IHeaderResponse response) {
    response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_DATE_CSS, "screen"));
    response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JS));
    response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_ATTACH_JS));
    response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_DATE_JS));

    if (component.isEnabledInHierarchy()) {

        StringBuilder sb = new StringBuilder();
        sb.append("Date.defineParser(\"").append(getDatePattern()).append("\");");
        response.render(JavaScriptHeaderItem.forScript(sb.toString(), "pickerDatePattern"));

        sb = new StringBuilder();

        sb.append("new Picker.Date($(\"").append(component.getMarkupId()).append("\"), {");

        sb.append("format : \"").append(getDatePattern()).append("\",");
        sb.append("inject : $(\"").append(container.getMarkupId()).append("\"),");

        sb.append("months_abr : [");
        sb.append("\"Jan\",");
        sb.append("\"Fev\",");
        sb.append("\"Mar\",");
        sb.append("\"Abr\",");
        sb.append("\"Mai\",");
        sb.append("\"Jun\",");
        sb.append("\"Jul\",");
        sb.append("\"Ago\",");
        sb.append("\"Set\",");
        sb.append("\"Out\",");
        sb.append("\"Nov\",");
        sb.append("\"Dez\",");
        sb.append("],");

        sb.append("days_abr : [");
        sb.append("\"Seg\",");
        sb.append("\"Ter\",");
        sb.append("\"Qua\",");
        sb.append("\"Qui\",");
        sb.append("\"Sex\",");
        sb.append("\"Sab\",");
        sb.append("\"Dom\",");
        sb.append("],");

        sb.append("})");

        response.render(OnLoadHeaderItem.forScript(sb.toString()));
    }//from w w  w.  j  a va  2s  .c o m
}

From source file:com.servoy.j2db.server.headlessclient.dataui.TooltipAttributeModifier.java

License:Open Source License

@Override
public boolean isEnabled(Component component) {
    if (!component.isEnabledInHierarchy()) {
        return false;
    } else//from w ww.  j a v a  2  s  .c  o  m
        return super.isEnabled(component);
}

From source file:de.alpharogroup.wicket.component.search.ComponentExpression.java

License:Apache License

/**
 * Evaluates the given {@link org.apache.wicket.Component} with the given collection of
 * {@link Condition}s.//from  w  w w  .  j  a v a 2 s. co m
 * 
 * @param conditions
 *            a collection of {@link Condition}s to evaluate.
 * @param component
 *            the {@link org.apache.wicket.Component} that the evaluation will be executed.
 * @return true if the evaluation is successful otherwise false.
 */
private static final boolean evaluateConditions(Collection<Condition> conditions, Component component) {
    boolean result = true;
    for (Condition condition : conditions) {
        switch (condition.getAttr()) {
        case ENABLED: {
            result = result && (component.isEnabledInHierarchy() == condition.getCondition());
            break;
        }
        case VISIBLE: {
            result = result && (component.isVisibleInHierarchy() == condition.getCondition());
        }
        }
        if (!result) {
            break;
        }
    }
    return result;
}

From source file:net.dontdrinkandroot.wicket.bootstrap.behavior.DisabledCssBehavior.java

License:Apache License

@Override
public void onComponentTag(Component component, ComponentTag tag) {

    super.onComponentTag(component, tag);

    if (!component.isEnabledInHierarchy()) {

        String classAttribute = tag.getAttribute("class");

        if (classAttribute != null) {

            String[] parts = classAttribute.split(" ");
            for (String part : parts) {
                if (part.equalsIgnoreCase(BootstrapCssClass.DISABLED.getClassString())) {
                    return;
                }//from ww  w . j a  va  2 s . c om
            }

            classAttribute += " " + BootstrapCssClass.DISABLED.getClassString();
            tag.put("class", classAttribute);

        } else {

            tag.put("class", BootstrapCssClass.DISABLED.getClassString());
        }
    }
}

From source file:org.efaps.ui.wicket.behaviors.update.AbstractRemoteUpdateBehavior.java

License:Apache License

@Override
public void renderHead(final Component _component, final IHeaderResponse _response) {
    super.renderHead(_component, _response);

    if (_component.isEnabledInHierarchy()) {
        final CharSequence js = getCallbackScript(_component);

        final AjaxRequestTarget target = _component.getRequestCycle().find(AjaxRequestTarget.class);
        if (target == null) {
            _response.render(JavaScriptHeaderItem.forScript(js.toString(), getClass().getName()));
        } else {//www  . ja v  a2s  .c o m
            target.appendJavaScript(js);
        }
    }
}

From source file:org.efaps.ui.wicket.components.menu.ajax.AbstractItemBehavior.java

License:Apache License

@Override
public void renderHead(final Component _component, final IHeaderResponse _response) {
    if (_component.isEnabledInHierarchy()) {
        final CharSequence js = getCallbackScript(_component);

        final AjaxRequestTarget target = _component.getRequestCycle().find(AjaxRequestTarget.class);
        if (target == null) {
            _response.render(OnDojoReadyHeaderItem.forScript(js.toString()));
        } else {/* www . j  a va2s .c o  m*/
            target.appendJavaScript(js);
        }
    }
}