syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1489090 - in /syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages: Roles.java panels/RoleSummaryPanel.java panels/StatusPanel.java
Date Mon, 03 Jun 2013 18:20:05 GMT
Author: massi
Date: Mon Jun  3 18:20:04 2013
New Revision: 1489090

URL: http://svn.apache.org/r1489090
Log:
Builder instead of constructors

Modified:
    syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/Roles.java
    syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
    syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java

Modified: syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/Roles.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/Roles.java?rev=1489090&r1=1489089&r2=1489090&view=diff
==============================================================================
--- syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/Roles.java
(original)
+++ syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/Roles.java
Mon Jun  3 18:20:04 2013
@@ -67,8 +67,8 @@ public class Roles extends BasePage {
         treePanel.setOutputMarkupId(true);
         add(treePanel);
 
-        final RoleSummaryPanel summaryPanel = new RoleSummaryPanel("summaryPanel", editRoleWin,
-                Roles.this.getPageReference());
+        final RoleSummaryPanel summaryPanel = new RoleSummaryPanel.Builder("summaryPanel")
+                .window(editRoleWin).callerPageRef(Roles.this.getPageReference()).build();
         add(summaryPanel);
 
         editRoleWin.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
@@ -144,8 +144,9 @@ public class Roles extends BasePage {
         if (event.getPayload() instanceof TreeNodeClickUpdate) {
             final TreeNodeClickUpdate update = (TreeNodeClickUpdate) event.getPayload();
 
-            final RoleSummaryPanel summaryPanel = new RoleSummaryPanel("summaryPanel", editRoleWin,
-                    Roles.this.getPageReference(), update.getSelectedNodeId());
+            final RoleSummaryPanel summaryPanel = new RoleSummaryPanel.Builder("summaryPanel")
+                    .window(editRoleWin).callerPageRef(Roles.this.getPageReference())
+                    .selectedNodeId(update.getSelectedNodeId()).build();
 
             addOrReplace(summaryPanel);
             update.getTarget().add(this);

Modified: syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java?rev=1489090&r1=1489089&r2=1489090&view=diff
==============================================================================
--- syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
(original)
+++ syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/RoleSummaryPanel.java
Mon Jun  3 18:20:04 2013
@@ -18,6 +18,7 @@
  */
 package org.apache.syncope.console.pages.panels;
 
+import java.io.Serializable;
 import org.apache.syncope.common.to.RoleTO;
 import org.apache.syncope.common.validation.SyncopeClientCompositeErrorException;
 import org.apache.syncope.console.rest.RoleRestClient;
@@ -51,44 +52,68 @@ public class RoleSummaryPanel extends Pa
 
     private TreeActionLinkPanel actionLink;
 
-    private final PageReference callerPageRef;
+    public static class Builder implements Serializable {
 
-    private final ModalWindow window;
+        private static final long serialVersionUID = 8150440254654306070L;
 
-    public RoleSummaryPanel(final String id, final ModalWindow window, final PageReference
callerPageRef) {
-        this(id, window, callerPageRef, null);
-    }
+        private String id;
+
+        private ModalWindow window;
+
+        private PageReference callerPageRef;
+
+        private Long selectedNodeId = null;
 
-    public RoleSummaryPanel(final String id, final ModalWindow window, final PageReference
callerPageRef,
-            Long selectedNodeId) {
+        public Builder(final String id) {
+            this.id = id;
+        }
+
+        public RoleSummaryPanel.Builder window(final ModalWindow window) {
+            this.window = window;
+            return this;
+        }
 
-        super(id);
+        public RoleSummaryPanel.Builder callerPageRef(final PageReference callerPageRef)
{
+            this.callerPageRef = callerPageRef;
+            return this;
+        }
+
+        public RoleSummaryPanel.Builder selectedNodeId(final Long selectedNodeId) {
+            this.selectedNodeId = selectedNodeId;
+            return this;
+        }
+
+        public RoleSummaryPanel build() {
+            return new RoleSummaryPanel(this);
+        }
+    }
 
-        this.callerPageRef = callerPageRef;
-        this.window = window;
+    private RoleSummaryPanel(final Builder builder) {
+        super(builder.id);
 
-        if (selectedNodeId == null || selectedNodeId == 0) {
+        if (builder.selectedNodeId == null || builder.selectedNodeId == 0) {
             this.selectedNode = null;
         } else {
             try {
-                this.selectedNode = restClient.read(selectedNodeId);
+                this.selectedNode = restClient.read(builder.selectedNodeId);
             } catch (SyncopeClientCompositeErrorException e) {
-                LOG.error("Could not read {}", selectedNodeId, e);
+                LOG.error("Could not read {}", builder.selectedNodeId, e);
                 this.selectedNode = null;
-                selectedNodeId = null;
+                builder.selectedNodeId = null;
             }
         }
 
-        fragment = new Fragment("roleSummaryPanel", selectedNodeId == null ? "fakerootFrag"
-                : (selectedNodeId == 0 ? "rootPanel" : "roleViewPanel"), this);
+        fragment = new Fragment("roleSummaryPanel", builder.selectedNodeId == null ? "fakerootFrag"
+                : (builder.selectedNodeId == 0 ? "rootPanel" : "roleViewPanel"), this);
 
-        if (selectedNodeId != null) {
-            if (selectedNodeId == 0) {
-                actionLink = new TreeActionLinkPanel("actionLink", selectedNodeId, new Model(),
window, callerPageRef);
+        if (builder.selectedNodeId != null) {
+            if (builder.selectedNodeId == 0) {
+                actionLink = new TreeActionLinkPanel("actionLink", builder.selectedNodeId,
new Model(),
+                        builder.window, builder.callerPageRef);
                 actionLink.setOutputMarkupId(true);
                 fragment.add(actionLink);
             } else {
-                roleTabPanel = new RoleTabPanel("nodeViewPanel", selectedNode, window, callerPageRef);
+                roleTabPanel = new RoleTabPanel("nodeViewPanel", selectedNode, builder.window,
builder.callerPageRef);
                 roleTabPanel.setOutputMarkupId(true);
                 fragment.add(roleTabPanel);
             }

Modified: syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java
URL: http://svn.apache.org/viewvc/syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java?rev=1489090&r1=1489089&r2=1489090&view=diff
==============================================================================
--- syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java
(original)
+++ syncope/branches/1_1_X/console/src/main/java/org/apache/syncope/console/pages/panels/StatusPanel.java
Mon Jun  3 18:20:04 2013
@@ -165,39 +165,33 @@ public class StatusPanel extends Panel i
                 switch (item.getModelObject().getStatus()) {
 
                     case NOT_YET_SUBMITTED:
-                        image = new Image("icon", IMG_STATUES + StatusUtils.Status.UNDEFINED.toString()
-                                + Constants.PNG_EXT);
+                        image = newImage(StatusUtils.Status.UNDEFINED.toString());
                         alt = "undefined icon";
                         title = "Not yet submitted";
                         break;
 
                     case ACTIVE:
-                        image = new Image("icon", IMG_STATUES + StatusUtils.Status.ACTIVE.toString()
-                                + Constants.PNG_EXT);
+                        image = newImage(StatusUtils.Status.ACTIVE.toString());
                         alt = "active icon";
                         title = "Enabled";
                         break;
 
                     case UNDEFINED:
-                        image = new Image("icon", IMG_STATUES + StatusUtils.Status.UNDEFINED.toString()
-                                + Constants.PNG_EXT);
+                        image = newImage(StatusUtils.Status.UNDEFINED.toString());
                         checkVisibility = false;
                         alt = "undefined icon";
                         title = "Undefined status";
                         break;
 
                     case OBJECT_NOT_FOUND:
-                        image =
-                                new Image("icon", IMG_STATUES + StatusUtils.Status.OBJECT_NOT_FOUND.toString()
-                                + Constants.PNG_EXT);
+                        image = newImage(StatusUtils.Status.OBJECT_NOT_FOUND.toString());
                         checkVisibility = false;
                         alt = "notfound icon";
                         title = "User not found";
                         break;
 
                     default:
-                        image = new Image("icon", IMG_STATUES + StatusUtils.Status.SUSPENDED.toString()
-                                + Constants.PNG_EXT);
+                        image = newImage(StatusUtils.Status.SUSPENDED.toString());
                         alt = "inactive icon";
                         title = "Disabled";
                 }
@@ -267,6 +261,10 @@ public class StatusPanel extends Panel i
         checkGroup.add(statusBeansListView);
     }
 
+    private Image newImage(final String imageStatus) {
+        return new Image("icon", IMG_STATUES + imageStatus + Constants.PNG_EXT);
+    }
+
     public PropagationRequestTO getPropagationRequestTO() {
         PropagationRequestTO result = null;
 



Mime
View raw message