Example usage for org.apache.wicket.markup.html.link AbstractLink setEnabled

List of usage examples for org.apache.wicket.markup.html.link AbstractLink setEnabled

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.link AbstractLink setEnabled.

Prototype

public final Component setEnabled(final boolean enabled) 

Source Link

Document

Sets whether this component is enabled.

Usage

From source file:com.doculibre.constellio.wicket.panels.admin.crud.SingleColumnCRUDPanel.java

License:Open Source License

@Override
protected List<IColumn> getDataColumns() {
    List<IColumn> dataColumns = new ArrayList<IColumn>();
    IColumn detailsColumn = new HeaderlessColumn() {
        @Override// w w  w. j av  a2s .  co m
        public void populateItem(Item cellItem, String componentId, final IModel rowItemModel) {
            Item rowItem = (Item) cellItem.findParent(Item.class);
            final int rowIndex = getFirstRowItemAbsoluteIndex() + rowItem.getIndex();
            cellItem.add(new ModalLinkHolder(componentId) {
                @Override
                public WebMarkupContainer newLink(String id) {
                    AbstractLink link;
                    if (isUseModalsDetails()) {
                        link = new AjaxLink(id) {
                            @Override
                            public void onClick(AjaxRequestTarget target) {
                                ModalWindow detailsModal = getModalWindow();
                                detailsModal.setInitialHeight(MODAL_HEIGHT);
                                detailsModal.setInitialWidth(MODAL_WIDTH);
                                detailsModal.setTitle(getLabelModel());
                                onClickDetailsLink(rowItemModel, target, detailsModal, rowIndex);
                            }
                        };
                    } else {
                        link = new Link(id) {
                            @Override
                            public void onClick() {
                                onClickDetailsLink(rowItemModel, null, null, rowIndex);
                            }
                        };
                    }
                    link.setEnabled(isDetailsLink(rowItemModel, rowIndex));
                    return link;
                }

                @Override
                protected Component newLabel(String id, IModel labelModel) {
                    return createDetailsLabelComponent(id, rowItemModel, rowIndex);
                }
            });
        }

        @Override
        public Component getHeader(String componentId) {
            Component header = createDetailsColumnHeader(componentId);
            if (header == null) {
                header = super.getHeader(componentId);
            }
            return header;
        }
    };
    dataColumns.add(detailsColumn);
    return dataColumns;
}

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

License:Open Source License

@Override
protected void disable(AbstractLink link) {
    link.setEnabled(false);
}

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

License:Open Source License

protected void disable(AbstractLink link) {
    link.setEnabled(false);
}

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

License:Open Source License

/**
 * Returns a link to preview the study./*from w  w w .  j  ava  2s  .  c  o  m*/
 * 
 * @return
 *       An abstract link component, depending on registered admins.
 */
private AbstractLink getPreviewLink(final EventHandler callback) {
    PageParameters parameters = new PageParameters();

    AbstractLink link;

    IModel<String> linkLabelModel = new StringResourceModel("studylink", EditStudyEntityPanel.this, null);

    // see #974 for workflow.
    if (studyService.isAtLeastOneAdminRegistered(getStudy().getParentProject())) {
        parameters.set(0, getStudy().getHashCode());

        if (getStudy().getState() == StudyState.INIT) {
            linkLabelModel = new StringResourceModel("preview", EditStudyEntityPanel.this, null);
        }

        link = new BookmarkablePageLink<Void>("preview", DisplaySurveyUI.class, parameters);
    } else {
        linkLabelModel = new StringResourceModel("preview", EditStudyEntityPanel.this, null);

        link = new AjaxLink<Void>("preview") {
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                notRegiteredModalWindow.show(target);
            }
        };
    }

    link.add(new Label("previewLabel", linkLabelModel));

    link.setEnabled(getStudy().getState() != StudyState.FINISHED && !getStudy().isDeleted());

    return link;
}

From source file:name.martingeisse.admin.navigation.component.NavigationMenuPanel.java

License:Open Source License

/**
 * This method is used to populate the node items.
 * @param item the item to populate//from w w w . jav  a 2 s  .c o  m
 */
protected void populateItem(final ListItem<NavigationNode> item) {

    // create the node link
    final NavigationNode node = item.getModelObject();
    final AbstractLink link = node.createLink("link");
    link.add(new Label("title", node.getTitle()));
    item.add(link);

    // mark or disable the link based on the current location
    final String nodePath = node.getPath();
    if (nodePath.equals(currentPagePath)) {
        link.setEnabled(false);
    } else if (node.isEqualOrPlausibleAncestorOf(currentPagePath)) {
        link.add(new AttributeAppender("style", "color: red"));
    }

    // create a panel for the children, but hide if the maximum nesting level is reached
    final IModel<List<NavigationNode>> childrenModel = new PropertyModel<List<NavigationNode>>(item.getModel(),
            "children");
    final NavigationMenuPanel childrenPanel = new NavigationMenuPanel("children", childrenModel,
            maximumNestingDepth - 1);
    item.add(childrenPanel);
    if (maximumNestingDepth == 0) {
        childrenPanel.setVisible(false);
    }

}

From source file:name.martingeisse.admin.navigation.component.NavigationMenuView.java

License:Open Source License

@Override
protected void populateItem(final ListItem<NavigationNode> item) {

    // create the node link
    final NavigationNode node = item.getModelObject();
    final AbstractLink link = node.createLink("link");
    link.add(new Label("title", node.getTitle()));
    item.add(link);/*from w  ww .  j ava  2 s.c  o  m*/

    // mark or disable the link based on the current location
    final String nodePath = node.getPath();
    if (nodePath.equals(currentPagePath)) {
        link.setEnabled(false);
    } else if (node.isEqualOrPlausibleAncestorOf(currentPagePath)) {
        link.add(new AttributeAppender("style", "color: red"));
    }

    // create sub-lists
    if (maximumNestingDepth > 0) {
        final IModel<List<NavigationNode>> childrenModel = new PropertyModel<List<NavigationNode>>(
                item.getModel(), "children");
        item.add(new NavigationMenuView("children", childrenModel, maximumNestingDepth - 1));
    }

}

From source file:org.apache.isis.viewer.wicket.ui.components.actionmenu.entityactions.EntityActionLinkFactory.java

License:Apache License

@Override
public LinkAndLabel newLink(final String linkId, final ObjectAdapterMemento adapterMemento,
        final ObjectAction action) {

    final ObjectAdapter objectAdapter = adapterMemento.getObjectAdapter(ConcurrencyChecking.NO_CHECK);

    final Boolean persistent = objectAdapter.representsPersistent();
    if (!persistent) {
        throw new IllegalArgumentException(
                "Object '" + objectAdapter.titleString(null) + "' is not persistent.");
    }// w ww.j a  v a  2 s.  co m

    // check visibility and whether enabled
    final Consent visibility = action.isVisible(objectAdapter, InteractionInitiatedBy.USER, Where.OBJECT_FORMS);
    if (visibility.isVetoed()) {
        return null;
    }

    final AbstractLink link = newLink(linkId, objectAdapter, action);

    final Consent usability = action.isUsable(objectAdapter, InteractionInitiatedBy.USER, Where.OBJECT_FORMS);
    final String disabledReasonIfAny = usability.getReason();
    if (disabledReasonIfAny != null) {
        link.setEnabled(false);
    }

    return newLinkAndLabel(objectAdapter, action, link, disabledReasonIfAny);
}

From source file:org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions.CssMenuItem.java

License:Apache License

private Component addMenuItemComponentTo(final MarkupContainer markupContainer) {
    final AbstractLink link = getLink();
    final Label label = new Label(CssMenuItem.ID_MENU_LABEL, Model.of(this.getName()));

    if (link != null) {

        // show link...
        markupContainer.add(link);//from  w ww. j a v  a 2 s .  c o  m
        link.add(label);

        if (this.description != null) {
            label.add(new AttributeModifier("title", Model.of(description)));
        }
        if (this.blobOrClob) {
            link.add(new CssClassAppender("noVeil"));
        }
        if (this.prototype) {
            link.add(new CssClassAppender("prototype"));
        }

        if (this.cssClass != null) {
            link.add(new CssClassAppender(this.cssClass));
        }
        link.add(new CssClassAppender(this.actionIdentifier));

        String cssClassFa = getCssClassFa();
        if (!Strings.isNullOrEmpty(cssClassFa)) {
            label.add(new CssClassFaBehavior(cssClassFa, getCssClassFaPosition()));
        }

        if (!this.isEnabled()) {
            link.add(new AttributeModifier("title", Model.of(this.getDisabledReason())));
            link.add(new CssClassAppender("disabled"));

            link.setEnabled(false);
        }

        // .. and hide label
        Components.permanentlyHide(markupContainer, CssMenuItem.ID_MENU_LABEL);
        return link;
    } else {
        // hide link...
        Components.permanentlyHide(markupContainer, ID_MENU_LINK);
        // ... and show label, along with disabled reason
        label.add(new AttributeModifier("title", Model.of(this.getDisabledReason())));
        label.add(new AttributeModifier("class", Model.of("disabled")));

        markupContainer.add(label);

        return label;
    }
}

From source file:org.apache.isis.viewer.wicket.ui.components.actionmenu.serviceactions.ServiceActionUtil.java

License:Apache License

static void addLeafItem(final CssMenuItem menuItem, final ListItem<CssMenuItem> listItem,
        final MarkupContainer parent) {
    Fragment leafItem;/*from  w  w  w. j  a  va 2  s .  c om*/
    if (!menuItem.isSeparator()) {
        leafItem = new Fragment("content", "leafItem", parent);

        AbstractLink subMenuItemLink = menuItem.getLink();

        Label menuItemLabel = new Label("menuLinkLabel", menuItem.getName());
        subMenuItemLink.addOrReplace(menuItemLabel);

        if (!menuItem.isEnabled()) {
            listItem.add(new CssClassAppender("disabled"));
            subMenuItemLink.setEnabled(false);
            TooltipBehavior tooltipBehavior = new TooltipBehavior(Model.of(menuItem.getDisabledReason()));
            listItem.add(tooltipBehavior);
        }
        if (menuItem.isPrototyping()) {
            subMenuItemLink.add(new CssClassAppender("prototype"));
        }
        leafItem.add(subMenuItemLink);

        String cssClassFa = menuItem.getCssClassFa();
        if (Strings.isNullOrEmpty(cssClassFa)) {
            subMenuItemLink.add(new CssClassAppender("menuLinkSpacer"));
        } else {
            menuItemLabel.add(new CssClassFaBehavior(cssClassFa, menuItem.getCssClassFaPosition()));
        }

        String cssClass = menuItem.getCssClass();
        if (!Strings.isNullOrEmpty(cssClass)) {
            subMenuItemLink.add(new CssClassAppender(cssClass));
        }
    } else {
        leafItem = new Fragment("content", "empty", parent);
        listItem.add(new CssClassAppender("divider"));
    }
    listItem.add(leafItem);
}

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

License:Apache License

@Override
public LinkAndLabel newLink(final ObjectAdapterMemento adapterMemento, final ObjectAction action,
        final String linkId, final ActionPromptProvider actionPromptModalWindowProvider) {
    final ObjectAdapter adapter = adapterMemento.getObjectAdapter(ConcurrencyChecking.NO_CHECK);

    final Boolean persistent = adapter.representsPersistent();
    if (!persistent) {
        throw new IllegalArgumentException("Object '" + adapter.titleString(null) + "' is not persistent.");
    }// w w  w .  ja v a2  s.com

    // check visibility and whether enabled
    final AuthenticationSession session = getAuthenticationSession();

    final Consent visibility = action.isVisible(session, adapter, Where.OBJECT_FORMS);
    if (visibility.isVetoed()) {
        return null;
    }

    final AbstractLink link = newLink(linkId, adapter, action, actionPromptModalWindowProvider);

    final Consent usability = action.isUsable(session, adapter, Where.OBJECT_FORMS);
    final String disabledReasonIfAny = usability.getReason();
    if (disabledReasonIfAny != null) {
        link.setEnabled(false);
    }

    return newLinkAndLabel(action, link, disabledReasonIfAny);
}