org.apache.wicket.model.util.ListModel Java Examples

The following examples show how to use org.apache.wicket.model.util.ListModel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestFilters.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Test
public void testRangeFilterCriteria() {
    List<Integer> models = Lists.newArrayList();
    models.add(NUM_VALUE_1);
    models.add(NUM_VALUE_3);
    IModel<List<Integer>> listModel = new ListModel<>(models);
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
    manager.addFilterCriteria(manager.createRangeFilterCriteria(listModel, Model.of(true)));
    String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
    queryModel.addFilterCriteriaManager(field, manager);
    queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
    assertTrue("size must be 3, but it is - " + queryModel.size(), queryModel.size() == 3);
    assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
    assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
    assertTrue(queryModel.getObject().get(2).field(NUMBER_FIELD).equals(NUM_VALUE_3));
}
 
Example #2
Source File: SAML2IdPMappingPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public SAML2IdPMappingPanel(
        final String id,
        final SAML2IdPTO idpTO,
        final ItemTransformersTogglePanel mapItemTransformers,
        final JEXLTransformersTogglePanel jexlTransformers) {

    super(id,
            mapItemTransformers,
            jexlTransformers,
            new ListModel<ItemTO>(idpTO.getItems()),
            true,
            true,
            MappingPurpose.NONE);

    setOutputMarkupId(true);
}
 
Example #3
Source File: UserRequestFormsWidget.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected IModel<List<UserRequestForm>> getLatestAlerts() {
    return new ListModel<UserRequestForm>() {

        private static final long serialVersionUID = -2583290457773357445L;

        @Override
        public List<UserRequestForm> getObject() {
            List<UserRequestForm> updatedForms;
            if (SyncopeConsoleSession.get().owns(FlowableEntitlement.USER_REQUEST_FORM_LIST)) {
                updatedForms = UserRequestRestClient.getForms(1, MAX_SIZE, new SortParam<>("createTime", true));
            } else {
                updatedForms = Collections.<UserRequestForm>emptyList();
            }

            return updatedForms;
        }
    };
}
 
Example #4
Source File: BulkEditItemsPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public void onInitialize() {
	super.onInitialize();

	final String siteId = (String) getDefaultModelObject();

	final List<Assignment> assignments = this.businessService.getGradebookAssignments(siteId);

	final IModel<List<Assignment>> model = new ListModel<>(assignments);

	final Form<List<Assignment>> form = new Form<>("form", model);
	form.add(new GradebookItemView("listView", model.getObject()));
	form.add(new SubmitButton("submit"));
	form.add(new CancelButton("cancel"));
	form.add(new Label("releaseToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	form.add(new Label("includeToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	form.add(new Label("deleteToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	add(form);

}
 
Example #5
Source File: OIDCProviderMappingPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public OIDCProviderMappingPanel(
        final String id,
        final OIDCProviderTO opTO,
        final ItemTransformersTogglePanel mapItemTransformers,
        final JEXLTransformersTogglePanel jexlTransformers) {

    super(id,
            mapItemTransformers,
            jexlTransformers,
            new ListModel<ItemTO>(opTO.getItems()),
            true,
            true,
            MappingPurpose.NONE);

    setOutputMarkupId(true);
}
 
Example #6
Source File: TypeBrowser.java    From oodt with Apache License 2.0 6 votes vote down vote up
/**
 * @param id
 *          The wicket:id component ID of this form.
 */
public AddCriteriaForm(String id) {
  super(id, new CompoundPropertyModel<ElementCrit>(new ElementCrit()));
  List<Element> ptypeElements = fm.safeGetElementsForProductType(type);
  Collections.sort(ptypeElements, new Comparator<Element>() {
    public int compare(Element e1, Element e2) {
      return e1.getElementName().compareTo(e2.getElementName());
    }
  });

  add(new DropDownChoice<Element>("criteria_list", new PropertyModel(
      getDefaultModelObject(), "elem"), new ListModel<Element>(
      ptypeElements), new ChoiceRenderer<Element>("elementName",
      "elementId")));
  add(new TextField<TermQueryCriteria>(
      "criteria_form_add_element_value",
      new PropertyModel<TermQueryCriteria>(getDefaultModelObject(), "value")));
  add(new Button("criteria_elem_add"));
}
 
Example #7
Source File: WebappNotificationPanelRendererServiceImpl.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
public IWicketNotificationDescriptor renderNewVersionNotificationPanel(final List<ArtifactVersionNotification> notifications, final User user) {
	return new AbstractSimpleWicketNotificationDescriptor("notification.panel.newVersion") {
		@Override
		public Object getSubjectParameter() {
			return user;
		}
		@Override
		public Iterable<?> getSubjectPositionalParameters() {
			return ImmutableList.of(user.getDisplayName());
		}
		@Override
		public Component createComponent(String wicketId) {
			IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications);
			return new NewVersionsHtmlNotificationPanel(wicketId, notificationsModel);
		}
	};
}
 
Example #8
Source File: GetOClassesBehavior.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
protected void respond(AjaxRequestTarget target) {
    IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters();
    String json = params.getParameterValue(EXISTS_CLASSES_VAR).toString("[]");
    boolean classesList = params.getParameterValue(CLASSES_LIST_VAR).toBoolean(false);
    if (classesList) {
        target.appendJavaScript(String.format("app.executeCallback('%s');", getAllClassesAsJson()));
    } else {
        target.prependJavaScript(OArchitectJsUtils.switchPageScroll(true));
        widget.onModalWindowEvent(
                new OpenModalWindowEvent(
                        target,
                        createModalWindowTitle(),
                        id -> createPanel(id, new ListModel<>(JsonUtil.fromJSON(json)))
                )
        );
    }
}
 
Example #9
Source File: AccessSpecificSettingsPanel.java    From inception with Apache License 2.0 6 votes vote down vote up
private Form<Void> uploadForm(String aFormId, String aFieldId) {
        Form<Void> importProjectForm = new Form<Void>(aFormId) {
            private static final long serialVersionUID = -8284858297362896476L;
            
            @Override
            protected void onSubmit()
            {
                super.onSubmit();
                handleUploadedFiles();
            }
        };

        FileInputConfig config = new FileInputConfig();
        config.initialCaption("Import project archives ...");
        config.showPreview(false);
        config.showUpload(false);
        config.removeIcon("<i class=\"fa fa-remove\"></i>");
//        config.uploadIcon("<i class=\"fa fa-upload\"></i>");
        config.browseIcon("<i class=\"fa fa-folder-open\"></i>");
        importProjectForm.add(fileUpload = new BootstrapFileInputField(aFieldId,
            new ListModel<>(), config));
        return importProjectForm;
    }
 
Example #10
Source File: BulkEditItemsPanel.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public void onInitialize() {
	super.onInitialize();

	final String siteId = (String) getDefaultModelObject();

	final List<Assignment> assignments = this.businessService.getGradebookAssignments(siteId);

	final IModel<List<Assignment>> model = new ListModel<>(assignments);

	final Form<List<Assignment>> form = new Form<>("form", model);
	form.add(new GradebookItemView("listView", model.getObject()));
	form.add(new SubmitButton("submit"));
	form.add(new CancelButton("cancel"));
	form.add(new Label("releaseToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	form.add(new Label("includeToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	form.add(new Label("deleteToggleAllLabel", getString("label.addgradeitem.toggle.all")));
	add(form);

}
 
Example #11
Source File: RoleWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
public Entitlements(final RoleTO modelObject) {
    setTitleModel(new ResourceModel("entitlements"));
    add(new AjaxPalettePanel.Builder<String>().build("entitlements",
            new PropertyModel<List<String>>(modelObject, "entitlements") {

        private static final long serialVersionUID = -7809699384012595307L;

        @Override
        public List<String> getObject() {
            return new ArrayList<>(modelObject.getEntitlements());
        }

        @Override
        public void setObject(final List<String> object) {
            modelObject.getEntitlements().clear();
            modelObject.getEntitlements().addAll(object);
        }
    }, new ListModel<>(RoleRestClient.getAllAvailableEntitlements())).
            hideLabel().setOutputMarkupId(true));
}
 
Example #12
Source File: NewVersionsAdditionalEmailHtmlNotificationDemoPage.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
public NewVersionsAdditionalEmailHtmlNotificationDemoPage(PageParameters parameters) {
	super(parameters);
	
	User user = userService.getByUserName(ConsoleNotificationIndexPage.DEFAULT_USERNAME);
	if (user == null) {
		LOGGER.error("There is no user available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	
	Collection<EmailAddress> emailAddresses = user.getAdditionalEmails();
	if (emailAddresses == null || emailAddresses.isEmpty()) {
		LOGGER.error("There is no additional email address available");
		Session.get().error(getString("console.notifications.noDataAvailable"));
		
		throw new RestartResponseException(ConsoleNotificationIndexPage.class);
	}
	EmailAddress additionalEmail = Iterables.get(emailAddresses, 0);
	
	List<ArtifactVersionNotification> notifications = userService.listRecentNotifications(user);
	
	IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications);
	add(new NewVersionsHtmlNotificationPanel("htmlPanel", notificationsModel,
			new GenericEntityModel<Long, EmailAddress>(additionalEmail)));
}
 
Example #13
Source File: PlainAttrs.java    From syncope with Apache License 2.0 6 votes vote down vote up
public PlainSchemasMemberships(
        final String id,
        final Map<String, PlainSchemaTO> schemas,
        final IModel<Attributable> attributableTO) {

    super(id, schemas, attributableTO);

    add(new ListView<Attr>("schemas", new ListModel<Attr>(attributableTO.getObject().
            getPlainAttrs().stream().sorted(attrComparator).collect(Collectors.toList()))) {

        private static final long serialVersionUID = 5306618783986001008L;

        @Override
        protected void populateItem(final ListItem<Attr> item) {
            setPanel(schemas, item, false);
        }
    });
}
 
Example #14
Source File: AbstractAttrsWizardStep.java    From syncope with Apache License 2.0 6 votes vote down vote up
public AbstractAttrsWizardStep(
        final AnyTO anyTO,
        final AjaxWizard.Mode mode,
        final List<String> anyTypeClasses,
        final List<String> whichAttrs,
        final EntityWrapper<?> modelObject) {

    super();
    this.anyTypeClasses = anyTypeClasses;
    this.attrs = new ListModel<>(List.of());

    this.setOutputMarkupId(true);

    this.mode = mode;
    this.anyTO = anyTO;
    this.whichAttrs = whichAttrs;
}
 
Example #15
Source File: ConnObjectListViewPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
private AbstractSearchPanel getSearchPanel(final String id, final String anyType) {
    final List<SearchClause> clauses = new ArrayList<>();
    final SearchClause clause = new SearchClause();
    clauses.add(clause);

    clause.setComparator(SearchClause.Comparator.EQUALS);
    clause.setType(SearchClause.Type.ATTRIBUTE);
    clause.setProperty("");

    AnyTypeKind anyTypeKind =
            StringUtils.equals(anyType, SyncopeConstants.REALM_ANYTYPE) || StringUtils.isEmpty(anyType)
            ? AnyTypeKind.ANY_OBJECT
            : AnyTypeRestClient.read(anyType).getKind();

    return new ConnObjectSearchPanel.Builder(resource, anyTypeKind, anyType,
            new ListModel<>(clauses)).required(true).enableSearch().build(id);
}
 
Example #16
Source File: MergeLinkedAccountsSearchPanel.java    From syncope with Apache License 2.0 6 votes vote down vote up
public MergeLinkedAccountsSearchPanel(final MergeLinkedAccountsWizardModel model, final PageReference pageRef) {
    super();
    setOutputMarkupId(true);

    this.wizardModel = model;
    setTitleModel(new StringResourceModel("mergeLinkedAccounts.searchUser", Model.of(model.getBaseUser())));
    ownerContainer = new WebMarkupContainer("ownerContainer");
    ownerContainer.setOutputMarkupId(true);
    add(ownerContainer);

    userSearchFragment = new Fragment("search", "userSearchFragment", this);
    userSearchPanel = UserSearchPanel.class.cast(new UserSearchPanel.Builder(
        new ListModel<>(new ArrayList<>())).required(false).enableSearch(MergeLinkedAccountsSearchPanel.this).
        build("usersearch"));
    userSearchFragment.add(userSearchPanel);

    AnyTypeTO anyTypeTO = anyTypeRestClient.read(AnyTypeKind.USER.name());
    userDirectoryPanel = UserSelectionDirectoryPanel.class.cast(new UserSelectionDirectoryPanel.Builder(
        anyTypeClassRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).
        build("searchResult"));

    userSearchFragment.add(userDirectoryPanel);
    ownerContainer.add(userSearchFragment);
}
 
Example #17
Source File: JEXLTransformerWidget.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected IModel<List<String>> getLatestAlerts() {
    return new ListModel<String>() {

        private static final long serialVersionUID = -2583290457773357445L;

        @Override
        public List<String> getObject() {
            List<String> result = new ArrayList<>();
            if (StringUtils.isNotBlank(item.getPropagationJEXLTransformer())) {
                result.add(item.getPropagationJEXLTransformer());
            }
            if (StringUtils.isNotBlank(item.getPullJEXLTransformer())) {
                result.add(item.getPullJEXLTransformer());
            }
            return result;
        }
    };
}
 
Example #18
Source File: RemediationsWidget.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected IModel<List<RemediationTO>> getLatestAlerts() {
    return new ListModel<RemediationTO>() {

        private static final long serialVersionUID = 541491929575585613L;

        @Override
        public List<RemediationTO> getObject() {
            List<RemediationTO> updatedRemediations;
            if (SyncopeConsoleSession.get().owns(IdMEntitlement.REMEDIATION_LIST)
                    && SyncopeConsoleSession.get().owns(IdMEntitlement.REMEDIATION_READ)) {

                updatedRemediations = RemediationRestClient.getRemediations(1,
                        MAX_SIZE, new SortParam<>("instant", true));
            } else {
                updatedRemediations = List.of();
            }

            return updatedRemediations;
        }
    };
}
 
Example #19
Source File: CSVPushWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
public PushTask(final CSVPushSpec spec) {
    AjaxCheckBoxPanel ignorePaging = new AjaxCheckBoxPanel(
            "ignorePaging", "ignorePaging", new PropertyModel<>(spec, "ignorePaging"), true);
    add(ignorePaging);

    AjaxPalettePanel<String> propagationActions =
            new AjaxPalettePanel.Builder<String>().build("propagationActions",
                    new PropertyModel<>(spec, "propagationActions"), new ListModel<>(propActions.getObject()));
    add(propagationActions);

    AjaxDropDownChoicePanel<MatchingRule> matchingRule = new AjaxDropDownChoicePanel<>(
            "matchingRule", "matchingRule", new PropertyModel<>(spec, "matchingRule"), false);
    matchingRule.setChoices(List.of(MatchingRule.values()));
    add(matchingRule);

    AjaxDropDownChoicePanel<UnmatchingRule> unmatchingRule = new AjaxDropDownChoicePanel<>(
            "unmatchingRule", "unmatchingRule", new PropertyModel<>(spec, "unmatchingRule"),
            false);
    unmatchingRule.setChoices(List.of(UnmatchingRule.values()));
    add(unmatchingRule);

    AjaxPalettePanel<String> provisioningActions =
            new AjaxPalettePanel.Builder<String>().build("provisioningActions",
                    new PropertyModel<>(spec, "provisioningActions"), new ListModel<>(pushActions.getObject()));
    add(provisioningActions);
}
 
Example #20
Source File: WebappNotificationPanelRendererServiceImpl.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
public IWicketNotificationDescriptor renderNewVersionNotificationPanel(final List<ArtifactVersionNotification> notifications, final EmailAddress emailAddress) {
	return new AbstractSimpleWicketNotificationDescriptor("notification.panel.newVersion") {
		@Override
		public Object getSubjectParameter() {
			return emailAddress;
		}
		@Override
		public Iterable<?> getSubjectPositionalParameters() {
			return ImmutableList.of(emailAddress.getDisplayName());
		}
		@Override
		public Component createComponent(String wicketId) {
			IModel<List<ArtifactVersionNotification>> notificationsModel = new ListModel<ArtifactVersionNotification>(notifications);
			return new NewVersionsHtmlNotificationPanel(wicketId, notificationsModel, GenericEntityModel.of(emailAddress));
		}
	};
}
 
Example #21
Source File: ChangePasswordModal.java    From syncope with Apache License 2.0 6 votes vote down vote up
public ChangePasswordModal(
        final BaseModal<AnyWrapper<UserTO>> baseModal,
        final PageReference pageReference,
        final UserWrapper wrapper) {
    super(baseModal, pageReference);

    this.wrapper = wrapper;

    final PasswordPanel passwordPanel = new PasswordPanel("passwordPanel", wrapper, false);
    passwordPanel.setOutputMarkupId(true);
    add(passwordPanel);

    statusModel = new ListModel<>(new ArrayList<>());
    StatusPanel statusPanel = new StatusPanel("status", wrapper.getInnerObject(), statusModel, pageReference);
    statusPanel.setCheckAvailability(ListViewPanel.CheckAvailability.AVAILABLE);
    add(statusPanel.setRenderBodyOnly(true));
}
 
Example #22
Source File: NotificationWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
private AbstractSearchPanel.Builder<?> getClauseBuilder(
        final String type, final ListModel<SearchClause> clauseModel) {

    AbstractSearchPanel.Builder<?> clause;

    switch (type) {
        case "USER":
            clause = new UserSearchPanel.Builder(clauseModel);
            break;

        case "GROUP":
            clause = new GroupSearchPanel.Builder(clauseModel);
            break;

        default:
            clause = new AnyObjectSearchPanel.Builder(type, clauseModel);
    }

    return clause;
}
 
Example #23
Source File: RoleWizardBuilder.java    From syncope with Apache License 2.0 5 votes vote down vote up
public Privileges(final RoleTO modelObject) {
    setTitleModel(new ResourceModel("privileges"));
    add(new AjaxPalettePanel.Builder<>().build("privileges",
            new PropertyModel<>(modelObject, "privileges"),
            new ListModel<>(ApplicationRestClient.list().stream().
                    flatMap(application -> application.getPrivileges().stream()).
                    map(EntityTO::getKey).collect(Collectors.toList()))).
            hideLabel().setOutputMarkupId(true));
}
 
Example #24
Source File: AnyPanel.java    From syncope with Apache License 2.0 5 votes vote down vote up
protected AbstractSearchPanel getSearchPanel(final String id) {
    List<SearchClause> clauses = new ArrayList<>();
    SearchClause clause = new SearchClause();
    clauses.add(clause);

    AbstractSearchPanel panel;
    switch (anyTypeTO.getKind()) {
        case USER:
            clause.setComparator(SearchClause.Comparator.EQUALS);
            clause.setType(SearchClause.Type.ATTRIBUTE);
            clause.setProperty("username");

            panel = new UserSearchPanel.Builder(
                    new ListModel<>(clauses)).required(true).enableSearch().build(id);
            break;

        case GROUP:
            clause.setComparator(SearchClause.Comparator.EQUALS);
            clause.setType(SearchClause.Type.ATTRIBUTE);
            clause.setProperty("name");

            panel = new GroupSearchPanel.Builder(
                    new ListModel<>(clauses)).required(true).enableSearch().build(id);
            break;

        case ANY_OBJECT:
            clause.setComparator(SearchClause.Comparator.EQUALS);
            clause.setType(SearchClause.Type.ATTRIBUTE);
            clause.setProperty("name");

            panel = new AnyObjectSearchPanel.Builder(anyTypeTO.getKey(),
                    new ListModel<>(clauses)).required(true).enableSearch().build(id);
            break;

        default:
            panel = null;
    }

    return panel;
}
 
Example #25
Source File: WorkflowConditionViewer.java    From oodt with Apache License 2.0 5 votes vote down vote up
public WorkflowConditionViewer(String id, String wmUrlStr, String conditionId) {
  super(id);
  this.wm = new WorkflowMgrConn(wmUrlStr);
  final WorkflowCondition cond = this.wm.safeGetConditionById(conditionId);
  add(new Label("condition_id", cond.getConditionId()));
  add(new Label("condition_name", cond.getConditionName()));
  add(new Label("condition_class", cond.getConditionInstanceClassName()));
  final WorkflowConditionConfiguration config = cond.getCondConfig() != null ? 
      cond.getCondConfig():new WorkflowConditionConfiguration();
  List<String> condConfigKeyNames = Arrays.asList(config
      .getProperties().keySet().toArray(
          new String[config.getProperties().size()]));
  Collections.sort(condConfigKeyNames);
  add(new ListView<String>("cond_config", new ListModel<String>(
      condConfigKeyNames)) {
    /*
     * (non-Javadoc)
     * 
     * @see
     * org.apache.wicket.markup.html.list.ListView#populateItem(org.apache
     * .wicket.markup.html.list.ListItem)
     */
    @Override
    protected void populateItem(ListItem<String> item) {
      String keyName = item.getModelObject();
      String keyVal = config.getProperty(keyName);
      item.add(new Label("cond_pname", keyName));
      item.add(new Label("cond_pvalue", keyVal));
    }
  });

}
 
Example #26
Source File: StringMatchingRecommenderTraitsEditor.java    From inception with Apache License 2.0 5 votes vote down vote up
public StringMatchingRecommenderTraitsEditor(String aId, IModel<Recommender> aRecommender)
{
    super(aId, aRecommender);

    gazeteers = new GazeteerList("gazeteers", LoadableDetachableModel.of(this::listGazeteers));
    gazeteers.add(visibleWhen(() -> aRecommender.getObject() != null
            && aRecommender.getObject().getId() != null));
    add(gazeteers);
    
    FileInputConfig config = new FileInputConfig();
    config.initialCaption("Import gazeteers ...");
    config.allowedFileExtensions(asList("txt"));
    config.showPreview(false);
    config.showUpload(true);
    config.removeIcon("<i class=\"fa fa-remove\"></i>");
    config.uploadIcon("<i class=\"fa fa-upload\"></i>");
    config.browseIcon("<i class=\"fa fa-folder-open\"></i>");
    uploadField = new BootstrapFileInput("upload", new ListModel<>(), config) {
        private static final long serialVersionUID = -7072183979425490246L;

        @Override
        protected void onSubmit(AjaxRequestTarget aTarget)
        {
            actionUploadGazeteer(aTarget);
        }
    };
    uploadField.add(visibleWhen(() -> aRecommender.getObject() != null
            && aRecommender.getObject().getId() != null));
    add(uploadField);
}
 
Example #27
Source File: AbstractResources.java    From syncope with Apache License 2.0 5 votes vote down vote up
public <T extends AnyTO> AbstractResources(final AnyWrapper<T> modelObject) {
    final T entityTO = modelObject.getInnerObject();

    if (modelObject instanceof UserWrapper
            && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !modelObject.getInnerObject().getResources().equals(
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getResources())) {

        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }

    this.setOutputMarkupId(true);
    this.available = new ListModel<>(List.of());

    add(new AjaxPalettePanel.Builder<String>().build("resources",
            new PropertyModel<List<String>>(entityTO, "resources") {

        private static final long serialVersionUID = 3799387950428254072L;

        @Override
        public List<String> getObject() {
            return new ArrayList<>(entityTO.getResources());
        }

        @Override
        public void setObject(final List<String> object) {
            entityTO.getResources().clear();
            entityTO.getResources().addAll(object);
        }
    }, available).hideLabel().setOutputMarkupId(true));
}
 
Example #28
Source File: AbstractAuxClasses.java    From syncope with Apache License 2.0 5 votes vote down vote up
public <T extends AnyTO> AbstractAuxClasses(final AnyWrapper<T> modelObject, final List<String> anyTypeClasses) {
    super();
    setOutputMarkupId(true);

    List<AnyTypeClassTO> allAnyTypeClasses = listAnyTypecClasses();

    List<String> choices = new ArrayList<>();
    for (AnyTypeClassTO aux : allAnyTypeClasses) {
        if (!anyTypeClasses.contains(aux.getKey())) {
            choices.add(aux.getKey());
        }
    }
    Collections.sort(choices);
    add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true).build("auxClasses",
            new PropertyModel<>(modelObject.getInnerObject(), "auxClasses"),
            new ListModel<>(choices)).hideLabel().setOutputMarkupId(true));

    // ------------------
    // insert changed label if needed
    // ------------------
    if (modelObject instanceof UserWrapper
            && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(
                    modelObject.getInnerObject().getAuxClasses(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getAuxClasses())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }
    // ------------------
}
 
Example #29
Source File: AbstractAttrs.java    From syncope with Apache License 2.0 5 votes vote down vote up
public AbstractAttrs(
        final AnyWrapper<?> modelObject,
        final List<String> anyTypeClasses,
        final Map<String, CustomizationOption> whichAttrs) {
    super();
    this.anyTypeClasses = anyTypeClasses;
    this.attrs = new ListModel<>(List.of());
    this.membershipTOs = new ListModel<>(List.of());

    this.setOutputMarkupId(true);

    this.anyTO = modelObject.getInnerObject();
    this.whichAttrs = whichAttrs;
}
 
Example #30
Source File: DefaultRegistrationPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private Panel createSocialNetworksPanel(String id) {
    List<OAuth2Service> services = OAuth2Repository.getOAuth2Services(true);
    if (services.isEmpty()) {
        return new EmptyPanel(id);
    }

    return new SocialNetworkPanel(id, "panel.registration.social.networks.title", new ListModel<>(services)) {
        @Override
        protected OAuth2ServiceContext createOAuth2ServiceContext(OAuth2Service service) {
            OAuth2ServiceContext ctx = super.createOAuth2ServiceContext(service);
            ctx.setRegistration(true);
            return ctx;
        }
    };
}