use of org.apache.wicket.markup.html.link.ResourceLink in project ocvn by devgateway.
the class EditVietnamImportSourceFiles method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
TextFieldBootstrapFormComponent<String> name = new TextFieldBootstrapFormComponent<>("name");
name.required();
editForm.add(name);
TextAreaFieldBootstrapFormComponent<String> description = new TextAreaFieldBootstrapFormComponent<>("description");
editForm.add(description);
FileInputBootstrapFormComponent prototypeDatabaseFile = new FileInputBootstrapFormComponent("prototypeDatabaseFile");
prototypeDatabaseFile.maxFiles(1);
prototypeDatabaseFile.required();
editForm.add(prototypeDatabaseFile);
FileInputBootstrapFormComponent publicInstitutionsSuppliersFile = new FileInputBootstrapFormComponent("publicInstitutionsSuppliersFile");
publicInstitutionsSuppliersFile.maxFiles(1);
publicInstitutionsSuppliersFile.required();
editForm.add(publicInstitutionsSuppliersFile);
FileInputBootstrapFormComponent cityDepartmentGroupFile = new FileInputBootstrapFormComponent("cityDepartmentGroupFile");
cityDepartmentGroupFile.maxFiles(1);
cityDepartmentGroupFile.required();
editForm.add(cityDepartmentGroupFile);
ResourceLink locationsTemplate = new ResourceLink("locationsTemplate", new PackageResourceReference(RootXlsx.class, "Location_Table_SO.xlsx"));
editForm.add(locationsTemplate);
ResourceLink suppliersTemplate = new ResourceLink("suppliersTemplate", new PackageResourceReference(RootXlsx.class, "UM_PUBINSTITU_SUPPLIERS_DQA.xlsx"));
editForm.add(suppliersTemplate);
ResourceLink prototypeDatabase = new ResourceLink("prototypeDatabase", new PackageResourceReference(RootXlsx.class, "Prototype_Database_OCDSCore.xlsx"));
editForm.add(prototypeDatabase);
ResourceLink cityDepartmentGroupFileTemplate = new ResourceLink("cityDepartmentGroupFileTemplate", new PackageResourceReference(RootXlsx.class, "test_city_department_group.xlsx"));
editForm.add(cityDepartmentGroupFileTemplate);
FileInputBootstrapFormComponent locationsFile = new FileInputBootstrapFormComponent("locationsFile");
locationsFile.maxFiles(1);
locationsFile.required();
editForm.add(locationsFile);
}
use of org.apache.wicket.markup.html.link.ResourceLink in project wicket by apache.
the class WicketTesterTest method clickResourceLinkWithResourceReference.
/**
* https://issues.apache.org/jira/browse/WICKET-4810
*
* Clicking on ResourceLink should deliver the resource reference's content
*/
@Test
public void clickResourceLinkWithResourceReference() {
MockPageWithLink page = new MockPageWithLink();
String content = "content";
final ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(), "fileName.txt");
ResourceReference reference = new ResourceReference(WicketTesterTest.class, "resourceLinkWithResourceReferenceTest") {
@Override
public IResource getResource() {
return resource;
}
};
ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, reference);
page.add(link);
tester.startPage(page);
tester.clickLink(MockPageWithLink.LINK_ID, false);
assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
assertEquals(content, tester.getLastResponseAsString());
}
use of org.apache.wicket.markup.html.link.ResourceLink in project wicket by apache.
the class WicketTesterTest method clickResourceLinkWithResource.
/**
* https://issues.apache.org/jira/browse/WICKET-4437
*
* Clicking on ResourceLink should deliver the resource content
*/
@Test
public void clickResourceLinkWithResource() {
MockPageWithLink page = new MockPageWithLink();
String content = "content";
ByteArrayResource resource = new ByteArrayResource("text/plain", content.getBytes(), "fileName.txt");
ResourceLink<Void> link = new ResourceLink<Void>(MockPageWithLink.LINK_ID, resource);
page.add(link);
tester.startPage(page);
tester.clickLink(MockPageWithLink.LINK_ID, false);
assertEquals(tester.getContentTypeFromResponseHeader(), "text/plain");
assertEquals(content, tester.getLastResponseAsString());
}
use of org.apache.wicket.markup.html.link.ResourceLink in project midpoint by Evolveum.
the class PageTasks method initLayout.
private void initLayout() {
refreshPanel = new AutoRefreshPanel(ID_REFRESH_PANEL, refreshModel, this, false);
add(refreshPanel);
Form mainForm = new Form(ID_MAIN_FORM);
add(mainForm);
List<IColumn<TaskDto, String>> taskColumns = initTaskColumns();
TaskDtoProviderOptions options = TaskDtoProviderOptions.minimalOptions();
options.setGetNextRunStartTime(true);
options.setUseClusterInformation(true);
options.setResolveObjectRef(true);
TaskDtoProvider provider = new TaskDtoProvider(PageTasks.this, options) {
@Override
protected void saveProviderPaging(ObjectQuery query, ObjectPaging paging) {
TasksStorage storage = getSessionStorage().getTasks();
storage.setPaging(paging);
}
@Override
public TaskDto createTaskDto(PrismObject<TaskType> task, Task opTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
TaskDto dto = super.createTaskDto(task, opTask, result);
addInlineMenuToTaskRow(dto);
return dto;
}
};
provider.setQuery(createTaskQuery());
BoxedTablePanel<TaskDto> taskTable = new BoxedTablePanel(ID_TASK_TABLE, provider, taskColumns, UserProfileStorage.TableId.PAGE_TASKS_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_PANEL)) {
@Override
protected WebMarkupContainer createHeader(String headerId) {
return new SearchFragment(headerId, ID_TABLE_HEADER, PageTasks.this, searchModel);
}
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "TaskType_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter();
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getTaskTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
};
taskTable.setOutputMarkupId(true);
TasksStorage storage = getSessionStorage().getTasks();
taskTable.setCurrentPage(storage.getPaging());
mainForm.add(taskTable);
List<IColumn<NodeDto, String>> nodeColumns = initNodeColumns();
BoxedTablePanel nodeTable = new BoxedTablePanel(ID_NODE_TABLE, new NodeDtoProvider(PageTasks.this) {
@Override
public NodeDto createNodeDto(PrismObject<NodeType> node) {
NodeDto dto = super.createNodeDto(node);
addInlineMenuToNodeRow(dto);
return dto;
}
}, nodeColumns, UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL, (int) getItemsPerPage(UserProfileStorage.TableId.PAGE_TASKS_NODES_PANEL));
nodeTable.setOutputMarkupId(true);
nodeTable.setShowPaging(false);
mainForm.add(nodeTable);
initDiagnosticButtons();
}
use of org.apache.wicket.markup.html.link.ResourceLink in project midpoint by Evolveum.
the class AuditLogViewerPanel method addOrReplaceTable.
private void addOrReplaceTable(Form mainForm) {
AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {
private static final long serialVersionUID = 1L;
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
AuditSearchDto search = auditSearchDto.getObject();
parameters.put("from", search.getFrom());
parameters.put("to", search.getTo());
if (search.getChannel() != null) {
parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
}
parameters.put("hostIdentifier", search.getHostIdentifier());
if (search.getInitiatorName() != null) {
parameters.put("initiatorName", search.getInitiatorName().getOid());
}
if (search.getTargetOwnerName() != null) {
parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
}
List<String> targetOids = new ArrayList<>();
if (isNotEmpty(search.getTargetNamesObjects())) {
targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
}
if (isNotEmpty(search.getTargetNames())) {
targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
}
if (!targetOids.isEmpty()) {
parameters.put("targetNames", targetOids);
}
if (search.getChangedItem().toItemPath() != null) {
ItemPath itemPath = search.getChangedItem().toItemPath();
parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
}
parameters.put("eventType", search.getEventType());
parameters.put("eventStage", search.getEventStage());
parameters.put("outcome", search.getOutcome());
if (isNotEmpty(search.getvalueRefTargetNames())) {
parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
}
return parameters;
}
@Override
protected void saveCurrentPage(long from, long count) {
if (count != 0) {
auditLogStorage.setPageNumber(from / count);
}
}
};
UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
int pageSize = DEFAULT_PAGE_SIZE;
if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
}
List<IColumn<AuditEventRecordType, String>> columns = initColumns();
BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {
private static final long serialVersionUID = 1L;
@Override
protected WebMarkupContainer createButtonToolbar(String id) {
String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
CSVDataExporter csvDataExporter = new CSVDataExporter() {
@Override
public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
((AuditEventRecordProvider) dataProvider).setExportSize(true);
super.exportData(dataProvider, columns, outputStream);
((AuditEventRecordProvider) dataProvider).setExportSize(false);
}
};
ResourceStreamResource resource = (new ResourceStreamResource() {
protected IResourceStream getResourceStream() {
return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
}
}).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
return exportDataLink;
}
@Override
public void setShowPaging(boolean show) {
//we don't need to do anything here
}
};
table.setShowPaging(true);
table.setCurrentPage(auditLogStorage.getPageNumber());
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}
Aggregations