use of org.apache.wicket.model.StringResourceModel in project midpoint by Evolveum.
the class ModelOperationStatusPanel method initLayout.
protected void initLayout() {
add(new Label(ID_STATE, new StringResourceModel("ModelOperationStatusPanel.state.${}", new PropertyModel<ModelState>(getModel(), ModelOperationStatusDto.F_STATE))));
// add(new Label(ID_FOCUS_TYPE, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_TYPE)));
// add(new Label(ID_FOCUS_NAME, new PropertyModel<String>(getModel(), ModelOperationStatusDto.F_FOCUS_NAME)));
ScenePanel deltaPanel = new ScenePanel(ID_PRIMARY_DELTA, new PropertyModel<SceneDto>(getModel(), ModelOperationStatusDto.F_PRIMARY_DELTA));
deltaPanel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject() != null && getModelObject().getPrimaryDelta() != null;
}
});
add(deltaPanel);
}
use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.
the class AbstractListPage method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
if (jpaRepository == null) {
throw new NullJpaRepositoryException();
}
if (editPageClass == null) {
throw new NullEditPageClassException();
}
SortableJpaRepositoryDataProvider<T> dataProvider = getProvider();
dataProvider.setFilterState(newFilterState());
// add the 'Edit' button
columns.add(new AbstractColumn<T, String>(new StringResourceModel("actionsColumn", this, null)) {
private static final long serialVersionUID = -7447601118569862123L;
@Override
public void populateItem(final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> model) {
cellItem.add(getActionPanel(componentId, model));
}
});
dataTable = new AjaxFallbackBootstrapDataTable<>("table", columns, dataProvider, WebConstants.PAGE_SIZE);
ResettingFilterForm<JpaFilterState<T>> filterForm = new ResettingFilterForm<>("filterForm", dataProvider, dataTable);
filterForm.add(dataTable);
add(filterForm);
if (hasFilteredColumns()) {
dataTable.addTopToolbar(new FilterToolbar(dataTable, filterForm));
}
PageParameters pageParameters = new PageParameters();
pageParameters.set(WebConstants.PARAM_ID, null);
editPageLink = new BootstrapBookmarkablePageLink<T>("new", editPageClass, pageParameters, Buttons.Type.Success);
editPageLink.setIconType(FontAwesomeIconType.plus_circle).setSize(Size.Large).setLabel(new StringResourceModel("new", AbstractListPage.this, null));
add(editPageLink);
}
use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.
the class EditUserPage method getSaveEditPageButton.
@Override
public SaveEditPageButton getSaveEditPageButton() {
return new SaveEditPageButton("save", new StringResourceModel("save", EditUserPage.this, null)) {
private static final long serialVersionUID = 5214537995514151323L;
@Override
protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
Person saveable = editForm.getModelObject();
StandardPasswordEncoder encoder = new StandardPasswordEncoder("");
// encode the password
if (saveable.getChangePass()) {
saveable.setPassword(encoder.encode(password.getField().getModelObject()));
} else {
if (saveable.getPassword() == null || saveable.getPassword().compareTo("") == 0) {
feedbackPanel.error(new StringResourceModel("nullPassword", this, null).getString());
target.add(feedbackPanel);
return;
}
}
// it again next time
if (isChangePassPage()) {
saveable.setChangePassword(false);
}
saveable = jpaRepository.save(saveable);
ensureDefaultDashboardIsAlsoAssignedDashboard(saveable);
if (!SecurityUtil.isCurrentUserAdmin()) {
setResponsePage(Homepage.class);
} else {
setResponsePage(listPageClass);
}
}
};
}
use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addPendingFilesComponent.
/**
* pending files section
*/
private void addPendingFilesComponent() {
pendingFiles = new WebMarkupContainer("pendingFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onConfigure() {
if (filesModel != null && filesModel.size() > 0) {
for (FileMetadata file : filesModel) {
if (file.isNew()) {
setVisibilityAllowed(true);
return;
}
}
}
setVisibilityAllowed(false);
}
};
pendingFiles.setOutputMarkupPlaceholderTag(true);
pendingFiles.setOutputMarkupId(true);
add(pendingFiles);
pendingFiles.add(new Label("pendingFilesTitle", new StringResourceModel("pendingFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> pendingFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// upload)
for (FileMetadata file : filesModel) {
if (file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", pendingFilesModel) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
item.add(new Label("fileTitle", item.getModelObject().getName()));
IndicatingAjaxLink<Void> delete = new IndicatingAjaxLink<Void>("delete") {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
public void onClick(final AjaxRequestTarget target) {
filesModel.remove(item.getModelObject());
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(pendingFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
}
};
pendingFiles.add(list);
}
use of org.apache.wicket.model.StringResourceModel in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addBootstrapFileInputComponent.
private void addBootstrapFileInputComponent() {
// this is where the newly uploaded files are saved
final IModel<List<FileUpload>> internalUploadModel = new ListModel<>();
/*
* some customization of the BootstrapFileInput Component
*/
FileInputConfig fileInputConfig = new FileInputConfig();
fileInputConfig.put(new Key<String>("browseLabel"), new StringResourceModel("browseLabel", FileInputBootstrapFormComponentWrapper.this, null).getString());
fileInputConfig.put(new Key<String>("uploadClass"), "btn btn-blue");
fileInputConfig.put(new Key<String>("browseClass"), "btn btn-blue");
bootstrapFileInput = new BootstrapFileInput("bootstrapFileInput", internalUploadModel, fileInputConfig) {
private static final long serialVersionUID = 1L;
@SuppressWarnings("unchecked")
@Override
protected void onSubmit(final AjaxRequestTarget target) {
super.onSubmit(target);
List<FileUpload> fileUploads = internalUploadModel.getObject();
if (fileUploads != null) {
// check if we uploaded too many files
if (maxFiles > 0 && filesModel.size() + fileUploads.size() > maxFiles) {
if (maxFiles == 1) {
FileInputBootstrapFormComponentWrapper.this.fatal(new StringResourceModel("OneUpload", FileInputBootstrapFormComponentWrapper.this, null).getString());
} else {
FileInputBootstrapFormComponentWrapper.this.fatal(new StringResourceModel("tooManyFiles", FileInputBootstrapFormComponentWrapper.this, Model.of(maxFiles)).getString());
}
FileInputBootstrapFormComponentWrapper.this.invalid();
} else {
// and update the model
for (FileUpload upload : fileUploads) {
FileMetadata fileMetadata = new FileMetadata();
fileMetadata.setName(upload.getClientFileName());
fileMetadata.setContentType(upload.getContentType());
fileMetadata.setSize(upload.getSize());
FileContent fileContent = new FileContent();
fileContent.setBytes(upload.getBytes());
fileMetadata.setContent(fileContent);
filesModel.add(fileMetadata);
// don't display the success notification
// FileInputBootstrapFormComponentWrapper.this.success(new
// StringResourceModel("successUpload",
// FileInputBootstrapFormComponentWrapper.this,
// null, new
// Model(upload.getClientFileName())).getString());
}
}
}
FileInputBootstrapFormComponentWrapper.this.getModel().setObject((T) filesModel);
target.add(fileUploadFeedback);
target.add(pendingFiles);
}
};
add(bootstrapFileInput);
/**
* due to an upgrade of FormGroup in wicket7/wicket-bootrap-0.10, the
* visitor that finds inner FormComponentS, will now find two instead of
* one: the FileInputBootstrapFormComponentWrapper and also the
* BootstrapFileInputField. This is the RIGHT result, previously in
* wicket 6.x it only got the first level of children, hence only one
* FormComponent (the FileInputBootstrapFormComponentWrapper). It would
* then read the label from FileInputBootstrapFormComponentWrapper and
* use it for displaying the label of the FormGroup. In
* wicket7/wicket-bootstrap-0.10 this will result in reading the label
* of BootstrapFileInputField which is null. So you will notice no
* labels for FormGroupS. We fix this by forcing the label of the
* underlying fileInput element to the same model as the label used by
* FileInputBootstrapFormComponentWrapper
*/
FormComponent<?> fileInput = (FormComponent<?>) bootstrapFileInput.get("fileInputForm").get("fileInput");
fileInput.setLabel(this.getLabel());
// only to admins
if (visibleOnlyToAdmin) {
MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
}
// want to read only
if (disableDeleteButton) {
MetaDataRoleAuthorizationStrategy.authorize(bootstrapFileInput, Component.RENDER, MetaDataRoleAuthorizationStrategy.NO_ROLE);
}
}
Aggregations