Example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink AjaxSubmitLink

List of usage examples for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink AjaxSubmitLink

Introduction

In this page you can find the example usage for org.apache.wicket.ajax.markup.html.form AjaxSubmitLink AjaxSubmitLink.

Prototype

public AjaxSubmitLink(String id) 

Source Link

Document

Construct.

Usage

From source file:ch.bd.qv.quiz.panels.AdminPanel.java

License:Apache License

public AdminPanel(String id) {
    super(id);//from www .  jav  a 2  s  .c om
    add(new FeedbackPanel("feedback"));
    Form form = new Form("form");
    form.setMultiPart(true);
    form.add(fup = new FileUploadField("fileupload", new Model()));
    fup.setRequired(true);
    form.add(new AjaxSubmitLink("submit") {
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            List<FileUpload> uploads = fup.getConvertedInput();
            try {
                uploadBean.purgeAndUpload(uploads.get(0).getBytes());
            } catch (Exception e) {
                AdminPanel.this.get("feedback").error(Throwables.getStackTraceAsString(e));
            }
            target.add(findParent(AdminPanel.class));
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(findParent(AdminPanel.class));
        }
    });
    add(form);
}

From source file:ch.bd.qv.quiz.panels.BasePanel.java

License:Apache License

public BasePanel(String id) {
    super(id);/*from   w ww  .  j a  v a 2 s  .c  om*/
    add(new FeedbackPanel("feedback"));

    form = new Form("form");
    add(form);
    form.add(new LangPanel("swapPanel"));
    final AjaxSubmitLink ajaxSubmitLink = new AjaxSubmitLink("submit") {
        @Override
        public boolean isVisible() {
            return isVisibleNotOnLangAndEnd();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            driveNavigation();
            target.add(findParent(BasePanel.class));
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            target.add(findParent(BasePanel.class));
        }
    };
    final AjaxLink cancelLink = new AjaxLink("cancel") {
        @Override
        public void onClick(AjaxRequestTarget target) {
            getSession().invalidateNow();
            setResponsePage(HomePage.class);
            target.add(findParent(BasePanel.class));
        }

        @Override
        public boolean isVisible() {
            return isVisibleNotOnLangAndEnd();
        }
    };
    ajaxSubmitLink.add(new Label("label", new LoadableDetachableModel<String>() {
        @Override
        protected String load() {
            if (data.getNavigation() == NavigationEnum.QUESTION
                    && data.getQuestionNo() == data.getQuestions().size()) {
                LOGGER.debug("last question, display end. ");
                return new StringResourceModel("button.end", BasePanel.this, null).getObject();
            } else {

                return new StringResourceModel("button.weiter", BasePanel.this, null).getObject();
            }
        }
    }));

    form.add(ajaxSubmitLink, cancelLink);
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.StatisticsPanel.java

License:Apache License

/**
 * @return button that add new diagram to the table
 *//*from   w  w  w.j a  v a2 s  .  co m*/
private AjaxSubmitLink getAddDiagramButton() {

    AjaxSubmitLink addDiagramButton = new AjaxSubmitLink("addDiagramButton") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {

            // get the statistics, that should be added to the diagram
            List<DbStatisticDescription> selectedStatistics = getSelectedStatistics();
            if (selectedStatistics.size() > 0) {
                String diagramName = diagramNameModel.getObject();
                if (defaultDiagramName.equals(diagramName)) {
                    getTESession().setDiagramNameIndex(getTESession().getDiagramNameIndex() + 1);
                    defaultDiagramName = "Diagram" + getTESession().getDiagramNameIndex();
                }
                // check if there is already existing diagram with the same name and if do, we will add the new statistics to it
                Map<String, List<LinkedHashMap<String, List<DbStatisticDescription>>>> allDiagrams = getTESession()
                        .getDiagramContainer();
                if (allDiagrams.containsKey(diagramName)) {
                    List<LinkedHashMap<String, List<DbStatisticDescription>>> diagram = allDiagrams
                            .get(diagramName);
                    for (LinkedHashMap<String, List<DbStatisticDescription>> testcase : diagram) {
                        if (testcase.containsKey(testcaseId)) {
                            for (DbStatisticDescription stat : selectedStatistics) {
                                if (!testcase.get(testcaseId).contains(stat)) {
                                    testcase.get(testcaseId).add(stat);
                                }
                            }
                        } else {
                            testcase.put(testcaseId, selectedStatistics);
                            getTESession().getDiagramContainer().put(diagramName, diagram);
                        }
                    }
                } else {
                    LinkedHashMap<String, List<DbStatisticDescription>> newDiagram = new LinkedHashMap<String, List<DbStatisticDescription>>();
                    newDiagram.put(testcaseId, selectedStatistics);
                    List<LinkedHashMap<String, List<DbStatisticDescription>>> diagram = new ArrayList<LinkedHashMap<String, List<DbStatisticDescription>>>();
                    diagram.add(newDiagram);
                    getTESession().getDiagramContainer().put(diagramName, diagram);
                }
            }
            // update the content of the diagram table
            updateDiagramTableContent();

            diagramNameModel.setObject("Diagram" + getTESession().getDiagramNameIndex());

            // uncheck all selected statistics
            String uncheckCheckboxes = "checkboxes = document.getElementsByTagName('input');"
                    + "for(var i = 0; i < checkboxes.length; i++) {"
                    + "if(checkboxes[i].type.toLowerCase() == 'checkbox') {"
                    + "if(checkboxes[i].checked == true){" + "checkboxes[i].click();" + "}}}";
            target.appendJavaScript(uncheckCheckboxes);

            String scrollToTop = "$('html,body').scrollTop(0);";
            target.appendJavaScript(scrollToTop);

            target.add(statsForm);
            super.onSubmit(target, form);
        }
    };

    return addDiagramButton;
}

From source file:com.evolveum.midpoint.gui.api.util.WebComponentUtil.java

License:Apache License

@NotNull
public static TabbedPanel<ITab> createTabPanel(String id, final PageBase parentPage, final List<ITab> tabs,
        TabbedPanel.RightSideItemProvider provider, final String tabChangeParameter) {

    TabbedPanel<ITab> tabPanel = new TabbedPanel<ITab>(id, tabs, provider) {
        private static final long serialVersionUID = 1L;

        @Override/*from   w ww.  ja v a2s. c o  m*/
        protected void onTabChange(int index) {
            if (tabChangeParameter != null) {
                parentPage.updateBreadcrumbParameters(tabChangeParameter, index);
            }
        }

        @Override
        protected WebMarkupContainer newLink(String linkId, final int index) {
            return new AjaxSubmitLink(linkId) {
                private static final long serialVersionUID = 1L;

                @Override
                protected void onError(AjaxRequestTarget target,
                        org.apache.wicket.markup.html.form.Form<?> form) {
                    super.onError(target, form);
                    target.add(parentPage.getFeedbackPanel());
                }

                @Override
                protected void onSubmit(AjaxRequestTarget target,
                        org.apache.wicket.markup.html.form.Form<?> form) {
                    super.onSubmit(target, form);

                    setSelectedTab(index);
                    if (target != null) {
                        target.add(findParent(TabbedPanel.class));
                    }
                }

            };
        }
    };
    tabPanel.setOutputMarkupId(true);
    return tabPanel;
}

From source file:com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel.java

License:Apache License

private void initButtons(WebMarkupContainer buttonGroup, final ListItem<T> item) {
    AjaxSubmitLink edit = new AjaxSubmitLink(ID_EDIT) {

        @Override//from  ww w.  j  a  va 2  s .  c o m
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            editPerformed(target, item.getModelObject());
        }
    };
    edit.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }

            return "";
        }
    }));
    buttonGroup.add(edit);

    AjaxLink add = new AjaxLink(ID_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    add.add(new AttributeAppender("class", getPlusClassModifier(item)));
    buttonGroup.add(add);

    AjaxLink remove = new AjaxLink(ID_REMOVE) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValuePerformed(target, item);
        }
    };
    remove.add(new AttributeAppender("class", getMinusClassModifier()));
    buttonGroup.add(remove);
}

From source file:com.evolveum.midpoint.web.component.input.ExpressionEditorPanel.java

License:Apache License

@Override
protected void initLayout() {
    loadModel();//w w w . j  av a  2 s  .c o  m

    Label typeLabel = new Label(ID_LABEL_TYPE, createStringResource(getTypeLabelKey()));
    add(typeLabel);

    DropDownChoice type = new DropDownChoice<>(ID_TYPE,
            new PropertyModel<ExpressionUtil.ExpressionEvaluatorType>(model, ExpressionTypeDto.F_TYPE),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.ExpressionEvaluatorType.class),
            new EnumChoiceRenderer<ExpressionUtil.ExpressionEvaluatorType>(this));
    type.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionType();
            target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
        }
    });
    type.setOutputMarkupId(true);
    type.setOutputMarkupPlaceholderTag(true);
    type.setNullValid(true);
    add(type);

    WebMarkupContainer languageContainer = new WebMarkupContainer(ID_LANGUAGE_CONTAINER);
    languageContainer.setOutputMarkupId(true);
    languageContainer.setOutputMarkupPlaceholderTag(true);
    languageContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.SCRIPT.equals(model.getObject().getType());
        }
    });
    add(languageContainer);

    DropDownChoice language = new DropDownChoice<>(ID_LANGUAGE,
            new PropertyModel<ExpressionUtil.Language>(model, ExpressionTypeDto.F_LANGUAGE),
            WebMiscUtil.createReadonlyModelFromEnum(ExpressionUtil.Language.class),
            new EnumChoiceRenderer<ExpressionUtil.Language>(this));
    language.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionLanguage();
            target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
        }
    });
    language.setNullValid(false);
    languageContainer.add(language);

    WebMarkupContainer policyContainer = new WebMarkupContainer(ID_POLICY_CONTAINER);
    policyContainer.setOutputMarkupId(true);
    policyContainer.setOutputMarkupPlaceholderTag(true);
    policyContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return ExpressionUtil.ExpressionEvaluatorType.GENERATE.equals(model.getObject().getType());
        }
    });
    add(policyContainer);

    DropDownChoice policyRef = new DropDownChoice<>(ID_POLICY_REF,
            new PropertyModel<ObjectReferenceType>(model, ExpressionTypeDto.F_POLICY_REF),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return policyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            });
    policyRef.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            model.getObject().updateExpressionValuePolicyRef();
            target.add(get(ID_LANGUAGE_CONTAINER), get(ID_POLICY_CONTAINER), get(ID_EXPRESSION));
        }
    });
    policyRef.setNullValid(true);
    policyContainer.add(policyRef);

    Label expressionLabel = new Label(ID_LABEL_EXPRESSION, createStringResource(getExpressionLabelKey()));
    add(expressionLabel);

    TextArea expression = new TextArea<>(ID_EXPRESSION,
            new PropertyModel<String>(model, ExpressionTypeDto.F_EXPRESSION));
    expression.setOutputMarkupId(true);
    add(expression);

    AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            updateExpressionPerformed(target);
        }
    };
    add(update);

    Label typeTooltip = new Label(ID_T_TYPE);
    typeTooltip.add(new InfoTooltipBehavior());
    add(typeTooltip);

    Label languageTooltip = new Label(ID_T_LANGUAGE);
    languageTooltip.add(new InfoTooltipBehavior());
    languageContainer.add(languageTooltip);

    Label policyTooltip = new Label(ID_T_POLICY);
    policyTooltip.add(new InfoTooltipBehavior());
    policyContainer.add(policyTooltip);

    Label expressionTooltip = new Label(ID_T_EXPRESSION);
    expressionTooltip.add(new InfoTooltipBehavior());
    add(expressionTooltip);
}

From source file:com.evolveum.midpoint.web.component.input.SearchFilterPanel.java

License:Apache License

@Override
protected void initLayout() {
    loadModel();/*from   w  w  w . j av  a2 s.c om*/

    TextArea description = new TextArea<>(ID_DESCRIPTION,
            new PropertyModel<String>(model, SearchFilterTypeDto.F_FILTER_OBJECT + ".description"));
    add(description);

    TextArea filterClause = new TextArea<>(ID_FILTER_CLAUSE,
            new PropertyModel<String>(model, SearchFilterTypeDto.F_FILTER_CLAUSE));
    add(filterClause);

    AjaxSubmitLink update = new AjaxSubmitLink(ID_BUTTON_UPDATE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            updateClausePerformed(target);
        }
    };
    add(update);

    Label clauseTooltip = new Label(ID_T_CLAUSE);
    clauseTooltip.add(new InfoTooltipBehavior());
    add(clauseTooltip);
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceAttributeEditor.java

License:Apache License

@Override
protected void initLayout() {
    Label label = new Label(ID_LABEL, new AbstractReadOnlyModel<String>() {

        @Override/*  ww  w  .  jav a 2s.  c  o  m*/
        public String getObject() {
            ResourceAttributeDefinitionType attribute = getModelObject();

            if (attribute.getRef() == null || attribute.getRef().equals(new ItemPathType())) {
                return getString("ResourceAttributeEditor.label.new");
            } else {
                return getString("ResourceAttributeEditor.label.edit",
                        ItemPathUtil.getOnlySegmentQName(attribute.getRef()).getLocalPart());
            }
        }
    });
    add(label);

    QNameEditorPanel nonSchemaRefPanel = new QNameEditorPanel(ID_NON_SCHEMA_REF_PANEL,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            "SchemaHandlingStep.attribute.label.attributeName",
            "SchemaHandlingStep.attribute.tooltip.attributeLocalPart",
            "SchemaHandlingStep.attribute.label.attributeNamespace",
            "SchemaHandlingStep.attribute.tooltip.attributeNamespace");

    nonSchemaRefPanel.setOutputMarkupId(true);
    nonSchemaRefPanel.setOutputMarkupPlaceholderTag(true);
    nonSchemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return nonSchemaRefValueAllowed;
        }
    });
    add(nonSchemaRefPanel);

    WebMarkupContainer schemaRefPanel = new WebMarkupContainer(ID_SCHEMA_REF_PANEL);
    schemaRefPanel.setOutputMarkupId(true);
    schemaRefPanel.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !nonSchemaRefValueAllowed;
        }

    });
    add(schemaRefPanel);

    Label refTooltip = new Label(ID_T_REF);
    refTooltip.add(new InfoTooltipBehavior());
    refTooltip.setOutputMarkupId(true);
    refTooltip.setOutputMarkupId(true);
    schemaRefPanel.add(refTooltip);

    DropDownChoice refSelect = new DropDownChoice<ItemPathType>(ID_REFERENCE_SELECT,
            new PropertyModel<ItemPathType>(getModel(), "ref"),
            new AbstractReadOnlyModel<List<ItemPathType>>() {

                @Override
                public List<ItemPathType> getObject() {
                    return loadObjectReferences();
                }
            }, new IChoiceRenderer<ItemPathType>() {

                @Override
                public Object getDisplayValue(ItemPathType object) {
                    return prepareReferenceDisplayValue(object);
                }

                @Override
                public String getIdValue(ItemPathType object, int index) {
                    return Integer.toString(index);
                }
            }) {

        @Override
        protected boolean isSelected(ItemPathType object, int index, String selected) {
            if (getModelObject() == null || getModelObject().equals(new ItemPathType())) {
                return false;
            }

            QName referenceQName = ItemPathUtil.getOnlySegmentQName(getModelObject());
            QName optionQName = ItemPathUtil.getOnlySegmentQName(object);

            return referenceQName.equals(optionQName);
        }
    };
    refSelect.setNullValid(false);

    refSelect.setOutputMarkupId(true);
    refSelect.setOutputMarkupPlaceholderTag(true);
    schemaRefPanel.add(refSelect);

    CheckBox allowNonSchema = new CheckBox(ID_REFERENCE_ALLOW,
            new PropertyModel<Boolean>(this, "nonSchemaRefValueAllowed"));
    allowNonSchema.add(new AjaxFormComponentUpdatingBehavior("onchange") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(get(ID_NON_SCHEMA_REF_PANEL), get(ID_SCHEMA_REF_PANEL));
        }
    });
    add(allowNonSchema);

    TextField displayName = new TextField<>(ID_DISPLAY_NAME,
            new PropertyModel<String>(getModel(), "displayName"));
    add(displayName);

    TextArea description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), "description"));
    add(description);

    AjaxLink limitations = new AjaxLink(ID_BUTTON_LIMITATIONS) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            limitationsEditPerformed(target);
        }
    };
    add(limitations);

    CheckBox exclusiveStrong = new CheckBox(ID_EXCLUSIVE_STRONG,
            new PropertyModel<Boolean>(getModel(), "exclusiveStrong"));
    add(exclusiveStrong);

    CheckBox tolerant = new CheckBox(ID_TOLERANT, new PropertyModel<Boolean>(getModel(), "tolerant"));
    add(tolerant);

    MultiValueTextPanel tolerantVP = new MultiValueTextPanel<>(ID_TOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "tolerantValuePattern"));
    add(tolerantVP);

    MultiValueTextPanel intolerantVP = new MultiValueTextPanel<>(ID_INTOLERANT_VP,
            new PropertyModel<List<String>>(getModel(), "intolerantValuePattern"));
    add(intolerantVP);

    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    fetchStrategy.setNullValid(true);
    add(fetchStrategy);

    DropDownChoice matchingRule = new DropDownChoice<>(ID_MATCHING_RULE,
            new PropertyModel<QName>(getModel(), "matchingRule"), new AbstractReadOnlyModel<List<QName>>() {

                @Override
                public List<QName> getObject() {
                    return WebMiscUtil.getMatchingRuleList();
                }
            }, new IChoiceRenderer<QName>() {

                @Override
                public Object getDisplayValue(QName object) {
                    return object.getLocalPart();
                }

                @Override
                public String getIdValue(QName object, int index) {
                    return Integer.toString(index);
                }
            });
    matchingRule.setNullValid(true);
    add(matchingRule);

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceAttributeDefinitionType attributeDefinition = getModel().getObject();

            if (attributeDefinition == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(attributeDefinition.getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_BUTTON_OUTBOUND) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    Label allowTooltip = new Label(ID_T_ALLOW);
    allowTooltip.add(new InfoTooltipBehavior());
    add(allowTooltip);

    Label limitationsTooltip = new Label(ID_T_LIMITATIONS);
    limitationsTooltip.add(new InfoTooltipBehavior());
    add(limitationsTooltip);

    Label exclusiveStrongTooltip = new Label(ID_T_EXCLUSIVE_STRONG);
    exclusiveStrongTooltip.add(new InfoTooltipBehavior());
    add(exclusiveStrongTooltip);

    Label tolerantTooltip = new Label(ID_T_TOLERANT);
    tolerantTooltip.add(new InfoTooltipBehavior());
    add(tolerantTooltip);

    Label tolerantVPTooltip = new Label(ID_T_TOLERANT_VP);
    tolerantVPTooltip.add(new InfoTooltipBehavior());
    add(tolerantVPTooltip);

    Label intolerantVPTooltip = new Label(ID_T_INTOLERANT_VP);
    intolerantVPTooltip.add(new InfoTooltipBehavior());
    add(intolerantVPTooltip);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label matchingRuleTooltip = new Label(ID_T_MATCHING_RULE);
    matchingRuleTooltip.add(new InfoTooltipBehavior());
    add(matchingRuleTooltip);

    Label outboundTooltip = new Label(ID_T_OUTBOUND);
    outboundTooltip.add(new InfoTooltipBehavior());
    add(outboundTooltip);

    Label inboundTooltip = new Label(ID_T_INBOUND);
    inboundTooltip.add(new InfoTooltipBehavior());
    add(inboundTooltip);

    initModals();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.schemahandling.ResourceCredentialsEditor.java

License:Apache License

@Override
protected void initLayout() {
    DropDownChoice fetchStrategy = new DropDownChoice<>(ID_FETCH_STRATEGY,
            new PropertyModel<AttributeFetchStrategyType>(getModel(), "password.fetchStrategy"),
            WebMiscUtil.createReadonlyModelFromEnum(AttributeFetchStrategyType.class),
            new EnumChoiceRenderer<AttributeFetchStrategyType>(this));
    add(fetchStrategy);/*www.j  av a  2 s .  c o m*/

    TextField outboundLabel = new TextField<>(ID_OUTBOUND_LABEL, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            ResourceCredentialsDefinitionType credentials = getModel().getObject();

            if (credentials == null || credentials.getPassword() == null) {
                return null;
            }

            return MappingTypeDto.createMappingLabel(credentials.getPassword().getOutbound(), LOGGER,
                    getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                    getString("MultiValueField.nameNotSpecified"));
        }
    });
    outboundLabel.setEnabled(false);
    outboundLabel.setOutputMarkupId(true);
    add(outboundLabel);

    AjaxSubmitLink outbound = new AjaxSubmitLink(ID_OUTBOUND_BUTTON) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            outboundEditPerformed(target);
        }
    };
    outbound.setOutputMarkupId(true);
    add(outbound);

    MultiValueTextEditPanel inbound = new MultiValueTextEditPanel<MappingType>(ID_INBOUND,
            new PropertyModel<List<MappingType>>(getModel(), "password.inbound"), false) {

        @Override
        protected IModel<String> createTextModel(final IModel<MappingType> model) {
            return new Model<String>() {

                @Override
                public String getObject() {
                    return MappingTypeDto.createMappingLabel(model.getObject(), LOGGER,
                            getPageBase().getPrismContext(), getString("MappingType.label.placeholder"),
                            getString("MultiValueField.nameNotSpecified"));
                }
            };
        }

        @Override
        protected MappingType createNewEmptyItem() {
            return WizardUtil.createEmptyMapping();
        }

        @Override
        protected void editPerformed(AjaxRequestTarget target, MappingType object) {
            inboundEditPerformed(target, object);
        }
    };
    inbound.setOutputMarkupId(true);
    add(inbound);

    DropDownChoice passwordPolicy = new DropDownChoice<>(ID_PASS_POLICY,
            new PropertyModel<ObjectReferenceType>(getModel(), "password.passwordPolicyRef"),
            new AbstractReadOnlyModel<List<ObjectReferenceType>>() {

                @Override
                public List<ObjectReferenceType> getObject() {
                    return createPasswordPolicyList();
                }
            }, new IChoiceRenderer<ObjectReferenceType>() {

                @Override
                public Object getDisplayValue(ObjectReferenceType object) {
                    return passPolicyMap.get(object.getOid());
                }

                @Override
                public String getIdValue(ObjectReferenceType object, int index) {
                    return Integer.toString(index);
                }
            });
    add(passwordPolicy);

    Label fetchTooltip = new Label(ID_T_FETCH);
    fetchTooltip.add(new InfoTooltipBehavior());
    add(fetchTooltip);

    Label outTooltip = new Label(ID_T_OUT);
    outTooltip.add(new InfoTooltipBehavior());
    add(outTooltip);

    Label inTooltip = new Label(ID_T_IN);
    inTooltip.add(new InfoTooltipBehavior());
    add(inTooltip);

    Label passPolicyTooltip = new Label(ID_T_PASS_POLICY);
    passPolicyTooltip.add(new InfoTooltipBehavior());
    add(passPolicyTooltip);

    initModals();
}

From source file:com.evolveum.midpoint.web.component.wizard.resource.component.synchronization.SynchronizationActionEditorDialog.java

License:Apache License

private void initButtons(Form form) {
    AjaxLink cancel = new AjaxLink(ID_BUTTON_CANCEL) {

        @Override/*  w  w  w . j  a  v  a  2 s.c  o m*/
        public void onClick(AjaxRequestTarget target) {
            cancelPerformed(target);
        }
    };
    form.add(cancel);

    AjaxSubmitLink save = new AjaxSubmitLink(ID_BUTTON_SAVE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            savePerformed(target);
        }
    };
    form.add(save);
}