Search in sources :

Example 1 with LinkIconPanel

use of com.evolveum.midpoint.web.component.data.column.LinkIconPanel in project midpoint by Evolveum.

the class AutoRefreshPanel method initLayout.

private void initLayout(final Refreshable refreshable, boolean inSummaryPanel) {
    final LinkIconPanel refreshNow = new LinkIconPanel(ID_REFRESH_NOW, new Model("fa fa-refresh"), createStringResource("autoRefreshPanel.refreshNow")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            refreshable.refresh(target);
        }
    };
    refreshNow.setRenderBodyOnly(true);
    add(refreshNow);
    final LinkIconPanel resumeRefreshing = new LinkIconPanel(ID_START, new Model("fa fa-play"), createStringResource("autoRefreshPanel.resumeRefreshing")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            getModelObject().setEnabled(true);
            refreshable.refresh(target);
            startRefreshing(refreshable, target);
        }
    };
    resumeRefreshing.setRenderBodyOnly(true);
    resumeRefreshing.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModelObject().isEnabled();
        }
    });
    add(resumeRefreshing);
    final LinkIconPanel pauseRefreshing = new LinkIconPanel(ID_PAUSE, new Model("fa fa-pause"), createStringResource("autoRefreshPanel.pauseRefreshing")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            getModelObject().setEnabled(false);
            refreshable.refresh(target);
            stopRefreshing(refreshable, target);
        }
    };
    pauseRefreshing.setRenderBodyOnly(true);
    pauseRefreshing.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isEnabled();
        }
    });
    add(pauseRefreshing);
    final Label status = new Label(ID_STATUS, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            AutoRefreshDto dto = getModelObject();
            if (dto.isEnabled()) {
                return createStringResource("autoRefreshPanel.refreshingEach", dto.getInterval() / 1000).getString();
            } else {
                return createStringResource("autoRefreshPanel.noRefreshing").getString();
            }
        }
    });
    status.setRenderBodyOnly(true);
    add(status);
    if (inSummaryPanel) {
        add(new AttributeModifier("class", "summary-tag"));
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) Label(org.apache.wicket.markup.html.basic.Label) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AttributeModifier(org.apache.wicket.AttributeModifier) LinkIconPanel(com.evolveum.midpoint.web.component.data.column.LinkIconPanel)

Example 2 with LinkIconPanel

use of com.evolveum.midpoint.web.component.data.column.LinkIconPanel in project midpoint by Evolveum.

the class LiveSyncHandlerPanel method initLayout.

private void initLayout(final PageTaskEdit parentPage) {
    WebMarkupContainer tokenContainer = new WebMarkupContainer(ID_TOKEN_CONTAINER);
    tokenContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            //TODO
            return true;
        }
    });
    tokenContainer.add(new Label(ID_TOKEN, new PropertyModel<>(getModel(), LiveSyncHandlerDto.F_TOKEN)));
    LinkIconPanel deleteTokenPanel = new LinkIconPanel(ID_DELETE_TOKEN, new Model("fa fa-fw fa-trash-o fa-lg text-danger"), createStringResource("LiveSyncHandlerPanel.deleteToken")) {

        @Override
        protected void onClickPerformed(AjaxRequestTarget target) {
            parentPage.getController().deleteSyncTokenPerformed(target);
        }
    };
    deleteTokenPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            // TODO ... and security
            return !parentPage.isEdit() && getModelObject().hasToken();
        }
    });
    deleteTokenPanel.setRenderBodyOnly(true);
    tokenContainer.add(deleteTokenPanel);
    add(tokenContainer);
    WebMarkupContainer retryContainer = new WebMarkupContainer(ID_TOKEN_RETRY_CONTAINER);
    add(retryContainer);
    WebMarkupContainer retryCheckboxContainer = new WebMarkupContainer(ID_TOKEN_RETRY_CHECKBOX_CONTAINER);
    retryContainer.add(retryCheckboxContainer);
    CheckBox retryCheckbox = new CheckBox(ID_TOKEN_RETRY_CHECKBOX, new PropertyModel<Boolean>(getModel(), ResourceRelatedHandlerDto.F_TOKEN_RETRY_UNHANDLED_ERR));
    retryCheckbox.add(enabledIfEdit);
    retryCheckboxContainer.add(retryCheckbox);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) Model(org.apache.wicket.model.Model) IModel(org.apache.wicket.model.IModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkIconPanel(com.evolveum.midpoint.web.component.data.column.LinkIconPanel)

Aggregations

LinkIconPanel (com.evolveum.midpoint.web.component.data.column.LinkIconPanel)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 Label (org.apache.wicket.markup.html.basic.Label)2 IModel (org.apache.wicket.model.IModel)2 Model (org.apache.wicket.model.Model)2 AttributeModifier (org.apache.wicket.AttributeModifier)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)1 PropertyModel (org.apache.wicket.model.PropertyModel)1