X-Git-Url: https://code.grnet.gr/git/pithos/blobdiff_plain/3ef43feda664562fbf05b513e4254685f0001ba0..4cef6f041d0cc36231421c462eddfeedfddfc276:/src/gr/ebs/gss/client/FolderPropertiesDialog.java diff --git a/src/gr/ebs/gss/client/FolderPropertiesDialog.java b/src/gr/ebs/gss/client/FolderPropertiesDialog.java index eb6da0f..d127227 100644 --- a/src/gr/ebs/gss/client/FolderPropertiesDialog.java +++ b/src/gr/ebs/gss/client/FolderPropertiesDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd. + * Copyright 2007, 2008, 2009, 2010 Electronic Business Systems Ltd. * * This file is part of GSS. * @@ -31,9 +31,13 @@ import java.util.Set; import com.google.gwt.core.client.GWT; import com.google.gwt.dom.client.NativeEvent; +import com.google.gwt.event.dom.client.ChangeEvent; +import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.dom.client.KeyCodes; +import com.google.gwt.event.dom.client.KeyDownEvent; +import com.google.gwt.event.dom.client.KeyDownHandler; import com.google.gwt.http.client.URL; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.json.client.JSONArray; @@ -123,6 +127,10 @@ public class FolderPropertiesDialog extends DialogBox { inner.add(permPanel, "Sharing"); inner.selectTab(0); + final Label folderNameNote = new Label("Please note that slashes ('/') are not allowed in folder names.", true); + folderNameNote.setVisible(false); + folderNameNote.setStylePrimaryName("gss-readForAllNote"); + FlexTable generalTable = new FlexTable(); generalTable.setText(0, 0, "Name"); generalTable.setText(1, 0, "Parent"); @@ -130,12 +138,26 @@ public class FolderPropertiesDialog extends DialogBox { generalTable.setText(3, 0, "Last modified"); folderName.setText(create ? "" : folder.getName()); generalTable.setWidget(0, 1, folderName); + folderName.addChangeHandler(new ChangeHandler() { + + @Override + public void onChange(ChangeEvent event) { + if(folderName.getText().contains("/")) + folderNameNote.setVisible(true); + else + folderNameNote.setVisible(false); + + } + }); + + if (create) generalTable.setText(1, 1, folder.getName()); else if(folder.getParentName() == null) generalTable.setText(1, 1, "-"); else generalTable.setText(1, 1, folder.getParentName()); + generalTable.setWidget(0, 2, folderNameNote); generalTable.setText(2, 1, folder.getOwner()); DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a"); if(folder.getModificationDate() != null) @@ -159,13 +181,17 @@ public class FolderPropertiesDialog extends DialogBox { okLabel = "Update"; Button ok = new Button(okLabel, new ClickHandler() { @Override - public void onClick(ClickEvent event) { - - createOrUpdateFolder(); + public void onClick(ClickEvent event) { + if(folderName.getText().contains("/")) + folderNameNote.setVisible(true); + else { + folderNameNote.setVisible(false); + createOrUpdateFolder(); + closeDialog(); + } - closeDialog(); } - }); + }); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -314,8 +340,13 @@ public class FolderPropertiesDialog extends DialogBox { * @param _folderName the name of the folder to create */ private void createFolder() { + String name = folderName.getText(); + if (!GSS.isValidResourceName(name)) { + GSS.get().displayError("The folder name '" + name + "' is invalid"); + return; + } PostCommand ep = new PostCommand(folder.getUri() + "?new=" + - URL.encodeComponent(folderName.getText()), "", 201) { + URL.encodeComponent(name), "", 201) { @Override public void onComplete() {