\r
protected PermissionsList permList;\r
\r
- protected CheckBox readForAll;\r
- \r
private HorizontalPanel pathPanel;\r
\r
private TextBox path;\r
\r
- private Dictionary otherProperties = Dictionary.getDictionary("otherProperties");\r
- \r
/**\r
* An image bundle for this widgets images.\r
*/\r
@Source("gr/grnet/pithos/resources/groups22.png")\r
ImageResource permGroup();\r
\r
- @Source("gr/grnet/pithos/resources/editdelete.png")\r
+ @Source("gr/grnet/pithos/resources/delete.gif")\r
ImageResource delete();\r
}\r
\r
super(_app);\r
file = _file;\r
\r
- Anchor close = new Anchor();\r
+ Anchor close = new Anchor("close");\r
close.addStyleName("close");\r
close.addClickHandler(new ClickHandler() {\r
\r
\r
outer.add(inner);\r
\r
- final Button ok = new Button("Close", new ClickHandler() {\r
+ final Button ok = new Button("OK", new ClickHandler() {\r
@Override\r
public void onClick(ClickEvent event) {\r
closeDialog();\r
Button add = new Button("Add Group", new ClickHandler() {\r
@Override\r
public void onClick(ClickEvent event) {\r
- PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);\r
- dlg.center();\r
- permList.updatePermissionTable();\r
+ if (app.getAccount().getGroups().isEmpty()) {\r
+ new GroupCreateDialog(app, new Command() {\r
+ \r
+ @Override\r
+ public void execute() {\r
+ if (app.getAccount().getGroups().isEmpty())\r
+ return;\r
+ PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);\r
+ dlg.center();\r
+ permList.updatePermissionTable();\r
+ }\r
+ }).center();\r
+ }\r
+ else {\r
+ PermissionsAddDialog dlg = new PermissionsAddDialog(app, app.getAccount().getGroups(), permList, false);\r
+ dlg.center();\r
+ permList.updatePermissionTable();\r
+ }\r
}\r
});\r
add.addStyleName("button");\r
"distribute this file and that it does not violate the Terms of Use.", true);\r
readForAllNote.setStylePrimaryName("pithos-readForAllNote");\r
\r
- readForAll = new CheckBox();\r
- readForAll.setValue(file.isPublished());\r
- readForAll.addClickHandler(new ClickHandler() {\r
- @Override\r
- public void onClick(ClickEvent event) {\r
- accept();\r
- }\r
- });\r
-\r
- // Only show the read for all permission if the user is the owner.\r
- if (file.getOwner().equals(app.getUsername())) {\r
- final HorizontalPanel permForAll = new HorizontalPanel();\r
- permForAll.add(new Label("Public"));\r
- permForAll.add(readForAll);\r
- permForAll.setSpacing(8);\r
- permForAll.addStyleName("pithos-TabPanelBottom");\r
- permForAll.add(readForAllNote);\r
- permPanel.add(permForAll);\r
- }\r
-\r
pathPanel = new HorizontalPanel();\r
pathPanel.setVisible(false);\r
pathPanel.setWidth("100%");\r
\r
@Override\r
public void execute() {\r
- showLinkIfPublished();\r
+ showLinkIfShared();\r
}\r
});\r
return permPanel;\r
}\r
\r
- void showLinkIfPublished() {\r
+ void showLinkIfShared() {\r
if (file.isShared()) {\r
UrlBuilder b = Window.Location.createUrlBuilder();\r
- if (file.isPublished()) {\r
- b.setPath(file.getPublicUri());\r
- path.setText(b.buildString());\r
- }\r
- else {\r
- b.setPath(app.getApiPath() + file.getOwner() + file.getUri());\r
- String href = Window.Location.getHref();\r
- boolean hasParameters = href.contains("?");\r
- path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString());\r
- }\r
+ b.setPath(app.getApiPath() + file.getOwner() + file.getUri());\r
+ String href = Window.Location.getHref();\r
+ boolean hasParameters = href.contains("?");\r
+ path.setText(href + (hasParameters ? "&" : "?") + "goto=" + b.buildString());\r
pathPanel.setVisible(true);\r
}\r
else {\r
*\r
*/\r
@Override\r
- protected void accept() {\r
- Boolean published = null;\r
- if (readForAll.getValue() != file.isPublished())\r
- if (file.getOwner().equals(app.getUsername()))\r
- published = readForAll.getValue();\r
- updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", published, permList.getPermissions());\r
+ protected boolean accept() {\r
+ updateMetaData(app.getApiPath(), app.getUsername(), file.getUri() + "?update=", permList.getPermissions());\r
+ return true;\r
}\r
\r
- protected void updateMetaData(String api, String owner, final String path, final Boolean published, final Map<String, Boolean[]> newPermissions) {\r
- if (published != null || newPermissions != null) {\r
+ protected void updateMetaData(String api, String owner, final String path, final Map<String, Boolean[]> newPermissions) {\r
+ if (newPermissions != null) {\r
PostRequest updateFile = new PostRequest(api, owner, path) {\r
@Override\r
public void onSuccess(Resource result) {\r
\r
@Override\r
public void onSuccess(File _result) {\r
- showLinkIfPublished();\r
- app.updateFolder(file.getParent(), true, new Command() {\r
- \r
- @Override\r
- public void execute() {\r
- app.updateMySharedRoot();\r
- }\r
- });\r
+ showLinkIfShared();\r
+ if (!app.isMySharedSelected())\r
+ app.updateFolder(file.getParent(), true, new Command() {\r
+ \r
+ @Override\r
+ public void execute() {\r
+ app.updateMySharedRoot();\r
+ }\r
+ }, true);\r
+ else\r
+ app.updateSharedFolder(file.getParent(), true);\r
}\r
\r
@Override\r
};\r
updateFile.setHeader("X-Auth-Token", app.getToken());\r
\r
- if (published != null)\r
- updateFile.setHeader("X-Object-Public", published.toString());\r
- if (newPermissions != null) {\r
- String readPermHeader = "read=";\r
- String writePermHeader = "write=";\r
- for (String u : newPermissions.keySet()) {\r
- Boolean[] p = newPermissions.get(u);\r
- if (p[0] != null && p[0])\r
- readPermHeader += u + ",";\r
- if (p[1] != null && p[1])\r
- writePermHeader += u + ",";\r
- }\r
- if (readPermHeader.endsWith("="))\r
- readPermHeader = "";\r
- else if (readPermHeader.endsWith(","))\r
- readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
- if (writePermHeader.endsWith("="))\r
- writePermHeader = "";\r
- else if (writePermHeader.endsWith(","))\r
- writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
- String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader;\r
- if (permHeader.length() == 0)\r
- permHeader="~";\r
- else\r
- permHeader = URL.encodePathSegment(permHeader);\r
- updateFile.setHeader("X-Object-Sharing", permHeader);\r
+ String readPermHeader = "read=";\r
+ String writePermHeader = "write=";\r
+ for (String u : newPermissions.keySet()) {\r
+ Boolean[] p = newPermissions.get(u);\r
+ if (p[0] != null && p[0])\r
+ readPermHeader += u + ",";\r
+ if (p[1] != null && p[1])\r
+ writePermHeader += u + ",";\r
}\r
+ if (readPermHeader.endsWith("="))\r
+ readPermHeader = "";\r
+ else if (readPermHeader.endsWith(","))\r
+ readPermHeader = readPermHeader.substring(0, readPermHeader.length() - 1);\r
+ if (writePermHeader.endsWith("="))\r
+ writePermHeader = "";\r
+ else if (writePermHeader.endsWith(","))\r
+ writePermHeader = writePermHeader.substring(0, writePermHeader.length() - 1);\r
+ String permHeader = readPermHeader + ((readPermHeader.length() > 0 && writePermHeader.length() > 0) ? ";" : "") + writePermHeader;\r
+ if (permHeader.length() == 0)\r
+ permHeader="~";\r
+ else\r
+ permHeader = URL.encodePathSegment(permHeader);\r
+ updateFile.setHeader("X-Object-Sharing", permHeader);\r
Scheduler.get().scheduleDeferred(updateFile);\r
}\r
- else\r
+ else if (!app.isMySharedSelected())\r
app.updateFolder(file.getParent(), true, new Command() {\r
\r
@Override\r
public void execute() {\r
- if (file.isShared())\r
+ if (file.isSharedOrPublished())\r
app.updateMySharedRoot();\r
}\r
- });\r
+ }, true);\r
+ else\r
+ app.updateSharedFolder(file.getParent(), true);\r
}\r
\r
@Override\r