-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVariantReleaseDisplayColumnFactory.java
More file actions
112 lines (96 loc) · 4.01 KB
/
VariantReleaseDisplayColumnFactory.java
File metadata and controls
112 lines (96 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package org.labkey.mgap.query;
import org.jetbrains.annotations.NotNull;
import org.labkey.api.data.ColumnInfo;
import org.labkey.api.data.ContainerManager;
import org.labkey.api.data.DataColumn;
import org.labkey.api.data.DisplayColumn;
import org.labkey.api.data.DisplayColumnFactory;
import org.labkey.api.data.RenderContext;
import org.labkey.api.query.DetailsURL;
import org.labkey.api.query.FieldKey;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.view.HttpView;
import org.labkey.api.view.template.ClientDependency;
import org.labkey.api.writer.HtmlWriter;
import java.util.Set;
/**
* Created by bimber on 5/17/2017.
*/
public class VariantReleaseDisplayColumnFactory implements DisplayColumnFactory
{
@Override
public DisplayColumn createRenderer(ColumnInfo colInfo)
{
return new DataColumn(colInfo)
{
@Override
public void addQueryFieldKeys(Set<FieldKey> keys)
{
super.addQueryFieldKeys(keys);
keys.add(getBoundKey("rowid"));
keys.add(getBoundKey("objectId"));
keys.add(getBoundKey("version"));
keys.add(getBoundKey("jbrowseId"));
keys.add(getBoundKey("container"));
keys.add(getBoundKey("hasSignificantVariants"));
}
private FieldKey getBoundKey(String colName)
{
return new FieldKey(getBoundColumn().getFieldKey().getParent(), colName);
}
private boolean _clickHandlerRegistered = false;
@Override
public void renderGridCellContents(RenderContext ctx, HtmlWriter out)
{
Integer rowId = ctx.get(getBoundKey("rowid"), Integer.class);
if (rowId != null)
{
out.write(PageFlowUtil.link("Download").
addClass("vrdc-row").
attributes(PageFlowUtil.map("data-rowid", rowId.toString()))
);
if (!_clickHandlerRegistered)
{
HttpView.currentPageConfig().addHandlerForQuerySelector("a.vrdc-row", "click", "mGAP.window.DownloadWindow.buttonHandler(this.attributes.getNamedItem('data-rowid').value); return false;");
_clickHandlerRegistered = true;
}
}
String jbrowseId = ctx.get(getBoundKey("jbrowseId"), String.class);
String containerId = ctx.get(getBoundKey("container"), String.class);
if (jbrowseId != null)
{
if (rowId != null)
{
out.write(HtmlString.BR);
}
DetailsURL url = DetailsURL.fromString("/jbrowse/browser.view?database=" + jbrowseId, ContainerManager.getForId(containerId));
out.write(PageFlowUtil.link("View In Genome Browser", url.getActionURL()));
}
Boolean showVariantList = ctx.get(getBoundKey("hasSignificantVariants"), Boolean.class);
if (showVariantList)
{
out.write(HtmlString.BR);
DetailsURL url = DetailsURL.fromString("/mgap/variantList.view?release=" + rowId, ContainerManager.getForId(containerId));
out.write(PageFlowUtil.link("Significant Variant List", url.getActionURL()));
}
}
@NotNull
@Override
public Set<ClientDependency> getClientDependencies()
{
return PageFlowUtil.set(ClientDependency.fromPath("Ext4"), ClientDependency.fromPath("mgap/DownloadWindow.js"));
}
@Override
public boolean isFilterable()
{
return false;
}
@Override
public boolean isSortable()
{
return false;
}
};
}
}