You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/02/05 17:01:05 UTC
[34/52] syncope git commit: [SYNCOPE-620] Console (JAR) in,
now time for console-reference
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java
new file mode 100644
index 0000000..b9162da
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/AttrTemplatesPanel.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.SelectChoiceRenderer;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.form.NonI18nPalette;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.syncope.common.lib.types.SchemaType;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.extensions.markup.html.form.palette.component.Recorder;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.util.ListModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+public class AttrTemplatesPanel extends Panel {
+
+ public enum Type {
+
+ rAttrTemplates,
+ rDerAttrTemplates,
+ rVirAttrTemplates,
+ mPlainAttrTemplates,
+ mDerAttrTemplates,
+ mVirAttrTemplates;
+
+ }
+
+ private static final long serialVersionUID = 1016028222120619000L;
+
+ @SpringBean
+ private SchemaRestClient schemaRestClient;
+
+ private final RoleTO roleTO;
+
+ private final NonI18nPalette<String> rPlainAttrTemplates;
+
+ private final NonI18nPalette<String> rDerAttrTemplates;
+
+ private final NonI18nPalette<String> rVirAttrTemplates;
+
+ public AttrTemplatesPanel(final String id, final RoleTO roleTO) {
+ super(id);
+ this.roleTO = roleTO;
+
+ rPlainAttrTemplates = buildPalette(Type.rAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.ROLE, SchemaType.PLAIN));
+ this.add(rPlainAttrTemplates);
+ rDerAttrTemplates = buildPalette(Type.rDerAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.ROLE, SchemaType.DERIVED));
+ this.add(rDerAttrTemplates);
+ rVirAttrTemplates = buildPalette(Type.rVirAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.ROLE, SchemaType.VIRTUAL));
+ this.add(rVirAttrTemplates);
+
+ this.add(buildPalette(Type.mPlainAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.PLAIN)));
+ this.add(buildPalette(Type.mDerAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.DERIVED)));
+ this.add(buildPalette(Type.mVirAttrTemplates,
+ schemaRestClient.getSchemaNames(AttributableType.MEMBERSHIP, SchemaType.VIRTUAL)));
+ }
+
+ private NonI18nPalette<String> buildPalette(final Type type, final List<String> allSchemas) {
+ if (allSchemas != null && !allSchemas.isEmpty()) {
+ Collections.sort(allSchemas);
+ }
+ ListModel<String> availableSchemas = new ListModel<String>(allSchemas);
+
+ return new NonI18nPalette<String>(type.name(), new PropertyModel<List<String>>(roleTO, type.name()),
+ availableSchemas, new SelectChoiceRenderer<String>(), 8, false, true) {
+
+ private static final long serialVersionUID = 2295567122085510330L;
+
+ @Override
+ protected Recorder<String> newRecorderComponent() {
+ final Recorder<String> recorder = super.newRecorderComponent();
+
+ switch (type) {
+ case rAttrTemplates:
+ case rDerAttrTemplates:
+ case rVirAttrTemplates:
+ recorder.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(getPage(), Broadcast.BREADTH, new RoleAttrTemplatesChange(type, target));
+ }
+ });
+ break;
+
+ default:
+ }
+
+ return recorder;
+ }
+ };
+ }
+
+ public Collection<String> getSelected(final Type type) {
+ Collection<String> selected;
+ switch (type) {
+ case rAttrTemplates:
+ selected = this.rPlainAttrTemplates.getModelCollection();
+ break;
+
+ case rDerAttrTemplates:
+ selected = this.rDerAttrTemplates.getModelCollection();
+ break;
+
+ case rVirAttrTemplates:
+ selected = this.rVirAttrTemplates.getModelCollection();
+ break;
+
+ default:
+ selected = Collections.emptyList();
+ }
+
+ return selected;
+ }
+
+ public static class RoleAttrTemplatesChange {
+
+ private final Type type;
+
+ private final AjaxRequestTarget target;
+
+ public RoleAttrTemplatesChange(final Type type, final AjaxRequestTarget target) {
+ this.type = type;
+ this.target = target;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java
new file mode 100644
index 0000000..a5f6588
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DataTablePanel.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import org.apache.wicket.Component;
+import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable;
+import org.apache.wicket.extensions.markup.html.repeater.data.grid.DataGridView;
+import org.apache.wicket.markup.html.form.CheckGroup;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.model.IModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class DataTablePanel<T, S> extends Panel {
+
+ private static final long serialVersionUID = -7264400471578272966L;
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(DataTablePanel.class);
+
+ protected CheckGroup<T> group;
+
+ protected AjaxFallbackDefaultDataTable<T, S> dataTable;
+
+ protected IModel<Collection<T>> model;
+
+ public DataTablePanel(final String id) {
+ super(id);
+
+ model = new IModel<Collection<T>>() {
+
+ private static final long serialVersionUID = 4886729136344643465L;
+
+ private Collection<T> values = new HashSet<T>();
+
+ @Override
+ public Collection<T> getObject() {
+ // Someone or something call this method to change the model: this is not the right behavior.
+ // Return a copy of the model object in order to avoid SYNCOPE-465
+ return new HashSet<T>(values);
+ }
+
+ @Override
+ public void setObject(final Collection<T> selected) {
+ final Collection<T> all = getGroupModelObjects();
+ values.removeAll(all);
+ values.addAll(selected);
+ }
+
+ @Override
+ public void detach() {
+ }
+ };
+ }
+
+ public final void setCurrentPage(final long page) {
+ dataTable.setCurrentPage(page);
+ }
+
+ public final long getRowCount() {
+ return dataTable.getRowCount();
+ }
+
+ public final long getCurrentPage() {
+ return dataTable.getCurrentPage();
+ }
+
+ public final long getPageCount() {
+ return dataTable.getPageCount();
+ }
+
+ public void setItemsPerPage(final int resourcePaginatorRows) {
+ dataTable.setItemsPerPage(resourcePaginatorRows);
+ }
+
+ protected Collection<T> getGroupModelObjects() {
+ final Set<T> res = new HashSet<T>();
+
+ final Component rows = group.get("dataTable:body:rows");
+ if (rows instanceof DataGridView) {
+ @SuppressWarnings("unchecked")
+ final Iterator<Item<T>> iter = ((DataGridView<T>) rows).getItems();
+
+ while (iter.hasNext()) {
+ res.add(iter.next().getModelObject());
+ }
+ }
+ return res;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java
new file mode 100644
index 0000000..d68038f
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/DerAttrsPanel.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.panels.AttrTemplatesPanel.RoleAttrTemplatesChange;
+import org.apache.syncope.client.console.rest.RoleRestClient;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDecoratedCheckbox;
+import org.apache.syncope.common.lib.to.AbstractAttributableTO;
+import org.apache.syncope.common.lib.to.AttrTO;
+import org.apache.syncope.common.lib.to.MembershipTO;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.syncope.common.lib.types.AttributableType;
+import org.apache.wicket.Component;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxCallListener;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.ajax.attributes.IAjaxCallListener;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.LoadableDetachableModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+public class DerAttrsPanel extends Panel {
+
+ private static final long serialVersionUID = -5387344116983102292L;
+
+ @SpringBean
+ private SchemaRestClient schemaRestClient;
+
+ @SpringBean
+ private RoleRestClient roleRestClient;
+
+ private final AttrTemplatesPanel attrTemplates;
+
+ public <T extends AbstractAttributableTO> DerAttrsPanel(final String id, final T entityTO) {
+ this(id, entityTO, null);
+ }
+
+ public <T extends AbstractAttributableTO> DerAttrsPanel(final String id, final T entityTO,
+ final AttrTemplatesPanel attrTemplates) {
+
+ super(id);
+ this.attrTemplates = attrTemplates;
+ setOutputMarkupId(true);
+
+ final IModel<List<String>> derSchemas = new LoadableDetachableModel<List<String>>() {
+
+ private static final long serialVersionUID = 5275935387613157437L;
+
+ @Override
+ protected List<String> load() {
+ List<String> derSchemaNames;
+
+ if (entityTO instanceof RoleTO) {
+ final RoleTO roleTO = (RoleTO) entityTO;
+
+ if (attrTemplates == null) {
+ derSchemaNames = roleTO.getRDerAttrTemplates();
+ } else {
+ derSchemaNames = new ArrayList<>(
+ attrTemplates.getSelected(AttrTemplatesPanel.Type.rDerAttrTemplates));
+ if (roleTO.isInheritTemplates() && roleTO.getParent() != 0) {
+ derSchemaNames.addAll(roleRestClient.read(roleTO.getParent()).getRDerAttrTemplates());
+ }
+ }
+ } else if (entityTO instanceof UserTO) {
+ derSchemaNames = schemaRestClient.getDerSchemaNames(AttributableType.USER);
+ } else {
+ derSchemaNames = roleRestClient.read(((MembershipTO) entityTO).getRoleId()).getMDerAttrTemplates();
+ }
+
+ return derSchemaNames;
+ }
+ };
+
+ final WebMarkupContainer attributesContainer = new WebMarkupContainer("derAttrContainer");
+
+ attributesContainer.setOutputMarkupId(true);
+ add(attributesContainer);
+
+ AjaxButton addAttributeBtn = new IndicatingAjaxButton("addAttributeBtn", new ResourceModel("addAttributeBtn")) {
+
+ private static final long serialVersionUID = -4804368561204623354L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ entityTO.getDerAttrs().add(new AttrTO());
+ target.add(attributesContainer);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ target.add(attributesContainer);
+ }
+ };
+ add(addAttributeBtn.setDefaultFormProcessing(false));
+
+ ListView<AttrTO> attributes = new ListView<AttrTO>("attrs",
+ new PropertyModel<List<? extends AttrTO>>(entityTO, "derAttrs")) {
+
+ private static final long serialVersionUID = 9101744072914090143L;
+
+ @Override
+ protected void populateItem(final ListItem<AttrTO> item) {
+ final AttrTO attributeTO = item.getModelObject();
+
+ item.add(new AjaxDecoratedCheckbox("toRemove", new Model<>(Boolean.FALSE)) {
+
+ private static final long serialVersionUID = 7170946748485726506L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ entityTO.getDerAttrs().remove(attributeTO);
+ target.add(attributesContainer);
+ }
+
+ @Override
+ protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+
+ IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
+
+ private static final long serialVersionUID = 7160235486520935153L;
+
+ @Override
+ public CharSequence getPrecondition(final Component component) {
+ return "if (!confirm('" + getString("confirmDelete") + "')) return false;";
+ }
+ };
+ attributes.getAjaxCallListeners().add(ajaxCallListener);
+ }
+ });
+
+ final DropDownChoice<String> schemaChoice = new DropDownChoice<String>("schema",
+ new PropertyModel<String>(attributeTO, "schema"), derSchemas);
+ schemaChoice.add(new AjaxFormComponentUpdatingBehavior(Constants.ON_BLUR) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ attributeTO.setSchema(schemaChoice.getModelObject());
+ }
+ });
+ schemaChoice.setRequired(true);
+ schemaChoice.setOutputMarkupId(true);
+ schemaChoice.setRequired(true);
+ item.add(schemaChoice);
+
+ final List<String> values = attributeTO.getValues();
+ if (values == null || values.isEmpty()) {
+ item.add(new TextField<String>("value",
+ new Model<String>(null)).setVisible(false));
+ } else {
+ item.add(new TextField<String>("value",
+ new Model<String>(values.get(0))).setEnabled(false));
+ }
+ }
+ };
+ attributesContainer.add(attributes);
+ }
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ if ((event.getPayload() instanceof RoleAttrTemplatesChange)) {
+ final RoleAttrTemplatesChange update = (RoleAttrTemplatesChange) event.getPayload();
+ if (attrTemplates != null && update.getType() == AttrTemplatesPanel.Type.rDerAttrTemplates) {
+ update.getTarget().add(this);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java
new file mode 100644
index 0000000..5332cb5
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/EventSelectionPanel.java
@@ -0,0 +1,243 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.wicket.markup.html.list.AltListView;
+import org.apache.syncope.common.lib.to.EventCategoryTO;
+import org.apache.syncope.common.lib.types.AuditElements;
+import org.apache.syncope.common.lib.types.AuditLoggerName;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
+import org.apache.wicket.event.Broadcast;
+import org.apache.wicket.event.IEvent;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Check;
+import org.apache.wicket.markup.html.form.CheckGroup;
+import org.apache.wicket.markup.html.form.CheckGroupSelector;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.ResourceModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class EventSelectionPanel extends Panel {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(EventSelectionPanel.class);
+
+ private static final long serialVersionUID = 752233163798301002L;
+
+ private final Set<String> selected = new HashSet<String>();
+
+ public EventSelectionPanel(
+ final String id, final EventCategoryTO eventCategoryTO, final IModel<List<String>> model) {
+ super(id);
+ setOutputMarkupId(true);
+
+ final List<String> events = getEvents(eventCategoryTO);
+
+ // needed to avoid model reset: model have to be managed into SelectedEventsPanel
+ selected.addAll(model.getObject());
+
+ final CheckGroup<String> successGroup = new CheckGroup<String>(
+ "successGroup",
+ selected);
+
+ successGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+
+ private static final long serialVersionUID = -151291731388673682L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+
+ final Set<String> toBeRemoved = new HashSet<>();
+ final Set<String> toBeAdded = new HashSet<>();
+
+ for (String event : getEvents(eventCategoryTO)) {
+ final String eventString = AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.SUCCESS);
+
+ if (successGroup.getModelObject().contains(eventString)) {
+ toBeAdded.add(eventString);
+ } else {
+ toBeRemoved.add(eventString);
+ }
+ }
+
+ send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
+ new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
+ }
+ });
+
+ successGroup.setVisible(!events.isEmpty());
+ add(successGroup);
+
+ add(new Label("successLabel", new ResourceModel("Success", "Success"))).setVisible(!events.isEmpty());
+
+ final CheckGroupSelector successSelector = new CheckGroupSelector("successSelector", successGroup);
+ successSelector.setVisible(!events.isEmpty());
+ add(successSelector);
+
+ final ListView<String> categoryView = new AltListView<String>("categoryView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ final String subcategory = item.getModelObject();
+
+ item.add(new Label("subcategory", new ResourceModel(subcategory, subcategory)));
+ }
+ };
+ add(categoryView);
+
+ final ListView<String> successView = new AltListView<String>("successView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ final String event = item.getModelObject();
+
+ final Check<String> successCheck = new Check<>("successCheck",
+ new Model<String>(AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.SUCCESS)),
+ successGroup);
+ item.add(successCheck);
+ }
+ };
+ successGroup.add(successView);
+
+ final CheckGroup<String> failureGroup = new CheckGroup<String>(
+ "failureGroup",
+ selected);
+
+ failureGroup.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+
+ private static final long serialVersionUID = -151291731388673682L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+
+ final Set<String> toBeRemoved = new HashSet<>();
+ final Set<String> toBeAdded = new HashSet<>();
+
+ for (String event : getEvents(eventCategoryTO)) {
+ final String eventString = AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.FAILURE);
+
+ if (failureGroup.getModelObject().contains(eventString)) {
+ toBeAdded.add(eventString);
+ } else {
+ toBeRemoved.add(eventString);
+ }
+ }
+
+ send(EventSelectionPanel.this.getPage(), Broadcast.BREADTH,
+ new SelectedEventsPanel.EventSelectionChanged(target, toBeAdded, toBeRemoved));
+ }
+ });
+
+ failureGroup.setVisible(!events.isEmpty());
+ add(failureGroup);
+
+ add(new Label("failureLabel", new ResourceModel("Failure", "Failure"))).setVisible(!events.isEmpty());
+
+ final CheckGroupSelector failureSelector = new CheckGroupSelector("failureSelector", failureGroup);
+ failureSelector.setVisible(!events.isEmpty());
+ add(failureSelector);
+
+ final ListView<String> failureView = new AltListView<String>("failureView", events) {
+
+ private static final long serialVersionUID = 4949588177564901031L;
+
+ @Override
+ protected void populateItem(final ListItem<String> item) {
+ final String event = item.getModelObject();
+
+ final Check<String> failureCheck = new Check<>("failureCheck",
+ new Model<String>(AuditLoggerName.buildEvent(
+ eventCategoryTO.getType(),
+ eventCategoryTO.getCategory(),
+ eventCategoryTO.getSubcategory(),
+ event,
+ AuditElements.Result.FAILURE)),
+ failureGroup);
+ item.add(failureCheck);
+ }
+ };
+ failureGroup.add(failureView);
+ }
+
+ private List<String> getEvents(final EventCategoryTO eventCategoryTO) {
+ final List<String> res;
+
+ res = eventCategoryTO.getEvents();
+
+ if (res.isEmpty()) {
+ if ((AuditElements.EventCategoryType.PROPAGATION == eventCategoryTO.getType()
+ || AuditElements.EventCategoryType.SYNCHRONIZATION == eventCategoryTO.getType()
+ || AuditElements.EventCategoryType.PUSH == eventCategoryTO.getType())
+ && StringUtils.isEmpty(eventCategoryTO.getCategory())) {
+ res.add(eventCategoryTO.getType().toString());
+ } else if (AuditElements.EventCategoryType.TASK == eventCategoryTO.getType()
+ && StringUtils.isNotEmpty(eventCategoryTO.getCategory())) {
+ res.add(eventCategoryTO.getCategory());
+ }
+ } else {
+ Collections.sort(res);
+ }
+
+ return res;
+ }
+
+ /**
+ * To be extended in order to add actions on events.
+ *
+ * @param event event.
+ */
+ protected abstract void onEventAction(final IEvent<?> event);
+
+ @Override
+ public void onEvent(final IEvent<?> event) {
+ onEventAction(event);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/ImagePanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/ImagePanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/ImagePanel.java
new file mode 100644
index 0000000..b0b3d9a
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/ImagePanel.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import org.apache.wicket.Component;
+import org.apache.wicket.behavior.Behavior;
+import org.apache.wicket.markup.html.image.Image;
+import org.apache.wicket.markup.html.panel.Panel;
+
+public class ImagePanel extends Panel {
+
+ private static final long serialVersionUID = 5564818820574092960L;
+
+ final Image img;
+
+ public ImagePanel(final String id, final String img) {
+ super(id);
+ this.img = new Image("img", img);
+ add(this.img);
+ }
+
+ @Override
+ public Component add(final Behavior... behaviors) {
+ this.img.add(behaviors);
+ return this;
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/JQueryUITabbedPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/JQueryUITabbedPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/JQueryUITabbedPanel.java
new file mode 100644
index 0000000..d898ba6
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/JQueryUITabbedPanel.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.List;
+import org.apache.wicket.extensions.ajax.markup.html.tabs.AjaxTabbedPanel;
+import org.apache.wicket.extensions.markup.html.tabs.ITab;
+
+/**
+ * AjaxTabbedPanel with JQueryUI styling.
+ */
+public class JQueryUITabbedPanel<T extends ITab> extends AjaxTabbedPanel<T> {
+
+ private static final long serialVersionUID = -5059184710433341333L;
+
+ public JQueryUITabbedPanel(final String id, final List<T> tabs) {
+ super(id, tabs);
+ }
+
+ @Override
+ protected String getTabContainerCssClass() {
+ return "";
+ }
+
+ @Override
+ protected String getSelectedTabCssClass() {
+ return "ui-state-active selected";
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LayoutsPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LayoutsPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LayoutsPanel.java
new file mode 100644
index 0000000..a68d8cd
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LayoutsPanel.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.List;
+import org.apache.syncope.client.console.commons.AttrLayoutType;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.commons.SelectChoiceRenderer;
+import org.apache.syncope.client.console.commons.XMLRolesReader;
+import org.apache.syncope.client.console.rest.ConfigurationRestClient;
+import org.apache.syncope.client.console.rest.SchemaRestClient;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxPalettePanel;
+import org.apache.syncope.common.lib.to.AttrTO;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxButton;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.model.util.ListModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LayoutsPanel extends Panel {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(LayoutsPanel.class);
+
+ private static final long serialVersionUID = -6804066913177804275L;
+
+ private static final String CANCEL = "cancel";
+
+ private static final String APPLY = "apply";
+
+ @SpringBean
+ protected XMLRolesReader xmlRolesReader;
+
+ @SpringBean
+ private SchemaRestClient schemaRestClient;
+
+ @SpringBean
+ private ConfigurationRestClient confRestClient;
+
+ @SuppressWarnings("unchecked")
+ public LayoutsPanel(final String id, final AttrLayoutType attrLayoutType, final NotificationPanel feedbackPanel) {
+ super(id);
+
+ final WebMarkupContainer container = new WebMarkupContainer("container");
+ container.setOutputMarkupId(true);
+
+ final Form<String> form = new Form<String>("form");
+ form.setOutputMarkupId(true);
+
+ final AttrTO attrLayout = confRestClient.readAttrLayout(attrLayoutType);
+ form.setModel(new CompoundPropertyModel(attrLayout.getValues()));
+
+ final List<String> fields = schemaRestClient.getSchemaNames(attrLayoutType.getAttrType());
+ final ListModel<String> selectedFields =
+ new ListModel<String>(attrLayout.getValues().isEmpty() ? fields : attrLayout.getValues());
+ final ListModel<String> availableFields = new ListModel<String>(fields);
+
+ form.add(new AjaxPalettePanel<String>("fields", selectedFields, availableFields,
+ new SelectChoiceRenderer<String>(), true, true));
+
+ final AjaxButton submit = new IndicatingAjaxButton(APPLY, new ResourceModel(APPLY)) {
+
+ private static final long serialVersionUID = -958724007591692537L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ try {
+ confRestClient.set(attrLayout);
+ info(getString(Constants.OPERATION_SUCCEEDED));
+ } catch (Exception e) {
+ LOG.error("While saving layout configuration", e);
+ error(getString(Constants.ERROR) + ": " + e.getMessage());
+ }
+ feedbackPanel.refresh(target);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ error(getString(Constants.ERROR) + ": While saving layout configuration");
+ feedbackPanel.refresh(target);
+ }
+ };
+
+ form.add(submit);
+
+ final IndicatingAjaxButton cancel = new IndicatingAjaxButton(CANCEL, new ResourceModel(CANCEL)) {
+
+ private static final long serialVersionUID = -958724007591692537L;
+
+ @Override
+ protected void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
+ target.add(container);
+ }
+
+ @Override
+ protected void onError(final AjaxRequestTarget target, final Form<?> form) {
+ }
+ };
+
+ cancel.setDefaultFormProcessing(false);
+ form.add(cancel);
+ container.add(form);
+ add(container);
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LoggerCategoryPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LoggerCategoryPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LoggerCategoryPanel.java
new file mode 100644
index 0000000..aa3c3eb
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/LoggerCategoryPanel.java
@@ -0,0 +1,468 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.panels.SelectedEventsPanel.EventSelectionChanged;
+import org.apache.syncope.client.console.panels.SelectedEventsPanel.InspectSelectedEvent;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
+import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel;
+import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
+import org.apache.syncope.common.lib.to.EventCategoryTO;
+import org.apache.syncope.common.lib.types.AuditElements;
+import org.apache.syncope.common.lib.types.AuditElements.EventCategoryType;
+import org.apache.syncope.common.lib.types.AuditLoggerName;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+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.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.model.ResourceModel;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class LoggerCategoryPanel extends Panel {
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(LoggerCategoryPanel.class);
+
+ private static final long serialVersionUID = 6429053774964787734L;
+
+ private final List<EventCategoryTO> eventCategoryTOs;
+
+ private final EventCategoryTO eventCategoryTO = new EventCategoryTO();
+
+ private final WebMarkupContainer categoryContainer;
+
+ private final WebMarkupContainer eventsContainer;
+
+ private final SelectedEventsPanel selectedEventsPanel;
+
+ private final AjaxDropDownChoicePanel<EventCategoryType> type;
+
+ private final AjaxDropDownChoicePanel<String> category;
+
+ private final AjaxDropDownChoicePanel<String> subcategory;
+
+ private final AjaxTextFieldPanel custom;
+
+ private final ActionLinksPanel actionPanel;
+
+ private final IModel<List<String>> model;
+
+ public LoggerCategoryPanel(
+ final String id,
+ final List<EventCategoryTO> eventCategoryTOs,
+ final IModel<List<String>> model,
+ final PageReference pageReference,
+ final String pageId) {
+ super(id);
+
+ this.model = model;
+ selectedEventsPanel = new SelectedEventsPanel("selectedEventsPanel", model);
+ add(selectedEventsPanel);
+
+ this.eventCategoryTOs = eventCategoryTOs;
+
+ categoryContainer = new WebMarkupContainer("categoryContainer");
+ categoryContainer.setOutputMarkupId(true);
+ add(categoryContainer);
+
+ eventsContainer = new WebMarkupContainer("eventsContainer");
+ eventsContainer.setOutputMarkupId(true);
+ add(eventsContainer);
+
+ authorizeList();
+ authorizeChanges();
+
+ categoryContainer.add(new Label("typeLabel", new ResourceModel("type", "type")));
+
+ type = new AjaxDropDownChoicePanel<EventCategoryType>(
+ "type",
+ "type",
+ new PropertyModel<EventCategoryType>(eventCategoryTO, "type"),
+ false);
+ type.setChoices(Arrays.asList(EventCategoryType.values()));
+ type.setStyleSheet("ui-widget-content ui-corner-all");
+ type.setChoiceRenderer(new IChoiceRenderer<EventCategoryType>() {
+
+ private static final long serialVersionUID = 2317134950949778735L;
+
+ @Override
+ public String getDisplayValue(final EventCategoryType eventCategoryType) {
+ return eventCategoryType.name();
+ }
+
+ @Override
+ public String getIdValue(final EventCategoryType eventCategoryType, final int i) {
+ return eventCategoryType.name();
+ }
+ });
+ categoryContainer.add(type);
+
+ type.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306810L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, type));
+ }
+ });
+
+ categoryContainer.add(new Label("categoryLabel", new ResourceModel("category", "category")));
+
+ category = new AjaxDropDownChoicePanel<String>(
+ "category",
+ "category",
+ new PropertyModel<String>(eventCategoryTO, "category"),
+ false);
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+ category.setStyleSheet("ui-widget-content ui-corner-all");
+ categoryContainer.add(category);
+
+ category.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306811L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, category));
+ }
+ });
+
+ categoryContainer.add(new Label("subcategoryLabel", new ResourceModel("subcategory", "subcategory")));
+
+ subcategory = new AjaxDropDownChoicePanel<String>(
+ "subcategory",
+ "subcategory",
+ new PropertyModel<String>(eventCategoryTO, "subcategory"),
+ false);
+ subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+ subcategory.setStyleSheet("ui-widget-content ui-corner-all");
+ categoryContainer.add(subcategory);
+
+ subcategory.getField().add(new AjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {
+
+ private static final long serialVersionUID = -1107858522700306812L;
+
+ @Override
+ protected void onUpdate(final AjaxRequestTarget target) {
+ send(LoggerCategoryPanel.this, Broadcast.EXACT, new ChangeCategoryEvent(target, subcategory));
+ }
+ });
+
+ categoryContainer.add(new Label("customLabel", new ResourceModel("custom", "custom")).setVisible(false));
+
+ custom = new AjaxTextFieldPanel("custom", "custom", new Model<String>(null));
+ custom.setStyleSheet("ui-widget-content ui-corner-all short_fixedsize");
+ custom.setVisible(false);
+ custom.setEnabled(false);
+
+ categoryContainer.add(custom);
+
+ actionPanel = new ActionLinksPanel("customActions", new Model(), pageReference);
+ categoryContainer.add(actionPanel);
+
+ actionPanel.add(new ActionLink() {
+
+ private static final long serialVersionUID = -3722207913631435501L;
+
+ @Override
+ public void onClick(final AjaxRequestTarget target) {
+ if (StringUtils.isNotBlank(custom.getModelObject())) {
+ final Map.Entry<EventCategoryTO, AuditElements.Result> parsed =
+ AuditLoggerName.parseEventCategory(custom.getModelObject());
+
+ final String eventString = AuditLoggerName.buildEvent(
+ parsed.getKey().getType(),
+ null,
+ null,
+ parsed.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
+ parsed.getValue());
+
+ custom.setModelObject(StringUtils.EMPTY);
+ send(LoggerCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
+ target,
+ Collections.<String>singleton(eventString),
+ Collections.<String>emptySet()));
+ target.add(categoryContainer);
+ }
+ }
+ }, ActionLink.ActionType.CREATE, pageId, true);
+
+ actionPanel.add(new ActionLink() {
+
+ private static final long serialVersionUID = -3722207913631435502L;
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ if (StringUtils.isNotBlank(custom.getModelObject())) {
+ final Map.Entry<EventCategoryTO, AuditElements.Result> parsed =
+ AuditLoggerName.parseEventCategory(custom.getModelObject());
+
+ final String eventString = AuditLoggerName.buildEvent(
+ parsed.getKey().getType(),
+ null,
+ null,
+ parsed.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : parsed.getKey().getEvents().iterator().next(),
+ parsed.getValue());
+
+ custom.setModelObject(StringUtils.EMPTY);
+ send(LoggerCategoryPanel.this.getPage(), Broadcast.BREADTH, new EventSelectionChanged(
+ target,
+ Collections.<String>emptySet(),
+ Collections.<String>singleton(eventString)));
+ target.add(categoryContainer);
+ }
+ }
+ }, ActionLink.ActionType.DELETE, pageId, true);
+
+ actionPanel.setVisible(false);
+ actionPanel.setEnabled(false);
+
+ eventsContainer.add(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
+
+ private static final long serialVersionUID = 3513194801190026082L;
+
+ @Override
+ protected void onEventAction(final IEvent<?> event) {
+ LoggerCategoryPanel.this.onEventAction(event);
+ }
+ });
+ }
+
+ private List<String> filter(
+ final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type) {
+ final Set<String> res = new HashSet<String>();
+
+ for (EventCategoryTO eventCategory : eventCategoryTOs) {
+ if (type == eventCategory.getType() && StringUtils.isNotEmpty(eventCategory.getCategory())) {
+ res.add(eventCategory.getCategory());
+ }
+ }
+
+ final List<String> filtered = new ArrayList<String>(res);
+ Collections.sort(filtered);
+ return filtered;
+ }
+
+ private List<String> filter(
+ final List<EventCategoryTO> eventCategoryTOs, final EventCategoryType type, final String category) {
+ final Set<String> res = new HashSet<String>();
+
+ for (EventCategoryTO eventCategory : eventCategoryTOs) {
+ if (type == eventCategory.getType() && StringUtils.equals(category, eventCategory.getCategory())
+ && StringUtils.isNotEmpty(eventCategory.getSubcategory())) {
+ res.add(eventCategory.getSubcategory());
+ }
+ }
+
+ final List<String> filtered = new ArrayList<String>(res);
+ Collections.sort(filtered);
+ return filtered;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void onEvent(final IEvent<?> event) {
+ if (event.getPayload() instanceof ChangeCategoryEvent) {
+ // update objects ....
+ eventCategoryTO.getEvents().clear();
+
+ final ChangeCategoryEvent change = (ChangeCategoryEvent) event.getPayload();
+
+ final Panel changedPanel = change.getChangedPanel();
+ if ("type".equals(changedPanel.getId())) {
+ eventCategoryTO.setType(type.getModelObject());
+ eventCategoryTO.setCategory(null);
+ eventCategoryTO.setSubcategory(null);
+
+ if (type.getModelObject() == EventCategoryType.CUSTOM) {
+ category.setChoices(Collections.<String>emptyList());
+ subcategory.setChoices(Collections.<String>emptyList());
+ category.setEnabled(false);
+ subcategory.setEnabled(false);
+ custom.setVisible(true);
+ custom.setEnabled(true);
+ actionPanel.setVisible(true);
+ actionPanel.setEnabled(true);
+
+ } else {
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+ subcategory.setChoices(Collections.<String>emptyList());
+ category.setEnabled(true);
+ subcategory.setEnabled(true);
+ custom.setVisible(false);
+ custom.setEnabled(false);
+ actionPanel.setVisible(false);
+ actionPanel.setEnabled(false);
+ }
+ change.getTarget().add(categoryContainer);
+ } else if ("category".equals(changedPanel.getId())) {
+ subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+ eventCategoryTO.setCategory(category.getModelObject());
+ eventCategoryTO.setSubcategory(null);
+ change.getTarget().add(categoryContainer);
+ } else {
+ eventCategoryTO.setSubcategory(subcategory.getModelObject());
+ }
+
+ updateEventsContainer(change.getTarget());
+ } else if (event.getPayload() instanceof InspectSelectedEvent) {
+ // update objects ....
+ eventCategoryTO.getEvents().clear();
+
+ final InspectSelectedEvent inspectSelectedEvent = (InspectSelectedEvent) event.getPayload();
+
+ final Map.Entry<EventCategoryTO, AuditElements.Result> categoryEvent =
+ AuditLoggerName.parseEventCategory(inspectSelectedEvent.getEvent());
+
+ eventCategoryTO.setType(categoryEvent.getKey().getType());
+ category.setChoices(filter(eventCategoryTOs, type.getModelObject()));
+
+ eventCategoryTO.setCategory(categoryEvent.getKey().getCategory());
+ subcategory.setChoices(filter(eventCategoryTOs, type.getModelObject(), category.getModelObject()));
+
+ eventCategoryTO.setSubcategory(categoryEvent.getKey().getSubcategory());
+
+ if (categoryEvent.getKey().getType() == EventCategoryType.CUSTOM) {
+ custom.setModelObject(AuditLoggerName.buildEvent(
+ categoryEvent.getKey().getType(),
+ categoryEvent.getKey().getCategory(),
+ categoryEvent.getKey().getSubcategory(),
+ categoryEvent.getKey().getEvents().isEmpty()
+ ? StringUtils.EMPTY : categoryEvent.getKey().getEvents().iterator().next(),
+ categoryEvent.getValue()));
+
+ category.setEnabled(false);
+ subcategory.setEnabled(false);
+ custom.setVisible(true);
+ custom.setEnabled(true);
+ actionPanel.setVisible(true);
+ actionPanel.setEnabled(true);
+ } else {
+ category.setEnabled(true);
+ subcategory.setEnabled(true);
+ custom.setVisible(false);
+ custom.setEnabled(false);
+ actionPanel.setVisible(false);
+ actionPanel.setEnabled(false);
+ }
+
+ inspectSelectedEvent.getTarget().add(categoryContainer);
+ updateEventsContainer(inspectSelectedEvent.getTarget());
+ }
+ }
+
+ private void setEvents() {
+ final Iterator<EventCategoryTO> itor = eventCategoryTOs.iterator();
+ while (itor.hasNext() && eventCategoryTO.getEvents().isEmpty()) {
+ final EventCategoryTO eventCategory = itor.next();
+ if (eventCategory.getType() == eventCategoryTO.getType()
+ && StringUtils.equals(eventCategory.getCategory(), eventCategoryTO.getCategory())
+ && StringUtils.equals(eventCategory.getSubcategory(), eventCategoryTO.getSubcategory())) {
+ eventCategoryTO.getEvents().addAll(eventCategory.getEvents());
+ }
+ }
+ }
+
+ private class ChangeCategoryEvent {
+
+ private final AjaxRequestTarget target;
+
+ private final Panel changedPanel;
+
+ public ChangeCategoryEvent(final AjaxRequestTarget target, final Panel changedPanel) {
+ this.target = target;
+ this.changedPanel = changedPanel;
+ }
+
+ public AjaxRequestTarget getTarget() {
+ return target;
+ }
+
+ public Panel getChangedPanel() {
+ return changedPanel;
+ }
+ }
+
+ /**
+ * To be extended in order to add actions on events.
+ *
+ * @param event event.
+ */
+ protected void onEventAction(final IEvent<?> event) {
+ // nothing by default
+ }
+
+ private void authorizeList() {
+ for (String role : getListRoles()) {
+ MetaDataRoleAuthorizationStrategy.authorize(selectedEventsPanel, RENDER, role);
+ }
+ }
+
+ private void authorizeChanges() {
+ for (String role : getChangeRoles()) {
+ MetaDataRoleAuthorizationStrategy.authorize(categoryContainer, RENDER, role);
+ MetaDataRoleAuthorizationStrategy.authorize(eventsContainer, RENDER, role);
+ }
+ }
+
+ private void updateEventsContainer(final AjaxRequestTarget target) {
+ setEvents();
+
+ eventsContainer.addOrReplace(new EventSelectionPanel("eventsPanel", eventCategoryTO, model) {
+
+ private static final long serialVersionUID = 3513194801190026082L;
+
+ @Override
+ public void onEventAction(final IEvent<?> event) {
+ LoggerCategoryPanel.this.onEventAction(event);
+ }
+ });
+ target.add(eventsContainer);
+ }
+
+ protected abstract String[] getListRoles();
+
+ protected abstract String[] getChangeRoles();
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/MembershipsPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/MembershipsPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/MembershipsPanel.java
new file mode 100644
index 0000000..fb00dcf
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/MembershipsPanel.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.swing.tree.DefaultMutableTreeNode;
+import org.apache.syncope.client.console.commons.Mode;
+import org.apache.syncope.client.console.commons.RoleTreeBuilder;
+import org.apache.syncope.client.console.commons.RoleUtils;
+import org.apache.syncope.client.console.commons.status.StatusUtils;
+import org.apache.syncope.client.console.pages.MembershipModalPage;
+import org.apache.syncope.client.console.pages.UserModalPage;
+import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink;
+import org.apache.syncope.client.console.wicket.ajax.markup.html.IndicatingOnConfirmAjaxLink;
+import org.apache.syncope.client.console.wicket.markup.html.tree.DefaultMutableTreeNodeExpansion;
+import org.apache.syncope.client.console.wicket.markup.html.tree.DefaultMutableTreeNodeExpansionModel;
+import org.apache.syncope.client.console.wicket.markup.html.tree.TreeRoleProvider;
+import org.apache.syncope.common.lib.to.MembershipTO;
+import org.apache.syncope.common.lib.to.RoleTO;
+import org.apache.syncope.common.lib.to.UserTO;
+import org.apache.wicket.Component;
+import org.apache.wicket.Page;
+import org.apache.wicket.PageReference;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
+import org.apache.wicket.extensions.markup.html.repeater.tree.DefaultNestedTree;
+import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider;
+import org.apache.wicket.extensions.markup.html.repeater.tree.NestedTree;
+import org.apache.wicket.extensions.markup.html.repeater.tree.content.Folder;
+import org.apache.wicket.extensions.markup.html.repeater.tree.theme.WindowsTheme;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.list.ListItem;
+import org.apache.wicket.markup.html.list.ListView;
+import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.PropertyModel;
+import org.apache.wicket.spring.injection.annot.SpringBean;
+
+public class MembershipsPanel extends Panel {
+
+ private static final long serialVersionUID = -2559791301973107191L;
+
+ @SpringBean
+ private RoleTreeBuilder roleTreeBuilder;
+
+ private final ListView<MembershipTO> membView;
+
+ private final UserTO userTO;
+
+ private final StatusPanel statusPanel;
+
+ private final NestedTree<DefaultMutableTreeNode> tree;
+
+ public MembershipsPanel(final String id, final UserTO userTO, final Mode mode,
+ final StatusPanel statusPanel, final PageReference pageRef) {
+
+ super(id);
+ this.userTO = userTO;
+ this.statusPanel = statusPanel;
+
+ final WebMarkupContainer membershipsContainer = new WebMarkupContainer("membershipsContainer");
+ membershipsContainer.setOutputMarkupId(true);
+ add(membershipsContainer);
+
+ final ModalWindow membWin = new ModalWindow("membershipWin");
+ membWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
+ membWin.setCookieName("create-membership-modal");
+ add(membWin);
+
+ final ITreeProvider<DefaultMutableTreeNode> treeProvider = new TreeRoleProvider(roleTreeBuilder, true);
+ final DefaultMutableTreeNodeExpansionModel treeModel = new DefaultMutableTreeNodeExpansionModel();
+
+ tree = new DefaultNestedTree<DefaultMutableTreeNode>("treeTable", treeProvider, treeModel) {
+
+ private static final long serialVersionUID = 7137658050662575546L;
+
+ @Override
+ protected Component newContentComponent(final String id, final IModel<DefaultMutableTreeNode> node) {
+ final DefaultMutableTreeNode treeNode = node.getObject();
+ final RoleTO roleTO = (RoleTO) treeNode.getUserObject();
+
+ return new Folder<DefaultMutableTreeNode>(id, MembershipsPanel.this.tree, node) {
+
+ private static final long serialVersionUID = 9046323319920426493L;
+
+ @Override
+ protected boolean isClickable() {
+ return true;
+ }
+
+ @Override
+ protected IModel<?> newLabelModel(final IModel<DefaultMutableTreeNode> model) {
+ return new Model<String>(roleTO.getDisplayName());
+ }
+
+ @Override
+ protected void onClick(final AjaxRequestTarget target) {
+ if (roleTO.getKey() > 0) {
+ membWin.setPageCreator(new ModalWindow.PageCreator() {
+
+ private static final long serialVersionUID = 7661763358801821185L;
+
+ @Override
+ public Page createPage() {
+ PageReference pageRef = getPage().getPageReference();
+
+ for (MembershipTO membTO : membView.getList()) {
+ if (membTO.getRoleId() == roleTO.getKey()) {
+ return new MembershipModalPage(pageRef, membWin, membTO, mode);
+ }
+ }
+ MembershipTO membTO = new MembershipTO();
+ membTO.setRoleId(roleTO.getKey());
+ membTO.setRoleName(roleTO.getName());
+
+ return new MembershipModalPage(pageRef, membWin, membTO, mode);
+ }
+ });
+ membWin.show(target);
+ }
+ }
+ };
+ }
+ };
+ tree.add(new WindowsTheme());
+ tree.setOutputMarkupId(true);
+
+ DefaultMutableTreeNodeExpansion.get().expandAll();
+
+ this.add(tree);
+
+ membView = new ListView<MembershipTO>("memberships",
+ new PropertyModel<List<? extends MembershipTO>>(userTO, "memberships")) {
+
+ private static final long serialVersionUID = 9101744072914090143L;
+
+ @Override
+ protected void populateItem(final ListItem<MembershipTO> item) {
+ final MembershipTO membershipTO = (MembershipTO) item.getDefaultModelObject();
+
+ item.add(new Label("roleId", new Model<Long>(membershipTO.getRoleId())));
+ item.add(new Label("roleName", new Model<String>(membershipTO.getRoleName())));
+
+ AjaxLink editLink = new ClearIndicatingAjaxLink("editLink", pageRef) {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ protected void onClickInternal(final AjaxRequestTarget target) {
+ membWin.setPageCreator(new ModalWindow.PageCreator() {
+
+ private static final long serialVersionUID = -7834632442532690940L;
+
+ @Override
+ public Page createPage() {
+ return new MembershipModalPage(getPage().getPageReference(), membWin,
+ membershipTO, mode);
+
+ }
+ });
+ membWin.show(target);
+ }
+ };
+ item.add(editLink);
+
+ AjaxLink deleteLink = new IndicatingOnConfirmAjaxLink("deleteLink", pageRef) {
+
+ private static final long serialVersionUID = -7978723352517770644L;
+
+ @Override
+ protected void onClickInternal(final AjaxRequestTarget target) {
+ userTO.getMemberships().remove(membershipTO);
+ ((UserModalPage) getPage()).getUserTO().getMemberships().remove(membershipTO);
+ target.add(membershipsContainer);
+
+ RoleTO roleTO = RoleUtils.findRole(roleTreeBuilder, membershipTO.getRoleId());
+ Set<String> resourcesToRemove = roleTO == null
+ ? Collections.<String>emptySet() : roleTO.getResources();
+ if (!resourcesToRemove.isEmpty()) {
+ Set<String> resourcesAssignedViaMembership = new HashSet<String>();
+ for (MembershipTO membTO : userTO.getMemberships()) {
+ roleTO = RoleUtils.findRole(roleTreeBuilder, membTO.getRoleId());
+ if (roleTO != null) {
+ resourcesAssignedViaMembership.addAll(roleTO.getResources());
+ }
+ }
+ resourcesToRemove.removeAll(resourcesAssignedViaMembership);
+ resourcesToRemove.removeAll(userTO.getResources());
+ }
+
+ StatusUtils.update(
+ userTO, statusPanel, target, Collections.<String>emptySet(), resourcesToRemove);
+ }
+ };
+ item.add(deleteLink);
+ }
+ };
+
+ membershipsContainer.add(membView);
+
+ setWindowClosedCallback(membWin, membershipsContainer);
+ }
+
+ private void setWindowClosedCallback(final ModalWindow window, final WebMarkupContainer container) {
+ window.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+
+ private static final long serialVersionUID = 8804221891699487139L;
+
+ @Override
+ public void onClose(final AjaxRequestTarget target) {
+ final UserTO updatedUserTO = ((UserModalPage) getPage()).getUserTO();
+ if (!userTO.equals(updatedUserTO)) {
+ if (updatedUserTO.getMemberships().size() > userTO.getMemberships().size()) {
+ Set<Long> diff = new HashSet<Long>(updatedUserTO.getMembershipMap().keySet());
+ diff.removeAll(userTO.getMembershipMap().keySet());
+
+ Set<String> resourcesToAdd = new HashSet<String>();
+ for (Long diffMembId : diff) {
+ long roleId = updatedUserTO.getMembershipMap().get(diffMembId).getRoleId();
+ RoleTO roleTO = RoleUtils.findRole(roleTreeBuilder, roleId);
+ resourcesToAdd.addAll(roleTO.getResources());
+ StatusUtils.update(
+ userTO, statusPanel, target, resourcesToAdd, Collections.<String>emptySet());
+ }
+ }
+
+ MembershipsPanel.this.userTO.getMemberships().clear();
+ MembershipsPanel.this.userTO.getMemberships().addAll(updatedUserTO.getMemberships());
+ target.add(container);
+ }
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/32707b3b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/NotificationPanel.java
----------------------------------------------------------------------
diff --git a/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/NotificationPanel.java b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/NotificationPanel.java
new file mode 100644
index 0000000..8624d26
--- /dev/null
+++ b/syncope620/client/console/src/main/java/org/apache/syncope/client/console/panels/NotificationPanel.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.client.console.panels;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.syncope.client.console.commons.Constants;
+import org.apache.wicket.AttributeModifier;
+import org.apache.wicket.ajax.AjaxEventBehavior;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.feedback.FeedbackMessage;
+import org.apache.wicket.feedback.IFeedbackMessageFilter;
+import org.apache.wicket.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.Model;
+
+public class NotificationPanel extends FeedbackPanel {
+
+ private static final long serialVersionUID = 5895940553202128621L;
+
+ private static final String CSS_CLASS = "notificationpanel";
+
+ private static final String DEFAULT_ADDITIONAL_CSS_CLASS = "notificationpanel_top_right";
+
+ private final String additionalCSSClass;
+
+ public NotificationPanel(final String id) {
+ this(id, null, null);
+ }
+
+ public NotificationPanel(final String id, final String additionalCSSClass,
+ final IFeedbackMessageFilter feedbackMessageFilter) {
+
+ super(id, feedbackMessageFilter);
+
+ this.add(new AjaxEventBehavior(Constants.ON_CLICK) {
+
+ private static final long serialVersionUID = -7133385027739964990L;
+
+ @Override
+ protected void onEvent(final AjaxRequestTarget target) {
+ target.appendJavaScript(
+ "setTimeout(\"$('div#" + getMarkupId() + "').fadeOut('normal')\", 0);");
+ }
+ });
+
+ this.additionalCSSClass = StringUtils.isBlank(additionalCSSClass)
+ ? DEFAULT_ADDITIONAL_CSS_CLASS
+ : additionalCSSClass;
+
+ // set custom markup id and ouput it, to find the component later on in the js function
+ setMarkupId(id);
+ setOutputMarkupId(true);
+
+ // Add the additional cssClass and hide the element by default
+ add(new AttributeModifier("class", new Model<String>(CSS_CLASS + " " + this.additionalCSSClass)));
+ add(new AttributeModifier("style", new Model<String>("opacity: 0;")));
+ }
+
+ /**
+ * Method to refresh the notification panel.
+ *
+ * If there are any feedback messages for the user, find the gravest level, format the notification panel
+ * accordingly and show it.
+ *
+ * @param target AjaxRequestTarget to add panel and the calling javascript function
+ */
+ public void refresh(final AjaxRequestTarget target) {
+ // any feedback at all in the current form?
+ if (anyMessage()) {
+ int highestFeedbackLevel = FeedbackMessage.INFO;
+
+ // any feedback with the given level?
+ if (anyMessage(FeedbackMessage.WARNING)) {
+ highestFeedbackLevel = FeedbackMessage.WARNING;
+ }
+ if (anyMessage(FeedbackMessage.ERROR)) {
+ highestFeedbackLevel = FeedbackMessage.ERROR;
+ }
+
+ // add the css classes to the notification panel,
+ // including the border css which represents the highest level of feedback
+ add(new AttributeModifier("class",
+ new Model<String>(CSS_CLASS
+ + " " + additionalCSSClass
+ + " notificationpanel_border_" + highestFeedbackLevel)));
+
+ // refresh the panel and call the js function with the panel markup id
+ // and the total count of messages
+ target.add(this);
+ if (anyMessage(FeedbackMessage.ERROR)) {
+ target.appendJavaScript(
+ "$('div#" + getMarkupId() + "').fadeTo('normal', 1.0);");
+ } else {
+ target.appendJavaScript(
+ "showNotification('" + getMarkupId() + "', " + getCurrentMessages().size() + ");");
+ }
+ }
+ }
+
+ @Override
+ protected String getCSSClass(final FeedbackMessage message) {
+ return "notificationpanel_row_" + message.getLevelAsString();
+ }
+}