Repository: syncope Updated Branches: refs/heads/master 48c2ab456 -> 97744afe7
[SYNCOPE-1190] Toggle menu header is now updated when elements get updated Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/97744afe Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/97744afe Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/97744afe Branch: refs/heads/master Commit: 97744afe7fe103101ceca95294af51ed48333be3 Parents: 48c2ab4 Author: skylark17 <matteo.alessandr...@tirasa.net> Authored: Thu Aug 10 10:44:51 2017 +0200 Committer: skylark17 <matteo.alessandr...@tirasa.net> Committed: Thu Aug 10 10:45:39 2017 +0200 ---------------------------------------------------------------------- .../console/panels/AbstractLogsPanel.java | 1 + .../panels/SecurityQuestionsModalPanel.java | 6 ++ .../client/console/panels/TogglePanel.java | 105 +++++++++++++++++++ .../policies/PolicyModalPanelBuilder.java | 7 ++ .../client/console/topology/Topology.java | 2 +- .../console/topology/TopologyTogglePanel.java | 18 +++- .../html/form/ActionLinksTogglePanel.java | 72 ++----------- .../console/wizards/AjaxWizardBuilder.java | 5 + 8 files changed, 152 insertions(+), 64 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/panels/AbstractLogsPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AbstractLogsPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AbstractLogsPanel.java index fef5be5..5246509 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AbstractLogsPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AbstractLogsPanel.java @@ -74,6 +74,7 @@ public abstract class AbstractLogsPanel<T extends AbstractBaseBean> extends Pane loggerTOs.hideLabel(); loggerTOs.setChoices(Arrays.asList(LoggerLevel.values())); + loggerTOs.setNullValid(false); loggerTOs.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -1107858522700306810L; http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionsModalPanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionsModalPanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionsModalPanel.java index a639035..883325d 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionsModalPanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/SecurityQuestionsModalPanel.java @@ -27,6 +27,7 @@ import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.Bas import org.apache.syncope.common.lib.to.SecurityQuestionTO; import org.apache.wicket.PageReference; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.event.Broadcast; import org.apache.wicket.markup.html.form.Form; public class SecurityQuestionsModalPanel extends AbstractModalPanel<SecurityQuestionTO> { @@ -62,6 +63,11 @@ public class SecurityQuestionsModalPanel extends AbstractModalPanel<SecurityQues } SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); + + // [SYNCOPE-1190] - refresh toggle panel after update + send(pageRef.getPage(), Broadcast.BREADTH, + new TogglePanel.ActionLinkToggleUpdateEventPayload<>(target, securityQuestionTO)); + modal.close(target); } catch (Exception e) { LOG.error("While creating or updating {}", securityQuestionTO, e); http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java index 62c2af4..ba9f9b1 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java @@ -21,7 +21,29 @@ package org.apache.syncope.client.console.panels; import java.io.Serializable; import org.apache.commons.lang3.StringUtils; import org.apache.syncope.client.console.commons.Constants; +import org.apache.syncope.client.console.commons.status.StatusBean; +import org.apache.syncope.client.console.policies.PolicyRuleDirectoryPanel; +import org.apache.syncope.client.console.reports.ReportletDirectoryPanel; import org.apache.syncope.client.console.wizards.WizardMgtPanel; +import org.apache.syncope.client.console.wizards.any.AnyWrapper; +import org.apache.syncope.client.console.wizards.any.GroupWrapper; +import org.apache.syncope.client.console.wizards.any.UserWrapper; +import org.apache.syncope.common.lib.policy.AbstractPolicyTO; +import org.apache.syncope.common.lib.to.AccessTokenTO; +import org.apache.syncope.common.lib.to.AnyObjectTO; +import org.apache.syncope.common.lib.to.AnyTO; +import org.apache.syncope.common.lib.to.AttrTO; +import org.apache.syncope.common.lib.to.ConnInstanceTO; +import org.apache.syncope.common.lib.to.EntityTO; +import org.apache.syncope.common.lib.to.ExecTO; +import org.apache.syncope.common.lib.to.GroupTO; +import org.apache.syncope.common.lib.to.JobTO; +import org.apache.syncope.common.lib.to.ReportTO; +import org.apache.syncope.common.lib.to.SchedTaskTO; +import org.apache.syncope.common.lib.to.SecurityQuestionTO; +import org.apache.syncope.common.lib.to.UserTO; +import org.apache.syncope.common.lib.to.WorkflowDefinitionTO; +import org.apache.syncope.common.lib.to.WorkflowFormTO; import org.apache.wicket.Component; import org.apache.wicket.PageReference; import org.apache.wicket.ajax.AjaxEventBehavior; @@ -29,6 +51,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.model.ResourceModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -152,4 +175,86 @@ public abstract class TogglePanel<T extends Serializable> extends WizardMgtPanel status = Status.INACTIVE; } } + + protected String getHeader(final T modelObject) { + final String headerValue; + if (modelObject == null) { + headerValue = new ResourceModel("actions", StringUtils.EMPTY).getObject(); + } else if (modelObject instanceof UserTO) { + headerValue = ((UserTO) modelObject).getUsername(); + } else if (modelObject instanceof GroupTO) { + headerValue = ((GroupTO) modelObject).getName(); + } else if (modelObject instanceof UserWrapper) { + headerValue = UserWrapper.class.cast(modelObject).getInnerObject().getUsername(); + } else if (modelObject instanceof GroupWrapper) { + headerValue = GroupWrapper.class.cast(modelObject).getInnerObject().getName(); + } else if (modelObject instanceof AnyWrapper) { + AnyTO anyWrapper = AnyWrapper.class.cast(modelObject).getInnerObject(); + if (anyWrapper instanceof AnyObjectTO) { + headerValue = ((AnyObjectTO) anyWrapper).getName(); + } else { + headerValue = new ResourceModel("actions", StringUtils.EMPTY).getObject(); + } + } else if (modelObject instanceof ConnInstanceTO) { + headerValue = ConnInstanceTO.class.cast(modelObject).getDisplayName(); + } else if (modelObject instanceof ReportTO) { + headerValue = ((ReportTO) modelObject).getName(); + } else if (modelObject instanceof AnyObjectTO) { + headerValue = ((AnyObjectTO) modelObject).getName(); + } else if (modelObject instanceof AttrTO) { + headerValue = ((AttrTO) modelObject).getSchema(); + } else if (modelObject instanceof AbstractPolicyTO) { + headerValue = ((AbstractPolicyTO) modelObject).getDescription(); + } else if (modelObject instanceof SecurityQuestionTO) { + headerValue = ((SecurityQuestionTO) modelObject).getContent(); + } else if (modelObject instanceof AccessTokenTO) { + headerValue = ((AccessTokenTO) modelObject).getOwner(); + } else if (modelObject instanceof ExecTO) { + headerValue = ((ExecTO) modelObject).getKey(); + } else if (modelObject instanceof WorkflowDefinitionTO) { + headerValue = ((WorkflowDefinitionTO) modelObject).getName(); + } else if (modelObject instanceof SchedTaskTO) { + headerValue = ((SchedTaskTO) modelObject).getName(); + } else if (modelObject instanceof WorkflowFormTO) { + headerValue = ((WorkflowFormTO) modelObject).getKey(); + } else if (modelObject instanceof EntityTO) { + headerValue = ((EntityTO) modelObject).getKey(); + } else if (modelObject instanceof StatusBean) { + headerValue = ((StatusBean) modelObject).getResource(); + } else if (modelObject instanceof PolicyRuleDirectoryPanel.PolicyRuleWrapper) { + headerValue = ((PolicyRuleDirectoryPanel.PolicyRuleWrapper) modelObject).getName(); + } else if (modelObject instanceof PolicyRuleDirectoryPanel.PolicyRuleWrapper) { + headerValue = ((PolicyRuleDirectoryPanel.PolicyRuleWrapper) modelObject).getName(); + } else if (modelObject instanceof ReportletDirectoryPanel.ReportletWrapper) { + headerValue = ((ReportletDirectoryPanel.ReportletWrapper) modelObject).getName(); + } else if (modelObject instanceof JobTO) { + headerValue = ((JobTO) modelObject).getRefKey() == null + ? ((JobTO) modelObject).getRefDesc() : ((JobTO) modelObject).getRefKey(); + } else { + headerValue = new ResourceModel("actions", StringUtils.EMPTY).getObject(); + } + + return headerValue; + } + + public static class ActionLinkToggleUpdateEventPayload<T> { + + private final AjaxRequestTarget target; + + private final T modelObj; + + public ActionLinkToggleUpdateEventPayload(final AjaxRequestTarget target, final T modelObj) { + this.target = target; + this.modelObj = modelObj; + } + + public AjaxRequestTarget getTarget() { + return target; + } + + public T getModelObj() { + return modelObj; + } + + } } http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java index 7507d04..608dcca 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/policies/PolicyModalPanelBuilder.java @@ -27,6 +27,7 @@ import org.apache.syncope.client.console.SyncopeConsoleSession; import org.apache.syncope.client.console.commons.Constants; import org.apache.syncope.client.console.pages.BasePage; import org.apache.syncope.client.console.panels.AbstractModalPanel; +import org.apache.syncope.client.console.panels.TogglePanel; import org.apache.syncope.client.console.panels.WizardModalPanel; import org.apache.syncope.client.console.rest.PolicyRestClient; import org.apache.syncope.client.console.rest.ResourceRestClient; @@ -45,6 +46,7 @@ import org.apache.syncope.common.lib.to.ResourceTO; import org.apache.wicket.Component; import org.apache.wicket.PageReference; import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.event.Broadcast; import org.apache.wicket.markup.html.form.Form; import org.apache.wicket.markup.html.list.ListItem; import org.apache.wicket.markup.html.list.ListView; @@ -161,6 +163,11 @@ public class PolicyModalPanelBuilder<T extends AbstractPolicyTO> extends Abstrac restClient.updatePolicy(policyTO); } SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); + + // [SYNCOPE-1190] - refresh toggle panel after update + send(pageRef.getPage(), Broadcast.BREADTH, + new TogglePanel.ActionLinkToggleUpdateEventPayload<>(target, policyTO)); + Profile.this.modal.close(target); } catch (Exception e) { LOG.error("While creating/updating policy", e); http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java index 606a32d..99a80ba 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/Topology.java @@ -165,7 +165,7 @@ public class Topology extends BasePage { body.add(new TopologyWebSocketBehavior()); - togglePanel = new TopologyTogglePanel("toggle", getPageReference()); + togglePanel = new TopologyTogglePanel<>("toggle", getPageReference()); body.add(togglePanel); // ----------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java index 8b6b1a5..57afa04 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/topology/TopologyTogglePanel.java @@ -53,6 +53,7 @@ import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; import org.apache.wicket.event.Broadcast; +import org.apache.wicket.event.IEvent; import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -63,7 +64,7 @@ import org.apache.wicket.model.Model; import org.apache.wicket.model.ResourceModel; import org.apache.wicket.model.StringResourceModel; -public class TopologyTogglePanel extends TogglePanel<Serializable> { +public class TopologyTogglePanel<T extends Serializable> extends TogglePanel<Serializable> { private static final long serialVersionUID = -2025535531121434056L; @@ -648,4 +649,19 @@ public class TopologyTogglePanel extends TogglePanel<Serializable> { } } + + @Override + @SuppressWarnings("unchecked") + public void onEvent(final IEvent<?> event) { + if (event.getPayload() instanceof ActionLinkToggleUpdateEventPayload) { + String header = getHeader((T) ActionLinkToggleUpdateEventPayload.class.cast(event. + getPayload()).getModelObj()); + if (StringUtils.isNotBlank(header)) { + setHeader(ActionLinkToggleUpdateEventPayload.class.cast(event.getPayload()). + getTarget(), StringUtils.abbreviate(header, 25)); + } + } + + super.onEvent(event); + } } http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksTogglePanel.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksTogglePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksTogglePanel.java index fb8ab83..16b79f5 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksTogglePanel.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/markup/html/form/ActionLinksTogglePanel.java @@ -22,31 +22,13 @@ import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal; import java.io.Serializable; import java.util.UUID; import org.apache.commons.lang3.StringUtils; -import org.apache.syncope.client.console.commons.status.StatusBean; import org.apache.syncope.client.console.panels.TogglePanel; -import org.apache.syncope.client.console.policies.PolicyRuleDirectoryPanel.PolicyRuleWrapper; -import org.apache.syncope.client.console.reports.ReportletDirectoryPanel.ReportletWrapper; -import org.apache.syncope.common.lib.to.AnyObjectTO; -import org.apache.syncope.common.lib.to.EntityTO; -import org.apache.syncope.common.lib.to.GroupTO; -import org.apache.syncope.common.lib.to.ReportTO; -import org.apache.syncope.common.lib.to.UserTO; -import org.apache.syncope.common.lib.to.AttrTO; -import org.apache.syncope.common.lib.to.SecurityQuestionTO; -import org.apache.syncope.common.lib.policy.AbstractPolicyTO; -import org.apache.syncope.common.lib.to.AccessTokenTO; -import org.apache.syncope.common.lib.to.ExecTO; -import org.apache.syncope.common.lib.to.JobTO; -import org.apache.syncope.common.lib.to.SchedTaskTO; -import org.apache.syncope.common.lib.to.WorkflowDefinitionTO; -import org.apache.syncope.common.lib.to.WorkflowFormTO; import org.apache.wicket.PageReference; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.event.IEvent; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; import org.apache.wicket.markup.html.WebMarkupContainer; import org.apache.wicket.markup.html.panel.Fragment; -import org.apache.wicket.model.ResourceModel; public class ActionLinksTogglePanel<T extends Serializable> extends TogglePanel<Serializable> { @@ -69,50 +51,8 @@ public class ActionLinksTogglePanel<T extends Serializable> extends TogglePanel< public void toggleWithContent( final AjaxRequestTarget target, final ActionsPanel<T> actionsPanel, final T modelObject) { - final String header; - if (modelObject == null) { - header = new ResourceModel("actions", StringUtils.EMPTY).getObject(); - } else if (modelObject instanceof UserTO) { - header = ((UserTO) modelObject).getUsername(); - } else if (modelObject instanceof GroupTO) { - header = ((GroupTO) modelObject).getName(); - } else if (modelObject instanceof ReportTO) { - header = ((ReportTO) modelObject).getName(); - } else if (modelObject instanceof AnyObjectTO) { - header = ((AnyObjectTO) modelObject).getName(); - } else if (modelObject instanceof AttrTO) { - header = ((AttrTO) modelObject).getSchema(); - } else if (modelObject instanceof AbstractPolicyTO) { - header = ((AbstractPolicyTO) modelObject).getDescription(); - } else if (modelObject instanceof SecurityQuestionTO) { - header = ((SecurityQuestionTO) modelObject).getContent(); - } else if (modelObject instanceof AccessTokenTO) { - header = ((AccessTokenTO) modelObject).getOwner(); - } else if (modelObject instanceof ExecTO) { - header = ((ExecTO) modelObject).getKey(); - } else if (modelObject instanceof WorkflowDefinitionTO) { - header = ((WorkflowDefinitionTO) modelObject).getName(); - } else if (modelObject instanceof SchedTaskTO) { - header = ((SchedTaskTO) modelObject).getName(); - } else if (modelObject instanceof WorkflowFormTO) { - header = ((WorkflowFormTO) modelObject).getKey(); - } else if (modelObject instanceof EntityTO) { - header = ((EntityTO) modelObject).getKey(); - } else if (modelObject instanceof StatusBean) { - header = ((StatusBean) modelObject).getResource(); - } else if (modelObject instanceof PolicyRuleWrapper) { - header = ((PolicyRuleWrapper) modelObject).getName(); - } else if (modelObject instanceof PolicyRuleWrapper) { - header = ((PolicyRuleWrapper) modelObject).getName(); - } else if (modelObject instanceof ReportletWrapper) { - header = ((ReportletWrapper) modelObject).getName(); - } else if (modelObject instanceof JobTO) { - header = ((JobTO) modelObject).getRefKey() == null - ? ((JobTO) modelObject).getRefDesc() : ((JobTO) modelObject).getRefKey(); - } else { - header = new ResourceModel("actions", StringUtils.EMPTY).getObject(); - } - setHeader(target, StringUtils.abbreviate(header, 25)); + + setHeader(target, StringUtils.abbreviate(getHeader(modelObject), 25)); modal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { @@ -139,9 +79,17 @@ public class ActionLinksTogglePanel<T extends Serializable> extends TogglePanel< } @Override + @SuppressWarnings("unchecked") public void onEvent(final IEvent<?> event) { if (event.getPayload() instanceof ActionLinkToggleCloseEventPayload) { close(ActionLinkToggleCloseEventPayload.class.cast(event.getPayload()).getTarget()); + } else if (event.getPayload() instanceof ActionLinkToggleUpdateEventPayload) { + String header = getHeader((T) ActionLinkToggleUpdateEventPayload.class.cast(event. + getPayload()).getModelObj()); + if (StringUtils.isNotBlank(header)) { + setHeader(ActionLinkToggleUpdateEventPayload.class.cast(event.getPayload()).getTarget(), + StringUtils.abbreviate(header, 25)); + } } } http://git-wip-us.apache.org/repos/asf/syncope/blob/97744afe/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java index 32514ad..f0896f1 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/AjaxWizardBuilder.java @@ -22,6 +22,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.apache.syncope.client.console.panels.TogglePanel; import org.apache.wicket.Component; import org.apache.wicket.PageReference; import org.apache.wicket.ajax.AjaxRequestTarget; @@ -120,6 +121,10 @@ public abstract class AjaxWizardBuilder<T extends Serializable> extends Abstract send(pageRef.getPage(), Broadcast.BUBBLE, payload); } + // [SYNCOPE-1190] - refresh toggle panel after update + send(pageRef.getPage(), Broadcast.BREADTH, + new TogglePanel.ActionLinkToggleUpdateEventPayload<>(target, modelObject)); + return res; } }.setEventSink(eventSink).addOuterObject(outerObjects);