Example usage for org.apache.wicket.event Broadcast BUBBLE

List of usage examples for org.apache.wicket.event Broadcast BUBBLE

Introduction

In this page you can find the example usage for org.apache.wicket.event Broadcast BUBBLE.

Prototype

Broadcast BUBBLE

To view the source code for org.apache.wicket.event Broadcast BUBBLE.

Click Source Link

Document

A bubble-up traversal.

Usage

From source file:de.flapdoodle.wicket.examples.events.UseEventsPage.java

License:Apache License

public UseEventsPage() {
    String reply = Events.from(this).broadcast(Broadcast.BUBBLE).sendWithReply("Hallo", String.class);
}

From source file:nl.mpi.lamus.web.components.UnlinkedNodesPanel.java

License:Open Source License

private void check(WorkspaceTreeNode wsTreeNode, boolean check) {
    if (check && !checked.contains(wsTreeNode)) {
        checked.add(wsTreeNode);/*from www .j  a v  a2  s . c om*/
    } else {
        checked.remove(wsTreeNode);
    }

    send(this, Broadcast.BUBBLE, new SelectedUnlinkedNodesWrapper(checked));
}

From source file:nl.mpi.lamus.web.components.WsNodeActionsPanel.java

License:Open Source License

private ListView<WsTreeNodesAction> createListView(List<WsTreeNodesAction> nodeActionsList) {

    return new ListView<WsTreeNodesAction>("wsNodeActions", nodeActionsList) {

        @Override//from  www.  ja v a2 s .  c o  m
        protected void populateItem(ListItem<WsTreeNodesAction> li) {

            Button nodeActionButton = new WsNodeActionButton("nodeActionButton", li.getModelObject(),
                    WsNodeActionsPanel.this.workspaceService, WsNodeActionsPanel.this.workspaceDao,
                    WsNodeActionsPanel.this.nodeUtil) {

                @Override
                public void refreshStuff() {
                    WsNodeActionsPanel.this.refreshTreeAndPanels();
                }

                @Override
                public void refreshSelectedUnlinkedNodes() {
                    WsNodeActionsPanel.this.refreshSelectedUnlinkedNodes();
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

                    final String currentUserId = LamusSession.get().getUserId();
                    try {

                        target.add(getFeedbackPanel());

                        setActionParameters(WsNodeActionsPanel.this.getModelObject(), selectedUnlinkedNodes);

                        if (getAction() instanceof UnlinkNodesAction
                                || getAction() instanceof DeleteNodesAction) {
                            //tell the page to clear the selected nodes from the tree
                            send(this, Broadcast.BUBBLE, new ClearSelectedTreeNodes());
                        }

                        executeAction(currentUserId);

                        //tell the unlinked nodes panel to clear the selected unlinked nodes
                        if (getAction() instanceof ReplaceNodesAction) {
                            send(this, Broadcast.BUBBLE, new ClearAllSelectedNodes());
                        } else {
                            send(this, Broadcast.BUBBLE, new ClearSelectedUnlinkedNodes());
                        }

                        //clear also the variable stored in the panel
                        clearSelectedUnlinkedNodes();

                    } catch (WorkspaceException | IllegalArgumentException | ProtectedNodeException ex) {
                        error(ex.getMessage());
                    }

                    target.add(WsNodeActionsPanel.this.getPage().get("workspaceTree"));
                    target.add(WsNodeActionsPanel.this.getPage().get("workspaceTabs"));
                    target.add(WsNodeActionsPanel.this);

                    refreshStuff();
                }
            };

            nodeActionButton.add(AttributeModifier.append("class",
                    new Model<>(getIconNameForNodeAction(li.getModelObject()))));
            nodeActionButton.add(new Label("nodeActionLabel",
                    getLocalizer().getString(nodeActionButton.getModelObject(), this)));

            li.add(nodeActionButton);
        }
    };
}

From source file:org.apache.syncope.client.console.panels.search.AnySelectionDirectoryPanel.java

License:Apache License

@Override
protected List<IColumn<A, String>> getColumns() {
    final List<IColumn<A, String>> columns = new ArrayList<>();

    for (String name : prefMan.getList(getRequest(), getPrefDetailsView())) {
        final Field field = ReflectionUtils.findField(AnyObjectTO.class, name);

        if ("key".equalsIgnoreCase(name)) {
            columns.add(new KeyPropertyColumn<A>(new ResourceModel(name, name), name, name));
        } else if (reference == UserTO.class && "token".equalsIgnoreCase(name)) {
            columns.add(new TokenColumn<A>(new ResourceModel(name, name), name));
        } else if (field != null
                && (field.getType().equals(Boolean.class) || field.getType().equals(boolean.class))) {

            columns.add(new BooleanPropertyColumn<A>(new ResourceModel(name, name), name, name));
        } else if (field != null && field.getType().equals(Date.class)) {
            columns.add(new DatePropertyColumn<A>(new ResourceModel(name, name), name, name));
        } else {/*from  w w  w .j  a  v  a 2  s. c om*/
            columns.add(new PropertyColumn<A, String>(new ResourceModel(name, name), name, name));
        }
    }

    for (String name : prefMan.getList(getRequest(), getPrefPlainAttributesView())) {
        if (pSchemaNames.contains(name)) {
            columns.add(new AttrColumn<A>(name, SchemaType.PLAIN));
        }
    }

    for (String name : prefMan.getList(getRequest(), getPrefDerivedAttributesView())) {
        if (dSchemaNames.contains(name)) {
            columns.add(new AttrColumn<A>(name, SchemaType.DERIVED));
        }
    }

    // Add defaults in case of no selection
    if (columns.isEmpty()) {
        for (String name : getDisplayAttributes()) {
            columns.add(new PropertyColumn<A, String>(new ResourceModel(name, name), name, name));
        }

        prefMan.setList(getRequest(), getResponse(), getPrefDetailsView(),
                Arrays.asList(getDisplayAttributes()));
    }

    columns.add(new ActionColumn<A, String>(new ResourceModel("actions")) {

        private static final long serialVersionUID = -3503023501954863131L;

        @Override
        public ActionLinksPanel<A> getActions(final String componentId, final IModel<A> model) {
            final ActionLinksPanel.Builder<A> panel = ActionLinksPanel.builder();

            panel.add(new ActionLink<A>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final A ignore) {
                    send(AnySelectionDirectoryPanel.this, Broadcast.BUBBLE,
                            new ItemSelection<>(target, model.getObject()));
                }
            }, ActionType.SELECT, AnyEntitlement.READ.getFor(type));

            return panel.build(componentId, model.getObject());
        }

        @Override
        public ActionLinksPanel<A> getHeader(final String componentId) {
            final ActionLinksPanel.Builder<A> panel = ActionLinksPanel.builder();

            return panel.add(new ActionLink<A>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final A ignore) {
                    // still missing content
                    target.add(altDefaultModal.setContent(new AnyObjectDisplayAttributesModalPanel<>(
                            altDefaultModal, page.getPageReference(), pSchemaNames, dSchemaNames, type)));

                    altDefaultModal.addSubmitButton();
                    altDefaultModal.header(new ResourceModel("any.attr.display"));
                    altDefaultModal.show(true);
                }
            }, ActionType.CHANGE_VIEW, AnyEntitlement.READ.getFor(type)).add(new ActionLink<A>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final A ignore) {
                    if (target != null) {
                        target.add(container);
                    }
                }
            }, ActionType.RELOAD, AnyEntitlement.SEARCH.getFor(type)).build(componentId);
        }
    });

    return columns;
}

From source file:org.apache.syncope.client.console.panels.search.AnySelectionSearchResultPanel.java

License:Apache License

@Override
protected List<IColumn<T, String>> getColumns() {

    final List<IColumn<T, String>> columns = new ArrayList<>();

    for (String name : prefMan.getList(getRequest(), getPrefDetailsView())) {
        final Field field = ReflectionUtils.findField(AnyObjectTO.class, name);

        if ("token".equalsIgnoreCase(name)) {
            columns.add(new PropertyColumn<T, String>(new ResourceModel(name, name), name, name));
        } else if (field != null && field.getType().equals(Date.class)) {
            columns.add(new PropertyColumn<T, String>(new ResourceModel(name, name), name, name));
        } else {/*  www  . ja  v  a2 s .  c  o m*/
            columns.add(new PropertyColumn<T, String>(new ResourceModel(name, name), name, name));
        }
    }

    for (String name : prefMan.getList(getRequest(), getPrefAttributesView())) {
        if (pSchemaNames.contains(name)) {
            columns.add(new AttrColumn<T>(name, SchemaType.PLAIN));
        }
    }

    for (String name : prefMan.getList(getRequest(), getPrefDerivedAttributesView())) {
        if (dSchemaNames.contains(name)) {
            columns.add(new AttrColumn<T>(name, SchemaType.DERIVED));
        }
    }

    // Add defaults in case of no selection
    if (columns.isEmpty()) {
        for (String name : getDislayAttributes()) {
            columns.add(new PropertyColumn<T, String>(new ResourceModel(name, name), name, name));
        }

        prefMan.setList(getRequest(), getResponse(), getPrefDetailsView(),
                Arrays.asList(getDislayAttributes()));
    }

    columns.add(new ActionColumn<T, String>(new ResourceModel("actions", "")) {

        private static final long serialVersionUID = -3503023501954863131L;

        @Override
        public ActionLinksPanel<T> getActions(final String componentId, final IModel<T> model) {

            final ActionLinksPanel.Builder<T> panel = ActionLinksPanel.builder(page.getPageReference());

            panel.add(new ActionLink<T>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final T ignore) {
                    send(AnySelectionSearchResultPanel.this, Broadcast.BUBBLE,
                            new ItemSelection<T>(target, model.getObject()));
                }
            }, ActionLink.ActionType.SELECT, String.format("%s_%s", type, AnyEntitlement.READ));

            return panel.build(componentId, model.getObject());
        }

        @Override
        public ActionLinksPanel<T> getHeader(final String componentId) {
            final ActionLinksPanel.Builder<T> panel = ActionLinksPanel.builder(page.getPageReference());

            return panel.add(new ActionLink<T>() {

                private static final long serialVersionUID = -7978723352517770644L;

                @Override
                public void onClick(final AjaxRequestTarget target, final T ignore) {
                    // still missing content
                    target.add(modal.setContent(new AnyObjectDisplayAttributesModalPage<>(modal,
                            page.getPageReference(), pSchemaNames, dSchemaNames, type)));

                    modal.header(new ResourceModel("any.attr.display", ""));
                    modal.show(true);
                }
            }, ActionLink.ActionType.CHANGE_VIEW, String.format("%s_%s", type, AnyEntitlement.READ))
                    .add(new ActionLink<T>() {

                        private static final long serialVersionUID = -7978723352517770644L;

                        @Override
                        public void onClick(final AjaxRequestTarget target, final T ignore) {
                            if (target != null) {
                                target.add(container);
                            }
                        }
                    }, ActionLink.ActionType.RELOAD, String.format("%s_%s", type, AnyEntitlement.SEARCH))
                    .build(componentId);
        }
    });

    return columns;
}

From source file:org.apache.syncope.client.console.panels.search.SearchClausePanel.java

License:Apache License

public SearchClausePanel(final String id, final String name, final Model<SearchClause> clause,
        final boolean required, final IModel<List<SearchClause.Type>> types, final IModel<List<String>> anames,
        final IModel<List<String>> dnames, final IModel<Map<String, String>> groupNames,
        final IModel<List<String>> roleNames, final IModel<List<String>> resourceNames) {

    super(id, name, clause);

    this.clause = clause == null ? new Model<SearchClause>(null) : clause;

    this.required = required;
    this.types = types;
    this.anames = anames;
    this.dnames = dnames;
    this.groupNames = groupNames;
    this.roleNames = roleNames;
    this.resourceNames = resourceNames;

    searchButton = new AjaxSubmitLink("search") {

        private static final long serialVersionUID = 5538299138211283825L;

        @Override//  w w w  .  ja va  2s . c  om
        protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
            if (resultContainer == null) {
                send(this, Broadcast.BUBBLE, new SearchEvent(target));
            } else {
                send(resultContainer, Broadcast.EXACT, new SearchEvent(target));
            }
        }
    };

    searchButtonFragment = new Fragment("operator", "searchButtonFragment", this);
    searchButtonFragment.add(searchButton.setEnabled(false));

    operatorFragment = new Fragment("operator", "operatorFragment", this);

    field = new FormComponent<SearchClause>("container", this.clause) {

        private static final long serialVersionUID = -8204140666393922700L;

    };

    add(field);

    comparators = new LoadableDetachableModel<List<Comparator>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<Comparator> load() {
            if (field.getModel().getObject() == null || field.getModel().getObject().getType() == null) {
                return Collections.<Comparator>emptyList();
            }

            switch (field.getModel().getObject().getType()) {
            case ATTRIBUTE:
                return Arrays.asList(SearchClause.Comparator.values());

            case ROLE_MEMBERSHIP:
            case GROUP_MEMBERSHIP:
            case GROUP_MEMBER:
            case RESOURCE:
                return Arrays.asList(SearchClause.Comparator.EQUALS, SearchClause.Comparator.NOT_EQUALS);

            case RELATIONSHIP:
                return Arrays.asList(SearchClause.Comparator.IS_NOT_NULL, SearchClause.Comparator.IS_NULL,
                        SearchClause.Comparator.EQUALS, SearchClause.Comparator.NOT_EQUALS);
            default:
                return Collections.<Comparator>emptyList();
            }
        }
    };

    properties = new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<String> load() {
            if (field.getModel().getObject() == null || field.getModel().getObject().getType() == null) {
                return Collections.<String>emptyList();
            }

            switch (field.getModel().getObject().getType()) {
            case ATTRIBUTE:
                final List<String> names = new ArrayList<>(dnames.getObject());
                if (anames != null && anames.getObject() != null && !anames.getObject().isEmpty()) {
                    names.addAll(anames.getObject());
                }
                Collections.sort(names);
                return names;

            case GROUP_MEMBERSHIP:
                final List<String> groups = CollectionUtils.collect(groupNames.getObject().keySet(),
                        StringValueTransformer.<String>stringValueTransformer(), new ArrayList<String>());

                Collections.sort(groups);
                return groups;

            case ROLE_MEMBERSHIP:
                final List<String> roles = new ArrayList<>(roleNames.getObject());
                Collections.sort(roles);
                return roles;

            case RESOURCE:
                final List<String> resources = new ArrayList<>(resourceNames.getObject());
                Collections.sort(resources);
                return resources;

            case RELATIONSHIP:
                final List<String> relations = CollectionUtils.collect(
                        SyncopeConsoleSession.get().getService(RelationshipTypeService.class).list(),
                        new Transformer<RelationshipTypeTO, String>() {

                            @Override
                            public String transform(final RelationshipTypeTO input) {
                                return input.getKey();
                            }
                        }, new ArrayList<String>());
                return relations;

            default:
                return Collections.<String>emptyList();
            }
        }
    };
}

From source file:org.apache.syncope.client.console.panels.search.SearchClausePanel.java

License:Apache License

public void enableSearch(final IEventSink resultContainer) {
    this.resultContainer = resultContainer;
    this.searchButton.setEnabled(true);

    field.add(AttributeModifier.replace("onkeydown",
            Model.of("if(event.keyCode == 13) {event.preventDefault();}")));

    field.add(new AjaxEventBehavior("onkeydown") {

        private static final long serialVersionUID = -7133385027739964990L;

        @Override/* w w  w . j a  va2 s  .  co m*/
        protected void onEvent(final AjaxRequestTarget target) {
            if (resultContainer == null) {
                send(SearchClausePanel.this, Broadcast.BUBBLE, new SearchEvent(target));
            } else {
                send(resultContainer, Broadcast.EXACT, new SearchEvent(target));
            }
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);

            attributes.getAjaxCallListeners().add(new AjaxCallListener() {

                private static final long serialVersionUID = 7160235486520935153L;

                @Override
                public CharSequence getPrecondition(final Component component) {
                    return "if (Wicket.Event.keyCode(attrs.event)  == 13) { return true; } else { return false; }";
                }
            });
        }
    });
}

From source file:org.apache.syncope.client.console.wicket.markup.html.form.ActionPanel.java

License:Apache License

protected void beforeOnClick(final AjaxRequestTarget target) {
    switch (this.action.getType()) {
    case DELETE:/*from w w  w. j a v a  2s.com*/
    case CREATE:
    case MEMBERS:
    case MAPPING:
    case SET_LATEST_SYNC_TOKEN:
    case REMOVE_SYNC_TOKEN:
    case EDIT_APPROVAL:
    case CLAIM:
        send(this, Broadcast.BUBBLE, new ActionLinksTogglePanel.ActionLinkToggleCloseEventPayload(target));
        break;
    default:
        break;
    }
}

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

License:Apache License

/**
 * @see org.apache.wicket.extensions.wizard.Wizard#onCancel()
 *///from   ww  w  .  j a  v a2s  . c o m
@Override
public final void onCancel() {
    final AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
    try {
        onCancelInternal();
        if (eventSink == null) {
            send(AjaxWizard.this, Broadcast.BUBBLE, new NewItemCancelEvent<>(item, target));
        } else {
            send(eventSink, Broadcast.EXACT, new NewItemCancelEvent<>(item, target));
        }
    } catch (Exception e) {
        LOG.warn("Wizard error on cancel", e);
        SyncopeConsoleSession.get()
                .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
        ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
    }
}

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

License:Apache License

/**
 * @see org.apache.wicket.extensions.wizard.Wizard#onFinish()
 *//*from ww w.  ja va  2 s .co m*/
@Override
public final void onFinish() {
    final AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
    try {
        final Serializable res = onApplyInternal(target);
        if (eventSink == null) {
            send(AjaxWizard.this, Broadcast.BUBBLE, new NewItemFinishEvent<>(item, target).setResult(res));
        } else {
            send(eventSink, Broadcast.EXACT, new NewItemFinishEvent<>(item, target).setResult(res));
        }
    } catch (Exception e) {
        LOG.error("Wizard error on finish", e);
        SyncopeConsoleSession.get()
                .error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
        ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
    }
}