Added ids in homefolder(tree.homeFolder), Trash(tree.Trash), My Shared (tree.myShared...
[pithos] / src / gr / ebs / gss / client / FilePropertiesDialog.java
index f22d609..0feaf92 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
+ * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd.\r
  *\r
  * This file is part of GSS.\r
  *\r
@@ -29,6 +29,8 @@ import java.util.List;
 import java.util.Set;\r
 \r
 import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.event.dom.client.ChangeEvent;\r
+import com.google.gwt.event.dom.client.ChangeHandler;\r
 import com.google.gwt.event.dom.client.ClickEvent;\r
 import com.google.gwt.event.dom.client.ClickHandler;\r
 import com.google.gwt.i18n.client.DateTimeFormat;\r
@@ -43,6 +45,7 @@ import com.google.gwt.user.client.DeferredCommand;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;\r
 import com.google.gwt.user.client.ui.Button;\r
 import com.google.gwt.user.client.ui.CheckBox;\r
+import com.google.gwt.user.client.ui.DecoratedTabPanel;\r
 import com.google.gwt.user.client.ui.DisclosurePanel;\r
 import com.google.gwt.user.client.ui.FlexTable;\r
 import com.google.gwt.user.client.ui.FlowPanel;\r
@@ -51,7 +54,6 @@ import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;\r
 import com.google.gwt.user.client.ui.HorizontalPanel;\r
 import com.google.gwt.user.client.ui.Label;\r
-import com.google.gwt.user.client.ui.TabPanel;\r
 import com.google.gwt.user.client.ui.TextBox;\r
 import com.google.gwt.user.client.ui.VerticalPanel;\r
 \r
@@ -96,6 +98,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
        final FileResource file;\r
 \r
+       private String userFullName;\r
 \r
        /**\r
         * The widget's constructor.\r
@@ -104,19 +107,22 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
         * @param groups\r
         * @param bodies\r
         */\r
-       public FilePropertiesDialog(final Images images, final List<GroupResource> groups, List<FileResource> bodies) {\r
+       public FilePropertiesDialog(final Images images, final List<GroupResource> groups, List<FileResource> bodies, String _userFullName) {\r
 \r
                // Set the dialog's caption.\r
                setText("File properties");\r
 \r
                file = (FileResource) GSS.get().getCurrentSelection();\r
+               userFullName = _userFullName;\r
                permList = new PermissionsList(images, file.getPermissions(), file.getOwner());\r
 \r
+\r
                // Outer contains inner and buttons.\r
                final VerticalPanel outer = new VerticalPanel();\r
                final FocusPanel focusPanel = new FocusPanel(outer);\r
                // Inner contains generalPanel and permPanel.\r
-               inner = new TabPanel();\r
+               inner = new DecoratedTabPanel();\r
+               inner.setAnimationEnabled(true);\r
                final VerticalPanel generalPanel = new VerticalPanel();\r
                final VerticalPanel permPanel = new VerticalPanel();\r
                final HorizontalPanel buttons = new HorizontalPanel();\r
@@ -133,19 +139,38 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                inner.add(verPanel, "Versions");\r
                inner.selectTab(0);\r
 \r
+               final Label fileNameNote = new Label("Please note that slashes ('/') are not allowed in file names.", true);\r
+               fileNameNote.setVisible(false);\r
+               fileNameNote.setStylePrimaryName("gss-readForAllNote");\r
+\r
                final FlexTable generalTable = new FlexTable();\r
                generalTable.setText(0, 0, "Name");\r
                generalTable.setText(1, 0, "Folder");\r
                generalTable.setText(2, 0, "Owner");\r
                generalTable.setText(3, 0, "Last modified");\r
                generalTable.setText(4, 0, "Tags");\r
+               name.setWidth("100%");\r
                name.setText(file.getName());\r
                generalTable.setWidget(0, 1, name);\r
+               name.addChangeHandler(new ChangeHandler() {\r
+\r
+                       @Override\r
+                       public void onChange(ChangeEvent event) {\r
+                               if(name.getText().contains("/"))\r
+                                       fileNameNote.setVisible(true);\r
+                               else\r
+                                       fileNameNote.setVisible(false);\r
+\r
+                       }\r
+               });\r
+\r
                if(file.getFolderName() != null)\r
                        generalTable.setText(1, 1, file.getFolderName());\r
                else\r
                        generalTable.setText(1, 1, "-");\r
-               generalTable.setText(2, 1, file.getOwner());\r
+               generalTable.setWidget(0, 2, fileNameNote);\r
+               generalTable.setText(2, 1,userFullName);\r
+\r
                final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
                generalTable.setText(3, 1, formatter.format(file.getModificationDate()));\r
                // Get the tags.\r
@@ -158,6 +183,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                if (tagsBuffer.length() > 1)\r
                        tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1);\r
                initialTagText = tagsBuffer.toString();\r
+               tags.setWidth("100%");\r
                tags.setText(initialTagText);\r
                generalTable.setWidget(4, 1, tags);\r
                generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
@@ -177,8 +203,13 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                final Button ok = new Button("OK", new ClickHandler() {\r
                        @Override\r
                        public void onClick(ClickEvent event) {\r
-                               accept();\r
-                               closeDialog();\r
+                               if(name.getText().contains("/"))\r
+                                       fileNameNote.setVisible(true);\r
+                               else{\r
+                                       fileNameNote.setVisible(true);\r
+                                       accept();\r
+                                       closeDialog();\r
+                               }               \r
                        }\r
                });\r
                buttons.add(ok);\r
@@ -194,13 +225,14 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                buttons.add(cancel);\r
                buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
                buttons.setSpacing(8);\r
-               buttons.addStyleName("gwt-TabPanelBottom");\r
+               buttons.addStyleName("gss-TabPanelBottom");\r
 \r
                generalPanel.add(generalTable);\r
 \r
                // Asynchronously retrieve the tags defined by this user.\r
                DeferredCommand.addCommand(new Command() {\r
 \r
+                       @Override\r
                        public void execute() {\r
                                updateTags();\r
                        }\r
@@ -208,6 +240,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
                DisclosurePanel allTags = new DisclosurePanel("All tags");\r
                allTagsContent = new FlowPanel();\r
+               allTagsContent.setWidth("100%");\r
                allTags.setContent(allTagsContent);\r
                generalPanel.add(allTags);\r
                generalPanel.setSpacing(4);\r
@@ -234,7 +267,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
                permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
                permButtons.setSpacing(8);\r
-               permButtons.addStyleName("gwt-TabPanelBottom");\r
+               permButtons.addStyleName("gss-TabPanelBottom");\r
 \r
                final Label readForAllNote = new Label("When this option is enabled, the file will be readable" +\r
                                        " by everyone. By checking this option, you are certifying that you have the right to " +\r
@@ -247,14 +280,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                readForAll.addClickHandler(new ClickHandler() {\r
                        @Override\r
                        public void onClick(ClickEvent event) {\r
-                               if (readForAll.getValue()) {\r
-                                       readForAllNote.setVisible(true);\r
-                                       pathPanel.setVisible(true);\r
-                               }\r
-                               else {\r
-                                       readForAllNote.setVisible(false);\r
-                                       pathPanel.setVisible(false);\r
-                               }\r
+                               readForAllNote.setVisible(readForAll.getValue());\r
                        }\r
 \r
                });\r
@@ -263,10 +289,10 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                permPanel.add(permButtons);\r
                // Only show the read for all permission if the user is the owner.\r
                if (file.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) {\r
-                       permForAll.add(new Label("Make Public"));\r
+                       permForAll.add(new Label("Public"));\r
                        permForAll.add(readForAll);\r
                        permForAll.setSpacing(8);\r
-                       permForAll.addStyleName("gwt-TabPanelBottom");\r
+                       permForAll.addStyleName("gss-TabPanelBottom");\r
                        permForAll.add(readForAllNote);\r
                        permPanel.add(permForAll);\r
                }\r
@@ -283,16 +309,15 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
                });\r
                path.setText(file.getUri());\r
-               path.setTitle("Use this URI for sharing this file with the world (crtl-C/cmd-C to copy to system clipboard)");\r
+               path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");\r
                path.setWidth("100%");\r
                path.setReadOnly(true);\r
                pathPanel.setWidth("100%");\r
                pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);\r
-               pathPanel.add(new Label("Sharing URI"));\r
+               pathPanel.add(new Label("Link"));\r
                pathPanel.setSpacing(8);\r
-               pathPanel.addStyleName("gwt-TabPanelBottom");\r
+               pathPanel.addStyleName("gss-TabPanelBottom");\r
                pathPanel.add(path);\r
-               pathPanel.setVisible(file.isReadForAll());\r
                permPanel.add(pathPanel);\r
 \r
                VersionsList verList = new VersionsList(this, images, bodies);\r
@@ -300,14 +325,14 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
                vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
                vPanel.setSpacing(8);\r
-               vPanel.addStyleName("gwt-TabPanelBottom");\r
+               vPanel.addStyleName("gss-TabPanelBottom");\r
                vPanel.add(new Label("Versioned"));\r
 \r
                vPanel.add(versioned);\r
                verPanel.add(vPanel);\r
                vPanel2.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
                vPanel2.setSpacing(8);\r
-               vPanel2.addStyleName("gwt-TabPanelBottom");\r
+               vPanel2.addStyleName("gss-TabPanelBottom");\r
                Button removeVersionsButton = new Button(AbstractImagePrototype.create(images.delete()).getHTML(), new ClickHandler() {\r
                        @Override\r
                        public void onClick(ClickEvent event) {\r
@@ -338,7 +363,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                outer.add(inner);\r
                outer.add(buttons);\r
                outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
-               outer.addStyleName("gwt-TabPanelBottom");\r
+               outer.addStyleName("gss-TabPanelBottom");\r
 \r
                focusPanel.setFocus(true);\r
                setWidget(outer);\r
@@ -498,5 +523,4 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                DeferredCommand.addCommand(cf);\r
        }\r
 \r
-\r
 }\r