List of usage examples for org.apache.wicket.markup.html.list ListView getModelObject
@SuppressWarnings("unchecked") public final List<T> getModelObject()
From source file:org.apache.syncope.client.console.pages.ResultStatusModalPage.java
License:Apache License
private ResultStatusModalPage(final Builder builder) { super();/*w ww . j a v a 2 s.c o m*/ this.subject = builder.subject; statusUtils = new StatusUtils(this.userRestClient); if (builder.mode == null) { this.mode = Mode.ADMIN; } else { this.mode = builder.mode; } final BaseModalPage page = this; final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); final Fragment fragment = new Fragment("resultFrag", mode == Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this); fragment.setOutputMarkupId(true); container.add(fragment); if (mode == Mode.ADMIN) { // add Syncope propagation status PropagationStatus syncope = new PropagationStatus(); syncope.setResource("Syncope"); syncope.setStatus(PropagationTaskExecStatus.SUCCESS); List<PropagationStatus> propagations = new ArrayList<PropagationStatus>(); propagations.add(syncope); propagations.addAll(subject.getPropagationStatusTOs()); fragment.add(new Label("info", ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null) ? ((UserTO) subject).getUsername() : ((subject instanceof GroupTO) && ((GroupTO) subject).getName() != null) ? ((GroupTO) subject).getName() : String.valueOf(subject.getKey()))); final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) { private static final long serialVersionUID = -1020475259727720708L; @Override protected void populateItem(final ListItem<PropagationStatus> item) { final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject(); final ListView attributes = getConnObjectView(propTO); final Fragment attrhead; if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) { attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page); } else { attrhead = new Fragment("attrhead", "attrHeadFrag", page); } item.add(attrhead); item.add(attributes); attrhead.add(new Label("resource", propTO.getResource())); attrhead.add(new Label("propagation", propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString())); final Image image; final String alt, title; final ModalWindow failureWindow = new ModalWindow("failureWindow"); final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(AjaxRequestTarget target) { failureWindow.show(target); } }; switch (propTO.getStatus()) { case SUCCESS: case SUBMITTED: case CREATED: image = new Image("icon", new ContextRelativeResource( IMG_PREFIX + Status.ACTIVE.toString() + Constants.PNG_EXT)); alt = "success icon"; title = "success"; failureWindow.setVisible(false); failureWindowLink.setEnabled(false); break; default: image = new Image("icon", new ContextRelativeResource( IMG_PREFIX + Status.SUSPENDED.toString() + Constants.PNG_EXT)); alt = "failure icon"; title = "failure"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); final FailureMessageModalPage executionFailureMessagePage; if (propTO.getFailureReason() == null) { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), StringUtils.EMPTY); } else { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), propTO.getFailureReason()); } failureWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return executionFailureMessagePage; } }); failureWindow.setCookieName("failureWindow"); failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); failureWindowLink.add(image); attrhead.add(failureWindowLink); attrhead.add(failureWindow); } }; fragment.add(propRes); } final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { builder.window.close(target); } }; container.add(close); setOutputMarkupId(true); }
From source file:org.apache.syncope.client.console.panels.ConnectorModal.java
License:Apache License
public ConnectorModal(final ModalWindow window, final PageReference pageRef, final ConnInstanceTO connInstanceTO) { super(window, pageRef); this.add(new Label("new", connInstanceTO.getKey() == 0 ? new ResourceModel("new") : new Model<>(StringUtils.EMPTY))); this.add(new Label("key", connInstanceTO.getKey() == 0 ? StringUtils.EMPTY : connInstanceTO.getKey())); // general data setup selectedCapabilities = new ArrayList<>( connInstanceTO.getKey() == 0 ? EnumSet.noneOf(ConnectorCapability.class) : connInstanceTO.getCapabilities()); mapConnBundleTOs = new HashMap<>(); for (ConnBundleTO connBundleTO : connectorRestClient.getAllBundles()) { // by location if (!mapConnBundleTOs.containsKey(connBundleTO.getLocation())) { mapConnBundleTOs.put(connBundleTO.getLocation(), new HashMap<String, Map<String, ConnBundleTO>>()); }/*from w ww . j av a 2s .c o m*/ final Map<String, Map<String, ConnBundleTO>> byLocation = mapConnBundleTOs .get(connBundleTO.getLocation()); // by name if (!byLocation.containsKey(connBundleTO.getBundleName())) { byLocation.put(connBundleTO.getBundleName(), new HashMap<String, ConnBundleTO>()); } final Map<String, ConnBundleTO> byName = byLocation.get(connBundleTO.getBundleName()); // by version if (!byName.containsKey(connBundleTO.getVersion())) { byName.put(connBundleTO.getVersion(), connBundleTO); } } bundleTO = getSelectedBundleTO(connInstanceTO); properties = fillProperties(bundleTO, connInstanceTO); // form - first tab final Form<ConnInstanceTO> connectorForm = new Form<>(FORM); connectorForm.setModel(new CompoundPropertyModel<>(connInstanceTO)); connectorForm.setOutputMarkupId(true); add(connectorForm); propertiesContainer = new WebMarkupContainer("container"); propertiesContainer.setOutputMarkupId(true); connectorForm.add(propertiesContainer); final Form<ConnInstanceTO> connectorPropForm = new Form<>("connectorPropForm"); connectorPropForm.setModel(new CompoundPropertyModel<>(connInstanceTO)); connectorPropForm.setOutputMarkupId(true); propertiesContainer.add(connectorPropForm); final AjaxTextFieldPanel displayName = new AjaxTextFieldPanel("displayName", "display name", new PropertyModel<String>(connInstanceTO, "displayName")); displayName.setOutputMarkupId(true); displayName.addRequiredLabel(); connectorForm.add(displayName); final AjaxDropDownChoicePanel<String> location = new AjaxDropDownChoicePanel<>("location", "location", new Model<>(bundleTO == null ? null : bundleTO.getLocation())); ((DropDownChoice<String>) location.getField()).setNullValid(true); location.setStyleSheet("long_dynamicsize"); location.setChoices(new ArrayList<>(mapConnBundleTOs.keySet())); location.setRequired(true); location.addRequiredLabel(); location.setOutputMarkupId(true); location.setEnabled(connInstanceTO.getKey() == 0); location.getField().setOutputMarkupId(true); connectorForm.add(location); final AjaxDropDownChoicePanel<String> connectorName = new AjaxDropDownChoicePanel<>("connectorName", "connectorName", new Model<>(bundleTO == null ? null : bundleTO.getBundleName())); ((DropDownChoice<String>) connectorName.getField()).setNullValid(true); connectorName.setStyleSheet("long_dynamicsize"); connectorName.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<>(mapConnBundleTOs.get(connInstanceTO.getLocation()).keySet())); connectorName.setRequired(true); connectorName.addRequiredLabel(); connectorName.setEnabled(connInstanceTO.getLocation() != null); connectorName.setOutputMarkupId(true); connectorName.setEnabled(connInstanceTO.getKey() == 0); connectorName.getField().setOutputMarkupId(true); connectorForm.add(connectorName); final AjaxDropDownChoicePanel<String> version = new AjaxDropDownChoicePanel<>("version", "version", new Model<>(bundleTO == null ? null : bundleTO.getVersion())); version.setStyleSheet("long_dynamicsize"); version.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<>(mapConnBundleTOs.get(connInstanceTO.getLocation()) .get(connInstanceTO.getBundleName()).keySet())); version.setRequired(true); version.addRequiredLabel(); version.setEnabled(connInstanceTO.getBundleName() != null); version.setOutputMarkupId(true); version.addRequiredLabel(); version.getField().setOutputMarkupId(true); connectorForm.add(version); final SpinnerFieldPanel<Integer> connRequestTimeout = new SpinnerFieldPanel<>("connRequestTimeout", "connRequestTimeout", Integer.class, new PropertyModel<Integer>(connInstanceTO, "connRequestTimeout"), 0, null); connRequestTimeout.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(connRequestTimeout); if (connInstanceTO.getPoolConf() == null) { connInstanceTO.setPoolConf(new ConnPoolConfTO()); } final SpinnerFieldPanel<Integer> poolMaxObjects = new SpinnerFieldPanel<>("poolMaxObjects", "poolMaxObjects", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxObjects"), 0, null); poolMaxObjects.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxObjects); final SpinnerFieldPanel<Integer> poolMinIdle = new SpinnerFieldPanel<>("poolMinIdle", "poolMinIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "minIdle"), 0, null); poolMinIdle.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMinIdle); final SpinnerFieldPanel<Integer> poolMaxIdle = new SpinnerFieldPanel<>("poolMaxIdle", "poolMaxIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxIdle"), 0, null); poolMaxIdle.getField().add(new RangeValidator<>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxIdle); final SpinnerFieldPanel<Long> poolMaxWait = new SpinnerFieldPanel<>("poolMaxWait", "poolMaxWait", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "maxWait"), 0L, null); poolMaxWait.getField().add(new RangeValidator<>(0L, Long.MAX_VALUE)); connectorForm.add(poolMaxWait); final SpinnerFieldPanel<Long> poolMinEvictableIdleTime = new SpinnerFieldPanel<>("poolMinEvictableIdleTime", "poolMinEvictableIdleTime", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "minEvictableIdleTimeMillis"), 0L, null); poolMinEvictableIdleTime.getField().add(new RangeValidator<>(0L, Long.MAX_VALUE)); connectorForm.add(poolMinEvictableIdleTime); // form - first tab - onchange() location.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) location.getField()).setNullValid(false); connInstanceTO.setLocation(location.getModelObject()); target.add(location); connectorName.setChoices(new ArrayList<>(mapConnBundleTOs.get(location.getModelObject()).keySet())); connectorName.setEnabled(true); connectorName.getField().setModelValue(null); target.add(connectorName); version.setChoices(new ArrayList<String>()); version.getField().setModelValue(null); version.setEnabled(false); target.add(version); properties.clear(); target.add(propertiesContainer); } }); connectorName.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) connectorName.getField()).setNullValid(false); connInstanceTO.setBundleName(connectorName.getModelObject()); target.add(connectorName); List<String> versions = new ArrayList<>(mapConnBundleTOs.get(location.getModelObject()) .get(connectorName.getModelObject()).keySet()); version.setChoices(versions); version.setEnabled(true); if (versions.size() == 1) { selectVersion(target, connInstanceTO, version, versions.get(0)); version.getField().setModelObject(versions.get(0)); } else { version.getField().setModelValue(null); properties.clear(); target.add(propertiesContainer); } target.add(version); } }); version.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { selectVersion(target, connInstanceTO, version, version.getModelObject()); } }); // form - second tab (properties) final ListView<ConnConfProperty> connPropView = new ConnConfPropertyListView("connectorProperties", new PropertyModel<List<ConnConfProperty>>(this, "properties"), true, connInstanceTO.getConfiguration()); connPropView.setOutputMarkupId(true); connectorPropForm.add(connPropView); final AjaxButton check = new IndicatingAjaxButton("check", new ResourceModel("check")) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); // ensure that connector bundle information is in sync conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.setConnectorName(bundleTO.getConnectorName()); if (connectorRestClient.check(conn)) { info(getString("success_connection")); } else { error(getString("error_connection")); } feedbackPanel.refresh(target); } }; connectorPropForm.add(check); // form - third tab (capabilities) final IModel<List<ConnectorCapability>> capabilities = new LoadableDetachableModel<List<ConnectorCapability>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnectorCapability> load() { return Arrays.asList(ConnectorCapability.values()); } }; CheckBoxMultipleChoice<ConnectorCapability> capabilitiesPalette = new CheckBoxMultipleChoice<>( "capabilitiesPalette", new PropertyModel<List<ConnectorCapability>>(this, "selectedCapabilities"), capabilities); capabilitiesPalette.add(new AjaxFormChoiceComponentUpdatingBehavior() { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { } }); connectorForm.add(capabilitiesPalette); // form - submit / cancel buttons final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); conn.setConnectorName(bundleTO.getConnectorName()); conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.getConfiguration().clear(); conn.getConfiguration().addAll(connPropView.getModelObject()); // Set the model object's capabilities to capabilitiesPalette's converted Set conn.getCapabilities().clear(); conn.getCapabilities() .addAll(selectedCapabilities.isEmpty() ? EnumSet.noneOf(ConnectorCapability.class) : EnumSet.copyOf(selectedCapabilities)); // Reset pool configuration if all fields are null if (conn.getPoolConf() != null && conn.getPoolConf().getMaxIdle() == null && conn.getPoolConf().getMaxObjects() == null && conn.getPoolConf().getMaxWait() == null && conn.getPoolConf().getMinEvictableIdleTimeMillis() == null && conn.getPoolConf().getMinIdle() == null) { conn.setPoolConf(null); } try { if (connInstanceTO.getKey() == 0) { connectorRestClient.create(conn); } else { connectorRestClient.update(conn); } ((BasePage) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); ((BasePage) pageRef.getPage()).setModalResult(false); LOG.error("While creating or updating connector {}", conn, e); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; String entitlements = connInstanceTO.getKey() == 0 ? Entitlement.CONNECTOR_CREATE : Entitlement.CONNECTOR_UPDATE; MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, entitlements); connectorForm.add(submit); final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); connectorForm.add(cancel); }
From source file:org.apache.syncope.console.pages.ConnectorModalPage.java
License:Apache License
public ConnectorModalPage(final PageReference pageRef, final ModalWindow window, final ConnInstanceTO connInstanceTO) { super();/*from w w w. j a va 2s .com*/ // general data setup selectedCapabilities = new ArrayList<ConnectorCapability>( connInstanceTO.getId() == 0 ? EnumSet.noneOf(ConnectorCapability.class) : connInstanceTO.getCapabilities()); mapConnBundleTOs = new HashMap<String, Map<String, Map<String, ConnBundleTO>>>(); for (ConnBundleTO connBundleTO : restClient.getAllBundles()) { // by location if (!mapConnBundleTOs.containsKey(connBundleTO.getLocation())) { mapConnBundleTOs.put(connBundleTO.getLocation(), new HashMap<String, Map<String, ConnBundleTO>>()); } final Map<String, Map<String, ConnBundleTO>> byLocation = mapConnBundleTOs .get(connBundleTO.getLocation()); // by name if (!byLocation.containsKey(connBundleTO.getBundleName())) { byLocation.put(connBundleTO.getBundleName(), new HashMap<String, ConnBundleTO>()); } final Map<String, ConnBundleTO> byName = byLocation.get(connBundleTO.getBundleName()); // by version if (!byName.containsKey(connBundleTO.getVersion())) { byName.put(connBundleTO.getVersion(), connBundleTO); } } bundleTO = getSelectedBundleTO(connInstanceTO); properties = fillProperties(bundleTO, connInstanceTO); // form - first tab final Form<ConnInstanceTO> connectorForm = new Form<ConnInstanceTO>(FORM); connectorForm.setModel(new CompoundPropertyModel<ConnInstanceTO>(connInstanceTO)); connectorForm.setOutputMarkupId(true); add(connectorForm); propertiesContainer = new WebMarkupContainer("container"); propertiesContainer.setOutputMarkupId(true); connectorForm.add(propertiesContainer); final Form<ConnInstanceTO> connectorPropForm = new Form<ConnInstanceTO>("connectorPropForm"); connectorPropForm.setModel(new CompoundPropertyModel<ConnInstanceTO>(connInstanceTO)); connectorPropForm.setOutputMarkupId(true); propertiesContainer.add(connectorPropForm); final AjaxTextFieldPanel displayName = new AjaxTextFieldPanel("displayName", "display name", new PropertyModel<String>(connInstanceTO, "displayName")); displayName.setOutputMarkupId(true); displayName.addRequiredLabel(); connectorForm.add(displayName); final AjaxDropDownChoicePanel<String> location = new AjaxDropDownChoicePanel<String>("location", "location", new Model<String>(bundleTO == null ? null : bundleTO.getLocation())); ((DropDownChoice<String>) location.getField()).setNullValid(true); location.setStyleSheet("long_dynamicsize"); location.setChoices(new ArrayList<String>(mapConnBundleTOs.keySet())); location.setRequired(true); location.addRequiredLabel(); location.setOutputMarkupId(true); location.setEnabled(connInstanceTO.getId() == 0); location.getField().setOutputMarkupId(true); connectorForm.add(location); final AjaxDropDownChoicePanel<String> connectorName = new AjaxDropDownChoicePanel<String>("connectorName", "connectorName", new Model<String>(bundleTO == null ? null : bundleTO.getBundleName())); ((DropDownChoice<String>) connectorName.getField()).setNullValid(true); connectorName.setStyleSheet("long_dynamicsize"); connectorName.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<String>(mapConnBundleTOs.get(connInstanceTO.getLocation()).keySet())); connectorName.setRequired(true); connectorName.addRequiredLabel(); connectorName.setEnabled(connInstanceTO.getLocation() != null); connectorName.setOutputMarkupId(true); connectorName.setEnabled(connInstanceTO.getId() == 0); connectorName.getField().setOutputMarkupId(true); connectorForm.add(connectorName); final AjaxDropDownChoicePanel<String> version = new AjaxDropDownChoicePanel<String>("version", "version", new Model<String>(bundleTO == null ? null : bundleTO.getVersion())); version.setStyleSheet("long_dynamicsize"); version.setChoices(bundleTO == null ? new ArrayList<String>() : new ArrayList<String>(mapConnBundleTOs.get(connInstanceTO.getLocation()) .get(connInstanceTO.getBundleName()).keySet())); version.setRequired(true); version.addRequiredLabel(); version.setEnabled(connInstanceTO.getBundleName() != null); version.setOutputMarkupId(true); version.addRequiredLabel(); version.getField().setOutputMarkupId(true); connectorForm.add(version); final SpinnerFieldPanel<Integer> connRequestTimeout = new SpinnerFieldPanel<Integer>("connRequestTimeout", "connRequestTimeout", Integer.class, new PropertyModel<Integer>(connInstanceTO, "connRequestTimeout"), 0, null); connRequestTimeout.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(connRequestTimeout); if (connInstanceTO.getPoolConf() == null) { connInstanceTO.setPoolConf(new ConnPoolConfTO()); } final SpinnerFieldPanel<Integer> poolMaxObjects = new SpinnerFieldPanel<Integer>("poolMaxObjects", "poolMaxObjects", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxObjects"), 0, null); poolMaxObjects.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxObjects); final SpinnerFieldPanel<Integer> poolMinIdle = new SpinnerFieldPanel<Integer>("poolMinIdle", "poolMinIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "minIdle"), 0, null); poolMinIdle.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMinIdle); final SpinnerFieldPanel<Integer> poolMaxIdle = new SpinnerFieldPanel<Integer>("poolMaxIdle", "poolMaxIdle", Integer.class, new PropertyModel<Integer>(connInstanceTO.getPoolConf(), "maxIdle"), 0, null); poolMaxIdle.getField().add(new RangeValidator<Integer>(0, Integer.MAX_VALUE)); connectorForm.add(poolMaxIdle); final SpinnerFieldPanel<Long> poolMaxWait = new SpinnerFieldPanel<Long>("poolMaxWait", "poolMaxWait", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "maxWait"), 0L, null); poolMaxWait.getField().add(new RangeValidator<Long>(0L, Long.MAX_VALUE)); connectorForm.add(poolMaxWait); final SpinnerFieldPanel<Long> poolMinEvictableIdleTime = new SpinnerFieldPanel<Long>( "poolMinEvictableIdleTime", "poolMinEvictableIdleTime", Long.class, new PropertyModel<Long>(connInstanceTO.getPoolConf(), "minEvictableIdleTimeMillis"), 0L, null); poolMinEvictableIdleTime.getField().add(new RangeValidator<Long>(0L, Long.MAX_VALUE)); connectorForm.add(poolMinEvictableIdleTime); // form - first tab - onchange() location.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) location.getField()).setNullValid(false); connInstanceTO.setLocation(location.getModelObject()); target.add(location); connectorName.setChoices( new ArrayList<String>(mapConnBundleTOs.get(location.getModelObject()).keySet())); connectorName.setEnabled(true); connectorName.getField().setModelValue(null); target.add(connectorName); version.setChoices(new ArrayList<String>()); version.getField().setModelValue(null); version.setEnabled(false); target.add(version); properties.clear(); target.add(propertiesContainer); } }); connectorName.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { ((DropDownChoice<String>) connectorName.getField()).setNullValid(false); connInstanceTO.setBundleName(connectorName.getModelObject()); target.add(connectorName); List<String> versions = new ArrayList<String>(mapConnBundleTOs.get(location.getModelObject()) .get(connectorName.getModelObject()).keySet()); version.setChoices(versions); version.setEnabled(true); if (versions.size() == 1) { selectVersion(target, connInstanceTO, version, versions.get(0)); version.getField().setModelObject(versions.get(0)); } else { version.getField().setModelValue(null); properties.clear(); target.add(propertiesContainer); } target.add(version); } }); version.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; @Override protected void onUpdate(final AjaxRequestTarget target) { selectVersion(target, connInstanceTO, version, version.getModelObject()); } }); // form - second tab (properties) final ListView<ConnConfProperty> connPropView = new AltListView<ConnConfProperty>("connectorProperties", new PropertyModel<List<ConnConfProperty>>(this, "properties")) { private static final long serialVersionUID = 9101744072914090143L; @Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void populateItem(final ListItem<ConnConfProperty> item) { final ConnConfProperty property = item.getModelObject(); final Label label = new Label("connPropAttrSchema", StringUtils.isBlank(property.getSchema().getDisplayName()) ? property.getSchema().getName() : property.getSchema().getDisplayName()); item.add(label); final FieldPanel field; boolean required = false; boolean isArray = false; if (property.getSchema().isConfidential() || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) { field = new AjaxPasswordFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model<String>()); ((PasswordTextField) field.getField()).setResetPassword(false); required = property.getSchema().isRequired(); } else { Class<?> propertySchemaClass; try { propertySchemaClass = ClassUtils.forName(property.getSchema().getType(), ClassUtils.getDefaultClassLoader()); if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) { propertySchemaClass = org.apache.commons.lang3.ClassUtils .primitiveToWrapper(propertySchemaClass); } } catch (Exception e) { LOG.error("Error parsing attribute type", e); propertySchemaClass = String.class; } if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) { field = new SpinnerFieldPanel<Number>("panel", label.getDefaultModelObjectAsString(), (Class<Number>) propertySchemaClass, new Model<Number>(), null, null); required = property.getSchema().isRequired(); } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) { field = new AjaxCheckBoxPanel("panel", label.getDefaultModelObjectAsString(), new Model<Boolean>()); } else { field = new AjaxTextFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model<String>()); required = property.getSchema().isRequired(); } if (propertySchemaClass.isArray()) { isArray = true; } } field.setTitle(property.getSchema().getHelpMessage()); if (required) { field.addRequiredLabel(); } if (isArray) { if (property.getValues().isEmpty()) { property.getValues().add(null); } item.add(new MultiFieldPanel<String>("panel", new PropertyModel<List<String>>(property, "values"), field)); } else { field.setNewModel(property.getValues()); item.add(field); } final AjaxCheckBoxPanel overridable = new AjaxCheckBoxPanel("connPropAttrOverridable", "connPropAttrOverridable", new PropertyModel<Boolean>(property, "overridable")); item.add(overridable); connInstanceTO.getConfiguration().add(property); } }; connPropView.setOutputMarkupId(true); connectorPropForm.add(connPropView); final AjaxLink<String> check = new IndicatingAjaxLink<String>("check", new ResourceModel("check")) { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { connInstanceTO.setBundleName(bundleTO.getBundleName()); connInstanceTO.setVersion(bundleTO.getVersion()); connInstanceTO.setConnectorName(bundleTO.getConnectorName()); if (restClient.check(connInstanceTO)) { info(getString("success_connection")); } else { error(getString("error_connection")); } feedbackPanel.refresh(target); } }; connectorPropForm.add(check); // form - third tab (capabilities) final IModel<List<ConnectorCapability>> capabilities = new LoadableDetachableModel<List<ConnectorCapability>>() { private static final long serialVersionUID = 5275935387613157437L; @Override protected List<ConnectorCapability> load() { return Arrays.asList(ConnectorCapability.values()); } }; CheckBoxMultipleChoice<ConnectorCapability> capabilitiesPalette = new CheckBoxMultipleChoice<ConnectorCapability>( "capabilitiesPalette", new PropertyModel<List<ConnectorCapability>>(this, "selectedCapabilities"), capabilities); connectorForm.add(capabilitiesPalette); // form - submit / cancel buttons final AjaxButton submit = new IndicatingAjaxButton(APPLY, new Model<String>(getString(SUBMIT))) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { final ConnInstanceTO conn = (ConnInstanceTO) form.getModelObject(); conn.setConnectorName(bundleTO.getConnectorName()); conn.setBundleName(bundleTO.getBundleName()); conn.setVersion(bundleTO.getVersion()); conn.getConfiguration().clear(); conn.getConfiguration().addAll(connPropView.getModelObject()); // Set the model object's capabilities to capabilitiesPalette's converted Set conn.getCapabilities() .addAll(selectedCapabilities.isEmpty() ? EnumSet.noneOf(ConnectorCapability.class) : EnumSet.copyOf(selectedCapabilities)); // Reset pool configuration if all fields are null if (conn.getPoolConf() != null && conn.getPoolConf().getMaxIdle() == null && conn.getPoolConf().getMaxObjects() == null && conn.getPoolConf().getMaxWait() == null && conn.getPoolConf().getMinEvictableIdleTimeMillis() == null && conn.getPoolConf().getMinIdle() == null) { conn.setPoolConf(null); } try { if (connInstanceTO.getId() == 0) { restClient.create(conn); } else { restClient.update(conn); } ((Resources) pageRef.getPage()).setModalResult(true); window.close(target); } catch (SyncopeClientException e) { error(getString(Constants.ERROR) + ": " + e.getMessage()); feedbackPanel.refresh(target); ((Resources) pageRef.getPage()).setModalResult(false); LOG.error("While creating or updating connector {}", conn, e); } } @Override protected void onError(final AjaxRequestTarget target, final Form<?> form) { feedbackPanel.refresh(target); } }; String roles = connInstanceTO.getId() == 0 ? xmlRolesReader.getAllAllowedRoles("Connectors", "create") : xmlRolesReader.getAllAllowedRoles("Connectors", "update"); MetaDataRoleAuthorizationStrategy.authorize(submit, ENABLE, roles); connectorForm.add(submit); final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) { private static final long serialVersionUID = -958724007591692537L; @Override protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) { window.close(target); } }; cancel.setDefaultFormProcessing(false); connectorForm.add(cancel); }
From source file:org.apache.syncope.console.pages.ResultStatusModalPage.java
License:Apache License
private ResultStatusModalPage(final Builder builder) { super();//from w ww . j a v a 2 s . co m this.subject = builder.subject; statusUtils = new StatusUtils(this.userRestClient); if (builder.mode == null) { this.mode = UserModalPage.Mode.ADMIN; } else { this.mode = builder.mode; } final BaseModalPage page = this; final WebMarkupContainer container = new WebMarkupContainer("container"); container.setOutputMarkupId(true); add(container); final Fragment fragment = new Fragment("resultFrag", mode == UserModalPage.Mode.SELF ? "userSelfResultFrag" : "propagationResultFrag", this); fragment.setOutputMarkupId(true); container.add(fragment); if (mode == UserModalPage.Mode.ADMIN) { // add Syncope propagation status PropagationStatus syncope = new PropagationStatus(); syncope.setResource("Syncope"); syncope.setStatus(PropagationTaskExecStatus.SUCCESS); List<PropagationStatus> propagations = new ArrayList<PropagationStatus>(); propagations.add(syncope); propagations.addAll(subject.getPropagationStatusTOs()); fragment.add(new Label("info", ((subject instanceof UserTO) && ((UserTO) subject).getUsername() != null) ? ((UserTO) subject).getUsername() : ((subject instanceof RoleTO) && ((RoleTO) subject).getName() != null) ? ((RoleTO) subject).getName() : String.valueOf(subject.getId()))); final ListView<PropagationStatus> propRes = new ListView<PropagationStatus>("resources", propagations) { private static final long serialVersionUID = -1020475259727720708L; @Override protected void populateItem(final ListItem<PropagationStatus> item) { final PropagationStatus propTO = (PropagationStatus) item.getDefaultModelObject(); final ListView attributes = getConnObjectView(propTO); final Fragment attrhead; if (attributes.getModelObject() == null || attributes.getModelObject().isEmpty()) { attrhead = new Fragment("attrhead", "emptyAttrHeadFrag", page); } else { attrhead = new Fragment("attrhead", "attrHeadFrag", page); } item.add(attrhead); item.add(attributes); attrhead.add(new Label("resource", propTO.getResource())); attrhead.add(new Label("propagation", propTO.getStatus() == null ? "UNDEFINED" : propTO.getStatus().toString())); final Image image; final String alt, title; final ModalWindow failureWindow = new ModalWindow("failureWindow"); final AjaxLink<?> failureWindowLink = new AjaxLink<Void>("showFailureWindow") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(AjaxRequestTarget target) { failureWindow.show(target); } }; switch (propTO.getStatus()) { case SUCCESS: case SUBMITTED: case CREATED: image = new Image("icon", IMG_STATUSES + Status.ACTIVE.toString() + Constants.PNG_EXT); alt = "success icon"; title = "success"; failureWindow.setVisible(false); failureWindowLink.setEnabled(false); break; default: image = new Image("icon", IMG_STATUSES + Status.SUSPENDED.toString() + Constants.PNG_EXT); alt = "failure icon"; title = "failure"; } image.add(new Behavior() { private static final long serialVersionUID = 1469628524240283489L; @Override public void onComponentTag(final Component component, final ComponentTag tag) { tag.put("alt", alt); tag.put("title", title); } }); final FailureMessageModalPage executionFailureMessagePage; if (propTO.getFailureReason() == null) { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), StringUtils.EMPTY); } else { executionFailureMessagePage = new FailureMessageModalPage(failureWindow.getContentId(), propTO.getFailureReason()); } failureWindow.setPageCreator(new ModalWindow.PageCreator() { private static final long serialVersionUID = -7834632442532690940L; @Override public Page createPage() { return executionFailureMessagePage; } }); failureWindow.setCookieName("failureWindow"); failureWindow.setCssClassName(ModalWindow.CSS_CLASS_GRAY); failureWindowLink.add(image); attrhead.add(failureWindowLink); attrhead.add(failureWindow); } }; fragment.add(propRes); } final AjaxLink<Void> close = new IndicatingAjaxLink<Void>("close") { private static final long serialVersionUID = -7978723352517770644L; @Override public void onClick(final AjaxRequestTarget target) { if (mode == UserModalPage.Mode.SELF && anonymousUser.equals(SyncopeSession.get().getUsername())) { SyncopeSession.get().invalidate(); } builder.window.close(target); } }; container.add(close); setOutputMarkupId(true); }
From source file:org.forgerock.amutils.web.codec.DecodingPage.java
License:CDDL license
private void addBootstrapComponents() { Form<Void> form = new BootstrapForm<Void>("bootstrap").type(FormType.Inline); form.add(new TextArea<>("bootstrapContent", new PropertyModel<>(this, "bootstrapContent"))); final WebMarkupContainer wmc = new WebMarkupContainer("bootstrapContainer"); LoadableDetachableModel<List<BootstrapData>> listViewModel = new LoadableDetachableModel<List<BootstrapData>>() { @Override/*ww w . j ava2 s . c o m*/ protected List<BootstrapData> load() { List<BootstrapData> ret = new ArrayList<>(); if (bootstrapContent != null && !bootstrapContent.isEmpty()) { String[] lines = bootstrapContent.split("\n"); for (String line : lines) { try { ret.add(BootstrapData.valueOf(line)); } catch (IllegalArgumentException iae) { iae.printStackTrace(); } } } return ret; } }; final ListView<BootstrapData> listView = new ListView<BootstrapData>("servers", listViewModel) { @Override protected void populateItem(ListItem<BootstrapData> item) { item.setModel(new CompoundPropertyModel<>(item.getModelObject())); item.add(new Label("directoryServer")); item.add(new Label("deploymentUrl")); item.add(new Label("adminUser")); item.add(new Label("adminPassword")); item.add(new Label("baseDN")); item.add(new Label("directoryUser")); item.add(new Label("directoryPassword")); } }; wmc.add(listView); wmc.setOutputMarkupPlaceholderTag(true); wmc.setVisible(false); add(wmc); form.add(new AjaxButton("parse") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { wmc.setVisible(!listView.getModelObject().isEmpty()); if (target != null) { target.add(wmc); } } }); add(form); }
From source file:org.hippoecm.frontend.editor.plugins.field.MultipleTextFieldWidget.java
License:Apache License
public MultipleTextFieldWidget(String id, final IModel<IPluginConfig> model, final IClusterConfig cluster, final String name, final boolean editable) { super(id, model); setOutputMarkupId(true);//w ww . j a va 2 s . c o m add(CssClass.append("hippo-multiple-text-field-widget")); IPluginConfig config = model.getObject(); final ListView<String> list = new MultipleValueListView(name, config, cluster, editable); add(list); AjaxButton button = new AjaxButton("add") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { List<String> values = list.getModelObject(); values.add(""); list.setModelObject(values); target.add(MultipleTextFieldWidget.this); } }; button.setVisible(editable); button.setDefaultFormProcessing(false); add(button); button.add(HippoIcon.fromSprite("icon", Icon.PLUS)); }
From source file:org.onehippo.forge.settings.management.config.formdata.FormdataConfigPanel.java
License:Apache License
private void addExclusionPaths(FormdataConfig formdataConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("excludedPathsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> excludedPathsView; excludedPathsView = new ListView<String>("formdata-excludedPaths", new PropertyModel(formdataConfig, "excludepaths")) { private static final long serialVersionUID = 1L; @Override// w w w .ja v a 2 s. co m protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("formdata-path", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-path") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { excludedPathsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; excludedPathsView.setReuseItems(true); listContainer.add(excludedPathsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.upload.AssetValidationServiceConfigPanel.java
License:Apache License
private void addAllowedExtensionsField(AssetValidationServiceConfig assetValidationServiceConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("allowedExtensionsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> allowedExtensionsView; allowedExtensionsView = new ListView<String>("assetvalidation-allowedExtensions", new PropertyModel(assetValidationServiceConfig, "allowedExtensions")) { private static final long serialVersionUID = 1L; @Override//w w w . j a v a2s. co m protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("asset-extension", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-extension") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { allowedExtensionsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; allowedExtensionsView.setReuseItems(true); listContainer.add(allowedExtensionsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.upload.ImageValidationServiceConfigPanel.java
License:Apache License
private void addAllowedExtensionsField(ImageValidationServiceConfig imageValidationServiceConfig) { final WebMarkupContainer listContainer = new WebMarkupContainer("allowedExtensionsView"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); // Don't do this in a listview final ListView<String> allowedExtensionsView; allowedExtensionsView = new ListView<String>("imagevalidation-allowedExtensions", new PropertyModel(imageValidationServiceConfig, "allowedExtensions")) { private static final long serialVersionUID = 1L; @Override/*from ww w.java 2 s . co m*/ protected void populateItem(final ListItem<String> item) { RequiredTextField extensionField = new RequiredTextField("image-extension", item.getModel()); extensionField.setOutputMarkupId(true); item.add(extensionField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { getModelObject().remove(item.getModelObject()); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addExtension = new AjaxLink("add-extension") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { allowedExtensionsView.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; allowedExtensionsView.setReuseItems(true); listContainer.add(allowedExtensionsView); listContainer.add(addExtension); add(listContainer); }
From source file:org.onehippo.forge.settings.management.config.urlrewriter.UrlRewriterConfigPanel.java
License:Apache License
private WebMarkupContainer createSkippedPrefixes(Model copyOfSkippedPrefixesModel) { final WebMarkupContainer listContainer = new WebMarkupContainer("skippedPrefixesContainer"); //generate a markup-id so the contents can be updated through an AJAX call listContainer.setOutputMarkupId(true); ListView<String> skippedPrefixes = new ListView<String>("urlrewriter-skipped-prefixes", copyOfSkippedPrefixesModel) { private static final long serialVersionUID = 1L; @Override// w w w . j av a 2 s . c o m protected void populateItem(final ListItem<String> item) { RequiredTextField prefixField = new RequiredTextField("prefix", item.getModel()); prefixField.setOutputMarkupId(true); prefixField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { } }); item.add(prefixField); AjaxSubmitLink remove = new AjaxSubmitLink("remove") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form form) { int index = item.getIndex(); getModelObject().remove(index); target.add(listContainer); } }; remove.setDefaultFormProcessing(false); item.add(remove); } }; AjaxLink addPrefix = new AjaxLink("add") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { skippedPrefixes.getModelObject().add(""); target.add(listContainer); target.focusComponent(this); } }; skippedPrefixes.setOutputMarkupId(true); listContainer.add(skippedPrefixes); listContainer.add(addPrefix); return listContainer; }