Search in sources :

Example 6 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PrismOptionButtonPanel method initButtons.

private void initButtons(final IModel<ObjectWrapper> model) {
    AjaxLink showEmpty = new AjaxLink("showEmptyButton") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            showEmptyOnClick(target);
        }
    };
    add(showEmpty);
    showEmpty.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().isReadonly();
        }
    });
    Image showEmptyImg = new Image("showEmptyImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyFalse.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "ShowEmptyTrue.png");
        }
    });
    showEmptyImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isShowEmpty()) {
                return getString("prismOptionButtonPanel.hideEmpty");
            }
            return getString("prismOptionButtonPanel.showEmpty");
        }
    }, ""));
    showEmpty.add(showEmptyImg);
    AjaxLink minimize = new AjaxLink("minimizeButton") {

        @Override
        public void onClick(AjaxRequestTarget target) {
            minimizeOnClick(target);
        }
    };
    add(minimize);
    Image minimizeImg = new Image("minimizeImg", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return new PackageResourceReference(PrismObjectPanel.class, "Maximize.png");
            }
            return new PackageResourceReference(PrismObjectPanel.class, "Minimize.png");
        }
    });
    minimizeImg.add(new AttributeAppender("title", new AbstractReadOnlyModel() {

        @Override
        public Object getObject() {
            ObjectWrapper wrapper = model.getObject();
            if (wrapper.isMinimalized()) {
                return getString("prismOptionButtonPanel.maximize");
            }
            return getString("prismOptionButtonPanel.minimize");
        }
    }, ""));
    minimize.add(minimizeImg);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) PackageResourceReference(org.apache.wicket.request.resource.PackageResourceReference) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Image(org.apache.wicket.markup.html.image.Image) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 7 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PrismValuePanel method initLayout.

private void initLayout(IModel<String> labelModel, Form form, String valueCssClass, String inputCssClass) {
    //container
    WebMarkupContainer valueContainer = new WebMarkupContainer(ID_VALUE_CONTAINER);
    valueContainer.setOutputMarkupId(true);
    valueContainer.add(new AttributeModifier("class", valueCssClass));
    add(valueContainer);
    //feedback
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK);
    feedback.setOutputMarkupId(true);
    add(feedback);
    //input
    Panel input = createInputComponent(ID_INPUT, labelModel, form);
    input.add(new AttributeModifier("class", inputCssClass));
    if (input instanceof InputPanel) {
        initAccessBehaviour((InputPanel) input);
        feedback.setFilter(new ComponentFeedbackMessageFilter(((InputPanel) input).getBaseFormComponent()));
    } else if (input instanceof LockoutStatusPanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof ValueChoosePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(input));
    } else if (input instanceof AssociationValueChoicePanel) {
        feedback.setFilter(new ComponentFeedbackMessageFilter(((AssociationValueChoicePanel) input).getTextComponent()));
    }
    valueContainer.add(input);
    //buttons
    AjaxLink addButton = new AjaxLink(ID_ADD_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValue(target);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isAddButtonVisible();
        }
    });
    valueContainer.add(addButton);
    AjaxLink removeButton = new AjaxLink(ID_REMOVE_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            removeValue(target);
        }
    };
    removeButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isRemoveButtonVisible();
        }
    });
    valueContainer.add(removeButton);
}
Also used : LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 8 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method createShadowMenu.

private List<InlineMenuItem> createShadowMenu() {
    List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
    PrismObjectDefinition def = getObjectWrapper().getObject().getDefinition();
    PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
    InlineMenuItem item;
    if (ref.canRead() && ref.canAdd()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                List<QName> supportedTypes = new ArrayList<>(1);
                supportedTypes.add(ResourceType.COMPLEX_TYPE);
                PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
                ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {

                    @Override
                    protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
                        // TODO Auto-generated method stub
                        FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
                    }
                };
                resourceSelectionPanel.setOutputMarkupId(true);
                pageBase.showMainPopup(resourceSelectionPanel, target);
            }
        });
        items.add(item);
        items.add(new InlineMenuItem());
    }
    PrismPropertyDefinition prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    if (prop.canRead() && prop.canModify()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                updateShadowActivation(target, getSelectedProjections(projectionModel), true);
            }
        });
        items.add(item);
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"), new InlineMenuItemAction() {

            /**
						 * 
						 */
            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                updateShadowActivation(target, getSelectedProjections(projectionModel), false);
            }
        });
        items.add(item);
    }
    if (ref.canRead() && ref.canAdd()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                unlinkProjectionPerformed(target, projectionModel, getSelectedProjections(projectionModel), ID_SHADOWS);
            }
        });
        items.add(item);
    }
    prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
    if (prop.canRead() && prop.canModify()) {
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                unlockShadowPerformed(target, projectionModel, getSelectedProjections(projectionModel));
            }
        });
        items.add(item);
    }
    prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
    if (prop.canRead() && prop.canModify()) {
        items.add(new InlineMenuItem());
        item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"), new InlineMenuItemAction() {

            private static final long serialVersionUID = 1L;

            @Override
            public void onClick(AjaxRequestTarget target) {
                deleteProjectionPerformed(target, projectionModel);
            }
        });
        items.add(item);
    }
    return items;
}
Also used : PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) QName(javax.xml.namespace.QName) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) ArrayList(java.util.ArrayList) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) PrismReferenceDefinition(com.evolveum.midpoint.prism.PrismReferenceDefinition) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class ObjectHistoryTabPanel method initLayout.

private void initLayout(final LoadableModel<ObjectWrapper<F>> focusWrapperModel, final PageAdminObjectDetails<F> page) {
    AuditSearchDto searchDto = new AuditSearchDto();
    ObjectReferenceType ort = new ObjectReferenceType();
    ort.setOid(focusWrapperModel.getObject().getOid());
    searchDto.setTargetNames(asList(ort));
    searchDto.setEventStage(AuditEventStageType.EXECUTION);
    Map<String, Boolean> visibilityMap = new HashMap<>();
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_NAME_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_LABEL_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_FIELD_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.EVENT_STAGE_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_COLUMN_VISIBILITY, false);
    visibilityMap.put(AuditLogViewerPanel.TARGET_OWNER_COLUMN_VISIBILITY, false);
    AuditLogViewerPanel panel = new AuditLogViewerPanel(ID_MAIN_PANEL, page, searchDto, visibilityMap) {

        @Override
        protected List<IColumn<AuditEventRecordType, String>> initColumns() {
            List<IColumn<AuditEventRecordType, String>> columns = super.initColumns();
            IColumn<AuditEventRecordType, String> column = new MultiButtonColumn<AuditEventRecordType>(new Model(), 2) {

                private final DoubleButtonColumn.BUTTON_COLOR_CLASS[] colors = { DoubleButtonColumn.BUTTON_COLOR_CLASS.INFO, DoubleButtonColumn.BUTTON_COLOR_CLASS.SUCCESS };

                @Override
                public String getCaption(int id) {
                    return "";
                }

                @Override
                public String getButtonTitle(int id) {
                    switch(id) {
                        case 0:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectDataTitle").getString();
                        case 1:
                            return page.createStringResource("ObjectHistoryTabPanel.viewHistoricalObjectXmlTitle").getString();
                    }
                    return "";
                }

                @Override
                public String getButtonColorCssClass(int id) {
                    return colors[id].toString();
                }

                @Override
                protected String getButtonCssClass(int id) {
                    StringBuilder sb = new StringBuilder();
                    sb.append(DoubleButtonColumn.BUTTON_BASE_CLASS).append(" ");
                    sb.append(getButtonColorCssClass(id)).append(" ");
                    switch(id) {
                        case 0:
                            sb.append("fa fa-circle-o");
                            break;
                        case 1:
                            sb.append("fa fa-file-text-o");
                            break;
                    }
                    return sb.toString();
                }

                @Override
                public void clickPerformed(int id, AjaxRequestTarget target, IModel<AuditEventRecordType> model) {
                    switch(id) {
                        case 0:
                            currentStateButtonClicked(target, focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE), page.getCompileTimeClass());
                            break;
                        case 1:
                            viewObjectXmlButtonClicked(focusWrapperModel.getObject().getOid(), model.getObject().getEventIdentifier(), page.getCompileTimeClass(), WebComponentUtil.getLocalizedDate(model.getObject().getTimestamp(), DateLabelComponent.SHORT_NOTIME_STYLE));
                            break;
                    }
                }
            };
            columns.add(column);
            return columns;
        }
    };
    panel.setOutputMarkupId(true);
    add(panel);
}
Also used : IModel(org.apache.wicket.model.IModel) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AuditLogViewerPanel(com.evolveum.midpoint.web.page.admin.reports.component.AuditLogViewerPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DoubleButtonColumn(com.evolveum.midpoint.web.component.data.column.DoubleButtonColumn) MultiButtonColumn(com.evolveum.midpoint.web.component.data.column.MultiButtonColumn)

Example 10 with AjaxRequestTarget

use of org.apache.wicket.ajax.AjaxRequestTarget in project midpoint by Evolveum.

the class PrismHeaderPanel method initLayout.

private void initLayout(final IModel model) {
    VisibleEnableBehaviour buttonsVisibleBehaviour = new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return PrismHeaderPanel.this.isButtonsVisible();
        }
    };
    ToggleIconButton showMetadataButton = new ToggleIconButton(ID_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA, GuiStyleConstants.CLASS_ICON_SHOW_METADATA) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setShowMetadata(!objectWrapper.isShowMetadata());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isShowMetadata();
        }
    };
    showMetadataButton.add(new AttributeModifier("title", getObjectWrapper(model) == null ? "" : (getObjectWrapper(model).isShowMetadata() ? createStringResource("PrismObjectPanel.hideMetadata") : createStringResource("PrismObjectPanel.showMetadata"))));
    showMetadataButton.add(buttonsVisibleBehaviour);
    add(showMetadataButton);
    ToggleIconButton showEmptyFieldsButton = new ToggleIconButton(ID_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_SHOW_EMPTY_FIELDS, GuiStyleConstants.CLASS_ICON_NOT_SHOW_EMPTY_FIELDS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setShowEmpty(!objectWrapper.isShowEmpty());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isShowEmpty();
        }
    };
    showEmptyFieldsButton.setMarkupId(ID_SHOW_EMPTY_FIELDS);
    showEmptyFieldsButton.add(buttonsVisibleBehaviour);
    add(showEmptyFieldsButton);
    ToggleIconButton sortPropertiesButton = new ToggleIconButton(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ObjectWrapper objectWrapper = getObjectWrapper(model);
            objectWrapper.setSorted(!objectWrapper.isSorted());
            objectWrapper.sort((PageBase) getPage());
            onButtonClick(target);
        }

        @Override
        public boolean isOn() {
            return getObjectWrapper(model).isSorted();
        }
    };
    sortPropertiesButton.add(buttonsVisibleBehaviour);
    add(sortPropertiesButton);
    IModel<String> headerLabelModel = new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            Object wrapper = model.getObject();
            String displayName = null;
            if (wrapper instanceof ContainerWrapper) {
                displayName = ((ContainerWrapper) wrapper).getDisplayName();
            } else if (wrapper instanceof ObjectWrapper) {
                // HACK HACK HACK
                // If we would display label for the object itself, display label for main container instead
                // the "object label" is actually displayed in front of main container
                ContainerWrapper mainContainerWrapper = ((ObjectWrapper) wrapper).findMainContainerWrapper();
                if (mainContainerWrapper != null) {
                    displayName = mainContainerWrapper.getDisplayName();
                } else {
                    // e.g. resource wizard needs this
                    displayName = ((ObjectWrapper) wrapper).getDisplayName();
                }
            }
            return getString(displayName, null, displayName);
        }
    };
    add(new Label(ID_LABEL, headerLabelModel));
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)379 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)116 Label (org.apache.wicket.markup.html.basic.Label)103 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)102 ArrayList (java.util.ArrayList)88 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)80 Form (org.apache.wicket.markup.html.form.Form)75 IModel (org.apache.wicket.model.IModel)71 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)69 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)65 List (java.util.List)53 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)48 Model (org.apache.wicket.model.Model)43 PropertyModel (org.apache.wicket.model.PropertyModel)42 ListItem (org.apache.wicket.markup.html.list.ListItem)41 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)37 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)34 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)32 TextField (org.apache.wicket.markup.html.form.TextField)30 ListView (org.apache.wicket.markup.html.list.ListView)30