commit 87487bbf9d41275ad0ccbb9d2150d8f36617fa8f
Author: Christos KK Loverdos <loverdos@gmail.com>
Date:   Mon Apr 15 18:07:27 2013 +0300

    In Share Dialog, remove the header line when the permission list is empty.
    
    Refs #3575

diff --git a/src/gr/grnet/pithos/web/client/Const.java b/src/gr/grnet/pithos/web/client/Const.java
index 6929476..3b5916f 100644
--- a/src/gr/grnet/pithos/web/client/Const.java
+++ b/src/gr/grnet/pithos/web/client/Const.java
@@ -36,6 +36,7 @@ public final class Const {
     public static final String COMMA = ",";
     public static final String TILDE = "~";
     public static final String SEMI = ";";
+    public static final String COLON = ":";
     public static final String QUESTION_MARK = "?";
     public static final String AMPERSAND = "&";
 
@@ -45,6 +46,8 @@ public final class Const {
     public static final String UPDATE_EQ = "update=";
     public static final String QUESTION_MARK_UPDATE_EQ = QUESTION_MARK + UPDATE_EQ;
 
+    public static final String HTML_NBSP = "&nbsp;";
+
 
     public static final String NL = "\n";
 
@@ -56,4 +59,21 @@ public final class Const {
     public static String PurgeContainer(String name) {
         return "Purge Container [" + name + "]";
     }
+
+    public static String inSpan(String html) {
+        return "<span>" + html + "</span>";
+    }
+
+    public static String inSpan(String html0, String html1, String ...html) {
+        final int knownLength = html0.length() + html1.length();
+        final int estimatedLength = knownLength * html.length;
+        final StringBuilder sb = new StringBuilder(estimatedLength);
+        sb.append(html0);
+        sb.append(html1);
+        for(String s : html) {
+            sb.append(s);
+        }
+
+        return inSpan(sb.toString());
+    }
 }
diff --git a/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
index e44bb00..4eef837 100644
--- a/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
+++ b/src/gr/grnet/pithos/web/client/FolderPermissionsDialog.java
@@ -34,13 +34,6 @@
  */
 package gr.grnet.pithos.web.client;
 
-import gr.grnet.pithos.web.client.foldertree.Folder;
-import gr.grnet.pithos.web.client.rest.PostRequest;
-import gr.grnet.pithos.web.client.rest.PutRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import java.util.Map;
-
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.dom.client.NativeEvent;
@@ -52,13 +45,13 @@ import com.google.gwt.http.client.Response;
 import com.google.gwt.http.client.URL;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.Event.NativePreviewEvent;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Button;
-import com.google.gwt.user.client.ui.DialogBox;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.*;
+import gr.grnet.pithos.web.client.foldertree.Folder;
+import gr.grnet.pithos.web.client.rest.PostRequest;
+import gr.grnet.pithos.web.client.rest.PutRequest;
+import gr.grnet.pithos.web.client.rest.RestException;
+
+import java.util.Map;
 
 /**
  * The 'Folder properties' dialog box implementation.
@@ -67,51 +60,55 @@ public class FolderPermissionsDialog extends DialogBox {
 
     protected Pithos app;
 
-	/**
-	 * The widget that holds the folderName of the folder.
-	 */
-	Label folderName = new Label();
+    /**
+     * The widget that holds the folderName of the folder.
+     */
+    Label folderName = new Label();
+
+    protected PermissionsList permList;
+
+    final Folder folder;
 
-	protected PermissionsList permList;
+    final VerticalPanel inner;
 
-	final Folder folder;
+    final Button updateButton;
 
-	final VerticalPanel inner;
+    private boolean _initialPermissionCheck = true;
 
-	/**
-	 * The widget's constructor.
-	 */
-	public FolderPermissionsDialog(final Pithos app, Folder selected) {
+    /**
+     * The widget's constructor.
+     */
+    public FolderPermissionsDialog(final Pithos app, Folder selected) {
         this.app = app;
-		Anchor close = new Anchor("close");
-		close.addStyleName("close");
-		close.addClickHandler(new ClickHandler() {
-			
-			@Override
-			public void onClick(ClickEvent event) {
-				hide();
-			}
-		});
+        Anchor close = new Anchor("close");
+        close.addStyleName("close");
+        close.addClickHandler(new ClickHandler() {
 
-		setGlassEnabled(true);
-		setStyleName("pithos-DialogBox");
+            @Override
+            public void onClick(ClickEvent event) {
+                hide();
+            }
+        });
 
-		// Enable IE selection for the dialog (must disable it upon closing it)
-		Pithos.enableIESelection();
+        setGlassEnabled(true);
+        setStyleName("pithos-DialogBox");
 
-		folder = selected;
+        // Enable IE selection for the dialog (must disable it upon closing it)
+        Pithos.enableIESelection();
 
-		setText("Folder permissions");
+        folder = selected;
 
-		// Outer contains inner and buttons
-		VerticalPanel outer = new VerticalPanel();
-		outer.add(close);
-		// Inner contains generalPanel and permPanel
-		inner = new VerticalPanel();
-		inner.addStyleName("inner");
+        setText("Folder permissions");
 
+        // Outer contains inner and buttons
+        VerticalPanel outer = new VerticalPanel();
+        outer.add(close);
+        // Inner contains generalPanel and permPanel
+        inner = new VerticalPanel();
+        inner.addStyleName("inner");
 
-		folderName.setText(folder.getName());
+
+        folderName.setText(folder.getName());
 
         VerticalPanel permPanel = new VerticalPanel();
         FileShareDialog.PrivateSharingImages images = GWT.create(FileShareDialog.PrivateSharingImages.class);
@@ -124,6 +121,7 @@ public class FolderPermissionsDialog extends DialogBox {
             public void onClick(ClickEvent event) {
                 PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, true);
                 dlg.center();
+                checkUpdateButtonVisibility();
             }
         });
         addUser.addStyleName("button");
@@ -133,22 +131,24 @@ public class FolderPermissionsDialog extends DialogBox {
         Button add = new Button("Add Group", new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
-            	if (app.getAccount().getGroups().isEmpty()) {
+                if(app.getAccount().getGroups().isEmpty()) {
                     new GroupCreateDialog(app, new Command() {
-						
-						@Override
-						public void execute() {
-			            	if (app.getAccount().getGroups().isEmpty())
-			            		return;
-			                PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
-			                dlg.center();
-						}
-					}).center();
-            	}
-            	else {
-	                PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
-	                dlg.center();
-            	}
+                        @Override
+                        public void execute() {
+                            if(app.getAccount().getGroups().isEmpty()) {
+                                return;
+                            }
+                            PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
+                            dlg.center();
+                            checkUpdateButtonVisibility();
+                        }
+                    }).center();
+                }
+                else {
+                    PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);
+                    dlg.center();
+                    checkUpdateButtonVisibility();
+                }
             }
         });
         add.addStyleName("button");
@@ -162,154 +162,178 @@ public class FolderPermissionsDialog extends DialogBox {
 
         outer.add(inner);
 
-		// Create the 'Create/Update' button, along with a listener that hides the dialog
-		// when the button is clicked and quits the application.
-		String okLabel = "Update";
-		final Button ok = new Button(okLabel, new ClickHandler() {
-			@Override
-			public void onClick(ClickEvent event) {
-				updateFolder();
-				closeDialog();
-			}
-		});
-		ok.addStyleName("button");
-		outer.add(ok);
+        // Create the 'Create/Update' button, along with a listener that hides the dialog
+        // when the button is clicked and quits the application.
+        final String okLabel = "Update";
+        updateButton = new Button(okLabel, new ClickHandler() {
+            @Override
+            public void onClick(ClickEvent event) {
+                updateFolder();
+                closeDialog();
+            }
+        });
+        updateButton.addStyleName("button");
+        checkUpdateButtonVisibility();
+        outer.add(updateButton);
         outer.setCellHorizontalAlignment(inner, HasHorizontalAlignment.ALIGN_CENTER);
 
         setWidget(outer);
-	}
-
-	@Override
-	protected void onPreviewNativeEvent(NativePreviewEvent preview) {
-		super.onPreviewNativeEvent(preview);
-
-		NativeEvent evt = preview.getNativeEvent();
-		if (evt.getType().equals(KeyDownEvent.getType().getName()))
-			// Use the popup's key preview hooks to close the dialog when either
-			// enter or escape is pressed.
-			switch (evt.getKeyCode()) {
-				case KeyCodes.KEY_ENTER:
-					updateFolder();
+    }
+
+    private void checkUpdateButtonVisibility() {
+        if(!this._initialPermissionCheck) {
+            updateButton.setVisible(true);
+            return;
+        }
+
+        updateButton.setVisible(permList.hasPermissions());
+
+        this._initialPermissionCheck = false;
+    }
+
+    @Override
+    protected void onPreviewNativeEvent(NativePreviewEvent preview) {
+        super.onPreviewNativeEvent(preview);
+
+        NativeEvent evt = preview.getNativeEvent();
+        if(evt.getType().equals(KeyDownEvent.getType().getName()))
+        // Use the popup's key preview hooks to close the dialog when either
+        // enter or escape is pressed.
+        {
+            switch(evt.getKeyCode()) {
+                case KeyCodes.KEY_ENTER:
+                    updateFolder();
                     closeDialog();
-					break;
-				case KeyCodes.KEY_ESCAPE:
-					closeDialog();
-					break;
-			}
-	}
-
-
-	/**
-	 * Enables IE selection prevention and hides the dialog
-	 * (we disable the prevention on creation of the dialog)
-	 */
-	public void closeDialog() {
-		Pithos.preventIESelection();
-		hide();
-	}
-
-	void updateFolder() {
+                    break;
+                case KeyCodes.KEY_ESCAPE:
+                    closeDialog();
+                    break;
+            }
+        }
+    }
+
+    /**
+     * Enables IE selection prevention and hides the dialog
+     * (we disable the prevention on creation of the dialog)
+     */
+    public void closeDialog() {
+        Pithos.preventIESelection();
+        hide();
+    }
+
+    void updateFolder() {
         final Map<String, Boolean[]> perms = (permList.hasChanges() ? permList.getPermissions() : null);
-        updateMetadata(folder.getUri() + "?update=", perms);
-	}
+        updateMetadata(
+            folder.getUri() + Const.QUESTION_MARK_UPDATE_EQ,
+            perms
+        );
+    }
 
-	protected void updateMetadata(final String path, final Map<String, Boolean[]> newPermissions) {
-        if (newPermissions != null) {
+    protected void updateMetadata(final String path, final Map<String, Boolean[]> newPermissions) {
+        if(newPermissions != null) {
             PostRequest updateFolder = new PostRequest(app.getApiPath(), folder.getOwnerID(), path) {
                 @Override
                 public void onSuccess(Resource result) {
                     app.updateFolder(folder.getParent(), false, new Command() {
-						
-						@Override
-						public void execute() {
-							app.updateMySharedRoot();
-						}
-					}, true);
+                        @Override
+                        public void execute() {
+                            app.updateMySharedRoot();
+                        }
+                    }, true);
                 }
 
                 @Override
                 public void onError(Throwable t) {
-                    GWT.log("", t);
-					app.setError(t);
-                    if (t instanceof RestException) {
-                    	if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { //Probably a virtual folder
+                    app.setError(t);
+                    if(t instanceof RestException) {
+                        if(((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) { //Probably a virtual folder
                             final String path1 = folder.getUri();
                             PutRequest newFolder = new PutRequest(app.getApiPath(), folder.getOwnerID(), path1) {
                                 @Override
                                 public void onSuccess(Resource result) {
-                                	updateMetadata(path, newPermissions);
+                                    updateMetadata(path, newPermissions);
                                 }
 
                                 @Override
                                 public void onError(Throwable _t) {
-                                    GWT.log("", _t);
-            						app.setError(_t);
-                                    if(_t instanceof RestException){
+                                    app.setError(_t);
+                                    if(_t instanceof RestException) {
                                         app.displayError("Unable to update folder: " + ((RestException) _t).getHttpStatusText());
                                     }
-                                    else
+                                    else {
                                         app.displayError("System error modifying folder: " + _t.getMessage());
+                                    }
                                 }
 
-                				@Override
-                				protected void onUnauthorized(Response response) {
-                					app.sessionExpired();
-                				}
+                                @Override
+                                protected void onUnauthorized(Response response) {
+                                    app.sessionExpired();
+                                }
                             };
                             newFolder.setHeader("X-Auth-Token", app.getUserToken());
                             newFolder.setHeader("Content-Type", "application/folder");
                             newFolder.setHeader("Accept", "*/*");
                             newFolder.setHeader("Content-Length", "0");
                             Scheduler.get().scheduleDeferred(newFolder);
-                    	}
-                    	else if (((RestException) t).getHttpStatusCode() == Response.SC_CONFLICT) {
-                    		app.displayError("Cannot set permissions. Probably subfolders or files already have permissions set");
-                    	}
-                    	else
-                    		app.displayError("Εrror modifying folder: " + t.getMessage());
+                        }
+                        else if(((RestException) t).getHttpStatusCode() == Response.SC_CONFLICT) {
+                            app.displayError("Cannot set permissions. Probably subfolders or files already have permissions set");
+                        }
+                        else {
+                            app.displayError("Εrror modifying folder: " + t.getMessage());
+                        }
+                    }
+                    else {
+                        app.displayError("System error modifying folder: " + t.getMessage());
                     }
-                    else
-                    	app.displayError("System error modifying folder: " + t.getMessage());
                 }
 
-				@Override
-				protected void onUnauthorized(Response response) {
-					app.sessionExpired();
-				}
+                @Override
+                protected void onUnauthorized(Response response) {
+                    app.sessionExpired();
+                }
             };
             updateFolder.setHeader("X-Auth-Token", app.getUserToken());
             String readPermHeader = "read=";
             String writePermHeader = "write=";
-            for (String u : newPermissions.keySet()) {
+            for(String u : newPermissions.keySet()) {
                 Boolean[] p = newPermissions.get(u);
-                if (p[0] != null && p[0])
+                if(p[0] != null && p[0]) {
                     readPermHeader += u + ",";
-                if (p[1] != null && p[1])
+                }
+                if(p[1] != null && p[1]) {
                     writePermHeader += u + ",";
+                }
             }
-            if (readPermHeader.endsWith("="))
+            if(readPermHeader.endsWith("=")) {
                 readPermHeader = "";
-            else if (readPermHeader.endsWith(","))
+            }
+            else if(readPermHeader.endsWith(",")) {
                 readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);
-            if (writePermHeader.endsWith("="))
+            }
+            if(writePermHeader.endsWith("=")) {
                 writePermHeader = "";
-            else if (writePermHeader.endsWith(","))
+            }
+            else if(writePermHeader.endsWith(",")) {
                 writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);
-            String permHeader = readPermHeader +  ((readPermHeader.length()  > 0 && writePermHeader.length() > 0) ?  ";" : "") + writePermHeader;
-            if (permHeader.length() == 0)
+            }
+            String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader;
+            if(permHeader.length() == 0) {
                 permHeader = "~";
-            else
-            	permHeader = URL.encodePathSegment(permHeader);
+            }
+            else {
+                permHeader = URL.encodePathSegment(permHeader);
+            }
             updateFolder.setHeader("X-Object-Sharing", permHeader);
             Scheduler.get().scheduleDeferred(updateFolder);
         }
-        else
+        else {
             app.updateFolder(folder.getParent(), false, new Command() {
-				
-				@Override
-				public void execute() {
-					app.updateMySharedRoot();
-				}
-			}, true);
+                @Override
+                public void execute() {
+                    app.updateMySharedRoot();
+                }
+            }, true);
+        }
     }
 }
diff --git a/src/gr/grnet/pithos/web/client/PermissionsList.java b/src/gr/grnet/pithos/web/client/PermissionsList.java
index a725cfb..e7e65ae 100644
--- a/src/gr/grnet/pithos/web/client/PermissionsList.java
+++ b/src/gr/grnet/pithos/web/client/PermissionsList.java
@@ -34,104 +34,139 @@
  */
 package gr.grnet.pithos.web.client;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.Anchor;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlexTable;
-import com.google.gwt.user.client.ui.HasHorizontalAlignment;
-import com.google.gwt.user.client.ui.RadioButton;
-import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.*;
 import gr.grnet.pithos.web.client.catalog.UpdateUserCatalogs;
 import gr.grnet.pithos.web.client.catalog.UserCatalogs;
 
+import java.util.HashMap;
+import java.util.Map;
+
 
 public class PermissionsList extends Composite {
 
-	Map<String, Boolean[]> permissions = null;
-	
-	final FileShareDialog.PrivateSharingImages images;
-	
-	final VerticalPanel permPanel = new VerticalPanel();
-	
-	final FlexTable permTable = new FlexTable();
-	
-	final String owner;
-	
-	protected boolean hasChanges = false;
+    Map<String, Boolean[]> permissions = null;
+
+    final FileShareDialog.PrivateSharingImages images;
+
+    final VerticalPanel permPanel = new VerticalPanel();
+
+    final FlexTable permTable = new FlexTable();
+
+    final String owner;
+
+    protected boolean hasChanges = false;
 
     private boolean readonly = false;
-    
+
     Command changePermissionsCallback;
 
     private final Pithos app;
-	
-	public PermissionsList(Pithos app, final FileShareDialog.PrivateSharingImages theImages, Map<String, Boolean[]> thePermissions, String theOwner, boolean inheritsPermissions, Command _changePermissionsCallback){
+
+    public PermissionsList(
+        Pithos app,
+        final FileShareDialog.PrivateSharingImages theImages,
+        Map<String, Boolean[]> thePermissions,
+        String theOwner,
+        boolean inheritsPermissions,
+        Command _changePermissionsCallback
+    ) {
         this.app = app;
-		changePermissionsCallback = _changePermissionsCallback;
-		images = theImages;
-		owner = theOwner;
-		permissions =  new HashMap<String, Boolean[]>(thePermissions);
-		permTable.setText(0, 0, "Users/Groups");
-		permTable.setText(0, 1, "Read Only");
-		permTable.setText(0, 2, "Read/Write");
-		permTable.setText(0, 3, "");
-		permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
-		permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
-		permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
-		permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
-		permPanel.add(permTable);
-		permPanel.addStyleName("pithos-TabPanelBottom");
-		initWidget(permPanel);
-		updatePermissionTable();
-	}
-
-	public boolean hasChanges(){
-		return hasChanges;
-	}
-
-	/**
-	 * Retrieve the permissions.
-	 *
-	 * @return the permissions
-	 */
-	public Map<String, Boolean[]> getPermissions() {
-		return permissions;
-	}
-
-	public void addPermission(String userID, boolean read, boolean write){
-		permissions.put(userID, new Boolean[] {Boolean.valueOf(read), Boolean.valueOf(write)});
-		hasChanges = true;
+        changePermissionsCallback = _changePermissionsCallback;
+        images = theImages;
+        owner = theOwner;
+        permissions = new HashMap<String, Boolean[]>(thePermissions);
+        updatePermissionsHeader();
+        permPanel.add(permTable);
+        permPanel.addStyleName("pithos-TabPanelBottom");
+        initWidget(permPanel);
         updatePermissionTable();
-        if (changePermissionsCallback != null)
-        	changePermissionsCallback.execute();
-	}
-
-	/**
-	 * Shows the permission table 
-	 * 
-	 */
-	void updatePermissionTable(){
-		int i = 1;
+    }
+
+    private void updatePermissionsHeader() {
+        if(hasPermissions()) {
+            permTable.setText(0, 0, "Users/Groups");
+            permTable.setText(0, 1, "Read Only");
+            permTable.setText(0, 2, "Read/Write");
+            permTable.setText(0, 3, "");
+            permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
+            permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
+            permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
+            permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
+        }
+        else {
+            permTable.setText(0, 0, "");
+            permTable.setText(0, 1, "");
+            permTable.setText(0, 2, "");
+            permTable.setText(0, 3, "");
+        }
+    }
+
+    public boolean hasPermissions() {
+        return permissionCount() > 0;
+    }
+
+    public int permissionCount() {
+        return permissions == null
+            ? 0
+            : permissions.size();
+    }
+
+    public boolean hasChanges() {
+        return hasChanges;
+    }
+
+    /**
+     * Retrieve the permissions.
+     *
+     * @return the permissions
+     */
+    public Map<String, Boolean[]> getPermissions() {
+        return permissions;
+    }
+
+    public void addPermission(String userID, boolean read, boolean write) {
+        permissions.put(userID, new Boolean[]{Boolean.valueOf(read), Boolean.valueOf(write)});
+        hasChanges = true;
+        updatePermissionTable();
+        if(changePermissionsCallback != null) {
+            changePermissionsCallback.execute();
+        }
+    }
+
+    private boolean isGroup(String userID) {
+        return userID.contains(Const.COLON);
+    }
+
+    /**
+     * Shows the permission table
+     */
+    void updatePermissionTable() {
+        int i = 1;
         final int ii = i;
-        for (int j=1; j<permTable.getRowCount(); j++)
+        for(int j = 1; j < permTable.getRowCount(); j++) {
             permTable.removeRow(j);
-		for(final String userID : permissions.keySet()) {
-            if (!userID.contains(":")) {
-                 //not a group
+        }
+
+        updatePermissionsHeader();
+
+        for(final String userID : permissions.keySet()) {
+            if(!isGroup(userID)) {
                 final String displayName = app.getDisplayNameForUserID(userID);
                 if(displayName != null) {
                     permTable.setHTML(
                         i,
                         0,
-                        "<span>" + AbstractImagePrototype.create(images.permUser()).getHTML() + "&nbsp;" + displayName + "</span>"
+                        Const.inSpan(
+                            AbstractImagePrototype.create(
+                                images.permUser()).getHTML() +
+                                Const.HTML_NBSP +
+                                displayName
+                        )
                     );
                 }
                 else {
@@ -142,14 +177,28 @@ public class PermissionsList extends Composite {
                             permTable.setHTML(
                                 ii,
                                 0,
-                                "<span>" + AbstractImagePrototype.create(images.permUser()).getHTML() + "&nbsp;" + displayName + "</span>"
+                                Const.inSpan(
+                                    AbstractImagePrototype.create(
+                                        images.permUser()).getHTML() +
+                                        Const.HTML_NBSP +
+                                        displayName
+                                )
                             );
                         }
                     }.scheduleDeferred();
                 }
             }
             else {
-                permTable.setHTML(i, 0, "<span>" + AbstractImagePrototype.create(images.permGroup()).getHTML() + "&nbsp;" + userID.split(":")[1].trim() + "</span>");
+                permTable.setHTML(
+                    i,
+                    0,
+                    Const.inSpan(
+                        AbstractImagePrototype.create(
+                            images.permGroup()).getHTML() +
+                            Const.HTML_NBSP +
+                            userID.split(Const.COLON)[1].trim()
+                    )
+                );
             }
             permTable.getFlexCellFormatter().setStyleName(i, 0, "props-values");
 
@@ -157,8 +206,8 @@ public class PermissionsList extends Composite {
             Boolean readP = userPerms[0];
             Boolean writeP = userPerms[1];
 
-			RadioButton read = new RadioButton("permissions" + i);
-			read.setValue(readP != null ? readP : false);
+            RadioButton read = new RadioButton("permissions" + i);
+            read.setValue(readP != null ? readP : false);
             permTable.setWidget(i, 1, read);
             permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
 
@@ -167,7 +216,7 @@ public class PermissionsList extends Composite {
             permTable.setWidget(i, 2, write);
             permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
 
-            if (!readonly) {
+            if(!readonly) {
                 read.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
                     @Override
                     public void onValueChange(ValueChangeEvent<Boolean> booleanValueChangeEvent) {
@@ -175,8 +224,9 @@ public class PermissionsList extends Composite {
                         ps[0] = booleanValueChangeEvent.getValue();
                         ps[1] = !booleanValueChangeEvent.getValue();
                         hasChanges = true;
-                        if (changePermissionsCallback != null)
-                        	changePermissionsCallback.execute();
+                        if(changePermissionsCallback != null) {
+                            changePermissionsCallback.execute();
+                        }
                     }
                 });
                 write.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@@ -186,8 +236,9 @@ public class PermissionsList extends Composite {
                         ps[0] = !booleanValueChangeEvent.getValue();
                         ps[1] = booleanValueChangeEvent.getValue();
                         hasChanges = true;
-                        if (changePermissionsCallback != null)
-                        	changePermissionsCallback.execute();
+                        if(changePermissionsCallback != null) {
+                            changePermissionsCallback.execute();
+                        }
                     }
                 });
                 Anchor removeButton = new Anchor("remove");
@@ -198,8 +249,9 @@ public class PermissionsList extends Composite {
                         permissions.remove(userID);
                         updatePermissionTable();
                         hasChanges = true;
-                        if (changePermissionsCallback != null)
-                        	changePermissionsCallback.execute();
+                        if(changePermissionsCallback != null) {
+                            changePermissionsCallback.execute();
+                        }
                     }
                 });
                 permTable.setWidget(i, 3, removeButton);
@@ -209,7 +261,7 @@ public class PermissionsList extends Composite {
                 read.setEnabled(false);
                 write.setEnabled(false);
             }
-			i++;
-		}
-	}
+            i++;
+        }
+    }
 }
