- selectionModels.add(model);
- }
-
- public OtherSharedTreeView getOtherSharedTreeView() {
- return otherSharedTreeView;
- }
-
- public void updateTrash(boolean showFiles, Command callback) {
- updateFolder(trash, showFiles, callback, true);
- }
-
- public void updateGroupsNode() {
- groupTreeView.updateGroupNode(null);
- }
-
- public Group addGroup(String groupname) {
- Group newGroup = new Group(groupname);
- account.addGroup(newGroup);
- groupTreeView.updateGroupNode(null);
- return newGroup;
- }
-
- public void removeGroup(Group group) {
- account.removeGroup(group);
- updateGroupsNode();
- }
-
- public TreeView getSelectedTree() {
- return selectedTree;
- }
-
- public void setSelectedTree(TreeView selected) {
- selectedTree = selected;
- }
-
- public Folder getSelection() {
- if (selectedTree != null)
- return selectedTree.getSelection();
- return null;
- }
-
- public void showFolderStatistics(int folderFileCount) {
- numOfFiles.setHTML(String.valueOf(folderFileCount));
- }
-
- public GroupTreeView getGroupTreeView() {
- return groupTreeView;
- }
-
- public void sessionExpired() {
- new SessionExpiredDialog(this).center();
- }
-
- public void updateRootFolder(Command callback) {
- updateFolder(account.getPithos(), false, callback, true);
- }
-
- void createMySharedTree() {
- mysharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if (mysharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(mysharedTreeView, mysharedTreeSelectionModel);
- upload.setEnabled(false);
- disableUploadArea();
- updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true);
- showRelevantToolbarButtons();
- }
- else {
- if (getSelectedTree().equals(mysharedTreeView))
- setSelectedTree(null);
- if (getSelectedTree() == null)
- showRelevantToolbarButtons();
- }
- }
- });
- selectionModels.add(mysharedTreeSelectionModel);
- mysharedTreeViewModel = new MysharedTreeViewModel(Pithos.this, mysharedTreeSelectionModel);
- mysharedTreeViewModel.initialize(new Command() {
-
- @Override
- public void execute() {
- mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
- trees.insert(mysharedTreeView, 2);
- treeViews.add(mysharedTreeView);
- createOtherSharedTree();
- }
- });
- }
-
- void createOtherSharedTree() {
- otherSharedTreeSelectionModel = new SingleSelectionModel<Folder>();
- otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
- @Override
- public void onSelectionChange(SelectionChangeEvent event) {
- if (otherSharedTreeSelectionModel.getSelectedObject() != null) {
- deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
- applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
- updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true, null);
- showRelevantToolbarButtons();
- }
- else {
- if (getSelectedTree().equals(otherSharedTreeView))
- setSelectedTree(null);
- if (getSelectedTree() == null)
- showRelevantToolbarButtons();
- }
- }
- });
- selectionModels.add(otherSharedTreeSelectionModel);
- otherSharedTreeViewModel = new OtherSharedTreeViewModel(Pithos.this, otherSharedTreeSelectionModel);
- otherSharedTreeViewModel.initialize(new Command() {
-
- @Override
- public void execute() {
- otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
- trees.insert(otherSharedTreeView, 1);
- treeViews.add(otherSharedTreeView);
- scheduleResfresh();
- }
- });
- }
-
- public native void log1(String message)/*-{
- $wnd.console.log(message);
- }-*/;
-
- public String getErrorData() {
- if (error != null)
- return error.toString();
- return "";
- }
-
- public void setError(Throwable t) {
- error = t;
- }
-
- public void showRelevantToolbarButtons() {
- toolbar.showRelevantButtons();
- }
-
- public FileUploadDialog getFileUploadDialog() {
- if (fileUploadDialog == null)
- fileUploadDialog = new FileUploadDialog(this);
- return fileUploadDialog;
- }
-
- public void hideUploadIndicator() {
- upload.removeStyleName("pithos-uploadButton-loading");
- upload.setTitle("");
- }
-
- public void showUploadIndicator() {
- upload.addStyleName("pithos-uploadButton-loading");
- upload.setTitle("Upload in progress. Click for details.");
- }
-
- public void scheduleFolderHeadCommand(final Folder folder, final Command callback) {
- if (folder == null) {
- if (callback != null)
- callback.execute();
- }
- else {
- HeadRequest<Folder> headFolder = new HeadRequest<Folder>(Folder.class, getApiPath(), folder.getOwner(), folder.getUri(), folder) {
-
- @Override
- public void onSuccess(Folder _result) {
- if (callback != null)
- callback.execute();
- }
-
- @Override
- public void onError(Throwable t) {
- if (t instanceof RestException) {
- if (((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) {
- final String path = folder.getUri();
- PutRequest newFolder = new PutRequest(getApiPath(), folder.getOwner(), path) {
- @Override
- public void onSuccess(Resource _result) {
- scheduleFolderHeadCommand(folder, callback);
- }
-
- @Override
- public void onError(Throwable _t) {
- GWT.log("", _t);
- setError(_t);
- if(_t instanceof RestException){
- displayError("Unable to create folder: " + ((RestException) _t).getHttpStatusText());
- }
- else
- displayError("System error creating folder: " + _t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- newFolder.setHeader("X-Auth-Token", getToken());
- newFolder.setHeader("Content-Type", "application/folder");
- newFolder.setHeader("Accept", "*/*");
- newFolder.setHeader("Content-Length", "0");
- Scheduler.get().scheduleDeferred(newFolder);
- }
- else
- displayError("Error heading folder: " + ((RestException) t).getHttpStatusText());
- }
- else
- displayError("System error heading folder: " + t.getMessage());
-
- GWT.log("Error heading folder", t);
- setError(t);
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- headFolder.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(headFolder);
- }
- }
-
- public void scheduleFileHeadCommand(File f, final Command callback) {
- HeadRequest<File> headFile = new HeadRequest<File>(File.class, getApiPath(), f.getOwner(), f.getUri(), f) {
-
- @Override
- public void onSuccess(File _result) {
- if (callback != null)
- callback.execute();
- }
-
- @Override
- public void onError(Throwable t) {
- GWT.log("Error heading file", t);
- setError(t);
- if (t instanceof RestException)
- displayError("Error heading file: " + ((RestException) t).getHttpStatusText());
- else
- displayError("System error heading file: " + t.getMessage());
- }
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
- };
- headFile.setHeader("X-Auth-Token", getToken());
- Scheduler.get().scheduleDeferred(headFile);
- }
-
- public boolean isMySharedSelected() {
- return getSelectedTree().equals(getMySharedTreeView());
- }
-
- private Folder getUploadFolder() {
- if (folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) {
- return getSelection();
- }
- return null;
- }
-
- private void updateUploadFolder() {
- updateUploadFolder(null);
- }
-
- private void updateUploadFolder(final JsArrayString urls) {
- if (folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) {
- Folder f = getSelection();
- if (getSelectedTree().equals(getFolderTreeView()))
- updateFolder(f, true, new Command() {
-
- @Override
- public void execute() {
- updateStatistics();
- if (urls != null)
- selectUploadedFiles(urls);
- }
- }, false);
- else
- updateOtherSharedFolder(f, true, null);
- }
- }
-
- public native void disableUploadArea() /*-{
- var uploader = $wnd.$("#uploader").pluploadQueue();
- var dropElm = $wnd.document.getElementById('rightPanel');
- $wnd.plupload.removeAllEvents(dropElm, uploader.id);
- }-*/;
-
- public native void enableUploadArea() /*-{
- var uploader = $wnd.$("#uploader").pluploadQueue();
- var dropElm = $wnd.document.getElementById('rightPanel');
- $wnd.plupload.removeAllEvents(dropElm, uploader.id);
- if (uploader.runtime == 'html5') {
- uploader.settings.drop_element = 'rightPanel';
- uploader.trigger('PostInit');
- }
- }-*/;
-
- public void showUploadAlert(int nOfFiles) {
- if (uploadAlert == null)
- uploadAlert = new UploadAlert(this, nOfFiles);
- if (!uploadAlert.isShowing())
- uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
-
- @Override
- public void setPosition(int offsetWidth, int offsetHeight) {
- uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth)/2, statusPanel.getAbsoluteTop() - offsetHeight);
- }
- });
- uploadAlert.setNumOfFiles(nOfFiles);
- }
-
- public void hideUploadAlert() {
- if (uploadAlert != null && uploadAlert.isShowing())
- uploadAlert.hide();
- }
-
- public void selectUploadedFiles(JsArrayString urls) {
- List<String> selectedUrls = new ArrayList<String>();
- for (int i=0; i<urls.length(); i++)
- selectedUrls.add(urls.get(i));
- fileList.selectByUrl(selectedUrls);
- }
-
- public void emptyContainer(final Folder container) {
- String path = "/" + container.getName() + "?delimiter=/";
- DeleteRequest delete = new DeleteRequest(getApiPath(), getUsername(), path) {
-
- @Override
- protected void onUnauthorized(Response response) {
- sessionExpired();
- }
-
- @Override
- public void onSuccess(Resource result) {
- updateFolder(container, true, null, true);
- }
-
- @Override
- public void onError(Throwable t) {
+ selectionModels.add(model);
+ }
+
+ public OtherSharedTreeView getOtherSharedTreeView() {
+ return otherSharedTreeView;
+ }
+
+ public void updateTrash(boolean showFiles, Command callback) {
+ updateFolder(trash, showFiles, callback, true);
+ }
+
+ public void updateGroupsNode() {
+ groupTreeView.updateGroupNode(null);
+ }
+
+ public Group addGroup(String groupname) {
+ Group newGroup = new Group(groupname);
+ account.addGroup(newGroup);
+ groupTreeView.updateGroupNode(null);
+ return newGroup;
+ }
+
+ public void removeGroup(Group group) {
+ account.removeGroup(group);
+ updateGroupsNode();
+ }
+
+ public TreeView getSelectedTree() {
+ return selectedTree;
+ }
+
+ public void setSelectedTree(TreeView selected) {
+ selectedTree = selected;
+ }
+
+ public Folder getSelection() {
+ if(selectedTree != null) {
+ return selectedTree.getSelection();
+ }
+ return null;
+ }
+
+ public void showFolderStatistics(int folderFileCount) {
+ numOfFiles.setHTML(String.valueOf(folderFileCount));
+ }
+
+ public GroupTreeView getGroupTreeView() {
+ return groupTreeView;
+ }
+
+ public void sessionExpired() {
+ new SessionExpiredDialog(this).center();
+ }
+
+ public void updateRootFolder(Command callback) {
+ updateFolder(account.getPithos(), false, callback, true);
+ }
+
+ void createMySharedTree() {
+ mysharedTreeSelectionModel = new SingleSelectionModel<Folder>();
+ mysharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
+ @Override
+ public void onSelectionChange(SelectionChangeEvent event) {
+ if(mysharedTreeSelectionModel.getSelectedObject() != null) {
+ deselectOthers(mysharedTreeView, mysharedTreeSelectionModel);
+ upload.setEnabled(false);
+ disableUploadArea();
+ updateSharedFolder(mysharedTreeSelectionModel.getSelectedObject(), true);
+ showRelevantToolbarButtons();
+ }
+ else {
+ if(getSelectedTree().equals(mysharedTreeView)) {
+ setSelectedTree(null);
+ }
+ if(getSelectedTree() == null) {
+ showRelevantToolbarButtons();
+ }
+ }
+ }
+ });
+ selectionModels.add(mysharedTreeSelectionModel);
+ mysharedTreeViewModel = new MysharedTreeViewModel(Pithos.this, mysharedTreeSelectionModel);
+ mysharedTreeViewModel.initialize(new Command() {
+
+ @Override
+ public void execute() {
+ mysharedTreeView = new MysharedTreeView(mysharedTreeViewModel);
+ trees.insert(mysharedTreeView, 2);
+ treeViews.add(mysharedTreeView);
+ createOtherSharedTree();
+ }
+ });
+ }
+
+ void createOtherSharedTree() {
+ otherSharedTreeSelectionModel = new SingleSelectionModel<Folder>();
+ otherSharedTreeSelectionModel.addSelectionChangeHandler(new Handler() {
+ @Override
+ public void onSelectionChange(SelectionChangeEvent event) {
+ if(otherSharedTreeSelectionModel.getSelectedObject() != null) {
+ deselectOthers(otherSharedTreeView, otherSharedTreeSelectionModel);
+ applyPermissions(otherSharedTreeSelectionModel.getSelectedObject());
+ updateOtherSharedFolder(otherSharedTreeSelectionModel.getSelectedObject(), true, null);
+ showRelevantToolbarButtons();
+ }
+ else {
+ if(getSelectedTree().equals(otherSharedTreeView)) {
+ setSelectedTree(null);
+ }
+ if(getSelectedTree() == null) {
+ showRelevantToolbarButtons();
+ }
+ }
+ }
+ });
+ selectionModels.add(otherSharedTreeSelectionModel);
+ otherSharedTreeViewModel = new OtherSharedTreeViewModel(Pithos.this, otherSharedTreeSelectionModel);
+ otherSharedTreeViewModel.initialize(new Command() {
+
+ @Override
+ public void execute() {
+ otherSharedTreeView = new OtherSharedTreeView(otherSharedTreeViewModel);
+ trees.insert(otherSharedTreeView, 1);
+ treeViews.add(otherSharedTreeView);
+ scheduleResfresh();
+ }
+ });
+ }
+
+ public native void log1(String message)/*-{
+ $wnd.console.log(message);
+ }-*/;
+
+ public String getErrorData() {
+ if(error != null) {
+ return error.toString();
+ }
+ return "";
+ }
+
+ public void setError(Throwable t) {
+ error = t;
+ }
+
+ public void showRelevantToolbarButtons() {
+ toolbar.showRelevantButtons();
+ }
+
+ public FileUploadDialog getFileUploadDialog() {
+ if(fileUploadDialog == null) {
+ fileUploadDialog = new FileUploadDialog(this);
+ }
+ return fileUploadDialog;
+ }
+
+ public void hideUploadIndicator() {
+ upload.removeStyleName("pithos-uploadButton-loading");
+ upload.setTitle("");
+ }
+
+ public void showUploadIndicator() {
+ upload.addStyleName("pithos-uploadButton-loading");
+ upload.setTitle("Upload in progress. Click for details.");
+ }
+
+ public void scheduleFolderHeadCommand(final Folder folder, final Command callback) {
+ if(folder == null) {
+ if(callback != null) {
+ callback.execute();
+ }
+ }
+ else {
+ HeadRequest<Folder> headFolder = new HeadRequest<Folder>(Folder.class, getApiPath(), folder.getOwnerID(), folder.getUri(), folder) {
+
+ @Override
+ public void onSuccess(Folder _result) {
+ if(callback != null) {
+ callback.execute();
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ if(t instanceof RestException) {
+ if(((RestException) t).getHttpStatusCode() == Response.SC_NOT_FOUND) {
+ final String path = folder.getUri();
+ PutRequest newFolder = new PutRequest(getApiPath(), folder.getOwnerID(), path) {
+ @Override
+ public void onSuccess(Resource _result) {
+ scheduleFolderHeadCommand(folder, callback);
+ }
+
+ @Override
+ public void onError(Throwable _t) {
+ GWT.log("", _t);
+ setError(_t);
+ if(_t instanceof RestException) {
+ displayError("Unable to create folder: " + ((RestException) _t).getHttpStatusText());
+ }
+ else {
+ displayError("System error creating folder: " + _t.getMessage());
+ }
+ }
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
+ };
+ newFolder.setHeader(Const.X_AUTH_TOKEN, getUserToken());
+ newFolder.setHeader(Const.CONTENT_TYPE, "application/folder");
+ newFolder.setHeader(Const.ACCEPT, "*/*");
+ newFolder.setHeader(Const.CONTENT_LENGTH, "0");
+ Scheduler.get().scheduleDeferred(newFolder);
+ }
+ else if(((RestException) t).getHttpStatusCode() == Response.SC_FORBIDDEN) {
+ onSuccess(folder);
+ }
+ else {
+ displayError("Error heading folder: " + ((RestException) t).getHttpStatusText());
+ }
+ }
+ else {
+ displayError("System error heading folder: " + t.getMessage());
+ }
+
+ GWT.log("Error heading folder", t);
+ setError(t);
+ }
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
+ };
+ headFolder.setHeader(Const.X_AUTH_TOKEN, getUserToken());
+ Scheduler.get().scheduleDeferred(headFolder);
+ }
+ }
+
+ public void scheduleFileHeadCommand(File f, final Command callback) {
+ HeadRequest<File> headFile = new HeadRequest<File>(File.class, getApiPath(), f.getOwnerID(), f.getUri(), f) {
+
+ @Override
+ public void onSuccess(File _result) {
+ if(callback != null) {
+ callback.execute();
+ }
+ }
+
+ @Override
+ public void onError(Throwable t) {
+ GWT.log("Error heading file", t);
+ setError(t);
+ if(t instanceof RestException) {
+ displayError("Error heading file: " + ((RestException) t).getHttpStatusText());
+ }
+ else {
+ displayError("System error heading file: " + t.getMessage());
+ }
+ }
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
+ };
+ headFile.setHeader(Const.X_AUTH_TOKEN, getUserToken());
+ Scheduler.get().scheduleDeferred(headFile);
+ }
+
+ public boolean isMySharedSelected() {
+ return getSelectedTree().equals(getMySharedTreeView());
+ }
+
+ private Folder getUploadFolder() {
+ if(folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) {
+ return getSelection();
+ }
+ return null;
+ }
+
+ private void updateUploadFolder() {
+ updateUploadFolder(null);
+ }
+
+ private void updateUploadFolder(final JsArrayString urls) {
+ if(folderTreeView.equals(getSelectedTree()) || otherSharedTreeView.equals(getSelectedTree())) {
+ Folder f = getSelection();
+ if(getSelectedTree().equals(getFolderTreeView())) {
+ updateFolder(f, true, new Command() {
+
+ @Override
+ public void execute() {
+ updateStatistics();
+ if(urls != null) {
+ selectUploadedFiles(urls);
+ }
+ }
+ }, false);
+ }
+ else {
+ updateOtherSharedFolder(f, true, null);
+ }
+ }
+ }
+
+ public native void disableUploadArea() /*-{
+ var uploader = $wnd.$("#uploader").pluploadQueue();
+ var dropElm = $wnd.document.getElementById('rightPanel');
+ $wnd.plupload.removeAllEvents(dropElm, uploader.id);
+ }-*/;
+
+ public native void enableUploadArea() /*-{
+ var uploader = $wnd.$("#uploader").pluploadQueue();
+ var dropElm = $wnd.document.getElementById('rightPanel');
+ $wnd.plupload.removeAllEvents(dropElm, uploader.id);
+ if (uploader.runtime == 'html5') {
+ uploader.settings.drop_element = 'rightPanel';
+ uploader.trigger('PostInit');
+ }
+ }-*/;
+
+ public void showUploadAlert(int nOfFiles) {
+ if(uploadAlert == null) {
+ uploadAlert = new UploadAlert(this, nOfFiles);
+ }
+ if(!uploadAlert.isShowing()) {
+ uploadAlert.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
+
+ @Override
+ public void setPosition(int offsetWidth, int offsetHeight) {
+ uploadAlert.setPopupPosition((Window.getClientWidth() - offsetWidth) / 2, statusPanel.getAbsoluteTop() - offsetHeight);
+ }
+ });
+ }
+ uploadAlert.setNumOfFiles(nOfFiles);
+ }
+
+ public void hideUploadAlert() {
+ if(uploadAlert != null && uploadAlert.isShowing()) {
+ uploadAlert.hide();
+ }
+ }
+
+ public void selectUploadedFiles(JsArrayString urls) {
+ List<String> selectedUrls = new ArrayList<String>();
+ for(int i = 0; i < urls.length(); i++) {
+ selectedUrls.add(urls.get(i));
+ }
+ fileList.selectByUrl(selectedUrls);
+ }
+
+ public void emptyContainer(final Folder container) {
+ String path = "/" + container.getName() + "?delimiter=/";
+ DeleteRequest delete = new DeleteRequest(getApiPath(), getUserID(), path) {
+
+ @Override
+ protected void onUnauthorized(Response response) {
+ sessionExpired();
+ }
+
+ @Override
+ public void onSuccess(Resource result) {
+ updateFolder(container, true, null, true);
+ }
+
+ @Override
+ public void onError(Throwable t) {