Search in sources :

Example 11 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class Security method buildTabList.

private List<ITab> buildTabList() {
    final List<ITab> tabs = new ArrayList<>();
    tabs.add(new AbstractTab(new ResourceModel("roles")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new RoleDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.addNewItemPanelBuilder(new RoleWizardBuilder(new RoleTO(), getPageReference()), true).build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("dynRealms")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new DynRealmDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("applications")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new ApplicationDirectoryPanel.Builder(getPageReference()) {

                private static final long serialVersionUID = -5960765294082359003L;
            }.build(panelId);
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("securityQuestions")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new SecurityQuestionsPanel(panelId, getPageReference());
        }
    });
    return tabs;
}
Also used : RoleWizardBuilder(org.apache.syncope.client.console.wizards.role.RoleWizardBuilder) SecurityQuestionsPanel(org.apache.syncope.client.console.panels.SecurityQuestionsPanel) RoleWizardBuilder(org.apache.syncope.client.console.wizards.role.RoleWizardBuilder) BookmarkablePageLinkBuilder(org.apache.syncope.client.console.BookmarkablePageLinkBuilder) ArrayList(java.util.ArrayList) RoleTO(org.apache.syncope.common.lib.to.RoleTO) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) SecurityQuestionsPanel(org.apache.syncope.client.console.panels.SecurityQuestionsPanel) DynRealmDirectoryPanel(org.apache.syncope.client.console.panels.DynRealmDirectoryPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) RoleDirectoryPanel(org.apache.syncope.client.console.panels.RoleDirectoryPanel) ApplicationDirectoryPanel(org.apache.syncope.client.console.panels.ApplicationDirectoryPanel) RoleDirectoryPanel(org.apache.syncope.client.console.panels.RoleDirectoryPanel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) ResourceModel(org.apache.wicket.model.ResourceModel)

Example 12 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class Reports method buildTabList.

private List<ITab> buildTabList() {
    final List<ITab> tabs = new ArrayList<>();
    tabs.add(new AbstractTab(new ResourceModel("reports")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            final MultilevelPanel mlp = new MultilevelPanel(panelId);
            mlp.setFirstLevel(new ReportDirectoryPanel(mlp, getPageReference()) {

                private static final long serialVersionUID = -2195387360323687302L;

                @Override
                protected void viewTask(final ReportTO reportTO, final AjaxRequestTarget target) {
                    mlp.next(new StringResourceModel("report.view", this, new Model<>(reportTO)).getObject(), new ReportExecutionDetails(reportTO, getPageReference()), target);
                }
            });
            return mlp;
        }
    });
    tabs.add(new AbstractTab(new ResourceModel("report.templates")) {

        private static final long serialVersionUID = -6815067322125799251L;

        @Override
        public Panel getPanel(final String panelId) {
            return new ReportTemplateDirectoryPanel(panelId, getPageReference());
        }
    });
    return tabs;
}
Also used : ReportDirectoryPanel(org.apache.syncope.client.console.reports.ReportDirectoryPanel) ArrayList(java.util.ArrayList) ReportTO(org.apache.syncope.common.lib.to.ReportTO) ReportExecutionDetails(org.apache.syncope.client.console.reports.ReportExecutionDetails) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ReportDirectoryPanel(org.apache.syncope.client.console.reports.ReportDirectoryPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) MultilevelPanel(org.apache.syncope.client.console.panels.MultilevelPanel) ReportTemplateDirectoryPanel(org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel) MultilevelPanel(org.apache.syncope.client.console.panels.MultilevelPanel) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) StringResourceModel(org.apache.wicket.model.StringResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) ReportTemplateDirectoryPanel(org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Example 13 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class AjaxPalettePanel method initialize.

private void initialize(final IModel<List<T>> model, final Builder<T> builder) {
    setOutputMarkupId(true);
    this.palette = new NonI18nPalette<T>("paletteField", model, choicesModel, builder.renderer, 8, builder.allowOrder, builder.allowMoveAll) {

        private static final long serialVersionUID = -3074655279011678437L;

        @Override
        protected Component newAvailableHeader(final String componentId) {
            return new Label(componentId, new ResourceModel("palette.available", builder.availableLabel));
        }

        @Override
        protected Component newSelectedHeader(final String componentId) {
            return new Label(componentId, new ResourceModel("palette.selected", builder.selectedLabel));
        }

        @Override
        protected Recorder<T> newRecorderComponent() {
            return new Recorder<T>("recorder", this) {

                private static final long serialVersionUID = -9169109967480083523L;

                @Override
                public List<T> getUnselectedList() {
                    final IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer();
                    final Collection<? extends T> choices = getPalette().getChoices();
                    final List<T> unselected = new ArrayList<>(choices.size());
                    final List<String> ids = Arrays.asList(getValue().split(","));
                    choices.forEach(choice -> {
                        final String choiceId = renderer.getIdValue(choice, 0);
                        if (!ids.contains(choiceId)) {
                            unselected.add(choice);
                        }
                    });
                    return unselected;
                }

                @Override
                public List<T> getSelectedList() {
                    final IChoiceRenderer<? super T> renderer = getPalette().getChoiceRenderer();
                    final Collection<? extends T> choices = getPalette().getChoices();
                    final List<T> selected = new ArrayList<>(choices.size());
                    // reduce number of method calls by building a lookup table
                    final Map<T, String> idForChoice = new HashMap<>(choices.size());
                    choices.forEach(choice -> {
                        idForChoice.put(choice, renderer.getIdValue(choice, 0));
                    });
                    final String value = getValue();
                    int start = value.indexOf(';') + 1;
                    for (final String id : Strings.split(value.substring(start), ',')) {
                        for (final T choice : choices) {
                            final String idValue = idForChoice.get(choice);
                            if (id.equals(idValue)) {
                                selected.add(choice);
                                break;
                            }
                        }
                    }
                    return selected;
                }
            };
        }
    };
    add(palette.setOutputMarkupId(true));
    final Form<?> form = new Form<>("form");
    add(form.setEnabled(builder.filtered).setVisible(builder.filtered));
    final AjaxTextFieldPanel filter = new AjaxTextFieldPanel("filter", "filter", queryFilter, false);
    filter.hideLabel().setOutputMarkupId(true);
    form.add(filter);
    form.add(new AjaxSubmitLink("search") {

        private static final long serialVersionUID = -1765773642975892072L;

        @Override
        protected void onAfterSubmit(final AjaxRequestTarget target, final Form<?> form) {
            super.onAfterSubmit(target, form);
            target.add(palette);
        }
    });
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) Label(org.apache.wicket.markup.html.basic.Label) Form(org.apache.wicket.markup.html.form.Form) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) Arrays(java.util.Arrays) Iterator(java.util.Iterator) Palette(org.apache.wicket.extensions.markup.html.form.palette.Palette) Recorder(org.apache.wicket.extensions.markup.html.form.palette.component.Recorder) Collection(java.util.Collection) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) HashMap(java.util.HashMap) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) StringUtils(org.apache.commons.lang3.StringUtils) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) ListUtils(org.apache.commons.collections4.ListUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Strings(org.apache.wicket.util.string.Strings) Pattern(java.util.regex.Pattern) IModel(org.apache.wicket.model.IModel) ResourceModel(org.apache.wicket.model.ResourceModel) Form(org.apache.wicket.markup.html.form.Form) Label(org.apache.wicket.markup.html.basic.Label) Recorder(org.apache.wicket.extensions.markup.html.form.palette.component.Recorder) AjaxSubmitLink(org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ResourceModel(org.apache.wicket.model.ResourceModel) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.apache.wicket.Component) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class RealmChoicePanel method reloadRealmTree.

public final void reloadRealmTree() {
    final Label realmLabel = new Label("realmLabel", new Model<>());
    realmLabel.setOutputMarkupId(true);
    container.addOrReplace(realmLabel);
    if (model.getObject().getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
        realmLabel.setDefaultModel(new ResourceModel("realmLabel", "Realm"));
    } else {
        realmLabel.setDefaultModel(new ResourceModel("dynRealmLabel", "Dynamic Realm"));
    }
    final Label label = new Label("realm", model.getObject().getFullPath());
    label.setOutputMarkupId(true);
    container.addOrReplace(label);
    final DropDownButton realms = new DropDownButton("realms", new ResourceModel("select", ""), new Model<IconType>(GlyphIconType.folderopen)) {

        private static final long serialVersionUID = -5560086780455361131L;

        @Override
        protected List<AbstractLink> newSubMenuButtons(final String buttonMarkupId) {
            RealmChoicePanel.this.links.clear();
            RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new ResourceModel("realms", "Realms")) {

                private static final long serialVersionUID = -7978723352517770744L;

                @Override
                public void onClick(final AjaxRequestTarget target) {
                }

                @Override
                public boolean isEnabled() {
                    return false;
                }

                @Override
                protected void onComponentTag(final ComponentTag tag) {
                    tag.put("class", "panel box box-primary box-header with-border");
                    tag.put("style", "margin: 20px 5px 0px 5px; width: 90%");
                }
            });
            for (Pair<String, RealmTO> link : realmTree.getObject()) {
                final RealmTO realmTO = link.getValue();
                RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), Model.of(realmTO), Buttons.Type.Link, new Model<>(link.getKey())) {

                    private static final long serialVersionUID = -7978723352517770644L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        model.setObject(realmTO);
                        label.setDefaultModelObject(model.getObject().getFullPath());
                        realmLabel.setDefaultModel(new ResourceModel("realmLabel", "Realm"));
                        target.add(label);
                        send(pageRef.getPage(), Broadcast.EXACT, new ChosenRealm<>(realmTO, target));
                    }

                    @Override
                    public boolean isEnabled() {
                        return availableRealms.stream().anyMatch(availableRealm -> realmTO.getFullPath().startsWith(availableRealm));
                    }
                });
            }
            if (!dynRealmTree.getObject().isEmpty()) {
                RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new ResourceModel("dynrealms", "Dynamic Realms")) {

                    private static final long serialVersionUID = -7978723352517770744L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                    }

                    @Override
                    public boolean isEnabled() {
                        return false;
                    }

                    @Override
                    protected void onComponentTag(final ComponentTag tag) {
                        tag.put("class", "panel box box-primary box-header with-border");
                        tag.put("style", "margin: 20px 5px 0px 5px; width: 90%");
                    }
                });
                for (DynRealmTO dynRealmTO : dynRealmTree.getObject()) {
                    final RealmTO realmTO = new RealmTO();
                    realmTO.setKey(dynRealmTO.getKey());
                    realmTO.setName(dynRealmTO.getKey());
                    realmTO.setFullPath(dynRealmTO.getKey());
                    RealmChoicePanel.this.links.add(new BootstrapAjaxLink<RealmTO>(ButtonList.getButtonMarkupId(), new Model<RealmTO>(), Buttons.Type.Link, new Model<>(realmTO.getKey())) {

                        private static final long serialVersionUID = -7978723352517770644L;

                        @Override
                        public void onClick(final AjaxRequestTarget target) {
                            model.setObject(realmTO);
                            label.setDefaultModelObject(realmTO.getKey());
                            realmLabel.setDefaultModel(new ResourceModel("dynRealmLabel", "Dynamic Realm"));
                            target.add(label);
                            send(pageRef.getPage(), Broadcast.EXACT, new ChosenRealm<>(realmTO, target));
                        }

                        @Override
                        public boolean isEnabled() {
                            return availableRealms.stream().anyMatch(availableRealm -> {
                                return SyncopeConstants.ROOT_REALM.equals(availableRealm) || realmTO.getKey().equals(availableRealm);
                            });
                        }
                    });
                }
            }
            return RealmChoicePanel.this.links;
        }
    };
    realms.setOutputMarkupId(true);
    realms.setAlignment(AlignmentBehavior.Alignment.RIGHT);
    realms.setType(Buttons.Type.Menu);
    MetaDataRoleAuthorizationStrategy.authorize(realms, ENABLE, StandardEntitlement.REALM_LIST);
    container.addOrReplace(realms);
}
Also used : StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) DynRealmTO(org.apache.syncope.common.lib.to.DynRealmTO) RealmTO(org.apache.syncope.common.lib.to.RealmTO) Buttons(de.agilecoders.wicket.core.markup.html.bootstrap.button.Buttons) HashMap(java.util.HashMap) SyncopeConsoleSession(org.apache.syncope.client.console.SyncopeConsoleSession) IconType(de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType) StringUtils(org.apache.commons.lang3.StringUtils) GlyphIconType(de.agilecoders.wicket.core.markup.html.bootstrap.image.GlyphIconType) ArrayList(java.util.ArrayList) BootstrapAjaxLink(de.agilecoders.wicket.core.markup.html.bootstrap.button.BootstrapAjaxLink) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) Label(org.apache.wicket.markup.html.basic.Label) AlignmentBehavior(de.agilecoders.wicket.core.markup.html.bootstrap.behavior.AlignmentBehavior) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) MetaDataRoleAuthorizationStrategy(org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy) ButtonList(de.agilecoders.wicket.core.markup.html.bootstrap.button.ButtonList) Collection(java.util.Collection) Model(org.apache.wicket.model.Model) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) PageReference(org.apache.wicket.PageReference) Collectors(java.util.stream.Collectors) Panel(org.apache.wicket.markup.html.panel.Panel) List(java.util.List) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) DropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.DropDownButton) Comparator(java.util.Comparator) RealmRestClient(org.apache.syncope.client.console.rest.RealmRestClient) ResourceModel(org.apache.wicket.model.ResourceModel) Collections(java.util.Collections) Broadcast(org.apache.wicket.event.Broadcast) DropDownButton(de.agilecoders.wicket.core.markup.html.bootstrap.button.dropdown.DropDownButton) Label(org.apache.wicket.markup.html.basic.Label) DynRealmTO(org.apache.syncope.common.lib.to.DynRealmTO) RealmTO(org.apache.syncope.common.lib.to.RealmTO) DynRealmTO(org.apache.syncope.common.lib.to.DynRealmTO) IconType(de.agilecoders.wicket.core.markup.html.bootstrap.image.IconType) GlyphIconType(de.agilecoders.wicket.core.markup.html.bootstrap.image.GlyphIconType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentTag(org.apache.wicket.markup.ComponentTag) Model(org.apache.wicket.model.Model) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) ResourceModel(org.apache.wicket.model.ResourceModel) ResourceModel(org.apache.wicket.model.ResourceModel) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink)

Example 15 with ResourceModel

use of org.apache.wicket.model.ResourceModel in project syncope by apache.

the class SchemaTypePanel method getColumns.

@Override
protected List<IColumn<SchemaTO, String>> getColumns() {
    final List<IColumn<SchemaTO, String>> columns = new ArrayList<>();
    for (final String field : COL_NAMES.get(schemaType)) {
        final Field clazzField = ReflectionUtils.findField(schemaType.getToClass(), field);
        if (clazzField != null) {
            if (clazzField.getType().equals(Boolean.class) || clazzField.getType().equals(boolean.class)) {
                columns.add(new BooleanPropertyColumn<>(new ResourceModel(field), field, field));
            } else {
                final IColumn<SchemaTO, String> column = new PropertyColumn<SchemaTO, String>(new ResourceModel(field), field, field) {

                    private static final long serialVersionUID = 3282547854226892169L;

                    @Override
                    public String getCssClass() {
                        String css = super.getCssClass();
                        if ("key".equals(field)) {
                            css = StringUtils.isBlank(css) ? "col-xs-1" : css + " col-xs-1";
                        }
                        return css;
                    }
                };
                columns.add(column);
            }
        }
    }
    return columns;
}
Also used : Field(java.lang.reflect.Field) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) BooleanPropertyColumn(org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) SchemaTO(org.apache.syncope.common.lib.to.SchemaTO) ResourceModel(org.apache.wicket.model.ResourceModel)

Aggregations

ResourceModel (org.apache.wicket.model.ResourceModel)48 ArrayList (java.util.ArrayList)20 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)19 Label (org.apache.wicket.markup.html.basic.Label)17 StringResourceModel (org.apache.wicket.model.StringResourceModel)15 Panel (org.apache.wicket.markup.html.panel.Panel)11 List (java.util.List)9 AbstractTab (org.apache.wicket.extensions.markup.html.tabs.AbstractTab)9 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)8 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)8 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)6 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)5 Form (org.apache.wicket.markup.html.form.Form)5 Serializable (java.io.Serializable)4 HashMap (java.util.HashMap)4 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)4 Fragment (org.apache.wicket.markup.html.panel.Fragment)4 NavbarButton (de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton)3 StringUtils (org.apache.commons.lang3.StringUtils)3