use of pl.edu.icm.unity.webui.common.SingleActionHandler in project unity by unity-idm.
the class IdentitiesPanel method getHamburgerMenu.
private HamburgerMenu<IdentityEntry> getHamburgerMenu(RemoveFromGroupHandler removeFromGroupHandler, AddToGroupHandler addToGroupHandler, EntityCreationHandler entityCreationDialogHandler, DeleteEntityHandler deleteEntityHandler, IdentityConfirmationResendHandler confirmationResendHandler, IdentityConfirmHandler confirmHandler, EntityMergeHandler entityMergeHandler) {
HamburgerMenu<IdentityEntry> hamburgerMenu = new HamburgerMenu<>();
identitiesTable.addSelectionListener(hamburgerMenu.getSelectionListener());
SingleActionHandler<IdentityEntry> entityCreationAction = entityCreationDialogHandler.getAction(identitiesTable::getGroup, added -> refresh());
hamburgerMenu.addActionHandler(entityCreationAction);
hamburgerMenu.addSeparator();
SingleActionHandler<IdentityEntry> addToGroupAction = addToGroupHandler.getAction();
hamburgerMenu.addActionHandler(addToGroupAction);
SingleActionHandler<IdentityEntry> removeFromGroupAction = removeFromGroupHandler.getAction(identitiesTable::getGroupPath, this::refresh);
hamburgerMenu.addActionHandler(removeFromGroupAction);
SingleActionHandler<IdentityEntry> confirmationResendAction = confirmationResendHandler.getAction();
hamburgerMenu.addActionHandler(confirmationResendAction);
SingleActionHandler<IdentityEntry> confirmAction = confirmHandler.getAction(this::refresh);
hamburgerMenu.addActionHandler(confirmAction);
SingleActionHandler<IdentityEntry> entityMergeAction = entityMergeHandler.getAction(identitiesTable::getGroup);
hamburgerMenu.addActionHandler(entityMergeAction);
SingleActionHandler<IdentityEntry> deleteEntityAction = deleteEntityHandler.getAction(identitiesTable::removeEntity);
hamburgerMenu.addActionHandler(deleteEntityAction);
hamburgerMenu.addSeparator();
hamburgerMenu.addItem(msg.getMessage("Identities.addFilter"), Images.addFilter.getResource(), c -> {
List<String> columnIds = identitiesTable.getColumnIds();
new AddFilterDialog(msg, columnIds, (filter, description) -> addFilterInfo(filter, description)).show();
});
hamburgerMenu.addItem(msg.getMessage("Identities.addAttributes"), Images.addColumn.getResource(), c -> {
new AddAttributeColumnDialog(msg, attrsMan, (attributeType, group) -> identitiesTable.addAttributeColumn(attributeType, group)).show();
});
hamburgerMenu.addItem(msg.getMessage("Identities.removeAttributes"), Images.removeColumn.getResource(), c -> {
Set<String> alreadyUsedRoot = identitiesTable.getAttributeColumns(true);
Set<String> alreadyUsedCurrent = identitiesTable.getAttributeColumns(false);
new RemoveAttributeColumnDialog(msg, alreadyUsedRoot, alreadyUsedCurrent, identitiesTable.getGroupPath(), (attributeType, group) -> identitiesTable.removeAttributeColumn(group, attributeType)).show();
});
MenuItem showTargeted = hamburgerMenu.addItem(msg.getMessage("Identities.showTargeted"), null, c -> {
try {
identitiesTable.setShowTargeted(c.isChecked());
} catch (EngineException e) {
setIdProblem(IdentitiesPanel.this.identitiesTable.getGroup(), e);
}
});
showTargeted.setCheckable(true);
showTargeted.setChecked(identitiesTable.isShowTargeted());
MenuItem mode = hamburgerMenu.addItem(msg.getMessage("Identities.mode"), null, c -> {
identitiesTable.setMode(c.isChecked());
});
mode.setCheckable(true);
mode.setChecked(identitiesTable.isGroupByEntity());
return hamburgerMenu;
}
use of pl.edu.icm.unity.webui.common.SingleActionHandler in project unity by unity-idm.
the class PasswordCredentialResetSettingsEditor method initUI.
private void initUI() {
binder = new Binder<>(PasswordCredentialResetSettings.class);
confirmationMode = new ComboBox<>(msg.getMessage("PasswordCredentialResetSettings.confirmationMode"));
confirmationMode.setItems(ConfirmationMode.values());
confirmationMode.addSelectionListener(e -> {
emailCodeMessageTemplate.setEnabled(getEmailMessageTemplateState());
mobileCodeMessageTemplate.setEnabled(getMobileMessageTemplateState());
});
confirmationMode.setItemCaptionGenerator(i -> msg.getMessage("PasswordCredentialResetSettings.confirmationMode" + i.toString()));
confirmationMode.setEmptySelectionAllowed(false);
binder.forField(confirmationMode).bind("confirmationMode");
enable = new CheckBox(msg.getMessage("PasswordCredentialResetSettings.enable"));
enable.addValueChangeListener(event -> setEnabled(enable.getValue()));
binder.forField(enable).bind("enabled");
codeLength = new IntStepper(msg.getMessage("PasswordCredentialResetSettings.codeLength"));
codeLength.setMinValue(2);
codeLength.setMaxValue(10);
codeLength.setWidth(3, Unit.EM);
binder.forField(codeLength).bind("codeLength");
requireQuestionConfirmation = new CheckBox(msg.getMessage("PasswordCredentialResetSettings.requireQuestionConfirmation"));
emailCodeMessageTemplate = new CompatibleTemplatesComboBox(EmailPasswordResetTemplateDef.NAME, msgTplMan);
emailCodeMessageTemplate.setCaption(msg.getMessage("PasswordCredentialResetSettings.emailMessageTemplate"));
emailCodeMessageTemplate.setEmptySelectionAllowed(false);
binder.forField(emailCodeMessageTemplate).asRequired((v, c) -> ((v == null || v.isEmpty()) && getEmailMessageTemplateState()) ? ValidationResult.error(msg.getMessage("fieldRequired")) : ValidationResult.ok()).bind("emailSecurityCodeMsgTemplate");
emailCodeMessageTemplate.setEnabled(false);
mobileCodeMessageTemplate = new CompatibleTemplatesComboBox(MobilePasswordResetTemplateDef.NAME, msgTplMan);
mobileCodeMessageTemplate.setCaption(msg.getMessage("PasswordCredentialResetSettings.mobileMessageTemplate"));
mobileCodeMessageTemplate.setEmptySelectionAllowed(false);
mobileCodeMessageTemplate.setEnabled(false);
binder.forField(mobileCodeMessageTemplate).asRequired((v, c) -> ((v == null || v.isEmpty()) && getMobileMessageTemplateState()) ? ValidationResult.error(msg.getMessage("fieldRequired")) : ValidationResult.ok()).bind("mobileSecurityCodeMsgTemplate");
requireQuestionConfirmation.addValueChangeListener(event -> {
boolean state = requireQuestionConfirmation.getValue();
questionAdder.setEnabled(state);
questions.setEnabled(state);
});
binder.forField(requireQuestionConfirmation).bind("requireSecurityQuestion");
questionAdder = new TextFieldWithButton(msg.getMessage("PasswordCredentialResetSettings.defineNewQuestion"), Images.add.getResource(), msg.getMessage("PasswordCredentialResetSettings.addQuestion"), new ButtonHandler() {
@Override
public String validate(String value) {
if (value == null || value.trim().equals(""))
return msg.getMessage("PasswordCredentialResetSettings.questionMustBeNonEmpty");
return null;
}
@Override
public boolean perform(String value) {
questions.addEntry(value);
return true;
}
});
SingleActionHandler<String> remove = SingleActionHandler.builder4Delete(msg, String.class).withHandler(r -> {
questions.removeEntry(r.iterator().next());
}).build();
questions = new ListOfElementsWithActions<>(Arrays.asList(new Column<>(null, r -> new Label(r), 1)), new ActionColumn<>(null, Arrays.asList(remove), 0, Position.Left));
}
use of pl.edu.icm.unity.webui.common.SingleActionHandler in project unity by unity-idm.
the class IdpServicesView method getAdditionalActionsHandlers.
private List<SingleActionHandler<ServiceDefinition>> getAdditionalActionsHandlers() {
List<SingleActionHandler<ServiceDefinition>> additionalActions = new ArrayList<>();
for (IdpServiceAdditionalAction action : extraActionsRegistry.getAll()) {
SingleActionHandler<ServiceDefinition> actionHandler = SingleActionHandler.builder(ServiceDefinition.class).withCaption(action.getActionRepresentation().caption).withIcon(action.getActionRepresentation().icon).withHandler(r -> gotoExtraAction(r.iterator().next(), action.getName())).withDisabledPredicate(r -> !r.getType().equals(action.getSupportedServiceType())).hideIfInactive().build();
additionalActions.add(actionHandler);
}
return additionalActions;
}
Aggregations