Added regex in order to remove list of chars when renaming or creating new item. It is different for folder and item name
Updated pom version at 6.17.1 git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@150974 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3a8697659e
commit
ac1e018c9a
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-1"
|
||||
date="2017-07-10">
|
||||
<Change>Added regex in order to remove list of chars when renaming or creating new item. It is different for folder and item name</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-user.workspace-portlet-tree.6-17-0"
|
||||
date="2017-05-22">
|
||||
<Change>[Feature #5207] Integrate Image Preview Widget</Change>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>workspace-tree-widget</artifactId>
|
||||
<version>6.17.0-SNAPSHOT</version>
|
||||
<version>6.17.1-SNAPSHOT</version>
|
||||
<name>gCube Workspace Tree Widget</name>
|
||||
<description>
|
||||
gCube Workspace Tree Widget is a widget to navigate and interact with gCube Workspace
|
||||
|
|
|
@ -1215,7 +1215,7 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
private void doRenameItem(final RenameItemEvent event) {
|
||||
|
||||
final FileModel target = event.getFileTarget();
|
||||
final DialogText dgt = new DialogText(ConstantsExplorer.MESSAGE_RENAME, ConstantsExplorer.MESSAGE_ITEM_NAME, event.getFileTarget().getName());
|
||||
final DialogText dgt = new DialogText(ConstantsExplorer.MESSAGE_RENAME, ConstantsExplorer.MESSAGE_ITEM_NAME, event.getFileTarget().getName(), target.isDirectory());
|
||||
|
||||
dgt.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ConstantsExplorer {
|
|||
public static final String NUMREQUESTS = "numrequests";
|
||||
public static final String MESSAGE_WEBDAV_URL = "View Url WebDAV ";
|
||||
public static final String URL_WEBDAV = "WebDAV URL";
|
||||
public static final String REGEX_FOLDER_NAME = "Field name must not begin with one of the following characters";
|
||||
|
||||
public static final String MESSAGE_SEARCH_FORCE_APHANUMERIC = "Field search must be alphanumeric and not contain special chars!";
|
||||
public static final String MESSAGE_CREATE_NEW_MESSAGE = "Create New Message";
|
||||
|
||||
|
@ -106,6 +106,12 @@ public class ConstantsExplorer {
|
|||
protected static final String UNSHARING = "Unsharing...";
|
||||
|
||||
public static final String FILEUPLOADHEADER = "File upload in: ";
|
||||
|
||||
public static final String REGEX_TO_WSITEM_NAME = "[^\\[\\]<>\\|?/*%$\\\\:]*$";
|
||||
public static final String REGEX_TO_WSFOLDER_NAME = "[^.\\[\\]<>\\|?/*%$\\\\:]*$";
|
||||
public static final String REGEX_WSITEM_NAME_ALERT_MSG = "Field name must not contain: <>[]:\\|?/*%$ or contains / or \\";
|
||||
public static final String REGEX_WSFOLDER_NAME_ALERT_MSG = "Folder name must not contain: .<>[]:\\|?/*%$ or contains / or \\";
|
||||
|
||||
// public static final String FILE = "File";
|
||||
// public static final String ARCHIVE = "Archive";
|
||||
|
||||
|
|
|
@ -35,11 +35,12 @@ import com.google.gwt.user.client.ui.Label;
|
|||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The Class DialogShareFolder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 6, 2017
|
||||
* Jul 10, 2017
|
||||
*/
|
||||
public class DialogShareFolder extends Dialog {
|
||||
|
||||
|
@ -81,6 +82,8 @@ public class DialogShareFolder extends Dialog {
|
|||
txtName.setReadOnly(true);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
|
||||
txtName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
|
||||
|
||||
txtOwner = new TextField<String>();
|
||||
txtOwner.setAllowBlank(true);
|
||||
|
@ -335,8 +338,9 @@ public class DialogShareFolder extends Dialog {
|
|||
txtName.setAllowBlank(false);
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.setFieldLabel("Folder Name");
|
||||
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$ or contains / or \\");
|
||||
txtName.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
|
||||
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
|
||||
txtName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
|
||||
// txtName.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
|
||||
|
||||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
|
@ -533,7 +537,7 @@ public class DialogShareFolder extends Dialog {
|
|||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return txtName.getValue();
|
||||
return txtName.getValue().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
package org.gcube.portlets.user.workspace.client.view.windows;
|
||||
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
|
@ -15,144 +16,148 @@ import com.extjs.gxt.ui.client.widget.form.TextArea;
|
|||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* The Class DialogAddFolderAndSmart.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 10, 2017
|
||||
*/
|
||||
public class DialogAddFolderAndSmart extends Dialog {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int widthDialog = 500;
|
||||
private int heightTextArea = 150;
|
||||
private TextField<String> txtName;
|
||||
private TextArea textAreaDescription = new TextArea();
|
||||
public enum AddType {FOLDER, SMARTFOLDER};
|
||||
|
||||
|
||||
/**
|
||||
* The Enum AddType.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 10,
|
||||
* 2017
|
||||
*/
|
||||
public enum AddType {
|
||||
FOLDER, SMARTFOLDER
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog add folder and smart.
|
||||
*
|
||||
* @param headerTitle
|
||||
* the header title
|
||||
* @param type
|
||||
* the type
|
||||
*/
|
||||
public DialogAddFolderAndSmart(String headerTitle, AddType type) {
|
||||
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(300);
|
||||
setLayout(layout);
|
||||
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
// setHideOnButtonClick(true);
|
||||
// setIcon(IconHelper.createStyle("user"));
|
||||
if(type.equals(AddType.FOLDER)){
|
||||
setHeading(ConstantsExplorer.MESSAGE_ADD_FOLDER_IN + " "+ headerTitle);
|
||||
setIcon(Resources.getIconAddFolder());
|
||||
}
|
||||
else{
|
||||
setHeading(ConstantsExplorer.MESSAGE_ADD_SMART_FOLDER + " "+ headerTitle);
|
||||
setIcon(Resources.getIconStar());
|
||||
}
|
||||
setModal(true);
|
||||
// setBodyBorder(true);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
// this.getButtonById(Dialog.CANCEL).setText("Reset");
|
||||
|
||||
txtName = new TextField<String>();
|
||||
txtName.setAllowBlank(false);
|
||||
// txtName.setRegex("^[a-zA-Z0-9]+[ ]*[a-zA-Z0-9_-]+$");
|
||||
// txtName.setRegex("^[a-zA-Z0-9_]+[-]*[a-zA-Z0-9_\\s]*$");
|
||||
|
||||
// txtName.setRegex("^[a-zA-Z0-9]+[^.<>\\|?/*%$]*$");
|
||||
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$ or contains / or \\");
|
||||
txtName.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
layout.setDefaultWidth(300);
|
||||
setLayout(layout);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
// setHideOnButtonClick(true);
|
||||
// setIcon(IconHelper.createStyle("user"));
|
||||
if (type.equals(AddType.FOLDER)) {
|
||||
setHeading(ConstantsExplorer.MESSAGE_ADD_FOLDER_IN + " " +
|
||||
headerTitle);
|
||||
setIcon(Resources.getIconAddFolder());
|
||||
}
|
||||
else {
|
||||
setHeading(ConstantsExplorer.MESSAGE_ADD_SMART_FOLDER + " " +
|
||||
headerTitle);
|
||||
setIcon(Resources.getIconStar());
|
||||
}
|
||||
setModal(true);
|
||||
// setBodyBorder(true);
|
||||
setBodyStyle("padding: 9px; background: none");
|
||||
setWidth(widthDialog);
|
||||
setResizable(false);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
// this.getButtonById(Dialog.CANCEL).setText("Reset");
|
||||
txtName = new TextField<String>();
|
||||
txtName.setAllowBlank(false);
|
||||
// txtName.setRegex("^[a-zA-Z0-9]+[ ]*[a-zA-Z0-9_-]+$");
|
||||
// txtName.setRegex("^[a-zA-Z0-9_]+[-]*[a-zA-Z0-9_\\s]*$");
|
||||
// txtName.setRegex("^[a-zA-Z0-9]+[^.<>\\|?/*%$]*$");
|
||||
txtName.setAutoValidate(true);
|
||||
txtName.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
|
||||
txtName.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
|
||||
// txt.setMinLength(2);
|
||||
txtName.setFieldLabel(ConstantsExplorer.DIALOG_NAME);
|
||||
// txtName.setValue(msgTxt);
|
||||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
// textAreaDescription.setAllowBlank(false);
|
||||
// formData = new FormData("-20");
|
||||
// vp = new VerticalPanel();
|
||||
// vp.setSpacing(10);
|
||||
txtName.addKeyListener(new KeyListener() { // KEY ENTER
|
||||
|
||||
// txt.setMinLength(2);
|
||||
txtName.setFieldLabel(ConstantsExplorer.DIALOG_NAME);
|
||||
// txtName.setValue(msgTxt);
|
||||
|
||||
textAreaDescription.setFieldLabel(ConstantsExplorer.DIALOG_DESCRIPTION);
|
||||
textAreaDescription.setHeight(heightTextArea);
|
||||
// textAreaDescription.setAllowBlank(false);
|
||||
|
||||
// formData = new FormData("-20");
|
||||
// vp = new VerticalPanel();
|
||||
// vp.setSpacing(10);
|
||||
|
||||
|
||||
|
||||
txtName.addKeyListener(new KeyListener() { // KEY ENTER
|
||||
|
||||
public void componentKeyPress(ComponentEvent event) {
|
||||
if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
|
||||
|
||||
if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
|
||||
getButtonById(Dialog.OK).fireEvent(Events.Select);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
// txtName.reset();
|
||||
// textAreaDescription.reset();
|
||||
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
if(isValidForm())
|
||||
// txtName.reset();
|
||||
// textAreaDescription.reset();
|
||||
hide();
|
||||
}
|
||||
});
|
||||
|
||||
setFocusWidget(txtName);
|
||||
add(txtName);
|
||||
}
|
||||
});
|
||||
this.getButtonById(Dialog.OK).addSelectionListener(
|
||||
new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
public void componentSelected(ButtonEvent ce) {
|
||||
|
||||
if (isValidForm())
|
||||
hide();
|
||||
}
|
||||
});
|
||||
setFocusWidget(txtName);
|
||||
add(txtName);
|
||||
add(textAreaDescription);
|
||||
|
||||
this.show();
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return txtName.getValue();
|
||||
|
||||
return txtName.getValue().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
if(textAreaDescription.getValue()==null)
|
||||
|
||||
if (textAreaDescription.getValue() == null)
|
||||
return "";
|
||||
|
||||
return textAreaDescription.getValue();
|
||||
}
|
||||
|
||||
// private boolean isValidUrl(){
|
||||
//
|
||||
// try {
|
||||
// URL url = new URL(txtUrl.getValue());
|
||||
// URLConnection conn = url.openConnection();
|
||||
// conn.connect();
|
||||
// } catch (MalformedURLException e) {
|
||||
// System.out.println(ConstantsExplorer.ERRORURLNOTREACHABLE);
|
||||
// return false;
|
||||
// } catch (IOException e) {
|
||||
// System.out.println(ConstantsExplorer.ERRORURLNOTREACHABLE);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
public boolean isValidForm(){
|
||||
|
||||
if(txtName.isValid() && txtName.getValue() != null)
|
||||
/**
|
||||
* Checks if is valid form.
|
||||
*
|
||||
* @return true, if is valid form
|
||||
*/
|
||||
public boolean isValidForm() {
|
||||
|
||||
if (txtName.isValid() && txtName.getValue() != null)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,15 +13,27 @@ import com.extjs.gxt.ui.client.widget.Dialog;
|
|||
import com.extjs.gxt.ui.client.widget.form.TextField;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
|
||||
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* The Class DialogText.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 10, 2017
|
||||
*/
|
||||
public class DialogText extends Dialog {
|
||||
|
||||
private TextField<String> txt;
|
||||
|
||||
public DialogText(String headingTxt, String msgTitle, String msgTxt) {
|
||||
|
||||
/**
|
||||
* Instantiates a new dialog text.
|
||||
*
|
||||
* @param headingTxt the heading txt
|
||||
* @param msgTitle the msg title
|
||||
* @param msgTxt the msg txt
|
||||
* @param isFolder the is folder
|
||||
*/
|
||||
public DialogText(String headingTxt, String msgTitle, String msgTxt, boolean isFolder) {
|
||||
|
||||
FormLayout layout = new FormLayout();
|
||||
layout.setLabelWidth(90);
|
||||
|
@ -43,17 +55,24 @@ public class DialogText extends Dialog {
|
|||
txt.setValue(msgTxt);
|
||||
// txt.setRegex("^[a-zA-Z0-9]+[ a-zA-Z0-9_()-]*");
|
||||
// txt.setRegex("^[a-zA-Z0-9]+[^.<>\\|?/*%$]*$");
|
||||
txt.getMessages().setRegexText(ConstantsExplorer.REGEX_FOLDER_NAME+": .<>\\|?/*%$ or contains / or \\");
|
||||
txt.setRegex("^[^.<>\\|?/*%$]+[^\\/]*$");
|
||||
|
||||
if(isFolder){
|
||||
txt.getMessages().setRegexText(ConstantsExplorer.REGEX_WSFOLDER_NAME_ALERT_MSG);
|
||||
txt.setRegex(ConstantsExplorer.REGEX_TO_WSFOLDER_NAME);
|
||||
}else{
|
||||
txt.getMessages().setRegexText(ConstantsExplorer.REGEX_WSITEM_NAME_ALERT_MSG);
|
||||
txt.setRegex(ConstantsExplorer.REGEX_TO_WSITEM_NAME);
|
||||
}
|
||||
|
||||
txt.setAutoValidate(true);
|
||||
txt.setAllowBlank(false);
|
||||
|
||||
|
||||
txt.addKeyListener(new KeyListener() { // KEY ENTER
|
||||
|
||||
|
||||
public void componentKeyPress(ComponentEvent event) {
|
||||
if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
|
||||
if (event.getKeyCode() == KeyboardEvents.Enter.getEventCode())
|
||||
getButtonById(Dialog.OK).fireEvent(Events.Select);
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -66,7 +85,7 @@ public class DialogText extends Dialog {
|
|||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
this.getButtonById(Dialog.CANCEL).addSelectionListener(new SelectionListener<ButtonEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -80,16 +99,33 @@ public class DialogText extends Dialog {
|
|||
this.show();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the txt value.
|
||||
*
|
||||
* @return the txt value
|
||||
*/
|
||||
public String getTxtValue() {
|
||||
|
||||
return txt.getValue();
|
||||
return txt.getValue().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for value.
|
||||
*
|
||||
* @param field the field
|
||||
* @return true, if successful
|
||||
*/
|
||||
protected boolean hasValue(TextField<String> field) {
|
||||
return field.getValue() != null && field.getValue().length() > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if is valid form.
|
||||
*
|
||||
* @return true, if is valid form
|
||||
*/
|
||||
public boolean isValidForm() {
|
||||
if(txt.isValid())
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue