Search in sources :

Example 1 with SingleActionHandler

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;
}
Also used : CredentialRequirementChangedEvent(io.imunity.webconsole.authentication.credentialReq.CredentialRequirementChangedEvent) MenuItem(com.vaadin.ui.MenuBar.MenuItem) PrototypeComponent(pl.edu.icm.unity.engine.api.utils.PrototypeComponent) VerticalLayout(com.vaadin.ui.VerticalLayout) Alignment(com.vaadin.ui.Alignment) EventsBus(pl.edu.icm.unity.webui.bus.EventsBus) Autowired(org.springframework.beans.factory.annotation.Autowired) Log(pl.edu.icm.unity.base.utils.Log) SafePanel(pl.edu.icm.unity.webui.common.safehtml.SafePanel) AttributeTypeManagement(pl.edu.icm.unity.engine.api.AttributeTypeManagement) HtmlTag(pl.edu.icm.unity.webui.common.safehtml.HtmlTag) InvitationEntry(io.imunity.webconsole.signupAndEnquiry.invitations.InvitationEntry) AttributeSupport(pl.edu.icm.unity.engine.api.attributes.AttributeSupport) Orientation(com.vaadin.shared.ui.Orientation) CredentialDefinitionChangedEvent(io.imunity.webconsole.authentication.localCredentials.CredentialDefinitionChangedEvent) FilterableGridHelper(pl.edu.icm.unity.webui.common.grid.FilterableGridHelper) AttributeTypesUpdatedEvent(io.imunity.webconsole.directorySetup.attributeTypes.AttributeTypesUpdatedEvent) Label(com.vaadin.ui.Label) Identity(pl.edu.icm.unity.types.basic.Identity) AuthorizationException(pl.edu.icm.unity.exceptions.AuthorizationException) SearchField(pl.edu.icm.unity.webui.common.SearchField) RefreshAndSelectEvent(io.imunity.webconsole.directoryBrowser.RefreshAndSelectEvent) MessageSource(pl.edu.icm.unity.MessageSource) WebSession(pl.edu.icm.unity.webui.WebSession) Level(pl.edu.icm.unity.webui.common.ErrorComponent.Level) AttributeChangedEvent(io.imunity.webconsole.attribute.AttributeChangedEvent) SingleActionHandler(pl.edu.icm.unity.webui.common.SingleActionHandler) Set(java.util.Set) HamburgerMenu(pl.edu.icm.unity.webui.common.HamburgerMenu) Sets(com.google.common.collect.Sets) MarginInfo(com.vaadin.shared.ui.MarginInfo) AttributeType(pl.edu.icm.unity.types.basic.AttributeType) Images(pl.edu.icm.unity.webui.common.Images) EngineException(pl.edu.icm.unity.exceptions.EngineException) List(java.util.List) Button(com.vaadin.ui.Button) Logger(org.apache.logging.log4j.Logger) HorizontalLayout(com.vaadin.ui.HorizontalLayout) ErrorComponent(pl.edu.icm.unity.webui.common.ErrorComponent) Styles(pl.edu.icm.unity.webui.common.Styles) Toolbar(pl.edu.icm.unity.webui.common.Toolbar) Group(pl.edu.icm.unity.types.basic.Group) EntityNameMetadataProvider(pl.edu.icm.unity.stdext.utils.EntityNameMetadataProvider) GroupChangedEvent(io.imunity.webconsole.directoryBrowser.groupbrowser.GroupChangedEvent) EngineException(pl.edu.icm.unity.exceptions.EngineException) MenuItem(com.vaadin.ui.MenuBar.MenuItem) HamburgerMenu(pl.edu.icm.unity.webui.common.HamburgerMenu)

Example 2 with SingleActionHandler

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));
}
Also used : Arrays(java.util.Arrays) MessageTemplateManagement(pl.edu.icm.unity.engine.api.MessageTemplateManagement) ComboBox(com.vaadin.ui.ComboBox) ActionColumn(pl.edu.icm.unity.webui.common.ListOfElementsWithActions.ActionColumn) ValidationResult(com.vaadin.data.ValidationResult) EmailPasswordResetTemplateDef(pl.edu.icm.unity.stdext.credential.pass.EmailPasswordResetTemplateDef) CheckBox(com.vaadin.ui.CheckBox) Label(com.vaadin.ui.Label) Column(pl.edu.icm.unity.webui.common.ListOfElementsWithActions.Column) PasswordCredentialResetSettings(pl.edu.icm.unity.stdext.credential.pass.PasswordCredentialResetSettings) MessageSource(pl.edu.icm.unity.MessageSource) ConfirmationMode(pl.edu.icm.unity.stdext.credential.pass.PasswordCredentialResetSettings.ConfirmationMode) SingleActionHandler(pl.edu.icm.unity.webui.common.SingleActionHandler) Position(pl.edu.icm.unity.webui.common.ListOfElementsWithActions.ActionColumn.Position) TextFieldWithButton(pl.edu.icm.unity.webui.common.TextFieldWithButton) Binder(com.vaadin.data.Binder) CompatibleTemplatesComboBox(pl.edu.icm.unity.webui.common.CompatibleTemplatesComboBox) Images(pl.edu.icm.unity.webui.common.Images) FormLayout(com.vaadin.ui.FormLayout) ListOfElementsWithActions(pl.edu.icm.unity.webui.common.ListOfElementsWithActions) FormValidationException(pl.edu.icm.unity.webui.common.FormValidationException) ButtonHandler(pl.edu.icm.unity.webui.common.TextFieldWithButton.ButtonHandler) MobilePasswordResetTemplateDef(pl.edu.icm.unity.stdext.credential.pass.MobilePasswordResetTemplateDef) Unit(com.vaadin.server.Sizeable.Unit) IntStepper(org.vaadin.risto.stepper.IntStepper) PasswordCredentialResetSettings(pl.edu.icm.unity.stdext.credential.pass.PasswordCredentialResetSettings) Label(com.vaadin.ui.Label) ButtonHandler(pl.edu.icm.unity.webui.common.TextFieldWithButton.ButtonHandler) ActionColumn(pl.edu.icm.unity.webui.common.ListOfElementsWithActions.ActionColumn) CheckBox(com.vaadin.ui.CheckBox) TextFieldWithButton(pl.edu.icm.unity.webui.common.TextFieldWithButton) IntStepper(org.vaadin.risto.stepper.IntStepper) CompatibleTemplatesComboBox(pl.edu.icm.unity.webui.common.CompatibleTemplatesComboBox)

Example 3 with SingleActionHandler

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;
}
Also used : Arrays(java.util.Arrays) NavigationHelper(io.imunity.webelements.helpers.NavigationHelper) ServiceEditorTab(pl.edu.icm.unity.webui.console.services.ServiceEditorComponent.ServiceEditorTab) VaadinAuthentication(pl.edu.icm.unity.webui.authn.VaadinAuthentication) PrototypeComponent(pl.edu.icm.unity.engine.api.utils.PrototypeComponent) SingleActionHandler(pl.edu.icm.unity.webui.common.SingleActionHandler) Type(io.imunity.webelements.navigation.NavigationInfo.Type) Autowired(org.springframework.beans.factory.annotation.Autowired) ServicesViewBase(io.imunity.webconsole.services.base.ServicesViewBase) IdpServiceAdditionalAction(io.imunity.webconsole.spi.services.IdpServiceAdditionalAction) Collectors(java.util.stream.Collectors) Images(pl.edu.icm.unity.webui.common.Images) ServiceDefinition(pl.edu.icm.unity.webui.console.services.ServiceDefinition) ArrayList(java.util.ArrayList) ObjectFactory(org.springframework.beans.factory.ObjectFactory) List(java.util.List) Component(org.springframework.stereotype.Component) Stream(java.util.stream.Stream) IdentityProviderNavigationInfoProvider(io.imunity.webconsole.idprovider.IdentityProviderNavigationInfoProvider) WebConsoleNavigationInfoProviderBase(io.imunity.webconsole.WebConsoleNavigationInfoProviderBase) CommonViewParam(io.imunity.webelements.helpers.NavigationHelper.CommonViewParam) NavigationInfo(io.imunity.webelements.navigation.NavigationInfo) MessageSource(pl.edu.icm.unity.MessageSource) SingleActionHandler(pl.edu.icm.unity.webui.common.SingleActionHandler) ArrayList(java.util.ArrayList) IdpServiceAdditionalAction(io.imunity.webconsole.spi.services.IdpServiceAdditionalAction) ServiceDefinition(pl.edu.icm.unity.webui.console.services.ServiceDefinition)

Aggregations

MessageSource (pl.edu.icm.unity.MessageSource)3 Images (pl.edu.icm.unity.webui.common.Images)3 SingleActionHandler (pl.edu.icm.unity.webui.common.SingleActionHandler)3 Label (com.vaadin.ui.Label)2 Arrays (java.util.Arrays)2 List (java.util.List)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 PrototypeComponent (pl.edu.icm.unity.engine.api.utils.PrototypeComponent)2 Sets (com.google.common.collect.Sets)1 Binder (com.vaadin.data.Binder)1 ValidationResult (com.vaadin.data.ValidationResult)1 Unit (com.vaadin.server.Sizeable.Unit)1 MarginInfo (com.vaadin.shared.ui.MarginInfo)1 Orientation (com.vaadin.shared.ui.Orientation)1 Alignment (com.vaadin.ui.Alignment)1 Button (com.vaadin.ui.Button)1 CheckBox (com.vaadin.ui.CheckBox)1 ComboBox (com.vaadin.ui.ComboBox)1 FormLayout (com.vaadin.ui.FormLayout)1 HorizontalLayout (com.vaadin.ui.HorizontalLayout)1