Revision 287c3d8d
b/web_client/src/gr/grnet/pithos/web/client/CellTreeView.java | ||
---|---|---|
335 | 335 |
return; |
336 | 336 |
if (menu != null) |
337 | 337 |
menu.hide(); |
338 |
menu = new FolderContextMenu(images); |
|
339 |
menu.setPopupPosition(x, y); |
|
340 |
menu.show(); |
|
338 |
// menu = new FolderContextMenu(images);
|
|
339 |
// menu.setPopupPosition(x, y);
|
|
340 |
// menu.show();
|
|
341 | 341 |
} |
342 | 342 |
private boolean init=false; |
343 | 343 |
public boolean fetchRootFolders() { |
b/web_client/src/gr/grnet/pithos/web/client/FileList.java | ||
---|---|---|
78 | 78 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
79 | 79 |
import com.google.gwt.user.cellview.client.CellTable; |
80 | 80 |
import com.google.gwt.user.cellview.client.GssSimplePager; |
81 |
import com.google.gwt.user.client.DOM; |
|
82 | 81 |
import com.google.gwt.user.client.Event; |
83 |
import com.google.gwt.user.client.Window; |
|
84 | 82 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
85 | 83 |
import com.google.gwt.user.client.ui.Button; |
86 | 84 |
import com.google.gwt.user.client.ui.Composite; |
... | ... | |
240 | 238 |
*/ |
241 | 239 |
private final Images images; |
242 | 240 |
|
243 |
private FileContextMenu contextMenu; |
|
244 |
|
|
245 | 241 |
private DragAndDropCellTable<File> celltable; |
246 | 242 |
|
247 | 243 |
private final MultiSelectionModel<File> selectionModel; |
... | ... | |
451 | 447 |
vp.addHandler(new ContextMenuHandler() { |
452 | 448 |
@Override |
453 | 449 |
public void onContextMenu(ContextMenuEvent event) { |
454 |
contextMenu = new FileContextMenu(images, treeView.getSelection(), false); |
|
450 |
FileContextMenu contextMenu = new FileContextMenu(images, treeView.getSelection(), false);
|
|
455 | 451 |
int x = event.getNativeEvent().getClientX(); |
456 | 452 |
int y = event.getNativeEvent().getClientY(); |
457 | 453 |
contextMenu.setPopupPosition(x, y); |
... | ... | |
477 | 473 |
celltable.setPageSize(GSS.VISIBLE_FILE_COUNT); |
478 | 474 |
|
479 | 475 |
sinkEvents(Event.ONCONTEXTMENU); |
480 |
sinkEvents(Event.ONMOUSEUP); |
|
481 |
sinkEvents(Event.ONMOUSEDOWN); |
|
482 |
sinkEvents(Event.ONCLICK); |
|
483 |
sinkEvents(Event.ONKEYDOWN); |
|
484 |
sinkEvents(Event.ONDBLCLICK); |
|
476 |
// sinkEvents(Event.ONMOUSEUP);
|
|
477 |
// sinkEvents(Event.ONMOUSEDOWN);
|
|
478 |
// sinkEvents(Event.ONCLICK);
|
|
479 |
// sinkEvents(Event.ONKEYDOWN);
|
|
480 |
// sinkEvents(Event.ONDBLCLICK);
|
|
485 | 481 |
GSS.preventIESelection(); |
486 | 482 |
} |
487 | 483 |
|
b/web_client/src/gr/grnet/pithos/web/client/FileMenu.java | ||
---|---|---|
197 | 197 |
boolean newFolderVisible = !(selectedItem != null && (selectedItem instanceof TrashResource || selectedItem instanceof TrashFolderResource || selectedItem instanceof SharedResource || selectedItem instanceof OthersResource || selectedItem instanceof OtherUserResource)); |
198 | 198 |
boolean uploadVisible = !(selectedItem != null && (selectedItem instanceof TrashResource || selectedItem instanceof TrashFolderResource || selectedItem instanceof SharedResource || selectedItem instanceof OthersResource || selectedItem instanceof OtherUserResource)); |
199 | 199 |
if(newFolderVisible){ |
200 |
MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
201 |
newFolderItem.getElement().setId("topMenu.file.newFolder"); |
|
202 |
contextMenu.addItem(newFolderItem);
|
|
200 |
// MenuItem newFolderItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images));
|
|
201 |
// newFolderItem.getElement().setId("topMenu.file.newFolder");
|
|
202 |
// contextMenu.addItem(newFolderItem);
|
|
203 | 203 |
} |
204 | 204 |
if(uploadVisible){ |
205 | 205 |
MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
b/web_client/src/gr/grnet/pithos/web/client/FolderContextMenu.java | ||
---|---|---|
45 | 45 |
import gr.grnet.pithos.web.client.commands.RestoreTrashCommand; |
46 | 46 |
import gr.grnet.pithos.web.client.commands.ToTrashCommand; |
47 | 47 |
import gr.grnet.pithos.web.client.commands.UploadFileCommand; |
48 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
49 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
|
48 | 50 |
import gr.grnet.pithos.web.client.rest.resource.MyFolderResource; |
49 | 51 |
import gr.grnet.pithos.web.client.rest.resource.OtherUserResource; |
50 | 52 |
import gr.grnet.pithos.web.client.rest.resource.OthersFolderResource; |
... | ... | |
85 | 87 |
* |
86 | 88 |
* @param newImages the image bundle passed on by the parent object |
87 | 89 |
*/ |
88 |
public FolderContextMenu(final Images newImages) { |
|
90 |
public FolderContextMenu(final Images newImages, Folder folder) {
|
|
89 | 91 |
// The popup's constructor's argument is a boolean specifying that it |
90 | 92 |
// auto-close itself when the user clicks outside of it. |
91 | 93 |
super(true); |
92 | 94 |
setAnimationEnabled(true); |
93 | 95 |
images = newImages; |
96 |
MenuBar contextMenu = new MenuBar(true); |
|
94 | 97 |
|
95 |
pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(this)); |
|
96 |
MenuBar contextMenu = new MenuBar(true); |
|
97 |
|
|
98 |
RestResource selectedItem = GSS.get().getTreeView().getSelection(); |
|
98 |
MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, folder, images)); |
|
99 |
contextMenu.addItem(newFolder); |
|
99 | 100 |
|
100 |
if(selectedItem != null) |
|
101 |
if(selectedItem instanceof MyFolderResource){ |
|
102 |
MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
103 |
contextMenu.addItem(newFolder); |
|
104 |
|
|
105 |
MenuItem upload = new MenuItem("<span id = 'folderContextMenu.upload'>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
|
106 |
contextMenu.addItem(upload); |
|
107 |
|
|
108 |
boolean notRootFolder =(((MyFolderResource) selectedItem).getResource()).getParentURI() != null ? true : false; |
|
109 |
if (notRootFolder) { |
|
110 |
// do not show the copy & cut option for the user's root folder |
|
111 |
MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
112 |
contextMenu.addItem(cut); |
|
113 |
|
|
114 |
} |
|
115 |
MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
116 |
contextMenu.addItem(copy); |
|
117 |
contextMenu.addItem(pasteItem); |
|
118 |
if (notRootFolder) { |
|
119 |
// do not show delete options for the user's root folder |
|
120 |
MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
121 |
contextMenu.addItem(moveToTrash); |
|
122 |
|
|
123 |
MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
124 |
contextMenu.addItem(delete); |
|
125 |
} |
|
126 |
|
|
127 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
128 |
contextMenu.addItem(refresh); |
|
129 |
|
|
130 |
MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
131 |
contextMenu.addItem(sharing); |
|
132 |
|
|
133 |
MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
134 |
contextMenu.addItem(properties); |
|
135 |
} |
|
136 |
|
|
137 |
if(selectedItem instanceof SharedFolderResource){ |
|
138 |
MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
139 |
contextMenu.addItem(newFolder); |
|
140 |
|
|
141 |
MenuItem upload = new MenuItem("<span id = 'folderContextMenu.upload'>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
|
142 |
contextMenu.addItem(upload); |
|
143 |
|
|
144 |
MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
145 |
contextMenu.addItem(cut); |
|
146 |
|
|
147 |
MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
148 |
contextMenu.addItem(copy); |
|
149 |
|
|
150 |
contextMenu.addItem(pasteItem); |
|
151 |
|
|
152 |
MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
153 |
contextMenu.addItem(moveToTrash); |
|
154 |
|
|
155 |
MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
156 |
contextMenu.addItem(delete); |
|
101 |
// do not show the copy & cut option for the user's root folder |
|
102 |
MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
103 |
contextMenu.addItem(cut); |
|
157 | 104 |
|
158 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
159 |
contextMenu.addItem(refresh); |
|
160 |
|
|
161 |
MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
162 |
contextMenu.addItem(sharing); |
|
163 |
|
|
164 |
MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
165 |
contextMenu.addItem(properties); |
|
166 |
|
|
167 |
} |
|
168 |
if(selectedItem instanceof TrashFolderResource){ |
|
169 |
MenuItem restore = new MenuItem("<span id = 'folderContextMenu.restore'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Restore folder and contents</span>", true, new RestoreTrashCommand(this)); |
|
170 |
contextMenu.addItem(restore); |
|
171 |
|
|
172 |
MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
173 |
contextMenu.addItem(delete); |
|
174 |
|
|
175 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
176 |
contextMenu.addItem(refresh); |
|
177 |
|
|
178 |
} |
|
179 |
if(selectedItem instanceof OthersFolderResource){ |
|
180 |
MenuItem newFolder = new MenuItem("<span id = 'folderContextMenu.newFolder'>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
181 |
contextMenu.addItem(newFolder); |
|
105 |
MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
106 |
contextMenu.addItem(copy); |
|
182 | 107 |
|
183 |
MenuItem upload = new MenuItem("<span id ='folderContextMenu.upload'>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
|
184 |
contextMenu.addItem(upload); |
|
185 |
|
|
186 |
MenuItem cut = new MenuItem("<span id = 'folderContextMenu.cut'>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
187 |
contextMenu.addItem(cut); |
|
188 |
|
|
189 |
MenuItem copy = new MenuItem("<span id = 'folderContextMenu.copy'>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
190 |
contextMenu.addItem(copy); |
|
191 |
|
|
192 |
contextMenu.addItem(pasteItem); |
|
193 |
|
|
194 |
MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
195 |
contextMenu.addItem(moveToTrash); |
|
196 |
|
|
197 |
MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
198 |
contextMenu.addItem(delete); |
|
108 |
pasteItem = new MenuItem("<span id = 'folderContextMenu.paste'>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste</span>", true, new PasteCommand(this)); |
|
109 |
contextMenu.addItem(pasteItem); |
|
110 |
|
|
111 |
// do not show delete options for the user's root folder |
|
112 |
MenuItem moveToTrash = new MenuItem("<span id = 'folderContextMenu.moveToTrash'>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
113 |
contextMenu.addItem(moveToTrash); |
|
114 |
|
|
115 |
MenuItem delete = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
116 |
contextMenu.addItem(delete); |
|
117 |
|
|
118 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
119 |
contextMenu.addItem(refresh); |
|
120 |
|
|
121 |
MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
122 |
contextMenu.addItem(sharing); |
|
123 |
|
|
124 |
MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
125 |
contextMenu.addItem(properties); |
|
199 | 126 |
|
200 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.delete'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
201 |
contextMenu.addItem(refresh); |
|
202 |
|
|
203 |
MenuItem sharing = new MenuItem("<span id = 'folderContextMenu.sharing'>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
204 |
contextMenu.addItem(sharing); |
|
205 |
|
|
206 |
MenuItem properties = new MenuItem("<span id = 'folderContextMenu.properties'>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
207 |
contextMenu.addItem(properties); |
|
208 |
|
|
209 |
} |
|
210 |
if(selectedItem instanceof TrashResource){ |
|
211 |
MenuItem restore = new MenuItem("<span id ='folderContextMenu.restore'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Restore Trash</span>", true, new RestoreTrashCommand(this)); |
|
212 |
contextMenu.addItem(restore); |
|
213 |
|
|
214 |
MenuItem emptyTrash = new MenuItem("<span id = 'folderContextMenu.emptyTrash'>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this)); |
|
215 |
contextMenu.addItem(emptyTrash); |
|
216 |
|
|
217 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
218 |
contextMenu.addItem(refresh); |
|
219 |
|
|
220 |
} |
|
221 |
if(selectedItem instanceof SharedResource || selectedItem instanceof OthersResource || selectedItem instanceof OtherUserResource){ |
|
222 |
MenuItem refresh = new MenuItem("<span id = 'folderContextMenu.refresh'>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
223 |
contextMenu.addItem(refresh); |
|
224 |
|
|
225 |
} |
|
226 |
|
|
227 |
/* |
|
228 |
if(folders.isTrashItem(selectedItem)){ |
|
229 |
if (folders.isTrash(selectedItem)){ |
|
230 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Empty Trash</span>", true, new EmptyTrashCommand(this)); |
|
231 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
232 |
} |
|
233 |
else { |
|
234 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Restore folder and contents</span>", true, new RestoreTrashCommand(this)); |
|
235 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
236 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
237 |
} |
|
238 |
} |
|
239 |
else if(folders.isFileItem(selectedItem)){ |
|
240 |
|
|
241 |
} |
|
242 |
else if(!folders.isMyShares(selectedItem) && folders.isMySharedItem(selectedItem)){ |
|
243 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
244 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
|
245 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
246 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
247 |
contextMenu.addItem(pasteItem); |
|
248 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
249 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
250 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
251 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
252 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
253 |
} |
|
254 |
else if(!folders.isOthersShared(selectedItem) && folders.isOthersSharedItem(selectedItem) && !(GSS.get().getCurrentSelection() instanceof OtherUserResource)){ |
|
255 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.folderNew()).getHTML() + " New Folder</span>", true, new NewFolderCommand(this, images)); |
|
256 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + " Upload</span>", true, new UploadFileCommand(this)); |
|
257 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + " Cut</span>", true, new CutCommand(this)); |
|
258 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy</span>", true, new CopyCommand(this)); |
|
259 |
contextMenu.addItem(pasteItem); |
|
260 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + " Move to Trash</span>", true, new ToTrashCommand(this)); |
|
261 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete</span>", true, new DeleteCommand(this, newImages)); |
|
262 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
263 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + " Sharing</span>", true, new PropertiesCommand(this, newImages, 1)); |
|
264 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + " Properties</span>", true, new PropertiesCommand(this, newImages, 0)); |
|
265 |
} else if(!selectedItem.equals(folders.getSharesItem())) |
|
266 |
contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + " Refresh</span>", true, new RefreshCommand(this, images)); |
|
267 |
*/ |
|
268 |
|
|
269 | 127 |
add(contextMenu); |
270 |
if (GSS.get().getClipboard().hasFolderOrFileItem()) |
|
271 |
pasteItem.setVisible(true); |
|
272 |
else |
|
273 |
pasteItem.setVisible(false); |
|
274 | 128 |
} |
275 |
|
|
276 | 129 |
} |
b/web_client/src/gr/grnet/pithos/web/client/FolderPropertiesDialog.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client; |
36 | 36 |
|
37 |
import gr.grnet.pithos.web.client.FilePropertiesDialog.Images; |
|
37 |
import com.google.gwt.event.dom.client.KeyDownEvent; |
|
38 |
import com.google.gwt.user.client.Event; |
|
39 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
38 | 40 |
import gr.grnet.pithos.web.client.rest.PostCommand; |
39 | 41 |
import gr.grnet.pithos.web.client.rest.RestException; |
40 |
import gr.grnet.pithos.web.client.rest.resource.FolderResource; |
|
41 |
import gr.grnet.pithos.web.client.rest.resource.GroupResource; |
|
42 |
import gr.grnet.pithos.web.client.rest.resource.PermissionHolder; |
|
43 | 42 |
import gr.grnet.pithos.web.client.rest.resource.RestResourceWrapper; |
44 | 43 |
|
45 |
import java.util.List; |
|
46 |
import java.util.Set; |
|
47 |
|
|
48 | 44 |
import com.google.gwt.core.client.GWT; |
49 | 45 |
import com.google.gwt.dom.client.NativeEvent; |
50 |
import com.google.gwt.event.dom.client.ChangeEvent; |
|
51 |
import com.google.gwt.event.dom.client.ChangeHandler; |
|
52 | 46 |
import com.google.gwt.event.dom.client.ClickEvent; |
53 | 47 |
import com.google.gwt.event.dom.client.ClickHandler; |
54 | 48 |
import com.google.gwt.event.dom.client.KeyCodes; |
55 | 49 |
import com.google.gwt.http.client.URL; |
56 | 50 |
import com.google.gwt.i18n.client.DateTimeFormat; |
57 |
import com.google.gwt.json.client.JSONArray; |
|
58 |
import com.google.gwt.json.client.JSONBoolean; |
|
59 |
import com.google.gwt.json.client.JSONObject; |
|
60 |
import com.google.gwt.json.client.JSONString; |
|
61 | 51 |
import com.google.gwt.user.client.DeferredCommand; |
62 | 52 |
import com.google.gwt.user.client.Event.NativePreviewEvent; |
63 | 53 |
import com.google.gwt.user.client.ui.Button; |
... | ... | |
77 | 67 |
*/ |
78 | 68 |
public class FolderPropertiesDialog extends DialogBox { |
79 | 69 |
|
80 |
private List<GroupResource> groups = null; |
|
81 |
|
|
82 |
final PermissionsList permList; |
|
83 |
|
|
84 | 70 |
private CheckBox readForAll; |
85 | 71 |
|
86 | 72 |
/** |
... | ... | |
94 | 80 |
*/ |
95 | 81 |
private final boolean create; |
96 | 82 |
|
97 |
final FolderResource folder;
|
|
83 |
final Folder folder; |
|
98 | 84 |
|
99 | 85 |
final TabPanel inner; |
100 | 86 |
|
101 | 87 |
/** |
102 | 88 |
* The widget's constructor. |
103 | 89 |
* |
104 |
* @param images the image icons from the file properties dialog |
|
105 | 90 |
* @param _create true if the dialog is displayed for creating a new |
106 | 91 |
* sub-folder of the selected folder, false if it is displayed |
107 | 92 |
* for modifying the selected folder |
108 | 93 |
*/ |
109 |
public FolderPropertiesDialog(Images images, boolean _create, final List<GroupResource> _groups) {
|
|
94 |
public FolderPropertiesDialog(boolean _create, Folder selected) {
|
|
110 | 95 |
setAnimationEnabled(true); |
111 | 96 |
|
112 | 97 |
// Enable IE selection for the dialog (must disable it upon closing it) |
... | ... | |
114 | 99 |
|
115 | 100 |
create = _create; |
116 | 101 |
|
117 |
folder = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource(); |
|
118 |
permList = new PermissionsList(images, folder.getPermissions(), folder.getOwner()); |
|
119 |
groups = _groups; |
|
102 |
folder = selected; |
|
120 | 103 |
|
121 | 104 |
// Use this opportunity to set the dialog's caption. |
122 | 105 |
if (create) |
... | ... | |
141 | 124 |
inner.add(permPanel, "Sharing"); |
142 | 125 |
inner.selectTab(0); |
143 | 126 |
|
144 |
final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true); |
|
145 |
folderNameNote.setVisible(false); |
|
146 |
folderNameNote.setStylePrimaryName("pithos-readForAllNote"); |
|
147 |
|
|
148 | 127 |
FlexTable generalTable = new FlexTable(); |
149 | 128 |
generalTable.setText(0, 0, "Name"); |
150 | 129 |
generalTable.setText(1, 0, "Parent"); |
151 | 130 |
generalTable.setText(2, 0, "Creator"); |
152 | 131 |
generalTable.setText(3, 0, "Last modified"); |
153 | 132 |
folderName.setText(create ? "" : folder.getName()); |
154 |
folderName.getElement().setId("folderPropertiesDialog.textBox.name"); |
|
155 | 133 |
generalTable.setWidget(0, 1, folderName); |
156 |
folderName.addChangeHandler(new ChangeHandler() { |
|
157 |
|
|
158 |
@Override |
|
159 |
public void onChange(ChangeEvent event) { |
|
160 |
if(folderName.getText().contains("/")) |
|
161 |
folderNameNote.setVisible(true); |
|
162 |
else |
|
163 |
folderNameNote.setVisible(false); |
|
164 |
|
|
165 |
} |
|
166 |
}); |
|
167 |
|
|
168 | 134 |
|
169 | 135 |
if (create) |
170 | 136 |
generalTable.setText(1, 1, folder.getName()); |
171 |
else if(folder.getParentName() == null) |
|
172 |
generalTable.setText(1, 1, "-"); |
|
173 | 137 |
else |
174 |
generalTable.setText(1, 1, folder.getParentName()); |
|
175 |
generalTable.setWidget(0, 2, folderNameNote); |
|
176 |
generalTable.setText(2, 1, folder.getOwner()); |
|
138 |
generalTable.setText(1, 1, folder.getPrefix()); |
|
139 |
generalTable.setText(2, 1, ""); |
|
177 | 140 |
DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); |
178 |
if(folder.getModificationDate() != null)
|
|
179 |
generalTable.setText(3, 1, formatter.format(folder.getModificationDate()));
|
|
141 |
if(folder.getLastModified() != null)
|
|
142 |
generalTable.setText(3, 1, formatter.format(folder.getLastModified()));
|
|
180 | 143 |
generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); |
181 | 144 |
generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); |
182 | 145 |
generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); |
... | ... | |
196 | 159 |
okLabel = "Update"; |
197 | 160 |
Button ok = new Button(okLabel, new ClickHandler() { |
198 | 161 |
@Override |
199 |
public void onClick(ClickEvent event) { |
|
200 |
if(folderName.getText().contains("/")) |
|
201 |
folderNameNote.setVisible(true); |
|
202 |
else { |
|
203 |
folderNameNote.setVisible(false); |
|
204 |
createOrUpdateFolder(); |
|
205 |
closeDialog(); |
|
206 |
} |
|
207 |
|
|
162 |
public void onClick(ClickEvent event) { |
|
163 |
createOrUpdateFolder(); |
|
164 |
closeDialog(); |
|
208 | 165 |
} |
209 | 166 |
}); |
210 |
ok.getElement().setId("folderPropertiesDialog.button.ok"); |
|
211 | 167 |
buttons.add(ok); |
212 | 168 |
buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); |
213 | 169 |
// Create the 'Cancel' button, along with a listener that hides the |
... | ... | |
219 | 175 |
closeDialog(); |
220 | 176 |
} |
221 | 177 |
}); |
222 |
cancel.getElement().setId("folderPropertiesDialog.button.cancel"); |
|
223 | 178 |
buttons.add(cancel); |
224 | 179 |
buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
225 | 180 |
buttons.setSpacing(8); |
226 | 181 |
buttons.addStyleName("pithos-TabPanelBottom"); |
227 | 182 |
|
228 |
Button add = new Button("Add Group", new ClickHandler() { |
|
229 |
@Override |
|
230 |
public void onClick(ClickEvent event) { |
|
231 |
PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, false); |
|
232 |
dlg.center(); |
|
233 |
} |
|
234 |
}); |
|
235 |
add.getElement().setId("folderPropertiesDialog.button.addGroup"); |
|
236 |
permButtons.add(add); |
|
237 |
permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); |
|
238 |
|
|
239 |
Button addUser = new Button("Add User", new ClickHandler() { |
|
240 |
@Override |
|
241 |
public void onClick(ClickEvent event) { |
|
242 |
PermissionsAddDialog dlg = new PermissionsAddDialog(groups, permList, true); |
|
243 |
dlg.center(); |
|
244 |
} |
|
245 |
}); |
|
246 |
addUser.getElement().setId("folderPropertiesDialog.button.addUser"); |
|
247 |
permButtons.add(addUser); |
|
248 |
permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); |
|
249 |
|
|
250 |
permButtons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); |
|
251 |
permButtons.setSpacing(8); |
|
252 |
permButtons.addStyleName("pithos-TabPanelBottom"); |
|
253 |
|
|
254 |
final Label readForAllNote = new Label("When this option is enabled, the folder will be readable" + |
|
255 |
" by everyone. By checking this option, you are certifying that you have the right to " + |
|
256 |
"distribute this folder's contents and that it does not violate the Terms of Use.", true); |
|
257 |
readForAllNote.setVisible(false); |
|
258 |
readForAllNote.setStylePrimaryName("pithos-readForAllNote"); |
|
259 |
|
|
260 |
readForAll = new CheckBox(); |
|
261 |
readForAll.getElement().setId("folderPropertiesDialog.checkBox.public"); |
|
262 |
readForAll.setValue(folder.isReadForAll()); |
|
263 |
readForAll.addClickHandler(new ClickHandler() { |
|
264 |
@Override |
|
265 |
public void onClick(ClickEvent event) { |
|
266 |
readForAllNote.setVisible(readForAll.getValue()); |
|
267 |
} |
|
268 |
|
|
269 |
}); |
|
270 |
|
|
271 | 183 |
generalPanel.add(generalTable); |
272 |
permPanel.add(permList); |
|
273 |
permPanel.add(permButtons); |
|
274 |
|
|
275 |
// Only show the read for all permission if the user is the owner. |
|
276 |
if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) { |
|
277 |
permForAll.add(new Label("Public")); |
|
278 |
permForAll.add(readForAll); |
|
279 |
permForAll.setSpacing(8); |
|
280 |
permForAll.addStyleName("pithos-TabPanelBottom"); |
|
281 |
permForAll.add(readForAllNote); |
|
282 |
permPanel.add(permForAll); |
|
283 |
} |
|
284 |
TextBox path = new TextBox(); |
|
285 |
path.getElement().setId("folderPropertiesDialog.textBox.link"); |
|
286 |
path.setWidth("100%"); |
|
287 |
path.addClickHandler(new ClickHandler() { |
|
288 |
@Override |
|
289 |
public void onClick(ClickEvent event) { |
|
290 |
GSS.enableIESelection(); |
|
291 |
((TextBox) event.getSource()).selectAll(); |
|
292 |
GSS.preventIESelection(); |
|
293 |
} |
|
294 | 184 |
|
295 |
}); |
|
296 |
path.setText(folder.getUri()); |
|
297 |
path.setTitle("Use this link for sharing the folder via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)"); |
|
298 |
path.setWidth("100%"); |
|
299 |
path.setReadOnly(true); |
|
300 |
pathPanel.setWidth("100%"); |
|
301 |
pathPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); |
|
302 |
pathPanel.add(new Label("Link")); |
|
303 |
pathPanel.setSpacing(8); |
|
304 |
pathPanel.addStyleName("pithos-TabPanelBottom"); |
|
305 |
pathPanel.add(path); |
|
306 |
permPanel.add(pathPanel); |
|
307 | 185 |
|
308 | 186 |
outer.add(inner); |
309 | 187 |
outer.add(buttons); |
... | ... | |
329 | 207 |
super.onPreviewNativeEvent(preview); |
330 | 208 |
|
331 | 209 |
NativeEvent evt = preview.getNativeEvent(); |
332 |
if (evt.getType().equals("keydown"))
|
|
210 |
if (evt.getType().equals(KeyDownEvent.getType().getName()))
|
|
333 | 211 |
// Use the popup's key preview hooks to close the dialog when either |
334 | 212 |
// enter or escape is pressed. |
335 | 213 |
switch (evt.getKeyCode()) { |
... | ... | |
355 | 233 |
|
356 | 234 |
/** |
357 | 235 |
* Generate an RPC request to create a new folder. |
358 |
* |
|
359 |
* @param userId the ID of the user whose namespace will be searched for |
|
360 |
* folders |
|
361 |
* @param _folderName the name of the folder to create |
|
362 | 236 |
*/ |
363 | 237 |
private void createFolder() { |
364 | 238 |
String name = folderName.getText(); |
365 |
if (!GSS.isValidResourceName(name)) { |
|
366 |
GSS.get().displayError("The folder name '" + name + "' is invalid"); |
|
367 |
return; |
|
368 |
} |
|
369 |
PostCommand ep = new PostCommand(folder.getUri() + "?new=" + |
|
370 |
URL.encodeComponent(name), "", 201) { |
|
371 | 239 |
|
372 |
@Override |
|
373 |
public void onComplete() { |
|
374 |
//TODO:CELLTREE |
|
375 |
if(folder.getUri().equals(GSS.get().getTreeView().getMyFolders().getUri())){ |
|
376 |
GSS.get().getTreeView().updateRootNode(); |
|
377 |
} |
|
378 |
else |
|
379 |
GSS.get().getTreeView().updateNodeChildren((RestResourceWrapper) GSS.get().getTreeView().getSelection()); |
|
380 |
//GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent()); |
|
381 |
} |
|
382 |
|
|
383 |
@Override |
|
384 |
public void onError(Throwable t) { |
|
385 |
GWT.log("", t); |
|
386 |
if(t instanceof RestException){ |
|
387 |
int statusCode = ((RestException)t).getHttpStatusCode(); |
|
388 |
if(statusCode == 405) |
|
389 |
GSS.get().displayError("You don't have the necessary" + |
|
390 |
" permissions or a folder with same name " + |
|
391 |
"already exists"); |
|
392 |
else if(statusCode == 404) |
|
393 |
GSS.get().displayError("Resource not found"); |
|
394 |
else |
|
395 |
GSS.get().displayError("Unable to create folder:" + |
|
396 |
((RestException)t).getHttpStatusText()); |
|
397 |
} |
|
398 |
else |
|
399 |
GSS.get().displayError("System error creating folder:" + |
|
400 |
t.getMessage()); |
|
401 |
} |
|
402 |
}; |
|
403 |
DeferredCommand.addCommand(ep); |
|
240 |
// PostCommand ep = new PostCommand(folder.getUri() + "?new=" + |
|
241 |
// URL.encodeComponent(name), "", 201) { |
|
242 |
// |
|
243 |
// @Override |
|
244 |
// public void onComplete() { |
|
245 |
// //TODO:CELLTREE |
|
246 |
// if(folder.getUri().equals(GSS.get().getTreeView().getMyFolders().getUri())){ |
|
247 |
// GSS.get().getTreeView().updateRootNode(); |
|
248 |
// } |
|
249 |
// else |
|
250 |
// GSS.get().getTreeView().updateNodeChildren((RestResourceWrapper) GSS.get().getTreeView().getSelection()); |
|
251 |
// //GSS.get().getFolders().updateFolder((DnDTreeItem) GSS.get().getFolders().getCurrent()); |
|
252 |
// } |
|
253 |
// |
|
254 |
// @Override |
|
255 |
// public void onError(Throwable t) { |
|
256 |
// GWT.log("", t); |
|
257 |
// if(t instanceof RestException){ |
|
258 |
// int statusCode = ((RestException)t).getHttpStatusCode(); |
|
259 |
// if(statusCode == 405) |
|
260 |
// GSS.get().displayError("You don't have the necessary" + |
|
261 |
// " permissions or a folder with same name " + |
|
262 |
// "already exists"); |
|
263 |
// else if(statusCode == 404) |
|
264 |
// GSS.get().displayError("Resource not found"); |
|
265 |
// else |
|
266 |
// GSS.get().displayError("Unable to create folder:" + |
|
267 |
// ((RestException)t).getHttpStatusText()); |
|
268 |
// } |
|
269 |
// else |
|
270 |
// GSS.get().displayError("System error creating folder:" + |
|
271 |
// t.getMessage()); |
|
272 |
// } |
|
273 |
// }; |
|
274 |
// DeferredCommand.addCommand(ep); |
|
404 | 275 |
|
405 | 276 |
} |
406 | 277 |
|
... | ... | |
408 | 279 |
* Upon closing the dialog by clicking OK or pressing ENTER this method does |
409 | 280 |
* the actual work of modifying folder properties or creating a new Folder |
410 | 281 |
* depending on the value of the create field |
411 |
* |
|
412 |
* @param userId |
|
413 | 282 |
*/ |
414 | 283 |
private void createOrUpdateFolder() { |
415 | 284 |
if (create) |
... | ... | |
420 | 289 |
} |
421 | 290 |
|
422 | 291 |
private void updateFolder() { |
423 |
permList.updatePermissionsAccordingToInput(); |
|
424 |
Set<PermissionHolder> perms = permList.getPermissions(); |
|
425 |
JSONObject json = new JSONObject(); |
|
426 |
if(!folder.getName().equals(folderName.getText())) |
|
427 |
json.put("name", new JSONString(folderName.getText())); |
|
428 |
//only update the read for all perm if the user is the owner |
|
429 |
if (readForAll.getValue() != folder.isReadForAll()) |
|
430 |
if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername())) |
|
431 |
json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue())); |
|
432 |
if (permList.hasChanges()) { |
|
433 |
JSONArray perma = new JSONArray(); |
|
434 |
int i=0; |
|
435 |
for(PermissionHolder p : perms){ |
|
436 |
JSONObject po = new JSONObject(); |
|
437 |
if(p.getUser() != null) |
|
438 |
po.put("user", new JSONString(p.getUser())); |
|
439 |
if(p.getGroup() != null) |
|
440 |
po.put("group", new JSONString(p.getGroup())); |
|
441 |
po.put("read", JSONBoolean.getInstance(p.isRead())); |
|
442 |
po.put("write", JSONBoolean.getInstance(p.isWrite())); |
|
443 |
po.put("modifyACL", JSONBoolean.getInstance(p.isModifyACL())); |
|
444 |
perma.set(i,po); |
|
445 |
i++; |
|
446 |
} |
|
447 |
json.put("permissions", perma); |
|
448 |
GWT.log(json.toString(), null); |
|
449 |
} |
|
450 |
PostCommand ep = new PostCommand(folder.getUri()+"?update=", json.toString(), 200){ |
|
451 |
|
|
452 |
@Override |
|
453 |
public void onComplete() { |
|
454 |
//TODO:CELLTREE |
|
455 |
|
|
456 |
if(getPostBody() != null && !"".equals(getPostBody().trim())){ |
|
457 |
|
|
458 |
|
|
459 |
FolderResource fres = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource(); |
|
460 |
String initialPath = fres.getUri(); |
|
461 |
String newPath = getPostBody().trim(); |
|
462 |
fres.setUri(newPath); |
|
463 |
((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource().setUri(newPath); |
|
464 |
((RestResourceWrapper) GSS.get().getTreeView().getSelection()).setUri(newPath); |
|
465 |
GSS.get().getTreeView().updateNodeChildren(fres.getParentURI()); |
|
466 |
if (permList.hasChanges()) { |
|
467 |
GSS.get().getTreeView().updateMySharedNode(); |
|
468 |
} |
|
469 |
/* |
|
470 |
if(folderItem.getParentItem() != null && ((DnDTreeItem)folderItem.getParentItem()).getFolderResource() != null){ |
|
471 |
((DnDTreeItem)folderItem.getParentItem()).getFolderResource().removeSubfolderPath(initialPath); |
|
472 |
((DnDTreeItem)folderItem.getParentItem()).getFolderResource().getSubfolderPaths().add(newPath); |
|
473 |
}*/ |
|
474 |
} |
|
475 |
//GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent()); |
|
476 |
|
|
477 |
GSS.get().showFileList(true); |
|
478 |
} |
|
479 |
|
|
480 |
@Override |
|
481 |
public void onError(Throwable t) { |
|
482 |
GWT.log("", t); |
|
483 |
if(t instanceof RestException){ |
|
484 |
int statusCode = ((RestException)t).getHttpStatusCode(); |
|
485 |
if(statusCode == 405) |
|
486 |
GSS.get().displayError("You don't have the necessary permissions or" + |
|
487 |
" a folder with same name already exists"); |
|
488 |
else if(statusCode == 404) |
|
489 |
GSS.get().displayError("Resource not found, or user specified in sharing does not exist"); |
|
490 |
else |
|
491 |
GSS.get().displayError("Unable to update folder: "+((RestException)t).getHttpStatusText()); |
|
492 |
} |
|
493 |
else |
|
494 |
GSS.get().displayError("System error moifying file: "+t.getMessage()); |
|
495 |
//TODO:CELLTREE |
|
496 |
//GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent()); |
|
497 |
} |
|
498 |
}; |
|
499 |
DeferredCommand.addCommand(ep); |
|
292 |
// permList.updatePermissionsAccordingToInput();
|
|
293 |
// Set<PermissionHolder> perms = permList.getPermissions();
|
|
294 |
// JSONObject json = new JSONObject();
|
|
295 |
// if(!folder.getName().equals(folderName.getText()))
|
|
296 |
// json.put("name", new JSONString(folderName.getText()));
|
|
297 |
// //only update the read for all perm if the user is the owner
|
|
298 |
// if (readForAll.getValue() != folder.isReadForAll())
|
|
299 |
// if (folder.getOwner().equals(GSS.get().getCurrentUserResource().getUsername()))
|
|
300 |
// json.put("readForAll", JSONBoolean.getInstance(readForAll.getValue()));
|
|
301 |
// if (permList.hasChanges()) {
|
|
302 |
// JSONArray perma = new JSONArray();
|
|
303 |
// int i=0;
|
|
304 |
// for(PermissionHolder p : perms){
|
|
305 |
// JSONObject po = new JSONObject();
|
|
306 |
// if(p.getUser() != null)
|
|
307 |
// po.put("user", new JSONString(p.getUser()));
|
|
308 |
// if(p.getGroup() != null)
|
|
309 |
// po.put("group", new JSONString(p.getGroup()));
|
|
310 |
// po.put("read", JSONBoolean.getInstance(p.isRead()));
|
|
311 |
// po.put("write", JSONBoolean.getInstance(p.isWrite()));
|
|
312 |
// po.put("modifyACL", JSONBoolean.getInstance(p.isModifyACL()));
|
|
313 |
// perma.set(i,po);
|
|
314 |
// i++;
|
|
315 |
// }
|
|
316 |
// json.put("permissions", perma);
|
|
317 |
// GWT.log(json.toString(), null);
|
|
318 |
// }
|
|
319 |
// PostCommand ep = new PostCommand(folder.getUri()+"?update=", json.toString(), 200){
|
|
320 |
// |
|
321 |
// @Override
|
|
322 |
// public void onComplete() {
|
|
323 |
// //TODO:CELLTREE
|
|
324 |
// |
|
325 |
// if(getPostBody() != null && !"".equals(getPostBody().trim())){
|
|
326 |
// |
|
327 |
// |
|
328 |
// FolderResource fres = ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource();
|
|
329 |
// String initialPath = fres.getUri();
|
|
330 |
// String newPath = getPostBody().trim();
|
|
331 |
// fres.setUri(newPath);
|
|
332 |
// ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).getResource().setUri(newPath);
|
|
333 |
// ((RestResourceWrapper) GSS.get().getTreeView().getSelection()).setUri(newPath);
|
|
334 |
// GSS.get().getTreeView().updateNodeChildren(fres.getParentURI());
|
|
335 |
// if (permList.hasChanges()) {
|
|
336 |
// GSS.get().getTreeView().updateMySharedNode();
|
|
337 |
// }
|
|
338 |
// /*
|
|
339 |
// if(folderItem.getParentItem() != null && ((DnDTreeItem)folderItem.getParentItem()).getFolderResource() != null){
|
|
340 |
// ((DnDTreeItem)folderItem.getParentItem()).getFolderResource().removeSubfolderPath(initialPath);
|
|
341 |
// ((DnDTreeItem)folderItem.getParentItem()).getFolderResource().getSubfolderPaths().add(newPath);
|
|
342 |
// }*/
|
|
343 |
// }
|
|
344 |
// //GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());
|
|
345 |
// |
|
346 |
// GSS.get().showFileList(true);
|
|
347 |
// }
|
|
348 |
// |
|
349 |
// @Override
|
|
350 |
// public void onError(Throwable t) {
|
|
351 |
// GWT.log("", t);
|
|
352 |
// if(t instanceof RestException){
|
|
353 |
// int statusCode = ((RestException)t).getHttpStatusCode();
|
|
354 |
// if(statusCode == 405)
|
|
355 |
// GSS.get().displayError("You don't have the necessary permissions or" +
|
|
356 |
// " a folder with same name already exists");
|
|
357 |
// else if(statusCode == 404)
|
|
358 |
// GSS.get().displayError("Resource not found, or user specified in sharing does not exist");
|
|
359 |
// else
|
|
360 |
// GSS.get().displayError("Unable to update folder: "+((RestException)t).getHttpStatusText());
|
|
361 |
// }
|
|
362 |
// else
|
|
363 |
// GSS.get().displayError("System error moifying file: "+t.getMessage());
|
|
364 |
// //TODO:CELLTREE
|
|
365 |
// //GSS.get().getFolders().updateFolder( (DnDTreeItem) GSS.get().getFolders().getCurrent());
|
|
366 |
// }
|
|
367 |
// };
|
|
368 |
// DeferredCommand.addCommand(ep);
|
|
500 | 369 |
} |
501 | 370 |
|
502 | 371 |
public void selectTab(int _tab) { |
b/web_client/src/gr/grnet/pithos/web/client/commands/NewFolderCommand.java | ||
---|---|---|
34 | 34 |
*/ |
35 | 35 |
package gr.grnet.pithos.web.client.commands; |
36 | 36 |
|
37 |
import com.google.gwt.event.logical.shared.CloseEvent; |
|
38 |
import com.google.gwt.event.logical.shared.CloseHandler; |
|
37 | 39 |
import gr.grnet.pithos.web.client.FileMenu.Images; |
38 | 40 |
import gr.grnet.pithos.web.client.FolderPropertiesDialog; |
39 | 41 |
import gr.grnet.pithos.web.client.GSS; |
42 |
import gr.grnet.pithos.web.client.foldertree.Folder; |
|
43 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView; |
|
40 | 44 |
import gr.grnet.pithos.web.client.rest.GetCommand; |
41 | 45 |
import gr.grnet.pithos.web.client.rest.MultipleGetCommand; |
42 | 46 |
import gr.grnet.pithos.web.client.rest.resource.GroupResource; |
... | ... | |
58 | 62 |
*/ |
59 | 63 |
public class NewFolderCommand implements Command{ |
60 | 64 |
private PopupPanel containerPanel; |
65 |
|
|
66 |
private Folder folder; |
|
61 | 67 |
final Images images; |
62 | 68 |
|
63 | 69 |
private List<GroupResource> groups = null; |
... | ... | |
66 | 72 |
* @param aContainerPanel |
67 | 73 |
* @param newImages the images of the new folder dialog |
68 | 74 |
*/ |
69 |
public NewFolderCommand(PopupPanel aContainerPanel, final Images newImages){ |
|
75 |
public NewFolderCommand(PopupPanel aContainerPanel, Folder folder, final Images newImages){
|
|
70 | 76 |
containerPanel = aContainerPanel; |
71 | 77 |
images=newImages; |
78 |
this.folder = folder; |
|
72 | 79 |
} |
73 | 80 |
|
74 | 81 |
@Override |
75 | 82 |
public void execute() { |
76 | 83 |
containerPanel.hide(); |
77 |
getGroups(); |
|
78 |
DeferredCommand.addCommand(new IncrementalCommand() { |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean execute() { |
|
82 |
boolean res = canContinue(); |
|
83 |
if (res) { |
|
84 |
displayNewFolder(); |
|
85 |
return false; |
|
86 |
} |
|
87 |
return true; |
|
88 |
} |
|
89 |
|
|
90 |
}); |
|
84 |
displayNewFolderDialog(); |
|
91 | 85 |
} |
92 | 86 |
|
93 |
private boolean canContinue() { |
|
94 |
if (groups == null) |
|
95 |
return false; |
|
96 |
return true; |
|
87 |
void displayNewFolderDialog() { |
|
88 |
if (folder != null) { |
|
89 |
FolderPropertiesDialog dlg = new FolderPropertiesDialog(true, folder); |
|
90 |
dlg.center(); |
|
91 |
} |
|
97 | 92 |
} |
98 |
|
|
99 |
void displayNewFolder() { |
|
100 |
RestResource currentFolder = GSS.get().getTreeView().getSelection(); |
|
101 |
if (currentFolder == null) { |
|
102 |
GSS.get().displayError("You have to select the parent folder first"); |
|
103 |
return; |
|
104 |
} |
|
105 |
FolderPropertiesDialog dlg = new FolderPropertiesDialog(images, true, groups); |
|
106 |
dlg.center(); |
|
107 |
} |
|
108 |
|
|
109 |
private void getGroups() { |
|
110 |
GetCommand<GroupsResource> gg = new GetCommand<GroupsResource>(GroupsResource.class, GSS.get().getCurrentUserResource().getGroupsPath(), null){ |
|
111 |
|
|
112 |
@Override |
|
113 |
public void onComplete() { |
|
114 |
GroupsResource res = getResult(); |
|
115 |
MultipleGetCommand<GroupResource> ga = new MultipleGetCommand<GroupResource>(GroupResource.class, res.getGroupPaths().toArray(new String[]{}), null){ |
|
116 |
|
|
117 |
@Override |
|
118 |
public void onComplete() { |
|
119 |
List<GroupResource> groupList = getResult(); |
|
120 |
groups = groupList; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void onError(Throwable t) { |
|
125 |
GWT.log("", t); |
|
126 |
GSS.get().displayError("Unable to fetch groups"); |
|
127 |
groups = new ArrayList<GroupResource>(); |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public void onError(String p, Throwable throwable) { |
|
132 |
GWT.log("Path:"+p, throwable); |
|
133 |
} |
|
134 |
}; |
|
135 |
DeferredCommand.addCommand(ga); |
|
136 |
} |
|
137 |
|
|
138 |
@Override |
|
139 |
public void onError(Throwable t) { |
|
140 |
GWT.log("", t); |
|
141 |
GSS.get().displayError("Unable to fetch groups"); |
|
142 |
groups = new ArrayList<GroupResource>(); |
|
143 |
} |
|
144 |
}; |
|
145 |
DeferredCommand.addCommand(gg); |
|
146 |
} |
|
147 |
|
|
148 | 93 |
} |
b/web_client/src/gr/grnet/pithos/web/client/commands/PropertiesCommand.java | ||
---|---|---|
206 | 206 |
*/ |
207 | 207 |
void displayProperties(final Images propImages, final String _userName) { |
208 | 208 |
if (GSS.get().getCurrentSelection() instanceof RestResourceWrapper) { |
209 |
FolderPropertiesDialog dlg = new FolderPropertiesDialog(propImages, false, groups); |
|
210 |
dlg.selectTab(tabToShow); |
|
211 |
dlg.center(); |
|
209 |
// FolderPropertiesDialog dlg = new FolderPropertiesDialog(propImages, false, groups);
|
|
210 |
// dlg.selectTab(tabToShow);
|
|
211 |
// dlg.center();
|
|
212 | 212 |
} else if (GSS.get().getCurrentSelection() instanceof FileResource) { |
213 | 213 |
FilePropertiesDialog dlg = new FilePropertiesDialog(propImages, groups, versions, _userName); |
214 | 214 |
dlg.selectTab(tabToShow); |
b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeView.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.foldertree; |
37 | 37 |
|
38 |
import com.google.gwt.cell.client.AbstractCell; |
|
39 | 38 |
import com.google.gwt.core.client.GWT; |
40 | 39 |
import com.google.gwt.resources.client.ClientBundle; |
41 | 40 |
import com.google.gwt.resources.client.ImageResource; |
42 | 41 |
import com.google.gwt.resources.client.ImageResource.ImageOptions; |
43 | 42 |
import com.google.gwt.safehtml.client.SafeHtmlTemplates; |
44 | 43 |
import com.google.gwt.safehtml.shared.SafeHtml; |
45 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
|
46 | 44 |
import com.google.gwt.user.cellview.client.CellTree; |
47 | 45 |
import com.google.gwt.user.cellview.client.HasKeyboardSelectionPolicy.KeyboardSelectionPolicy; |
48 |
import com.google.gwt.user.client.Event; |
|
49 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
|
50 | 46 |
import com.google.gwt.user.client.ui.Composite; |
51 | 47 |
import com.google.gwt.user.client.ui.Tree; |
52 | 48 |
import gr.grnet.pithos.web.client.FolderContextMenu; |
... | ... | |
77 | 73 |
ImageResource home(); |
78 | 74 |
|
79 | 75 |
@Source("gr/grnet/pithos/resources/folder_yellow.png") |
80 |
ImageResource folderYellow(); |
|
76 |
public ImageResource folderYellow();
|
|
81 | 77 |
} |
82 | 78 |
|
83 |
private static Images images = GWT.create(Images.class);
|
|
79 |
static Images images = GWT.create(Images.class); |
|
84 | 80 |
|
85 | 81 |
static interface Templates extends SafeHtmlTemplates { |
86 |
Templates INSTANCE = GWT.create(Templates.class); |
|
82 |
public Templates INSTANCE = GWT.create(Templates.class);
|
|
87 | 83 |
|
88 | 84 |
@Template("<span>{0}</span>") |
89 | 85 |
public SafeHtml nameSpan(String name); |
90 | 86 |
} |
91 | 87 |
|
92 |
static class FolderCell extends AbstractCell<Folder> { |
|
93 |
|
|
94 |
@Override |
|
95 |
public void render(Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) { |
|
96 |
String html = AbstractImagePrototype.create(images.folderYellow()).getHTML(); |
|
97 |
safeHtmlBuilder.appendHtmlConstant(html); |
|
98 |
safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName())); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 | 88 |
private FolderTreeViewModel model; |
104 | 89 |
|
105 | 90 |
public FolderTreeView(FolderTreeViewModel viewModel) { |
... | ... | |
114 | 99 |
|
115 | 100 |
tree.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); |
116 | 101 |
|
117 |
sinkEvents(Event.ONCONTEXTMENU); |
|
118 |
sinkEvents(Event.ONMOUSEUP); |
|
119 | 102 |
initWidget(tree); |
120 | 103 |
} |
121 | 104 |
|
105 |
|
|
122 | 106 |
public Folder getSelection() { |
123 | 107 |
return model.getSelection(); |
124 | 108 |
} |
b/web_client/src/gr/grnet/pithos/web/client/foldertree/FolderTreeViewModel.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
package gr.grnet.pithos.web.client.foldertree; |
37 | 37 |
|
38 |
import com.google.gwt.cell.client.AbstractCell; |
|
39 |
import com.google.gwt.cell.client.Cell; |
|
38 | 40 |
import com.google.gwt.core.client.GWT; |
39 | 41 |
import com.google.gwt.core.client.Scheduler; |
40 | 42 |
import com.google.gwt.core.client.Scheduler.ScheduledCommand; |
43 |
import com.google.gwt.event.dom.client.ContextMenuEvent; |
|
44 |
import com.google.gwt.safehtml.shared.SafeHtmlBuilder; |
|
45 |
import com.google.gwt.user.client.ui.AbstractImagePrototype; |
|
41 | 46 |
import com.google.gwt.view.client.ListDataProvider; |
42 |
import com.google.gwt.view.client.SelectionChangeEvent; |
|
43 |
import com.google.gwt.view.client.SelectionChangeEvent.Handler; |
|
44 | 47 |
import com.google.gwt.view.client.SingleSelectionModel; |
45 | 48 |
import com.google.gwt.view.client.TreeViewModel; |
49 |
import gr.grnet.pithos.web.client.FolderContextMenu; |
|
46 | 50 |
import gr.grnet.pithos.web.client.GSS; |
47 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView.FolderCell;
|
|
51 |
import gr.grnet.pithos.web.client.foldertree.FolderTreeView.Templates;
|
|
48 | 52 |
import gr.grnet.pithos.web.client.rest.GetRequest; |
49 | 53 |
import gr.grnet.pithos.web.client.rest.RestException; |
50 | 54 |
import java.util.Iterator; |
... | ... | |
52 | 56 |
|
53 | 57 |
public class FolderTreeViewModel implements TreeViewModel { |
54 | 58 |
|
59 |
private Cell<Folder> folderCell = new AbstractCell<Folder>(ContextMenuEvent.getType().getName()) { |
|
60 |
|
|
61 |
@Override |
|
62 |
public void render(Context context, Folder folder, SafeHtmlBuilder safeHtmlBuilder) { |
|
63 |
String html = AbstractImagePrototype.create(FolderTreeView.images.folderYellow()).getHTML(); |
|
64 |
safeHtmlBuilder.appendHtmlConstant(html); |
|
65 |
safeHtmlBuilder.append(Templates.INSTANCE.nameSpan(folder.getName())); |
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public void onBrowserEvent(Cell.Context context, com.google.gwt.dom.client.Element parent, Folder folder, com.google.gwt.dom.client.NativeEvent event, com.google.gwt.cell.client.ValueUpdater<Folder> valueUpdater) { |
|
70 |
if (event.getType().equals(ContextMenuEvent.getType().getName())) { |
|
71 |
Folder target = (Folder) context.getKey(); |
|
72 |
FolderTreeViewModel.this.selectionModel.setSelected(target, true); |
|
73 |
FolderContextMenu menu = new FolderContextMenu(FolderTreeView.images, target); |
|
74 |
menu.setPopupPosition(event.getClientX(), event.getClientY()); |
|
75 |
menu.show(); |
|
76 |
} |
|
77 |
} |
|
78 |
}; |
|
79 |
|
|
55 | 80 |
private ListDataProvider<Folder> rootDataProvider = new ListDataProvider<Folder>(); |
56 | 81 |
|
57 | 82 |
private SingleSelectionModel<Folder> selectionModel; |
... | ... | |
65 | 90 |
if (value == null) { |
66 | 91 |
Folder f = new Folder("Loading ..."); |
67 | 92 |
rootDataProvider.getList().add(f); |
68 |
return new DefaultNodeInfo<Folder>(rootDataProvider, new FolderCell(), selectionModel, null);
|
|
93 |
return new DefaultNodeInfo<Folder>(rootDataProvider, folderCell, selectionModel, null);
|
|
69 | 94 |
} |
70 | 95 |
else { |
71 | 96 |
final Folder f = (Folder) value; |
... | ... | |
96 | 121 |
Scheduler.get().scheduleDeferred(getFolder); |
97 | 122 |
} |
98 | 123 |
}); |
99 |
return new DefaultNodeInfo<Folder>(dataProvider, new FolderCell(), selectionModel, null);
|
|
124 |
return new DefaultNodeInfo<Folder>(dataProvider, folderCell, selectionModel, null);
|
|
100 | 125 |
} |
101 | 126 |
} |
102 | 127 |
|
Also available in: Unified diff