Example usage for org.apache.wicket Component setEnabled

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

Introduction

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

Prototype

public final Component setEnabled(final boolean enabled) 

Source Link

Document

Sets whether this component is enabled.

Usage

From source file:com.userweave.pages.configuration.DisableComponentIfStudyStateNotInitVisitor.java

License:Open Source License

private void disable(Component component) {
    if (HIDE) {/* w  ww. j av a 2  s.  c om*/
        component.setVisible(false);
    } else {
        component.setEnabled(false);
    }
}

From source file:com.userweave.pages.configuration.editentitypanel.BaseFunctionEditEntityPanel.java

License:Open Source License

/**
 * Disable all annotated links with the given
 * which not match the given study state.
 *//*from w w w .j  a  va2s .  c om*/
@Override
protected void onBeforeRender() {
    // throw enable check to authorization strategy 
    visitChildren(new IVisitor<Component, Void>() {
        public void component(final Component component, final IVisit<Void> visit) {
            // calls auth. strategy
            boolean isEnabled = component.isActionAuthorized(ENABLE);

            component.setEnabled(isEnabled);
        }
    });

    visitChildren(new DisableEventLinkVisitor(getStudyStateModel()));

    super.onBeforeRender();
}

From source file:gr.interamerican.wicket.utils.WicketUtils.java

License:Open Source License

/**
 * Sets the enabled property on a number of wicket components.
 * /*from  ww  w.ja  v  a  2 s  . com*/
 * @param enabled
 * @param components
 */
public static void setEnabled(boolean enabled, Component... components) {
    for (Component cmp : components) {
        if (cmp != null) {
            cmp.setEnabled(enabled);
        }
    }
}

From source file:ontopoly.components.FieldsEditorExistingPanel.java

License:Apache License

public FieldsEditorExistingPanel(String id, final TopicTypeModel topicTypeModel,
        final FieldAssignmentModel fieldAssignmentModel, boolean readonly) {
    super(id);/*w  ww . ja v a 2 s  . c  om*/
    this.readonly = readonly;

    FieldAssignment fieldAssignment = fieldAssignmentModel.getFieldAssignment();

    WebMarkupContainer container = new WebMarkupContainer("field", fieldAssignmentModel);
    add(container);

    OntopolyImage icon = new OntopolyImage("icon", "dnd.gif", new ResourceModel("icon.dnd.reorder"));
    icon.setVisible(!readonly);
    container.add(icon);

    FieldDefinition fieldDefinition = fieldAssignment.getFieldDefinition();
    final FieldDefinitionModel fieldDefinitionModel = new FieldDefinitionModel(fieldDefinition);

    container.add(new FieldDefinitionLabel("fieldLabel", fieldDefinitionModel) {
        @Override
        protected boolean isFieldDefinitionLinkEnabled(Topic topic) {
            return true;
        }

        @Override
        protected boolean isOntologyTypeLinkEnabled(Topic topic) {
            return true;
        }
    });

    Component fieldType = getFieldType("valueType",
            fieldAssignmentModel.getFieldAssignment().getFieldDefinition());
    fieldType.setRenderBodyOnly(true);
    container.add(fieldType);

    Component cardinalityComponent = getCardinality("cardinality", fieldAssignmentModel);
    cardinalityComponent.setEnabled(!readonly);
    container.add(cardinalityComponent);

    // drag and drop
    if (!readonly) {
        String dndId = "fields_" + topicTypeModel.getTopicType().getId();
        container.add(new DraggableBehavior(dndId));
        container.add(new DroppableBehavior(dndId) {
            @Override
            protected MarkupContainer getDropContainer() {
                return FieldsEditorExistingPanel.this.getParent().getParent();
            }

            @Override
            protected void onDrop(Component component, AjaxRequestTarget target) {
                FieldAssignmentModel fam_dg = (FieldAssignmentModel) component.getDefaultModel();
                FieldAssignmentModel fam_do = (FieldAssignmentModel) getComponent().getDefaultModel();
                FieldAssignment fa_dg = fam_dg.getFieldAssignment();
                FieldAssignment fa_do = fam_do.getFieldAssignment();
                fa_do.moveAfter(fa_dg);
                FieldsEditorExistingPanel.this.onMoveAfter(fam_dg, fam_do, target);
            }
        });
    }

    TopicType topicType = topicTypeModel.getTopicType();
    TopicType declaredTopicType = fieldAssignmentModel.getFieldAssignment().getDeclaredTopicType();

    if (ObjectUtils.equals(topicType, declaredTopicType)) {
        OntopolyImageLink button = new OntopolyImageLink("button", "remove-value.gif",
                new ResourceModel("icon.remove.field")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                FieldsEditorExistingPanel.this.onRemove(fieldAssignmentModel, target);
            }

            @Override
            public boolean isVisible() {
                return !FieldsEditorExistingPanel.this.readonly;
                //! || (fieldDefinitionModel.getFieldDefinition().isSystemTopic() && ((OntopolySession)Session.get()).isAdministrationEnabled());
            }
        };
        container.add(button);
    } else {
        OntopolyImageLink button = new OntopolyImageLink("button", "goto.gif",
                new ResourceModel("icon.goto.assigning-type")) {
            @Override
            public void onClick(AjaxRequestTarget target) {
                TopicType declaredTopicType = fieldAssignmentModel.getFieldAssignment().getDeclaredTopicType();
                Map<String, String> pageParametersMap = new HashMap<String, String>(3);
                pageParametersMap.put("topicMapId", declaredTopicType.getTopicMap().getId());
                pageParametersMap.put("topicId", declaredTopicType.getId());
                pageParametersMap.put("ontology", "true");
                setResponsePage(InstancePage.class, new PageParameters(pageParametersMap));
            }
        };
        container.add(button);
    }
}

From source file:org.apache.syncope.client.console.wizards.any.UserDetails.java

License:Apache License

public UserDetails(final UserWrapper wrapper, final IModel<List<StatusBean>> statusModel,
        final boolean templateMode, final boolean includeStatusPanel, final boolean showPasswordManagement,
        final PageReference pageRef) {
    super(wrapper, statusModel, templateMode, includeStatusPanel, pageRef);

    final UserTO userTO = wrapper.getInnerObject();
    // ------------------------
    // Username//from w w  w.ja  v  a  2  s . co m
    // ------------------------
    final AjaxTextFieldPanel username = new AjaxTextFieldPanel("username", "username",
            new PropertyModel<String>(userTO, "username"), false);

    if (templateMode) {
        username.enableJexlHelp();
    } else {
        username.addRequiredLabel();
    }
    add(username);
    // ------------------------

    // ------------------------
    // Password
    // ------------------------
    final Model<Integer> model = Model.of(-1);

    final Accordion accordion = new Accordion("accordionPanel", Collections
            .<ITab>singletonList(new AbstractTab(new ResourceModel("password.change", "Change password")) {

                private static final long serialVersionUID = 1037272333056449378L;

                @Override
                public Panel getPanel(final String panelId) {
                    PasswordPanel panel = new PasswordPanel(panelId, wrapper, templateMode);
                    panel.setEnabled(model.getObject() >= 0);
                    return panel;
                }
            }), model) {

        private static final long serialVersionUID = -2898628183677758699L;

        @Override
        protected Component newTitle(final String markupId, final ITab tab, final Accordion.State state) {
            return new AjaxLink<Integer>(markupId) {

                private static final long serialVersionUID = 7021195294339489084L;

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    super.onComponentTag(tag);
                    tag.put("style", "color: #337ab7 !important");
                }

                @Override
                public void onClick(final AjaxRequestTarget target) {
                    model.setObject(model.getObject() == 0 ? -1 : 0);

                    boolean enable = model.getObject() >= 0;

                    if (statusPanel.isVisibleInHierarchy()) {
                        statusPanel.setCheckAvailability(enable ? ListViewPanel.CheckAvailability.AVAILABLE
                                : ListViewPanel.CheckAvailability.DISABLED);
                    }

                    Component passwordPanel = getParent().get(PASSWORD_CONTENT_PATH);
                    passwordPanel.setEnabled(enable);
                    target.add(passwordPanel);
                }
            }.setBody(new ResourceModel("password.change", "Change password ..."));
        }
    };

    accordion.setOutputMarkupId(true);
    accordion.setVisible(showPasswordManagement);
    add(accordion);
    // ------------------------        
}

From source file:org.artifactory.common.wicket.component.navigation.PagingNavigatorWithDropDown.java

License:Open Source License

private void updateButton(AjaxRequestTarget target, String buttonId, boolean state) {
    Component c = get(buttonId);

    // rendering the button ONLY if the state was changed
    if (c.isEnabled() != state) {
        c.setEnabled(state);
        if (target != null) {
            target.add(c);//  w  ww. j av a 2 s. com
        }
    }
}

From source file:org.devgateway.eudevfin.projects.module.components.tabs.CommonProjectTab.java

@Override
public MarkupContainer add(Component... childs) {
    for (Component component : childs) {
        component.setEnabled(editable);
    }// w w  w.  j a v a2  s  . co m

    return super.add(childs);
}

From source file:org.devgateway.eudevfin.ui.common.events.CofinancingField14UpdateBehavior.java

License:Open Source License

@Override
protected void onEventExtra(Component component, IEvent<?> event) {
    if (!component.getParent().getParent().getParent().getParent().isVisibleInHierarchy())
        return;/*from   w w  w .  jav  a 2  s .  co  m*/
    Field14aChangedEventPayload eventPayload = getEventPayload(event);
    if (!eventPayload.getField14Code()) {
        component.setEnabled(false);
        component.setDefaultModelObject(null);
    } else
        component.setEnabled(true);
}

From source file:org.devgateway.eudevfin.ui.common.events.DisbursementCurrentYearUpdateBehavior.java

License:Open Source License

@Override
protected void onEventExtra(Component component, IEvent<?> event) {
    if (!component.getParent().isVisibleInHierarchy())
        return;/*from   w ww.  j a v  a2s.  com*/
    ReportingYearChangedEventPayload eventPayload = getEventPayload(event);
    if (Calendar.getInstance().get(Calendar.YEAR) == eventPayload.getReportingYear()) {
        component.setEnabled(false);
        component.setDefaultModelObject(null);
    } else
        component.setEnabled(true);
}

From source file:org.devgateway.eudevfin.ui.common.events.LoansField12UpdateBehavior.java

License:Open Source License

@Override
protected void onEventExtra(Component component, IEvent<?> event) {
    if (!component.getParent().getParent().getParent().getParent().isVisibleInHierarchy())
        return;/*ww  w .j  av  a  2  s .  co  m*/
    Field12ChangedEventPayload eventPayload = getEventPayload(event);
    if (pattern.matcher(eventPayload.getField12Code()).matches()) {
        component.setEnabled(false);
        component.setDefaultModelObject(null);
    } else
        component.setEnabled(true);
}