use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class CapabilityStep method initLayout.
protected void initLayout() {
final ListDataProvider<CapabilityDto<CapabilityType>> capabilityProvider = new ListDataProvider<>(this, new PropertyModel<List<CapabilityDto<CapabilityType>>>(dtoModel, CapabilityStepDto.F_CAPABILITIES));
WebMarkupContainer tableBody = new WebMarkupContainer(ID_CAPABILITY_TABLE);
tableBody.setOutputMarkupId(true);
add(tableBody);
WebMarkupContainer configBody = new WebMarkupContainer(ID_CAPABILITY_CONFIG);
configBody.setOutputMarkupId(true);
add(configBody);
DataView<CapabilityDto<CapabilityType>> capabilityDataView = new DataView<CapabilityDto<CapabilityType>>(ID_CAPABILITY_ROW, capabilityProvider) {
@Override
protected void populateItem(final Item<CapabilityDto<CapabilityType>> capabilityRow) {
final CapabilityDto<CapabilityType> dto = capabilityRow.getModelObject();
AjaxLink name = new AjaxLink(ID_CAPABILITY_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
editCapabilityPerformed(target, dto);
}
};
Label label = new Label(ID_CAPABILITY_NAME, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String rv = dto.getDisplayName();
if (Boolean.FALSE.equals(dto.getCapability().isEnabled())) {
rv += " " + getString("CapabilityStep.disabled");
}
return rv;
}
});
name.add(label);
capabilityRow.add(name);
Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>());
if (dto.getTooltipKey() != null) {
tooltipLabel.add(new AttributeAppender("data-original-title", getString(dto.getTooltipKey())));
tooltipLabel.add(new InfoTooltipBehavior());
} else {
tooltipLabel.setVisible(false);
}
tooltipLabel.setOutputMarkupId(true);
tooltipLabel.setOutputMarkupPlaceholderTag(true);
name.add(tooltipLabel);
AjaxLink deleteLink = new AjaxLink(ID_CAPABILITY_DELETE) {
@Override
public void onClick(AjaxRequestTarget target) {
deleteCapabilityPerformed(target, dto);
}
};
deleteLink.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !dto.isAmongNativeCapabilities() && !parentPage.isReadOnly();
}
});
name.add(deleteLink);
capabilityRow.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<Object>() {
@Override
public Object getObject() {
return isSelected(capabilityRow.getModelObject()) ? "success" : null;
}
}));
}
};
tableBody.add(capabilityDataView);
AjaxLink addLink = new AjaxLink(ID_CAPABILITY_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addCapabilityPerformed(target);
}
};
parentPage.addEditingVisibleBehavior(addLink);
add(addLink);
ModalWindow dialog = new AddCapabilityDialog(DIALOG_SELECT_CAPABILITY, dtoModel) {
@Override
protected void addPerformed(AjaxRequestTarget target) {
addCapabilitiesPerformed(target, getSelectedData());
}
};
add(dialog);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class SearchPanel method initPopover.
private void initPopover() {
WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
popover.setOutputMarkupId(true);
add(popover);
final WebMarkupContainer propList = new WebMarkupContainer(ID_PROP_LIST);
propList.setOutputMarkupId(true);
popover.add(propList);
ListView properties = new ListView<Property>(ID_PROPERTIES, new PropertyModel<List<Property>>(moreDialogModel, MoreDialogDto.F_PROPERTIES)) {
@Override
protected void populateItem(final ListItem<Property> item) {
CheckBox check = new CheckBox(ID_CHECK, new PropertyModel<Boolean>(item.getModel(), Property.F_SELECTED));
check.add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//nothing, just update model.
}
});
item.add(check);
AjaxLink propLink = new AjaxLink(ID_PROP_LINK) {
@Override
public void onClick(AjaxRequestTarget target) {
addOneItemPerformed(item.getModelObject(), target);
}
};
item.add(propLink);
Label name = new Label(ID_PROP_NAME, new PropertyModel<>(item.getModel(), Property.F_NAME));
name.setRenderBodyOnly(true);
propLink.add(name);
item.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
Property property = item.getModelObject();
Search search = SearchPanel.this.getModelObject();
if (!search.getAvailableDefinitions().contains(property.getDefinition())) {
return false;
}
MoreDialogDto dto = moreDialogModel.getObject();
String nameFilter = dto.getNameFilter();
String propertyName = property.getName().toLowerCase();
if (StringUtils.isNotEmpty(nameFilter) && !propertyName.contains(nameFilter.toLowerCase())) {
return false;
}
return true;
}
});
}
};
propList.add(properties);
TextField addText = new TextField(ID_ADD_TEXT, new PropertyModel(moreDialogModel, MoreDialogDto.F_NAME_FILTER));
addText.add(new Behavior() {
@Override
public void bind(Component component) {
super.bind(component);
component.add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
}
});
popover.add(addText);
addText.add(new AjaxFormComponentUpdatingBehavior("keyup") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.add(propList);
}
});
popover.add(addText);
AjaxButton add = new AjaxButton(ID_ADD, createStringResource("SearchPanel.add")) {
@Override
public void onClick(AjaxRequestTarget target) {
addItemPerformed(target);
}
};
popover.add(add);
AjaxButton close = new AjaxButton(ID_CLOSE, createStringResource("SearchPanel.close")) {
@Override
public void onClick(AjaxRequestTarget target) {
closeMorePopoverPerformed(target);
}
};
popover.add(close);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class SearchPopupPanel method initButtons.
private void initButtons() {
AjaxLink remove = new AjaxLink(ID_REMOVE) {
@Override
public void onClick(AjaxRequestTarget target) {
removePerformed(target);
}
};
add(remove);
AjaxLink add = new AjaxLink(ID_ADD) {
@Override
public void onClick(AjaxRequestTarget target) {
addPerformed(target);
}
};
add(add);
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class SceneButtonPanel method initLayout.
private void initLayout(final IModel<SceneDto> model) {
AjaxLink<String> minimize = new AjaxLink<String>(ID_MINIMIZE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
minimizeOnClick(target);
}
};
add(minimize);
Label icon = new Label(ID_ICON);
icon.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.isMinimized()) {
return GuiStyleConstants.CLASS_ICON_EXPAND;
}
return GuiStyleConstants.CLASS_ICON_COLLAPSE;
}
}));
minimize.add(icon);
icon.add(new AttributeAppender("title", new AbstractReadOnlyModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.isMinimized()) {
return getString("prismOptionButtonPanel.maximize");
}
return getString("prismOptionButtonPanel.minimize");
}
}, ""));
}
use of org.apache.wicket.ajax.markup.html.AjaxLink in project midpoint by Evolveum.
the class BrowserPopupPanel method initLayout.
private void initLayout() {
IModel value = new PropertyModel(getModel(), SearchValue.F_LABEL);
TextField input = new TextField(ID_BROWSER_INPUT, value);
add(input);
AjaxLink browse = new AjaxLink(ID_BROWSE) {
@Override
public void onClick(AjaxRequestTarget target) {
browsePerformed(target);
}
};
add(browse);
}
Aggregations