Skip to content
Snippets Groups Projects
Commit bc6a35ab authored by felmer's avatar felmer
Browse files

LMS-819 GUI improved

SVN: 10598
parent 4983bc13
No related branches found
No related tags found
No related merge requests found
Showing
with 115 additions and 17 deletions
...@@ -321,6 +321,14 @@ public abstract class Dict ...@@ -321,6 +321,14 @@ public abstract class Dict
public static final String CONFIRM_DATASET_UPLOAD_TITLE = "confirm_dataset_upload_title"; public static final String CONFIRM_DATASET_UPLOAD_TITLE = "confirm_dataset_upload_title";
public static final String CONFIRM_DATASET_UPLOAD_MSG = "confirm_dataset_upload_msg"; public static final String CONFIRM_DATASET_UPLOAD_MSG = "confirm_dataset_upload_msg";
public static final String CONFIRM_DATASET_UPLOAD_FILE_NAME_FIELD = "confirm_dataset_upload_file_name_field";
public static final String CONFIRM_DATASET_UPLOAD_COMMENT_FIELD = "confirm_dataset_upload_comment_field";
public static final String CONFIRM_DATASET_UPLOAD_USER_FIELD = "confirm_dataset_upload_user_field";
public static final String CONFIRM_DATASET_UPLOAD_PASSWORD_FIELD = "confirm_dataset_upload_password_field";
// //
// Sample Registration // Sample Registration
......
...@@ -25,9 +25,11 @@ import com.extjs.gxt.ui.client.event.KeyListener; ...@@ -25,9 +25,11 @@ import com.extjs.gxt.ui.client.event.KeyListener;
import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.Dialog; import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.button.Button; import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextArea; 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.form.TextField;
import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem; import com.extjs.gxt.ui.client.widget.toolbar.AdapterToolItem;
import com.google.gwt.user.client.Element;
import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
...@@ -40,11 +42,13 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns ...@@ -40,11 +42,13 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.AbstractSimpleBrowserGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.AbstractSimpleBrowserGrid;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IBrowserGridActionInvoker; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IBrowserGridActionInvoker;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ICellListener; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.ICellListener;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.FieldUtil;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.DataSetUtils; import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.DataSetUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUploadParameters; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DataSetUploadParameters;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ExternalData;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.IColumnDefinition; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.IColumnDefinition;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteria;
import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
/** /**
* *
...@@ -78,6 +82,7 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid ...@@ -78,6 +82,7 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid
setHideOnButtonClick(true); setHideOnButtonClick(true);
setModal(true); setModal(true);
} }
} }
static final class DeletionCallback extends AbstractAsyncCallback<Void> static final class DeletionCallback extends AbstractAsyncCallback<Void>
...@@ -149,10 +154,14 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid ...@@ -149,10 +154,14 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid
private static final class UploadConfirmationDialog extends AbstractConfirmationDialog private static final class UploadConfirmationDialog extends AbstractConfirmationDialog
{ {
private static final int FIELD_WIDTH_IN_UPLOAD_DIALOG = 200;
private static final int LABEL_WIDTH_IN_UPLOAD_DIALOG = 120;
private final String cifexURL; private final String cifexURL;
private final TextField<String> password; private final TextField<String> passwordField;
private TextField<String> fileNameField; private TextField<String> fileNameField;
private TextArea commentField; private TextArea commentField;
private TextField<String> userField;
private FormPanel form;
public UploadConfirmationDialog(IViewContext<?> viewContext, List<ExternalData> dataSets, public UploadConfirmationDialog(IViewContext<?> viewContext, List<ExternalData> dataSets,
IBrowserGridActionInvoker invoker) IBrowserGridActionInvoker invoker)
...@@ -160,31 +169,69 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid ...@@ -160,31 +169,69 @@ public abstract class AbstractExternalDataGrid extends AbstractSimpleBrowserGrid
super(viewContext, dataSets, invoker, Dict.CONFIRM_DATASET_UPLOAD_TITLE); super(viewContext, dataSets, invoker, Dict.CONFIRM_DATASET_UPLOAD_TITLE);
cifexURL = viewContext.getModel().getApplicationInfo().getCIFEXURL(); cifexURL = viewContext.getModel().getApplicationInfo().getCIFEXURL();
addText(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_MSG, dataSets.size(), cifexURL)); addText(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_MSG, dataSets.size(), cifexURL));
form = new FormPanel();
form.setLabelWidth(LABEL_WIDTH_IN_UPLOAD_DIALOG);
form.setFieldWidth(FIELD_WIDTH_IN_UPLOAD_DIALOG);
form.setBodyBorder(false);
form.setHeaderVisible(false);
fileNameField = new TextField<String>(); fileNameField = new TextField<String>();
fileNameField.setFieldLabel(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_FILE_NAME_FIELD));
fileNameField.setSelectOnFocus(true); fileNameField.setSelectOnFocus(true);
add(fileNameField); fileNameField.setMaxLength(BasicConstant.MAX_LENGTH_OF_FILE_NAME + ".zip".length());
fileNameField.setAutoValidate(true);
KeyListener keyListener = new KeyListener()
{
@Override
public void handleEvent(ComponentEvent ce)
{
okBtn.setEnabled(form.isValid());
}
};
fileNameField.addKeyListener(keyListener);
form.add(fileNameField);
commentField = new TextArea(); commentField = new TextArea();
add(commentField); commentField.setMaxLength(BasicConstant.MAX_LENGTH_OF_CIFEX_COMMENT);
password = new TextField<String>(); commentField.setFieldLabel(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_COMMENT_FIELD));
password.setPassword(true); commentField.addKeyListener(keyListener);
password.setHideLabel(true); commentField.setAutoValidate(true);
password.setWidth("100%"); form.add(commentField);
password.setMaxLength(50); userField = new TextField<String>();
add(password); userField.setFieldLabel(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_USER_FIELD));
userField.setValue(viewContext.getModel().getSessionContext().getUser().getUserName());
FieldUtil.setMandatoryFlag(userField, true);
userField.addKeyListener(keyListener);
userField.setAutoValidate(true);
form.add(userField);
passwordField = new TextField<String>();
passwordField.setPassword(true);
passwordField.setFieldLabel(viewContext.getMessage(Dict.CONFIRM_DATASET_UPLOAD_PASSWORD_FIELD));
FieldUtil.setMandatoryFlag(passwordField, true);
passwordField.addKeyListener(keyListener);
passwordField.setAutoValidate(true);
form.add(passwordField);
add(form);
setWidth(LABEL_WIDTH_IN_UPLOAD_DIALOG + FIELD_WIDTH_IN_UPLOAD_DIALOG + 50);
}
@Override
protected void onRender(Element parent, int pos)
{
super.onRender(parent, pos);
okBtn.setEnabled(false);
} }
@Override @Override
protected void onButtonPressed(Button button) protected void onButtonPressed(Button button)
{ {
super.onButtonPressed(button); super.onButtonPressed(button);
if (button.getItemId().equals(Dialog.OK)) if (button.getItemId().equals(Dialog.OK) && form.isValid())
{ {
DataSetUploadParameters parameters = new DataSetUploadParameters(); DataSetUploadParameters parameters = new DataSetUploadParameters();
parameters.setCifexURL(cifexURL); parameters.setCifexURL(cifexURL);
parameters.setFileName(fileNameField.getValue()); parameters.setFileName(fileNameField.getValue());
parameters.setComment(commentField.getValue()); parameters.setComment(commentField.getValue());
parameters.setUserID(viewContext.getModel().getSessionContext().getUser().getUserName()); parameters.setUserID(userField.getValue());
parameters.setPassword(password.getValue()); parameters.setPassword(passwordField.getValue());
viewContext.getCommonService().uploadDataSets(dataSetCodes, parameters, viewContext.getCommonService().uploadDataSets(dataSetCodes, parameters,
new UploadCallback(viewContext)); new UploadCallback(viewContext));
} }
......
...@@ -26,7 +26,7 @@ import com.extjs.gxt.ui.client.widget.form.TextField; ...@@ -26,7 +26,7 @@ import com.extjs.gxt.ui.client.widget.form.TextField;
*/ */
public class FieldUtil public class FieldUtil
{ {
private static final String MANDATORY_LABEL_SEPARATOR = ": *"; private static final String MANDATORY_LABEL_SEPARATOR = ":&nbsp;*";
public static void setMandatoryFlag(Field<?> field, boolean isMandatory) public static void setMandatoryFlag(Field<?> field, boolean isMandatory)
{ {
......
...@@ -30,6 +30,7 @@ import ch.systemsx.cisd.openbis.generic.server.business.DataStoreServerSessionMa ...@@ -30,6 +30,7 @@ import ch.systemsx.cisd.openbis.generic.server.business.DataStoreServerSessionMa
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO;
import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService; import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService;
import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServerSession; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServerSession;
...@@ -55,7 +56,6 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; ...@@ -55,7 +56,6 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils;
public final class ExternalDataTable extends AbstractExternalDataBusinessObject implements public final class ExternalDataTable extends AbstractExternalDataBusinessObject implements
IExternalDataTable IExternalDataTable
{ {
@Private static final int MAX_LENGTH_OF_CIFEX_COMMENT = 1000;
@Private static final String UPLOAD_COMMENT_TEXT = "Uploaded zip file contains the following data sets:"; @Private static final String UPLOAD_COMMENT_TEXT = "Uploaded zip file contains the following data sets:";
@Private static final String NEW_LINE = "\n"; @Private static final String NEW_LINE = "\n";
@Private static final String AND_MORE_TEMPLATE = "and %d more."; @Private static final String AND_MORE_TEMPLATE = "and %d more.";
...@@ -73,7 +73,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject ...@@ -73,7 +73,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
{ {
length += NEW_LINE.length() + String.format(AND_MORE_TEMPLATE, n - i - 1).length(); length += NEW_LINE.length() + String.format(AND_MORE_TEMPLATE, n - i - 1).length();
} }
if (length < MAX_LENGTH_OF_CIFEX_COMMENT) if (length < BasicConstant.MAX_LENGTH_OF_CIFEX_COMMENT)
{ {
builder.append(code); builder.append(code);
} else } else
......
/*
* Copyright 2009 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.openbis.generic.shared.basic;
/**
* Definition of basic constants. Can be used by server and GWT client.
*
* @author Franz-Josef Elmer
*/
public class BasicConstant
{
/** Maximum length of a file name for uploading data sets to CIFEX. */
public static final int MAX_LENGTH_OF_FILE_NAME = 250;
/** Maximum length of a comment for uploading data sets to CIFEX. */
public static final int MAX_LENGTH_OF_CIFEX_COMMENT = 1000;
private BasicConstant()
{
}
}
...@@ -124,6 +124,7 @@ public class DataSetUploadContext implements Serializable ...@@ -124,6 +124,7 @@ public class DataSetUploadContext implements Serializable
builder.append(that.password, password); builder.append(that.password, password);
builder.append(that.email, email); builder.append(that.email, email);
builder.append(that.comment, comment); builder.append(that.comment, comment);
builder.append(that.fileName, fileName);
return builder.isEquals(); return builder.isEquals();
} }
...@@ -136,6 +137,7 @@ public class DataSetUploadContext implements Serializable ...@@ -136,6 +137,7 @@ public class DataSetUploadContext implements Serializable
builder.append(password); builder.append(password);
builder.append(email); builder.append(email);
builder.append(comment); builder.append(comment);
builder.append(fileName);
return builder.toHashCode(); return builder.toHashCode();
} }
......
...@@ -299,7 +299,11 @@ var common = { ...@@ -299,7 +299,11 @@ var common = {
confirm_dataset_deletion_msg: "You are deleting {0} data set(s). Please enter a reason:", confirm_dataset_deletion_msg: "You are deleting {0} data set(s). Please enter a reason:",
button_upload_datasets: "Upload to CIFEX", button_upload_datasets: "Upload to CIFEX",
confirm_dataset_upload_title: "Uploading Confirmation and Authentication", confirm_dataset_upload_title: "Uploading Confirmation and Authentication",
confirm_dataset_upload_msg: "You are uploading {0} data set(s) to CIFEX ({1}). Please, enter your CIFEX password:", confirm_dataset_upload_msg: "You are uploading {0} data set(s) to CIFEX ({1}) in a single ZIP file.<br/><br/>Please, enter additional information:",
confirm_dataset_upload_file_name_field: "File name",
confirm_dataset_upload_comment_field: "Comment",
confirm_dataset_upload_user_field: "CIFEX user",
confirm_dataset_upload_password_field: "CIFEX password",
......
...@@ -34,6 +34,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; ...@@ -34,6 +34,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.server.business.DataStoreServerSessionManager; import ch.systemsx.cisd.openbis.generic.server.business.DataStoreServerSessionManager;
import ch.systemsx.cisd.openbis.generic.server.business.ManagerTestTool; import ch.systemsx.cisd.openbis.generic.server.business.ManagerTestTool;
import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService; import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService;
import ch.systemsx.cisd.openbis.generic.shared.basic.BasicConstant;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE; import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext; import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServerSession; import ch.systemsx.cisd.openbis.generic.shared.dto.DataStoreServerSession;
...@@ -426,7 +427,7 @@ public final class ExternalDataTableTest extends AbstractBOTest ...@@ -426,7 +427,7 @@ public final class ExternalDataTableTest extends AbstractBOTest
String comment = ExternalDataTable.createUploadComment(dataSets); String comment = ExternalDataTable.createUploadComment(dataSets);
System.out.println(comment.length() + ":" + comment); System.out.println(comment.length() + ":" + comment);
assertEquals(builder.toString(), comment); assertEquals(builder.toString(), comment);
assertTrue(comment.length() <= ExternalDataTable.MAX_LENGTH_OF_CIFEX_COMMENT); assertTrue(comment.length() <= BasicConstant.MAX_LENGTH_OF_CIFEX_COMMENT);
} }
private String generateDataSetCode(int codeLength, int codeIndex) private String generateDataSetCode(int codeLength, int codeIndex)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment