use of org.apache.wicket.model.util.ListModel in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method initLayout.
protected void initLayout(IModel model, PageBase parentPage) {
PrismObject<ResourceType> resourceObject = (PrismObject<ResourceType>) model.getObject();
ResourceType resource = resourceObject.asObjectable();
add(createLastAvailabilityStatusInfo(resource));
add(createSourceTargetInfo(resource));
add(createSchemaStatusInfo(resource));
CapabilitiesPanel capabilities = new CapabilitiesPanel(PANEL_CAPABILITIES, capabilitiesModel);
add(capabilities);
List<ResourceConfigurationDto> resourceConfigList = createResourceConfigList(resource);
ListDataProvider<ResourceConfigurationDto> resourceConfigProvider = new ListDataProvider<ResourceConfigurationDto>(ResourceDetailsTabPanel.this, new ListModel<ResourceConfigurationDto>(resourceConfigList));
List<ColumnTypeDto<String>> columns = Arrays.asList(new ColumnTypeDto<String>("ShadowType.kind", "objectTypeDefinition.kind", ShadowType.F_KIND.getLocalPart()), new ColumnTypeDto<String>("ShadowType.objectClass", "objectTypeDefinition.objectClass.localPart", ShadowType.F_OBJECT_CLASS.getLocalPart()), new ColumnTypeDto<String>("ShadowType.intent", "objectTypeDefinition.intent", ShadowType.F_INTENT.getLocalPart()), new ColumnTypeDto<String>("ResourceType.isSync", "sync", null));
List<IColumn<SelectableBean<ResourceType>, String>> tableColumns = ColumnUtils.createColumns(columns);
PropertyColumn tasksColumn = new PropertyColumn(PageBase.createStringResourceStatic(this, "ResourceType.tasks"), "definedTasks") {
@Override
public void populateItem(Item item, String componentId, final IModel rowModel) {
ResourceConfigurationDto conf = (ResourceConfigurationDto) rowModel.getObject();
RepeatingView repeater = new RepeatingView(componentId);
for (final TaskType task : conf.getDefinedTasks()) {
repeater.add(new LinkPanel(repeater.newChildId(), new Model<String>(task.getName().getOrig())) {
@Override
public void onClick(AjaxRequestTarget target) {
ResourceDetailsTabPanel.this.taskDetailsPerformed(target, task.getOid());
}
});
}
item.add(repeater);
}
};
tableColumns.add(tasksColumn);
BoxedTablePanel<ResourceConfigurationDto> resourceConfig = new BoxedTablePanel("resourceConfig", resourceConfigProvider, tableColumns);
resourceConfig.setAdditionalBoxCssClasses("box-success");
add(resourceConfig);
}
use of org.apache.wicket.model.util.ListModel in project wicket by apache.
the class MultiFileUploadFieldTest method submitMultiFileUploadFields.
/**
* FormTester supports MultiFileUploadField
*
* https://issues.apache.org/jira/browse/WICKET-5346
*/
@Test
public void submitMultiFileUploadFields() {
final AtomicBoolean submitted = new AtomicBoolean(false);
final ListModel<FileUpload> filesModel = new ListModel<>(new ArrayList<FileUpload>());
TestPage page = new TestPage(filesModel) {
@Override
protected void onSubmit() {
super.onSubmit();
List<FileUpload> uploads = filesModel.getObject();
assertEquals(2, uploads.size());
for (int i = 0; i < 2; i++) {
FileUpload fileUpload = uploads.get(i);
String clientFileName = fileUpload.getClientFileName();
String id = clientFileName.replaceAll(MultiFileUploadFieldTest.class.getSimpleName() + "(\\d).txt", "$1");
try {
assertEquals("Test" + id, IOUtils.toString(fileUpload.getInputStream()));
} catch (IOException e) {
fail("Reading file upload '" + id + "' failed: " + e.getMessage());
}
}
submitted.set(true);
}
};
tester.startPage(page);
tester.assertContainsNot("disabled=\"disabled\"");
FormTester ft = tester.newFormTester("f");
ft.setFile("muf", new File("target/test-classes/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest0.txt"), "plain/text");
ft.setFile("muf", new File("target/test-classes/org/apache/wicket/markup/html/form/upload/MultiFileUploadFieldTest1.txt"), "plain/text");
ft.submit();
assertEquals("The form is not submitted", true, submitted.get());
}
use of org.apache.wicket.model.util.ListModel in project wicket by apache.
the class PaletteTest method required.
/**
* WICKET-5352
*/
@Test
public void required() {
IModel<List<String>> selected = new ListModel<>(new ArrayList<String>());
IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A")));
PaletteTestPage testPage = new PaletteTestPage(selected, all);
testPage.palette.setRequired(true);
tester.startPage(testPage);
FormTester formTester = tester.newFormTester(testPage.form.getId());
formTester.submit();
assertTrue(testPage.form.hasError());
}
use of org.apache.wicket.model.util.ListModel in project wicket by apache.
the class PaletteTest method validationErrorRawInput.
/**
* WICKET-5352
*/
@Test
public void validationErrorRawInput() {
IModel<List<String>> selected = new ListModel<>(new ArrayList<String>());
IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A", "B")));
PaletteTestPage testPage = new PaletteTestPage(selected, all);
testPage.palette.add(new IValidator<Collection<String>>() {
@Override
public void validate(IValidatable<Collection<String>> validatable) {
if (validatable.getValue().contains("A")) {
validatable.error(new ValidationError("A not allowed"));
}
}
});
tester.startPage(testPage);
FormTester formTester = tester.newFormTester(testPage.form.getId());
formTester.setValue("palette:recorder", "A");
formTester.submit();
assertTrue(testPage.form.hasError());
// with RAW_INPUT
tester.assertContains("<option value=\"B\">B</option>\\s*</select>");
tester.assertContains("<option value=\"A\">A</option>\\s*</select>");
testPage.form.clearInput();
tester.startPage(testPage);
// without RAW_INPUT
tester.assertContains("<option value=\"A\">A</option>\\s*<option value=\"B\">B</option>\\s*</select>");
}
use of org.apache.wicket.model.util.ListModel in project wicket by apache.
the class PaletteTest method standard.
/**
*/
@Test
public void standard() {
IModel<List<String>> selected = new ListModel<>(new ArrayList<>(Arrays.asList("A", "D")));
IModel<List<String>> all = new ListModel<>(new ArrayList<>(Arrays.asList("A", "B", "C", "D")));
PaletteTestPage testPage = new PaletteTestPage(selected, all);
tester.startPage(testPage);
FormTester formTester = tester.newFormTester(testPage.form.getId());
formTester.submit();
Collection<String> collection = testPage.palette.getModelCollection();
assertEquals(2, collection.size());
Iterator<String> iterator = collection.iterator();
assertEquals("A", iterator.next());
assertEquals("D", iterator.next());
}
Aggregations