Search in sources :

Example 66 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class NameStep method createConnectorDropDown.

private DropDownFormGroup<PrismObject<ConnectorType>> createConnectorDropDown() {
    return new DropDownFormGroup<PrismObject<ConnectorType>>(ID_CONNECTOR, selectedConnectorModel, relevantConnectorsModel, new IChoiceRenderer<PrismObject<ConnectorType>>() {

        @Override
        public PrismObject<ConnectorType> getObject(String id, IModel<? extends List<? extends PrismObject<ConnectorType>>> choices) {
            return StringUtils.isNotBlank(id) ? choices.getObject().get(Integer.parseInt(id)) : null;
        }

        @Override
        public Object getDisplayValue(PrismObject<ConnectorType> object) {
            return WebComponentUtil.getName(object);
        }

        @Override
        public String getIdValue(PrismObject<ConnectorType> object, int index) {
            if (index < 0) {
                // noinspection unchecked
                List<PrismObject<ConnectorType>> connectors = (List<PrismObject<ConnectorType>>) getConnectorDropDown().getInput().getChoices();
                for (PrismObject<ConnectorType> connector : connectors) {
                    if (connector.getOid().equals(selectedConnectorModel.getObject().getOid())) {
                        return Integer.toString(connectors.indexOf(connector));
                    }
                }
            }
            return Integer.toString(index);
        }
    }, createStringResource("NameStep.connectorType"), "col-md-3", "col-md-6", true) {

        @Override
        protected DropDownChoice<PrismObject<ConnectorType>> createDropDown(String id, IModel<List<PrismObject<ConnectorType>>> choices, IChoiceRenderer<PrismObject<ConnectorType>> renderer, boolean required) {
            DropDownChoice<PrismObject<ConnectorType>> choice = super.createDropDown(id, choices, renderer, required);
            choice.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                    target.add(getConnectorDropDown().getAdditionalInfoComponent());
                }
            });
            choice.setOutputMarkupId(true);
            return choice;
        }

        @Override
        protected Component createAdditionalInfoComponent(String id) {
            Label l = new Label(id, schemaChangeWarningModel);
            l.add(new AttributeAppender("class", "text-danger"));
            l.setOutputMarkupId(true);
            return l;
        }
    };
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) IModel(org.apache.wicket.model.IModel) ConnectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType) DropDownFormGroup(com.evolveum.midpoint.web.component.form.DropDownFormGroup) Label(org.apache.wicket.markup.html.basic.Label) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismObject(com.evolveum.midpoint.prism.PrismObject) List(java.util.List) ArrayList(java.util.ArrayList) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 67 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender 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 IModel<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 IModel<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");
        }
    }, ""));
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 68 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project midpoint by Evolveum.

the class OrgUnitAddDeletePopup method setState.

public void setState(ActionState state, AjaxRequestTarget target) {
    this.state = state;
    AjaxButton actionButton = (AjaxButton) getContent().get(ID_BUTTON_ACTION);
    actionButton.setModel(createActionButtonStringResource());
    actionButton.add(new AttributeAppender("class", getActionButtonClass()));
    target.add(actionButton);
    TablePanel panel = getTable();
    DataTable table = panel.getDataTable();
    ObjectDataProvider provider = (ObjectDataProvider) table.getDataProvider();
    provider.setQuery(getDataProviderQuery());
    target.add(panel);
}
Also used : DataTable(org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) ObjectDataProvider(com.evolveum.midpoint.web.component.data.ObjectDataProvider) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 69 with AttributeAppender

use of org.apache.wicket.behavior.AttributeAppender in project webanno by webanno.

the class TextAreaFeatureEditor method createInputField.

@Override
protected AbstractTextComponent createInputField() {
    TextArea<String> textarea = new TextArea<>("value");
    textarea.add(new AjaxPreventSubmitBehavior());
    try {
        String traitsString = getModelObject().feature.getTraits();
        StringFeatureTraits traits = JSONUtil.fromJsonString(StringFeatureTraits.class, traitsString);
        textarea.add(new AttributeModifier("rows", traits.getCollapsedRows()));
        textarea.add(new AttributeAppender("onfocus", "this.rows=" + traits.getExpandedRows() + ";"));
        textarea.add(new AttributeAppender("onblur", "this.rows=" + traits.getCollapsedRows() + ";"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    return textarea;
}
Also used : TextArea(org.apache.wicket.markup.html.form.TextArea) IOException(java.io.IOException) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxPreventSubmitBehavior(org.apache.wicket.ajax.AjaxPreventSubmitBehavior) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Aggregations

AttributeAppender (org.apache.wicket.behavior.AttributeAppender)69 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 Label (org.apache.wicket.markup.html.basic.Label)34 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 IModel (org.apache.wicket.model.IModel)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)28 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)19 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)10 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)8 ListItem (org.apache.wicket.markup.html.list.ListItem)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 AttributeModifier (org.apache.wicket.AttributeModifier)7 ListView (org.apache.wicket.markup.html.list.ListView)7 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)6 BoxedTablePanel (com.evolveum.midpoint.web.component.data.BoxedTablePanel)6 Component (org.apache.wicket.Component)6 Model (org.apache.wicket.model.Model)6 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)5 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)5