/*\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
package gr.ebs.gss.client;\r
\r
import gr.ebs.gss.client.FilePropertiesDialog.Images;\r
-import gr.ebs.gss.client.dnd.DnDTreeItem;\r
import gr.ebs.gss.client.rest.PostCommand;\r
import gr.ebs.gss.client.rest.RestException;\r
import gr.ebs.gss.client.rest.resource.FolderResource;\r
import gr.ebs.gss.client.rest.resource.GroupResource;\r
import gr.ebs.gss.client.rest.resource.PermissionHolder;\r
+import gr.ebs.gss.client.rest.resource.RestResource;\r
+import gr.ebs.gss.client.rest.resource.RestResourceWrapper;\r
\r
import java.util.List;\r
import java.util.Set;\r
\r
import com.google.gwt.core.client.GWT;\r
import com.google.gwt.dom.client.NativeEvent;\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.event.dom.client.KeyCodes;\r
import com.google.gwt.user.client.DeferredCommand;\r
import com.google.gwt.user.client.Event.NativePreviewEvent;\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.DialogBox;\r
import com.google.gwt.user.client.ui.FlexTable;\r
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
final PermissionsList permList;\r
\r
+ private CheckBox readForAll;\r
+\r
/**\r
* The widget that holds the folderName of the folder.\r
*/\r
GSS.enableIESelection();\r
\r
create = _create;\r
- DnDTreeItem folderItem = (DnDTreeItem)GSS.get().getFolders().getCurrent();\r
- folder = folderItem.getFolderResource();\r
+ \r
+ folder = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource();\r
permList = new PermissionsList(images, folder.getPermissions(), folder.getOwner());\r
groups = _groups;\r
\r
inner.setAnimationEnabled(true);\r
VerticalPanel generalPanel = new VerticalPanel();\r
VerticalPanel permPanel = new VerticalPanel();\r
+ final HorizontalPanel permForAll = new HorizontalPanel();\r
+ final HorizontalPanel pathPanel = new HorizontalPanel();\r
HorizontalPanel buttons = new HorizontalPanel();\r
HorizontalPanel permButtons = new HorizontalPanel();\r
+\r
inner.add(generalPanel, "General");\r
if (!create)\r
inner.add(permPanel, "Sharing");\r
inner.selectTab(0);\r
\r
+ final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true);\r
+ folderNameNote.setVisible(false);\r
+ folderNameNote.setStylePrimaryName("gss-readForAllNote");\r
+\r
FlexTable generalTable = new FlexTable();\r
generalTable.setText(0, 0, "Name");\r
generalTable.setText(1, 0, "Parent");\r
generalTable.setText(2, 0, "Creator");\r
generalTable.setText(3, 0, "Last modified");\r
folderName.setText(create ? "" : folder.getName());\r
+ folderName.getElement().setId("folderPropertiesDialog.textBox.name");\r
generalTable.setWidget(0, 1, folderName);\r
+ folderName.addChangeHandler(new ChangeHandler() {\r
+ \r
+ @Override\r
+ public void onChange(ChangeEvent event) {\r
+ if(folderName.getText().contains("/"))\r
+ folderNameNote.setVisible(true);\r
+ else\r
+ folderNameNote.setVisible(false); \r
+ \r
+ }\r
+ });\r
+\r
+\r
if (create)\r
generalTable.setText(1, 1, folder.getName());\r
else if(folder.getParentName() == null)\r
generalTable.setText(1, 1, "-");\r
else\r
generalTable.setText(1, 1, folder.getParentName());\r
+ generalTable.setWidget(0, 2, folderNameNote);\r
generalTable.setText(2, 1, folder.getOwner());\r
DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");\r
if(folder.getModificationDate() != null)\r
okLabel = "Update";\r
Button ok = new Button(okLabel, new ClickHandler() {\r
@Override\r
- public void onClick(ClickEvent event) {\r
-\r
- createOrUpdateFolder();\r
+ public void onClick(ClickEvent event) { \r
+ if(folderName.getText().contains("/"))\r
+ folderNameNote.setVisible(true);\r
+ else {\r
+ folderNameNote.setVisible(false);\r
+ createOrUpdateFolder();\r
+ closeDialog();\r
+ }\r
\r
- closeDialog();\r
}\r
});\r
+ ok.getElement().setId("folderPropertiesDialog.button.ok");\r
buttons.add(ok);\r
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
// Create the 'Cancel' button, along with a listener that hides the\r
closeDialog();\r
}\r
});\r
+ cancel.getElement().setId("folderPropertiesDialog.button.cancel");\r
buttons.add(cancel);\r
buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
buttons.setSpacing(8);\r
permButtons.setSpacing(8);\r
permButtons.addStyleName("gss-TabPanelBottom");\r
\r
+ final Label readForAllNote = new Label("When this option is enabled, the folder will be readable" +\r
+ " by everyone. By checking this option, you are certifying that you have the right to " +\r
+ "distribute this folder's contents and that it does not violate the Terms of Use.", true);\r
+ readForAllNote.setVisible(false);\r
+ readForAllNote.setStylePrimaryName("gss-readForAllNote");\r
+\r
+ readForAll = new CheckBox();\r
+ readForAll.setValue(folder.isReadForAll());\r
+ readForAll.addClickHandler(new ClickHandler() {\r
+ @Override\r
+ public void onClick(ClickEvent event) {\r
+ readForAllNote.setVisible(readForAll.getValue());\r
+ }\r
+\r
+ });\r
+\r
generalPanel.add(generalTable);\r
permPanel.add(permList);\r
permPanel.add(permButtons);\r
+\r
+ // Only show the read for all permission if the user is the owner.\r
+ if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) {\r
+ permForAll.add(new Label("Public"));\r
+ permForAll.add(readForAll);\r
+ permForAll.setSpacing(8);\r
+ permForAll.addStyleName("gss-TabPanelBottom");\r
+ permForAll.add(readForAllNote);\r
+ permPanel.add(permForAll);\r
+ }\r
+ TextBox path = new TextBox();\r
+ path.setWidth("100%");\r
+ path.addClickHandler(new ClickHandler() {\r
+ @Override\r
+ public void onClick(ClickEvent event) {\r
+ GSS.enableIESelection();\r
+ ((TextBox) event.getSource()).selectAll();\r
+ GSS.preventIESelection();\r
+ }\r
+\r
+ });\r
+ path.setText(folder.getUri());\r
+ path.setTitle("Use this link for sharing the folder 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("Link"));\r
+ pathPanel.setSpacing(8);\r
+ pathPanel.addStyleName("gss-TabPanelBottom");\r
+ pathPanel.add(path);\r
+ permPanel.add(pathPanel);\r
+\r
outer.add(inner);\r
outer.add(buttons);\r
outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);\r
* @param _folderName the name of the folder to create\r
*/\r
private void createFolder() {\r
- PostCommand ep = new PostCommand(folder.getUri()+"?new="+URL.encode(folderName.getText()),"", 201){\r
+ String name = folderName.getText();\r
+ if (!GSS.isValidResourceName(name)) {\r
+ GSS.get().displayError("The folder name '" + name + "' is invalid");\r
+ return;\r
+ }\r
+ PostCommand ep = new PostCommand(folder.getUri() + "?new=" +\r
+ URL.encodeComponent(name), "", 201) {\r
\r
@Override\r
public void onComplete() {\r
- GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());\r
+ //TODO:CELLTREE\r
+ GSS.get().getTreeView().updateNodeChildren((RestResourceWrapper) GSS.get().getTreeView().getSelection());\r
+ //GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent());\r
}\r
\r
@Override\r
if(t instanceof RestException){\r
int statusCode = ((RestException)t).getHttpStatusCode();\r
if(statusCode == 405)\r
- GSS.get().displayError("You don't have the necessary permissions or a folder with same name already exists");\r
+ GSS.get().displayError("You don't have the necessary" +\r
+ " permissions or a folder with same name " +\r
+ "already exists");\r
else if(statusCode == 404)\r
GSS.get().displayError("Resource not found");\r
else\r
- GSS.get().displayError("Unable to create folder:"+((RestException)t).getHttpStatusText());\r
+ GSS.get().displayError("Unable to create folder:" +\r
+ ((RestException)t).getHttpStatusText());\r
}\r
else\r
- GSS.get().displayError("System error creating folder:"+t.getMessage());\r
+ GSS.get().displayError("System error creating folder:" +\r
+ t.getMessage());\r
}\r
};\r
DeferredCommand.addCommand(ep);\r
JSONObject json = new JSONObject();\r
if(!folder.getName().equals(folderName.getText()))\r
json.put("name", new JSONString(folderName.getText()));\r
+ //only update the read for all perm if the user is the owner\r
+ if (readForAll.getValue() != folder.isReadForAll())\r
+ if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername()))\r
+ json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue()));\r
if (permList.hasChanges()) {\r
JSONArray perma = new JSONArray();\r
int i=0;\r
\r
@Override\r
public void onComplete() {\r
+ //TODO:CELLTREE\r
+ \r
if(getPostBody() != null && !"".equals(getPostBody().trim())){\r
- DnDTreeItem folderItem = (DnDTreeItem) GSS.get().getFolders().getCurrent();\r
- FolderResource fres = folderItem.getFolderResource();\r
+ \r
+ \r
+ FolderResource fres = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource();\r
String initialPath = fres.getUri();\r
String newPath = getPostBody().trim();\r
fres.setUri(newPath);\r
-\r
+ ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource().setUri(newPath);\r
+ ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).setUri(newPath);\r
+ GSS.get().getTreeView().updateNodeChildren(fres.getParentURI());\r
+ /*\r
if(folderItem.getParentItem() != null && ((DnDTreeItem)folderItem.getParentItem()).getFolderResource() != null){\r
((DnDTreeItem)folderItem.getParentItem()).getFolderResource().removeSubfolderPath(initialPath);\r
((DnDTreeItem)folderItem.getParentItem()).getFolderResource().getSubfolderPaths().add(newPath);\r
- }\r
+ }*/\r
}\r
- GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());\r
+ //GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());\r
+ \r
GSS.get().showFileList(true);\r
}\r
\r
}\r
else\r
GSS.get().displayError("System error moifying file: "+t.getMessage());\r
- GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());\r
+ //TODO:CELLTREE\r
+ //GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());\r
}\r
};\r
DeferredCommand.addCommand(ep);\r