syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject svn commit: r1554407 - in /syncope/trunk: ./ console/src/main/java/org/apache/syncope/console/commons/ console/src/main/java/org/apache/syncope/console/commons/status/ console/src/main/java/org/apache/syncope/console/pages/panels/ console/src/test/java...
Date Tue, 31 Dec 2013 11:58:55 GMT
Author: fmartelli
Date: Tue Dec 31 11:58:55 2013
New Revision: 1554407

URL: http://svn.apache.org/r1554407
Log:
Fix for SYNCOPE-465 merged from the branch 1.1.X

Added:
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/DataTablePanel.java
      - copied, changed from r1554395, syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
Modified:
    syncope/trunk/   (props changed)
    syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ActionDataTablePanel.java
    syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
    syncope/trunk/console/src/test/java/org/apache/syncope/console/UserTestITCase.java

Propchange: syncope/trunk/
------------------------------------------------------------------------------
  Merged /syncope/branches/1_1_X:r1554233-1554395

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java?rev=1554407&r1=1554406&r2=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/ActionTableCheckGroup.java
Tue Dec 31 11:58:55 2013
@@ -20,16 +20,20 @@ package org.apache.syncope.console.commo
 
 import java.util.Collection;
 import org.apache.wicket.markup.html.form.CheckGroup;
+import org.apache.wicket.model.IModel;
 
 public class ActionTableCheckGroup<T> extends CheckGroup<T> {
 
     private static final long serialVersionUID = 1288270558573401394L;
 
-    public ActionTableCheckGroup(String id,
-            Collection<T> collection) {
+    public ActionTableCheckGroup(final String id, final Collection<T> collection) {
         super(id, collection);
     }
 
+    public ActionTableCheckGroup(final String id, final IModel<Collection<T>>
model) {
+        super(id, model);
+    }
+
     public boolean isCheckable(final T element) {
         return true;
     }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java?rev=1554407&r1=1554406&r2=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/commons/status/StatusBean.java
Tue Dec 31 11:58:55 2013
@@ -19,6 +19,8 @@
 package org.apache.syncope.console.commons.status;
 
 import java.io.Serializable;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.syncope.common.to.AbstractAttributableTO;
@@ -88,4 +90,14 @@ public class StatusBean implements Seria
     public String toString() {
         return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
     }
+
+    @Override
+    public boolean equals(final Object obj) {
+        return EqualsBuilder.reflectionEquals(this, obj);
+    }
+
+    @Override
+    public int hashCode() {
+        return HashCodeBuilder.reflectionHashCode(this);
+    }
 }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ActionDataTablePanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ActionDataTablePanel.java?rev=1554407&r1=1554406&r2=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ActionDataTablePanel.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/ActionDataTablePanel.java
Tue Dec 31 11:58:55 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.console.pages.panels;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.apache.syncope.console.commons.ActionTableCheckGroup;
@@ -37,33 +36,20 @@ import org.apache.wicket.extensions.ajax
 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.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.form.CheckGroup;
 import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.panel.Panel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.model.ResourceModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-public class ActionDataTablePanel<T, S> extends Panel {
+public class ActionDataTablePanel<T, S> extends DataTablePanel<T, S> {
 
     private static final long serialVersionUID = -8826989026203543957L;
 
-    /**
-     * Logger.
-     */
-    private static final Logger LOG = LoggerFactory.getLogger(ActionDataTablePanel.class);
-
     private static final String CANCEL = "cancel";
 
-    private final CheckGroup<T> group;
-
-    private final Form<?> bulkActionForm;
+    private final Form<T> bulkActionForm;
 
     private final ActionLinksPanel actionPanel;
 
-    private final AjaxFallbackDefaultDataTable<T, S> dataTable;
-
     private final PageReference pageRef;
 
     public ActionDataTablePanel(
@@ -77,10 +63,10 @@ public class ActionDataTablePanel<T, S> 
 
         this.pageRef = pageRef;
 
-        bulkActionForm = new Form("groupForm");
+        bulkActionForm = new Form<T>("groupForm");
         add(bulkActionForm);
 
-        group = new ActionTableCheckGroup<T>("checkgroup", new ArrayList<T>())
{
+        group = new ActionTableCheckGroup<T>("checkgroup", model) {
 
             private static final long serialVersionUID = -8667764190925075389L;
 
@@ -95,7 +81,7 @@ public class ActionDataTablePanel<T, S> 
 
             @Override
             protected void onUpdate(final AjaxRequestTarget target) {
-                // ignore
+                // triggers AJAX form submit
             }
         });
         bulkActionForm.add(group);
@@ -125,26 +111,6 @@ public class ActionDataTablePanel<T, S> 
         }.setVisible(false).setEnabled(false));
     }
 
-    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);
-    }
-
     public void addAction(final ActionLink action, final ActionType type, final String pageId)
{
         actionPanel.add(action, type, pageId);
     }

Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java?rev=1554407&r1=1554406&r2=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
Tue Dec 31 11:58:55 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.syncope.console.pages.panels;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.apache.syncope.console.commons.Constants;
@@ -41,14 +40,11 @@ import org.apache.wicket.extensions.mark
 import org.apache.wicket.markup.html.form.CheckGroup;
 import org.apache.wicket.markup.html.form.Form;
 import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.markup.html.panel.Panel;
 
-public class AjaxDataTablePanel<T, S> extends Panel {
+public class AjaxDataTablePanel<T, S> extends DataTablePanel<T, S> {
 
     private static final long serialVersionUID = -7264400471578272966L;
 
-    private final AjaxFallbackDefaultDataTable<T, S> dataTable;
-
     public AjaxDataTablePanel(
             final String id,
             final List<IColumn<T, S>> columns,
@@ -100,7 +96,7 @@ public class AjaxDataTablePanel<T, S> ex
         Form<T> bulkActionForm = new Form<T>("groupForm");
         fragment.add(bulkActionForm);
 
-        final CheckGroup<T> group = new CheckGroup<T>("checkgroup", new ArrayList<T>());
+        group = new CheckGroup<T>("checkgroup", model);
         group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
 
             private static final long serialVersionUID = -151291731388673682L;
@@ -109,7 +105,6 @@ public class AjaxDataTablePanel<T, S> ex
             protected void onUpdate(final AjaxRequestTarget target) {
                 // triggers AJAX form submit
             }
-
         });
         bulkActionForm.add(group);
 
@@ -144,24 +139,4 @@ public class AjaxDataTablePanel<T, S> ex
             }
         });
     }
-
-    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);
-    }
 }

Copied: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/DataTablePanel.java
(from r1554395, syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java)
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/DataTablePanel.java?p2=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/DataTablePanel.java&p1=syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java&r1=1554395&r2=1554407&rev=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java
(original)
+++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/DataTablePanel.java
Tue Dec 31 11:58:55 2013
@@ -18,131 +18,62 @@
  */
 package org.apache.syncope.console.pages.panels;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
-import org.apache.syncope.console.commons.Constants;
-import org.apache.syncope.console.pages.AbstractBasePage;
-import org.apache.syncope.console.pages.BulkActionModalPage;
-import org.apache.syncope.console.pages.panels.AbstractSearchResultPanel.EventDataWrapper;
-import org.apache.syncope.console.rest.BaseRestClient;
-import org.apache.syncope.console.wicket.ajax.markup.html.ClearIndicatingAjaxButton;
-import org.apache.syncope.console.wicket.extensions.markup.html.repeater.data.table.CheckGroupColumn;
-import org.apache.syncope.console.wicket.markup.html.form.ActionLink;
-import org.apache.wicket.Page;
-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 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.table.IColumn;
-import org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider;
+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.form.Form;
-import org.apache.wicket.markup.html.panel.Fragment;
 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 class AjaxDataTablePanel<T, S> extends Panel {
+public abstract class DataTablePanel<T, S> extends Panel {
 
     private static final long serialVersionUID = -7264400471578272966L;
 
-    private final AjaxFallbackDefaultDataTable<T, S> dataTable;
+    /**
+     * Logger.
+     */
+    private static final Logger LOG = LoggerFactory.getLogger(DataTablePanel.class);
 
-    public AjaxDataTablePanel(
-            final String id,
-            final List<IColumn<T, S>> columns,
-            final ISortableDataProvider<T, S> dataProvider,
-            final int rowsPerPage,
-            final Collection<ActionLink.ActionType> actions,
-            final BaseRestClient bulkActionExecutor,
-            final String itemIdField,
-            final String pageId,
-            final PageReference pageRef) {
+    protected CheckGroup<T> group;
 
+    protected AjaxFallbackDefaultDataTable<T, S> dataTable;
+
+    protected IModel<Collection<T>> model;
+
+    public DataTablePanel(final String id) {
         super(id);
 
-        final ModalWindow bulkModalWin = new ModalWindow("bulkModal");
-        bulkModalWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
-        bulkModalWin.setInitialHeight(600);
-        bulkModalWin.setInitialWidth(900);
-        bulkModalWin.setCookieName("bulk-modal");
-        add(bulkModalWin);
+        model = new IModel<Collection<T>>() {
 
-        bulkModalWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
+            private static final long serialVersionUID = 4886729136344643465L;
 
-            private static final long serialVersionUID = 8804221891699487149L;
+            private Collection<T> values = new HashSet<T>();
 
             @Override
-            public void onClose(final AjaxRequestTarget target) {
-                final EventDataWrapper data = new EventDataWrapper();
-                data.setTarget(target);
-                data.setRows(rowsPerPage);
-
-                send(pageRef.getPage(), Broadcast.BREADTH, data);
-
-                final AbstractBasePage page = (AbstractBasePage) pageRef.getPage();
-
-                if (page.isModalResult()) {
-                    // reset modal result
-                    page.setModalResult(false);
-                    // set operation succeeded
-                    getSession().info(getString(Constants.OPERATION_SUCCEEDED));
-                    // refresh feedback panel
-                    target.add(page.getFeedbackPanel());
-                }
+            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);
             }
-        });
-
-        Fragment fragment = new Fragment("tablePanel", "bulkAvailable", this);
-        add(fragment);
-
-        Form<T> bulkActionForm = new Form<T>("groupForm");
-        fragment.add(bulkActionForm);
-
-        final CheckGroup<T> group = new CheckGroup<T>("checkgroup", new ArrayList<T>());
-        group.add(new AjaxFormChoiceComponentUpdatingBehavior() {
-
-            private static final long serialVersionUID = -151291731388673682L;
 
             @Override
-            protected void onUpdate(final AjaxRequestTarget target) {
-                // triggers AJAX form submit
+            public void setObject(final Collection<T> selected) {
+                final Collection<T> all = getGroupModelObjects();
+                values.removeAll(all);
+                values.addAll(selected);
             }
 
-        });
-        bulkActionForm.add(group);
-
-        columns.add(0, new CheckGroupColumn<T, S>(group));
-        dataTable = new AjaxFallbackDefaultDataTable<T, S>("dataTable", columns, dataProvider,
rowsPerPage);
-        group.add(dataTable);
-
-        fragment.add(new ClearIndicatingAjaxButton("bulkActionLink", bulkActionForm, pageRef)
{
-
-            private static final long serialVersionUID = 382302811235019988L;
-
             @Override
-            protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?>
form) {
-                bulkModalWin.setPageCreator(new ModalWindow.PageCreator() {
-
-                    private static final long serialVersionUID = -7834632442532690941L;
-
-                    @Override
-                    public Page createPage() {
-                        return new BulkActionModalPage<T, S>(
-                                bulkModalWin,
-                                group.getModelObject(),
-                                columns,
-                                actions,
-                                bulkActionExecutor,
-                                itemIdField,
-                                pageId);
-                    }
-                });
-
-                bulkModalWin.show(target);
+            public void detach() {
             }
-        });
+        };
     }
 
     public final void setCurrentPage(final long page) {
@@ -164,4 +95,19 @@ public class AjaxDataTablePanel<T, S> ex
     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;
+    }
 }

Modified: syncope/trunk/console/src/test/java/org/apache/syncope/console/UserTestITCase.java
URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/UserTestITCase.java?rev=1554407&r1=1554406&r2=1554407&view=diff
==============================================================================
--- syncope/trunk/console/src/test/java/org/apache/syncope/console/UserTestITCase.java (original)
+++ syncope/trunk/console/src/test/java/org/apache/syncope/console/UserTestITCase.java Tue
Dec 31 11:58:55 2013
@@ -109,6 +109,12 @@ public class UserTestITCase extends Abst
         selenium.waitForCondition("selenium.isElementPresent(" + "\"//td[div='ws-target-resource-1']\");",
"30000");
         selenium.waitForCondition("selenium.isElementPresent(" + "\"//td[div='resource-testdb']\");",
"30000");
 
+        selenium.click("//div[@class='navigator']/div/span[4]/a");
+        selenium.waitForCondition("selenium.isElementPresent(" + "\"//td[div='resource-ldap']\");",
"30000");
+
+        selenium.click("//div[@class='navigator']/div/span/a");
+        selenium.waitForCondition("selenium.isElementPresent(" + "\"//td[div='ws-target-resource-1']\");",
"30000");
+
         selenium.click("css=a.w_close");
     }
 }



Mime
View raw message