You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2015/11/27 17:32:31 UTC
syncope git commit: [SYNCOPE-734] Hide activity indicator on
datatable component
Repository: syncope
Updated Branches:
refs/heads/master e66dcf424 -> 073e29a16
[SYNCOPE-734] Hide activity indicator on datatable component
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/073e29a1
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/073e29a1
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/073e29a1
Branch: refs/heads/master
Commit: 073e29a16c6885163c94d7f5d3a9a5553a3ae231
Parents: e66dcf4
Author: Marco Di Sabatino Di Diodoro <md...@apache.org>
Authored: Fri Nov 27 17:32:11 2015 +0100
Committer: Marco Di Sabatino Di Diodoro <md...@apache.org>
Committed: Fri Nov 27 17:32:11 2015 +0100
----------------------------------------------------------------------
.../console/pages/ProvisioningModalPage.java | 253 -------------------
.../console/panels/ActionDataTablePanel.java | 4 +-
.../console/panels/AjaxDataTablePanel.java | 5 +-
...AjaxFormChoiceComponentUpdatingBehavior.java | 44 ++++
4 files changed, 48 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/073e29a1/client/console/src/main/java/org/apache/syncope/client/console/pages/ProvisioningModalPage.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/pages/ProvisioningModalPage.java b/client/console/src/main/java/org/apache/syncope/client/console/pages/ProvisioningModalPage.java
deleted file mode 100644
index 4fb3630..0000000
--- a/client/console/src/main/java/org/apache/syncope/client/console/pages/ProvisioningModalPage.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * 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.pages;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.client.console.commons.Constants;
-import org.apache.syncope.client.console.commons.status.AbstractStatusBeanProvider;
-import org.apache.syncope.client.console.commons.status.ConnObjectWrapper;
-import org.apache.syncope.client.console.commons.status.StatusBean;
-import org.apache.syncope.client.console.commons.status.StatusUtils;
-import org.apache.syncope.client.console.panels.ActionDataTablePanel;
-import org.apache.syncope.client.console.rest.GroupRestClient;
-import org.apache.syncope.client.console.rest.ResourceRestClient;
-import org.apache.syncope.client.console.rest.UserRestClient;
-import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
-import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
-import org.apache.syncope.client.lib.SyncopeClient;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.BulkActionResult;
-import org.apache.syncope.common.lib.to.ResourceTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.ResourceDeassociationAction;
-import org.apache.wicket.PageReference;
-import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
-import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.repeater.Item;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.StringResourceModel;
-
-public class ProvisioningModalPage<T extends AnyTO> extends AbstractStatusModalPage {
-
- private static final long serialVersionUID = -4285220460543213901L;
-
- private static final int ROWS_PER_PAGE = 10;
-
- private final UserRestClient userRestClient = new UserRestClient();
-
- private final GroupRestClient groupRestClient = new GroupRestClient();
-
- private final ResourceRestClient resourceRestClient = new ResourceRestClient();
-
- private final ResourceTO resourceTO;
-
- private final AnyTypeKind anyTypeKind;
-
- private final StatusUtils statusUtils;
-
- private final String realm = "/";
-
- public ProvisioningModalPage(
- final BaseModal<?> modal,
- final PageReference pageRef,
- final ResourceTO resourceTO,
- final AnyTypeKind anyTypeKind) {
-
- super(modal, pageRef);
-
- this.resourceTO = resourceTO;
- this.anyTypeKind = anyTypeKind;
-
- statusUtils = new StatusUtils(anyTypeKind == AnyTypeKind.USER ? userRestClient : groupRestClient);
-
- add(new Label("displayName", StringUtils.EMPTY));
-
- final List<IColumn<StatusBean, String>> columns = new ArrayList<>();
- columns.add(new PropertyColumn<StatusBean, String>(
- new StringResourceModel("key", this).setDefaultValue("Attributable key"),
- "attributableKey", "attributableKey"));
- columns.add(new PropertyColumn<StatusBean, String>(
- new StringResourceModel("name", this).setDefaultValue("Attributable name"),
- "attributableName", "attributableName"));
- columns.add(new PropertyColumn<StatusBean, String>(
- new StringResourceModel("resourceName", this).setDefaultValue("Resource name"),
- "resourceName", "resourceName"));
- columns.add(new PropertyColumn<StatusBean, String>(
- new StringResourceModel("connObjectLink", this).setDefaultValue("ConnObjectLink"),
- "connObjectLink", "connObjectLink"));
- columns.add(new AbstractColumn<StatusBean, String>(
- new StringResourceModel("status", this).setDefaultValue(StringUtils.EMPTY)) {
-
- private static final long serialVersionUID = -3503023501954863131L;
-
- @Override
- public String getCssClass() {
- return "action";
- }
-
- @Override
- public void populateItem(
- final Item<ICellPopulator<StatusBean>> cellItem,
- final String componentId,
- final IModel<StatusBean> model) {
- cellItem.
- add(statusUtils.getStatusImagePanel(componentId, model.getObject().getStatus()));
- }
- });
-
- final ActionDataTablePanel<StatusBean, String> table = new ActionDataTablePanel<>(
- "resourceDatatable",
- columns,
- (ISortableDataProvider<StatusBean, String>) new StatusBeanProvider(),
- ROWS_PER_PAGE,
- pageRef);
-
- final String pageId = "Resources";
-
- table.addAction(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- try {
- bulkAssociationAction(target, ResourceDeassociationAction.UNLINK, table, columns);
- } catch (Exception e) {
- LOG.error("Error unlinkink resources", e);
- error(getString(Constants.ERROR) + ": " + e.getMessage());
- modal.getFeedbackPanel().refresh(target);
- }
- }
- }, ActionLink.ActionType.UNLINK, pageId);
-
- table.addAction(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- try {
- bulkAssociationAction(target, ResourceDeassociationAction.DEPROVISION, table, columns);
- } catch (Exception e) {
- LOG.error("Error de-provisioning user", e);
- error(getString(Constants.ERROR) + ": " + e.getMessage());
- modal.getFeedbackPanel().refresh(target);
- }
- }
- }, ActionLink.ActionType.DEPROVISION, pageId);
-
- table.addAction(new ActionLink<Serializable>() {
-
- private static final long serialVersionUID = -3722207913631435501L;
-
- @Override
- public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
- try {
- bulkAssociationAction(target, ResourceDeassociationAction.UNASSIGN, table, columns);
- } catch (Exception e) {
- LOG.error("Error unassigning resources", e);
- error(getString(Constants.ERROR) + ": " + e.getMessage());
- modal.getFeedbackPanel().refresh(target);
- }
- }
- }, ActionLink.ActionType.UNASSIGN, pageId);
-
- table.addCancelButton(modal);
-
- add(table);
- }
-
- private class StatusBeanProvider extends AbstractStatusBeanProvider {
-
- private static final long serialVersionUID = 4287357360778016173L;
-
- StatusBeanProvider() {
- super("connObjectLink");
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List<StatusBean> getStatusBeans() {
- final String fiql = SyncopeClient.getUserSearchConditionBuilder().hasResources(resourceTO.getKey()).query();
-
- final List<T> subjects = new ArrayList<>();
- if (anyTypeKind == AnyTypeKind.USER) {
- subjects.addAll((List<T>) userRestClient.search(
- realm, fiql, 1, ROWS_PER_PAGE, new SortParam<>("key", true), AnyTypeKind.USER.toString()));
- } else {
- subjects.addAll((List<T>) groupRestClient.search(
- realm, fiql, 1, ROWS_PER_PAGE, new SortParam<>("key", true), AnyTypeKind.GROUP.toString()));
- }
-
- final List<ConnObjectWrapper> connObjects = statusUtils.getConnectorObjects(
- (List<AnyTO>) subjects, Collections.<String>singleton(resourceTO.getKey()));
-
- final List<StatusBean> statusBeans = new ArrayList<>(connObjects.size() + 1);
- final LinkedHashMap<String, StatusBean> initialStatusBeanMap = new LinkedHashMap<>(connObjects.size());
-
- for (ConnObjectWrapper entry : connObjects) {
- StatusBean statusBean = statusUtils.getStatusBean(entry.getAny(),
- entry.getResourceName(),
- entry.getConnObjectTO(),
- anyTypeKind == AnyTypeKind.GROUP);
-
- initialStatusBeanMap.put(entry.getResourceName(), statusBean);
- statusBeans.add(statusBean);
- }
-
- return statusBeans;
- }
- }
-
- private void bulkAssociationAction(
- final AjaxRequestTarget target,
- final ResourceDeassociationAction action,
- final ActionDataTablePanel<StatusBean, String> table,
- final List<IColumn<StatusBean, String>> columns) {
-
- List<StatusBean> beans = new ArrayList<>(table.getModelObject());
- List<Long> anyKeys = new ArrayList<>();
- for (StatusBean bean : beans) {
- anyKeys.add(bean.getAnyKey());
- }
-
- if (beans.isEmpty()) {
- modal.close(target);
- } else {
- BulkActionResult res = resourceRestClient.bulkAssociationAction(
- resourceTO.getKey(), anyTypeKind.name(), action, anyKeys);
-
- ((BasePage) pageRef.getPage()).setModalResult(true);
-
- target.add(modal.setContent(
- new BulkActionResultModalPage<>(modal, pageRef, beans, columns, res, "anyKey")));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/073e29a1/client/console/src/main/java/org/apache/syncope/client/console/panels/ActionDataTablePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/ActionDataTablePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/ActionDataTablePanel.java
index 73748c0..eb4421a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/ActionDataTablePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/ActionDataTablePanel.java
@@ -22,6 +22,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.apache.syncope.client.console.commons.ActionTableCheckGroup;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormChoiceComponentUpdatingBehavior;
import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxButton;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AjaxFallbackDataTable;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.CheckGroupColumn;
@@ -32,7 +33,6 @@ import org.apache.syncope.client.console.wicket.markup.html.form.ActionLinksPane
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
@@ -75,7 +75,7 @@ public class ActionDataTablePanel<T, S> extends DataTablePanel<T, S> {
return isElementEnabled(element);
}
};
- group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+ group.add(new IndicatorAjaxFormChoiceComponentUpdatingBehavior() {
private static final long serialVersionUID = -151291731388673682L;
http://git-wip-us.apache.org/repos/asf/syncope/blob/073e29a1/client/console/src/main/java/org/apache/syncope/client/console/panels/AjaxDataTablePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/AjaxDataTablePanel.java b/client/console/src/main/java/org/apache/syncope/client/console/panels/AjaxDataTablePanel.java
index 0272555..e1dba17 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/AjaxDataTablePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/AjaxDataTablePanel.java
@@ -25,6 +25,7 @@ import org.apache.syncope.client.console.wicket.markup.html.form.ActionLink;
import org.apache.syncope.client.console.panels.AbstractSearchResultPanel.EventDataWrapper;
import org.apache.syncope.client.console.pages.AbstractBasePage;
import org.apache.syncope.client.console.commons.Constants;
+import org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormChoiceComponentUpdatingBehavior;
import org.apache.syncope.client.console.pages.BulkActionModalPage;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.CheckGroupColumn;
import org.apache.syncope.client.console.wicket.ajax.markup.html.ClearIndicatingAjaxButton;
@@ -33,7 +34,6 @@ import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.Bas
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
import org.apache.wicket.event.Broadcast;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
@@ -96,13 +96,12 @@ public class AjaxDataTablePanel<T, S> extends DataTablePanel<T, S> {
fragment.add(bulkActionForm);
group = new CheckGroup<>("checkgroup", model);
- group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+ group.add(new IndicatorAjaxFormChoiceComponentUpdatingBehavior() {
private static final long serialVersionUID = -151291731388673682L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
- // triggers AJAX form submit
}
});
bulkActionForm.add(group);
http://git-wip-us.apache.org/repos/asf/syncope/blob/073e29a1/client/console/src/main/java/org/apache/syncope/client/console/wicket/ajax/form/IndicatorAjaxFormChoiceComponentUpdatingBehavior.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wicket/ajax/form/IndicatorAjaxFormChoiceComponentUpdatingBehavior.java b/client/console/src/main/java/org/apache/syncope/client/console/wicket/ajax/form/IndicatorAjaxFormChoiceComponentUpdatingBehavior.java
new file mode 100644
index 0000000..db9680e
--- /dev/null
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wicket/ajax/form/IndicatorAjaxFormChoiceComponentUpdatingBehavior.java
@@ -0,0 +1,44 @@
+/*
+ * 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.wicket.ajax.form;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.wicket.ajax.IAjaxIndicatorAware;
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
+
+public abstract class IndicatorAjaxFormChoiceComponentUpdatingBehavior
+ extends AjaxFormChoiceComponentUpdatingBehavior implements IAjaxIndicatorAware {
+
+ private static final long serialVersionUID = -5144403874783384604L;
+
+ private final String indicator;
+
+ public IndicatorAjaxFormChoiceComponentUpdatingBehavior() {
+ this(StringUtils.EMPTY);
+ }
+
+ public IndicatorAjaxFormChoiceComponentUpdatingBehavior(final String indicator) {
+ this.indicator = indicator;
+ }
+
+ @Override
+ public String getAjaxIndicatorMarkupId() {
+ return indicator;
+ }
+}