use of de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior in project ocvn by devgateway.
the class TooltipLabel method onConfigure.
/*
* (non-Javadoc)
*
* @see org.apache.wicket.Component#onConfigure()
*/
@Override
protected void onConfigure() {
super.onConfigure();
helpModelText = new StringResourceModel(fieldId + ".help", this);
helpModelText.setDefaultValue("");
if (!helpModelText.getString().isEmpty()) {
tooltipConfig = new CustomTooltipConfig();
add(new TooltipBehavior(helpModelText, tooltipConfig));
setVisibilityAllowed(!ComponentUtil.isViewMode());
} else {
setVisibilityAllowed(false);
}
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior 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 de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior in project oc-explorer by devgateway.
the class FileInputBootstrapFormComponentWrapper method addAlreadyUploadedFilesComponent.
/**
* already uploaded files section
*/
private void addAlreadyUploadedFilesComponent() {
alreadyUploadedFiles = new WebMarkupContainer("alreadyUploadedFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onInitialize() {
super.onInitialize();
setVisibilityAllowed(isVisibleAlreadyUploadedFiles());
}
};
alreadyUploadedFiles.setOutputMarkupPlaceholderTag(true);
alreadyUploadedFiles.setOutputMarkupId(true);
add(alreadyUploadedFiles);
alreadyUploadedFiles.add(new Label("uploadedFilesTitle", new StringResourceModel("uploadedFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> alreadyUploadedFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// get only the already uploaded files
for (FileMetadata file : filesModel) {
if (!file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", alreadyUploadedFilesModel) {
private static final long serialVersionUID = 1L;
private List<IndicatingAjaxLink<Void>> deleteButtons = new ArrayList<>();
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
// make file name clickable
Link<FileMetadata> downloadLink = new Link<FileMetadata>("downloadLink", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
final FileMetadata modelObject = getModelObject();
AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {
private static final long serialVersionUID = 1L;
@Override
public void write(final OutputStream output) throws IOException {
output.write(modelObject.getContent().getBytes());
}
@Override
public String getContentType() {
return modelObject.getContentType();
}
};
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, modelObject.getName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
};
downloadLink.add(new Label("downloadText", item.getModelObject().getName()));
downloadLink.add(new TooltipBehavior(new StringResourceModel("downloadUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
item.add(downloadLink);
Link<FileMetadata> download = new CustomDownloadLink("download", item.getModel());
item.add(download);
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(alreadyUploadedFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
deleteButtons.add(delete);
// only to admins
if (visibleOnlyToAdmin) {
MetaDataRoleAuthorizationStrategy.authorize(delete, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
}
if (disableDeleteButton) {
delete.setVisibilityAllowed(false);
}
}
@Override
public void onEvent(final IEvent<?> event) {
/*
* disable 'delete' buttons based on the form state
*/
if (event.getPayload() instanceof EditingDisabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(false);
}
}
if (event.getPayload() instanceof EditingEnabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(true);
}
}
}
};
alreadyUploadedFiles.add(list);
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior in project ocvn by devgateway.
the class FileInputBootstrapFormComponentWrapper method addAlreadyUploadedFilesComponent.
/**
* already uploaded files section
*/
private void addAlreadyUploadedFilesComponent() {
alreadyUploadedFiles = new WebMarkupContainer("alreadyUploadedFiles") {
private static final long serialVersionUID = 1L;
@Override
protected void onInitialize() {
super.onInitialize();
setVisibilityAllowed(isVisibleAlreadyUploadedFiles());
}
};
alreadyUploadedFiles.setOutputMarkupPlaceholderTag(true);
alreadyUploadedFiles.setOutputMarkupId(true);
add(alreadyUploadedFiles);
alreadyUploadedFiles.add(new Label("uploadedFilesTitle", new StringResourceModel("uploadedFilesTitle", this, null)));
AbstractReadOnlyModel<List<FileMetadata>> alreadyUploadedFilesModel = new AbstractReadOnlyModel<List<FileMetadata>>() {
private static final long serialVersionUID = 1L;
@Override
public List<FileMetadata> getObject() {
List<FileMetadata> fileObject = new ArrayList<>();
// get only the already uploaded files
for (FileMetadata file : filesModel) {
if (!file.isNew()) {
fileObject.add(file);
}
}
return fileObject;
}
};
ListView<FileMetadata> list = new ListView<FileMetadata>("list", alreadyUploadedFilesModel) {
private static final long serialVersionUID = 1L;
private List<IndicatingAjaxLink<Void>> deleteButtons = new ArrayList<>();
@Override
protected void populateItem(final ListItem<FileMetadata> item) {
// make file name clickable
Link<FileMetadata> downloadLink = new Link<FileMetadata>("downloadLink", item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
final FileMetadata modelObject = getModelObject();
AbstractResourceStreamWriter rstream = new AbstractResourceStreamWriter() {
private static final long serialVersionUID = 1L;
@Override
public void write(final OutputStream output) throws IOException {
output.write(modelObject.getContent().getBytes());
}
@Override
public String getContentType() {
return modelObject.getContentType();
}
};
ResourceStreamRequestHandler handler = new ResourceStreamRequestHandler(rstream, modelObject.getName());
handler.setContentDisposition(ContentDisposition.ATTACHMENT);
getRequestCycle().scheduleRequestHandlerAfterCurrent(handler);
}
};
downloadLink.add(new Label("downloadText", item.getModelObject().getName()));
downloadLink.add(new TooltipBehavior(new StringResourceModel("downloadUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
item.add(downloadLink);
Link<FileMetadata> download = new CustomDownloadLink("download", item.getModel());
item.add(download);
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(alreadyUploadedFiles);
}
};
delete.add(new IconBehavior(GlyphIconType.remove));
delete.add(new TooltipBehavior(new StringResourceModel("removeUploadedFileTooltip", FileInputBootstrapFormComponentWrapper.this, null), TOOLTIP_CONFIG));
delete.setVisible(true);
item.add(delete);
deleteButtons.add(delete);
// only to admins
if (visibleOnlyToAdmin) {
MetaDataRoleAuthorizationStrategy.authorize(delete, Component.RENDER, SecurityConstants.Roles.ROLE_ADMIN);
}
if (disableDeleteButton) {
delete.setVisibilityAllowed(false);
}
}
@Override
public void onEvent(final IEvent<?> event) {
/*
* disable 'delete' buttons based on the form state
*/
if (event.getPayload() instanceof EditingDisabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(false);
}
}
if (event.getPayload() instanceof EditingEnabledEvent) {
for (IndicatingAjaxLink<?> del : deleteButtons) {
del.setVisibilityAllowed(true);
}
}
}
};
alreadyUploadedFiles.add(list);
}
use of de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipBehavior in project oc-explorer 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);
}
Aggregations