Example usage for org.apache.wicket Component setVisibilityAllowed

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

Introduction

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

Prototype

public final Component setVisibilityAllowed(boolean allowed) 

Source Link

Document

Sets whether or not this component is allowed to be visible.

Usage

From source file:com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour.java

License:Apache License

@Override
public void onConfigure(Component component) {
    component.setEnabled(isEnabled());//from  w  ww  . j  a  va 2s .co m

    boolean visible = isVisible();
    component.setVisible(visible);
    component.setVisibilityAllowed(visible);
}

From source file:jp.xet.uncommons.wicket.behavior.VisibleIfCollectionIsEmptyBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);
    Collection<?> object = model.getObject();
    component.setVisibilityAllowed(object == null || object.isEmpty());
}

From source file:jp.xet.uncommons.wicket.behavior.VisibleIfCollectionIsNotEmptyBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);
    Collection<?> object = model.getObject();
    component.setVisibilityAllowed(object != null && object.isEmpty() == false);
}

From source file:jp.xet.uncommons.wicket.behavior.VisibleIfProviderIsEmptyBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);
    component.setVisibilityAllowed(provider == null || provider.size() == 0);
}

From source file:jp.xet.uncommons.wicket.behavior.VisibleIfProviderIsNotEmptyBehavior.java

License:Apache License

@Override
public void onConfigure(Component component) {
    super.onConfigure(component);
    component.setVisibilityAllowed(provider != null && provider.size() > 0);
}

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

License:Apache License

/**
 * Builds GUI lazily prior to first render.
 *
 * <p>//from   w w  w  .j  av a  2 s  .  c o m
 * This design allows the panel to be configured first.
 *
 * @see #onBeforeRender()
 */
private void buildGui() {

    scalarTypeContainer = new WebMarkupContainer(ID_SCALAR_TYPE_CONTAINER);
    scalarTypeContainer.setOutputMarkupId(true);
    scalarTypeContainer.add(new CssClassAppender(Model.of(getScalarPanelType())));
    addOrReplace(scalarTypeContainer);

    this.scalarIfCompact = createComponentForCompact();
    this.scalarIfRegular = createComponentForRegular();
    scalarIfRegular.setOutputMarkupId(true);

    scalarTypeContainer.addOrReplace(scalarIfCompact, scalarIfRegular);

    List<LinkAndLabel> linkAndLabels = LinkAndLabelUtil.asActionLinksForAssociation(this.scalarModel,
            getDeploymentCategory());

    final InlinePromptConfig inlinePromptConfig = getInlinePromptConfig();
    if (inlinePromptConfig.isSupported()) {

        this.scalarIfRegularInlinePromptForm = createInlinePromptForm();
        scalarTypeContainer.addOrReplace(scalarIfRegularInlinePromptForm);
        inlinePromptLink = createInlinePromptLink();
        scalarIfRegular.add(inlinePromptLink);

        // even if this particular scalarModel (property) is not configured for inline edits,
        // it's possible that one of the associated actions is.  Thus we set the prompt context
        scalarModel.setInlinePromptContext(new InlinePromptContext(getComponentForRegular(),
                scalarIfRegularInlinePromptForm, scalarTypeContainer));

        // start off assuming that neither the property nor any of the associated actions
        // are using inline prompts
        Component componentToHideIfAny = inlinePromptLink;

        // check if one of the associated actions is configured to use an inline form "as if edit"
        final LinkAndLabel linkAndLabelAsIfEdit = inlineAsIfEditIfAny(linkAndLabels);

        if (this.scalarModel.getPromptStyle().isInline() && scalarModel.canEnterEditMode()) {
            // we configure the prompt link if _this_ property is configured for inline edits...
            configureInlinePromptLinkCallback(inlinePromptLink);
            componentToHideIfAny = inlinePromptConfig.getComponentToHideIfAny();

        } else {

            // not editable property, but maybe one of the actions is.
            if (linkAndLabelAsIfEdit != null) {

                scalarModel.setHasActionWithInlineAsIfEdit(true);

                // safe to do this, the inlineAsEditIfAny(...) method checks for us
                final ActionLink actionLinkInlineAsIfEdit = (ActionLink) linkAndLabelAsIfEdit.getLink();

                if (actionLinkInlineAsIfEdit.isVisible() && actionLinkInlineAsIfEdit.isEnabled()) {
                    configureInlinePromptLinkCallback(inlinePromptLink, actionLinkInlineAsIfEdit);
                    componentToHideIfAny = inlinePromptConfig.getComponentToHideIfAny();
                }
            }
        }

        if (linkAndLabelAsIfEdit != null) {
            // irrespective of whether the property is itself editable, if the action is annotated as
            // INLINE_AS_IF_EDIT then we never render it as an action
            linkAndLabels = Lists.newArrayList(linkAndLabels);
            linkAndLabels.remove(linkAndLabelAsIfEdit);
        }

        if (componentToHideIfAny != null) {
            componentToHideIfAny.setVisibilityAllowed(false);
        }
    }
    if (scalarModel.getKind() == ScalarModel.Kind.PROPERTY && scalarModel.getMode() == EntityModel.Mode.VIEW
            && (scalarModel.getPromptStyle().isDialog() || !scalarModel.canEnterEditMode())) {
        getScalarValueComponent().add(new AttributeAppender("tabindex", "-1"));
    }

    addPositioningCssTo(scalarIfRegular, linkAndLabels);
    addActionLinksBelowAndRight(scalarIfRegular, linkAndLabels);

    addEditPropertyTo(scalarIfRegular);
    addFeedbackOnlyTo(scalarIfRegular, getScalarValueComponent());

    getRendering().buildGui(this);
    addCssFromMetaModel();

    notifyOnChange(this);
    addFormComponentBehaviourToUpdateSubscribers();

}

From source file:org.apache.isis.viewer.wicket.ui.pages.login.IsisSignInPanel.java

License:Apache License

private void setVisibilityAllowedBasedOnAvailableServices(final Component... components) {
    IsisContext.doInSession(new Runnable() {
        @Override//  w ww .j av a2s  .  c o m
        public void run() {
            final UserRegistrationService userRegistrationService = lookupService(
                    UserRegistrationService.class);
            final EmailNotificationService emailNotificationService = lookupService(
                    EmailNotificationService.class);
            final boolean visibilityAllowed = userRegistrationService != null
                    && emailNotificationService.isConfigured();
            for (final Component component : components) {
                if (component.isVisibilityAllowed()) {
                    component.setVisibilityAllowed(visibilityAllowed);
                }
            }
        }
    });
}

From source file:org.apache.jetspeed.portlets.AdminPortletWebPage.java

License:Apache License

/**
 * Set visibilities of components in a page based on preferences.
 * The preference name for a component is prepended by the specified preferenceNamePrefix.
 * @param prefix//from w  w  w . j ava 2  s .  c  o  m
 * @param defaultVisibility
 */
public void setVisibilitiesOfChildComponentsByPreferences(String prefix, boolean defaultVisibility) {
    PortletRequest request = ((AbstractAdminWebApplication) getApplication()).getPortletRequest();
    PortletPreferences prefs = request.getPreferences();

    for (Enumeration<String> prefNames = prefs.getNames(); prefNames.hasMoreElements();) {
        String prefName = prefNames.nextElement();

        if (prefName.startsWith(prefix)) {
            String componentName = prefName.substring(prefix.length());
            String prefValue = prefs.getValue(prefName, defaultVisibility ? "true" : "false");
            Component component = get(componentName);

            if (component != null) {
                component.setVisibilityAllowed(true).setVisible(BooleanUtils.toBoolean(prefValue));
            }
        }
    }
}

From source file:org.devgateway.toolkit.forms.wicket.components.form.GenericEnablingBootstrapFormComponent.java

License:Open Source License

/**
 * change visibility status of bound components based of the fact the level
 * has an affirmative answer or not//  w w  w  .  jav  a 2 s  .  c  o m
 * 
 * @param target
 */
protected void updateBoundComponents(final AjaxRequestTarget target) {
    TYPE selectedValue = this.getModelObject();
    if (selectedValue != null) {
        for (Component component : visibilityBoundComponents) {
            component.setVisibilityAllowed(boundComponentsVisibilityAllowed(selectedValue));
            if (target != null) {
                target.add(component);
            }
        }
    }
}

From source file:org.devgateway.toolkit.forms.wicket.components.form.GenericEnablingBootstrapFormComponent.java

License:Open Source License

/**
 * Reversed of {@link #updateBoundComponents(AjaxRequestTarget)}
 * //from  w w  w . j  a  va 2  s .  co m
 * @param target
 */
protected void updateReverseBoundComponents(final AjaxRequestTarget target) {
    TYPE selectedValue = this.getModelObject();
    if (selectedValue != null) {
        for (Component component : visibilityReverseBoundComponents) {
            component.setVisibilityAllowed(!boundComponentsVisibilityAllowed(selectedValue));
            if (target != null) {
                target.add(component);
            }
        }
    }
}