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

LMS-650 Introducing UELMethodWithParameters. Fixing a bug which reveals in Internet Explorer.

SVN: 9430
parent 967e4f20
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.PagingToolBarWithoutRefresh;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GxtTranslator;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.URLMethodWithParameters;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.IColumnDefinition;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleCriteria;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet;
......@@ -413,24 +414,12 @@ public final class SampleBrowserGrid extends LayoutContainer
@Override
protected void process(String exportDataKey)
{
String url = createExportWindowURL(exportDataKey);
openURL(url);
URLMethodWithParameters methodWithParameters =
new URLMethodWithParameters(GenericConstants.FILE_EXPORTER_DOWNLOAD_SERVLET_NAME);
methodWithParameters.addParameter(GenericConstants.EXPORT_CRITERIA_KEY_PARAMETER,
exportDataKey);
Window.open(methodWithParameters.toString(), "", null);
}
private void openURL(String url)
{
Window.open(url, "", null);
}
}
private static String createExportWindowURL(String exportDataKey)
{
final StringBuffer sb = new StringBuffer();
sb.append(GenericConstants.FILE_EXPORTER_DOWNLOAD_SERVLET_NAME);
sb.append("?");
sb.append(GenericConstants.EXPORT_CRITERIA_KEY_PARAMETER).append("=");
sb.append(exportDataKey);
return sb.toString();
}
protected boolean isExportEnabled()
......
/*
* Copyright 2008 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.client.web.client.application.util;
/**
*
*
* @author Franz-Josef Elmer
*/
public class URLMethodWithParameters
{
private final StringBuilder builder;
private char delim = '?';
public URLMethodWithParameters(String methodName)
{
builder = new StringBuilder(methodName);
}
public void addParameter(String parameterName, Object value)
{
builder.append(delim).append(parameterName).append('=');
if (value != null)
{
builder.append(value);
}
delim = '&';
}
@Override
public String toString()
{
return builder.toString();
}
}
......@@ -49,8 +49,12 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.Atta
import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.ColumnConfigFactory;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.URLMethodWithParameters;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Attachment;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DatabaseInstance;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Experiment;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Group;
import ch.systemsx.cisd.openbis.generic.client.web.client.dto.Project;
/**
* {@link SectionPanel} containing experiment attachments.
......@@ -116,7 +120,7 @@ public class ExperimentAttachmentsSection extends SectionPanel
if (ModelDataPropertyNames.FILE_NAME.equals(column))
{
Window.open(createURL(version, fileName, experiment), "Download file", "");
downloadAttachment(fileName, version);
} else if (ModelDataPropertyNames.VERSIONS.equals(column))
{
List<Attachment> versions = cast(selectedItem);
......@@ -185,7 +189,7 @@ public class ExperimentAttachmentsSection extends SectionPanel
Attachment selectedAttachment =
(Attachment) selectedItem.get(ModelDataPropertyNames.OBJECT);
int version = selectedAttachment.getVersion();
Window.open(createURL(version, fileName, experiment), "Download file", "");
downloadAttachment(fileName, version);
}
attachmentGrid.getSelectionModel().deselectAll();
}
......@@ -196,40 +200,26 @@ public class ExperimentAttachmentsSection extends SectionPanel
return panel;
}
final static String createURL(final int version, final String fileName, final Experiment exp)
private void downloadAttachment(String fileName, int version)
{
final StringBuffer buffer = new StringBuffer();
final String projectCode = exp.getProject().getCode();
final String groupCode = exp.getProject().getGroup().getCode();
final String experimentCode = exp.getCode();
final String instanceCode = exp.getProject().getGroup().getInstance().getCode();
buffer.append(GenericConstants.EXPERIMENT_ATTACHMENT_DOWNLOAD_SERVLET_NAME)
.append("?")
.append(GenericConstants.VERSION_PARAMETER).append("=").append(version)
.append("&")
.append(GenericConstants.FILE_NAME_PARAMETER).append("=").append(fileName)
.append("&")
.append(GenericConstants.PROJECT_PARAMETER).append("=").append(projectCode)
.append("&")
.append(GenericConstants.GROUP_PARAMETER).append("=").append(groupCode)
.append("&")
.append(GenericConstants.EXPERIMENT_PARAMETER).append("=").append(experimentCode)
.append("&")
.append(GenericConstants.DATABASE_PARAMETER).append("=").append(instanceCode);
return buffer.toString();
Window.open(createURL(version, fileName, experiment), "", null);
}
private final static String createURL(final int version, final String fileName, final Experiment exp)
{
Project project = exp.getProject();
Group group = project.getGroup();
DatabaseInstance instance = group.getInstance();
URLMethodWithParameters methodWithParameters =
new URLMethodWithParameters(
GenericConstants.EXPERIMENT_ATTACHMENT_DOWNLOAD_SERVLET_NAME);
methodWithParameters.addParameter(GenericConstants.VERSION_PARAMETER, version);
methodWithParameters.addParameter(GenericConstants.FILE_NAME_PARAMETER, fileName);
methodWithParameters.addParameter(GenericConstants.PROJECT_PARAMETER, project.getCode());
methodWithParameters.addParameter(GenericConstants.GROUP_PARAMETER, group.getCode());
methodWithParameters.addParameter(GenericConstants.EXPERIMENT_PARAMETER, exp.getCode());
methodWithParameters.addParameter(GenericConstants.DATABASE_PARAMETER, instance.getCode());
return methodWithParameters.toString();
}
private List<ColumnConfig> defineAttachmentColumns()
......
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