use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.
the class AssignmentPopup method createAddButton.
private AjaxButton createAddButton() {
AjaxButton addButton = new AjaxButton(ID_ASSIGN_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
Map<String, AssignmentType> selectedAssignmentsMap = new HashMap<>();
TabbedPanel<ITab> panel = (TabbedPanel) AssignmentPopup.this.get(createComponentPath(ID_FORM, ID_TABS_PANEL));
panel.getTabs().getObject().forEach(panelTab -> {
WebMarkupContainer assignmentPanel = ((PanelTab) panelTab).getPanel();
if (assignmentPanel == null) {
return;
}
if (AbstractAssignmentPopupTabPanel.class.isAssignableFrom(assignmentPanel.getClass())) {
Map<String, AssignmentType> map = (((AbstractAssignmentPopupTabPanel) assignmentPanel).getSelectedAssignmentsMap());
map.forEach(selectedAssignmentsMap::putIfAbsent);
}
});
List<AssignmentType> assignments = new ArrayList<>(selectedAssignmentsMap.values());
getPageBase().hideMainPopup(target);
addPerformed(target, assignments);
}
};
addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
addButton.add(new EnableBehaviour(this::isAssignButtonEnabled));
addButton.setOutputMarkupId(true);
return addButton;
}
use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.
the class ChooseMemberPopup method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
Form form = new Form(ID_FORM);
form.setOutputMarkupId(true);
add(form);
IModel<List<CompositedIconButtonDto>> assignButtonDescriptionModel = createAssignButtonDescriptionModel();
MultiCompositedButtonPanel assignDescriptionButtonsPanel = new MultiCompositedButtonPanel(ID_COMPOSITED_BUTTONS, assignButtonDescriptionModel) {
private static final long serialVersionUID = 1L;
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
Form form = (Form) ChooseMemberPopup.this.get(ID_FORM);
isCompositedButtonsPanelVisible = false;
addOrReplaceTabPanels(form, relationSpec);
target.add(form);
}
};
form.add(assignDescriptionButtonsPanel);
assignDescriptionButtonsPanel.add(new VisibleBehaviour(() -> isCompositedButtonsPanelVisible));
addOrReplaceTabPanels(form, null);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, createStringResource("userBrowserDialog.button.cancelButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
}
};
cancelButton.setOutputMarkupId(true);
form.add(cancelButton);
AjaxButton addButton = new AjaxButton(ID_ADD_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
boolean orgPanelProcessed = false;
for (ITab panelTab : tabs) {
WebMarkupContainer tabPanel = ((CountablePanelTab) panelTab).getPanel();
if (tabPanel == null) {
continue;
}
MemberPopupTabPanel memberPanel = (MemberPopupTabPanel) tabPanel;
if (memberPanel.getObjectType().equals(ObjectTypes.ORG) && orgPanelProcessed) {
continue;
}
List<ObjectType> selectedObjects = memberPanel.getObjectType().equals(ObjectTypes.ORG) ? memberPanel.getPreselectedObjects() : memberPanel.getSelectedObjectsList();
if (selectedObjects == null || selectedObjects.size() == 0) {
continue;
}
executeMemberOperation(memberPanel.getAbstractRoleTypeObject(), createInOidQuery(selectedObjects), memberPanel.getRelationValue(), memberPanel.getObjectType().getTypeQName(), target, getPageBase());
if (memberPanel.getObjectType().equals(ObjectTypes.ORG)) {
orgPanelProcessed = true;
}
}
ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
}
};
addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
addButton.add(new EnableBehaviour(() -> isAddButtonEnabled()));
addButton.setOutputMarkupId(true);
form.add(addButton);
}
use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.
the class CheckBoxPanel method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
add(container);
AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, checkboxModel) {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
CheckBoxPanel.this.onUpdate(target);
}
@Override
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
CheckBoxPanel.this.updateAjaxAttributes(attributes);
}
};
check.setOutputMarkupId(true);
check.add(new EnableBehaviour(() -> isCheckboxEnabled()));
container.add(check);
Label label = new Label(ID_LABEL, labelModel);
label.add(new VisibleBehaviour(() -> labelModel != null));
label.setRenderBodyOnly(true);
container.add(label);
if (tooltipModel != null) {
container.add(new AttributeModifier("title", tooltipModel));
}
}
use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.
the class LinkedReferencePanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
IModel<DisplayType> displayModel = new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return null;
}
DisplayType displayType = GuiDisplayTypeUtil.getDisplayTypeForObject(ref.getObject(), null, getPageBase());
if (displayType == null) {
displayType = new DisplayType();
}
if (displayType.getIcon() == null) {
displayType.setIcon(WebComponentUtil.createIconType(WebComponentUtil.createDefaultBlackIcon(ref.getTargetType())));
}
return displayType;
});
ImagePanel imagePanel = new ImagePanel(ID_ICON, displayModel);
imagePanel.setOutputMarkupId(true);
add(imagePanel);
AjaxLink<PrismReferenceValue> nameLink = new AjaxLink<PrismReferenceValue>(ID_NAME, referenceModel) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
WebComponentUtil.dispatchToObjectDetailsPage(referenceModel.getObject(), LinkedReferencePanel.this, false);
}
};
nameLink.add(new EnableBehaviour(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return false;
}
return ref.getObject() != null;
}));
nameLink.setOutputMarkupId(true);
add(nameLink);
Label nameLinkText = new Label(ID_NAME_TEXT, new ReadOnlyModel<>(() -> {
PrismReferenceValue ref = referenceModel.getObject();
if (ref == null) {
return "";
}
return WebComponentUtil.getReferencedObjectDisplayNameAndName(ref.asReferencable(), false, getPageBase());
}));
nameLinkText.setOutputMarkupId(true);
nameLink.add(nameLinkText);
}
use of com.evolveum.midpoint.web.component.util.EnableBehaviour in project midpoint by Evolveum.
the class SearchPropertiesConfigPanel method getTableColumns.
private List<IColumn<SelectableBean<ValueSearchFilterItem>, String>> getTableColumns() {
List<IColumn<SelectableBean<ValueSearchFilterItem>, String>> columns = new ArrayList<>();
CheckBoxHeaderColumn<SelectableBean<ValueSearchFilterItem>> checkboxColumn = new CheckBoxHeaderColumn<>();
columns.add(checkboxColumn);
IColumn<SelectableBean<ValueSearchFilterItem>, String> propertyColumn = new PropertyColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.property"), "value." + ValueSearchFilterItem.F_PROPERTY_NAME) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return getColumnStyleClass();
}
};
columns.add(propertyColumn);
IColumn<SelectableBean<ValueSearchFilterItem>, String> valueColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.value")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
item.add(new SwitchablePropertyValuePanel(id, rowModel));
}
@Override
public String getCssClass() {
return "max-width-column";
}
};
columns.add(valueColumn);
IColumn<SelectableBean<ValueSearchFilterItem>, String> filterColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.filter")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
List<ValueSearchFilterItem.FilterName> availableFilterNames = rowModel.getObject().getValue().getAvailableFilterNameList();
DropDownChoicePanel<ValueSearchFilterItem.FilterName> filterPanel = WebComponentUtil.createEnumPanel(id, Model.ofList(availableFilterNames), new PropertyModel<>(rowModel, "value." + ValueSearchFilterItem.F_FILTER_TYPE_NAME), SearchPropertiesConfigPanel.this, false, getPageBase().createStringResource("SearchPropertiesConfigPanel.selectFilter").getString());
filterPanel.setOutputMarkupId(true);
filterPanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
filterPanel.getBaseFormComponent().add(new EnableBehaviour(() -> availableFilterNames.size() > 1));
item.add(filterPanel);
}
@Override
public String getCssClass() {
return getColumnStyleClass();
}
};
columns.add(filterColumn);
IColumn<SelectableBean<ValueSearchFilterItem>, String> matchingRuleColumn = new AbstractColumn<SelectableBean<ValueSearchFilterItem>, String>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.matchingRule")) {
private static final long serialVersionUID = 1L;
@Override
public void populateItem(Item<ICellPopulator<SelectableBean<ValueSearchFilterItem>>> item, String id, IModel<SelectableBean<ValueSearchFilterItem>> rowModel) {
DropDownChoicePanel<ValueSearchFilterItem.MatchingRule> matchingRulePanel = WebComponentUtil.createEnumPanel(id, Model.ofList(rowModel.getObject().getValue().getAvailableMatchingRuleList()), new PropertyModel<>(rowModel, "value." + ValueSearchFilterItem.F_MATCHING_RULE), SearchPropertiesConfigPanel.this, true, getPageBase().createStringResource("SearchPropertiesConfigPanel.selectMatchingRule").getString());
matchingRulePanel.setOutputMarkupId(true);
matchingRulePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
item.add(matchingRulePanel);
}
@Override
public String getCssClass() {
return getColumnStyleClass();
}
};
columns.add(matchingRuleColumn);
CheckBoxColumn<SelectableBean<ValueSearchFilterItem>> negationColumn = new CheckBoxColumn<SelectableBean<ValueSearchFilterItem>>(getPageBase().createStringResource("SearchPropertiesConfigPanel.table.column.applyNegotiation"), "value." + ValueSearchFilterItem.F_APPLY_NEGATION) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return "min-width-column";
}
};
columns.add(negationColumn);
InlineMenuButtonColumn<SelectableBean<ValueSearchFilterItem>> actionsColumn = new InlineMenuButtonColumn<SelectableBean<ValueSearchFilterItem>>(getTableMenuItems(), getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return "min-width-column";
}
};
columns.add(actionsColumn);
return columns;
}
Aggregations