1717
1818import org .apache .commons .lang3 .StringUtils ;
1919import org .jetbrains .annotations .NotNull ;
20+ import org .jetbrains .annotations .Nullable ;
2021import org .labkey .api .analytics .AnalyticsService ;
2122import org .labkey .api .data .ColumnInfo ;
2223import org .labkey .api .data .DataColumn ;
3334import org .labkey .api .util .Link ;
3435import org .labkey .api .util .PageFlowUtil ;
3536import org .labkey .api .view .ActionURL ;
37+ import org .labkey .api .writer .HtmlWriter ;
3638import org .labkey .lincs .psp .LincsPspJob ;
3739
38- import java .io .IOException ;
39- import java .io .Writer ;
4040import java .nio .file .Files ;
4141import java .nio .file .Path ;
4242import java .util .ArrayList ;
4545import java .util .regex .Matcher ;
4646import java .util .regex .Pattern ;
4747
48+ import static org .labkey .api .util .DOM .Attribute .style ;
49+ import static org .labkey .api .util .DOM .SPAN ;
50+ import static org .labkey .api .util .DOM .at ;
51+
4852/**
4953 * Created by vsharma on 8/21/2017.
5054 */
@@ -72,17 +76,21 @@ public LincsDataTable(@NotNull TableInfo table, @NotNull UserSchema userSchema)
7276 addColumn (level1Col );
7377 level1Col .setDisplayColumnFactory (colInfo -> new DataColumn (colInfo ){
7478 @ Override
75- public void renderGridCellContents (RenderContext ctx , Writer out ) throws IOException
79+ public void renderGridCellContents (RenderContext ctx , HtmlWriter out )
7680 {
7781 ActionURL downloadUrl = new ActionURL ("targetedms" , "DownloadDocument" , getContainer ());
7882 Integer runId = ctx .get (FieldKey .fromParts ("Id" ), Integer .class );
7983 downloadUrl .addParameter ("id" , runId );
80- out .write ("<nobr>" );
81- out .write (new Link .LinkBuilder ("Download" ).iconCls ("fa fa-download" ).href (downloadUrl ).toString ());
8284 ActionURL docDetailsUrl = new ActionURL ("targetedms" , "ShowPrecursorList" , getContainer ());
8385 docDetailsUrl .addParameter ("id" , runId );
84- out .write (" " + new Link .LinkBuilder ("Skyline" ).href (docDetailsUrl ).clearClasses ().toString ());
85- out .write ("</nobr>" );
86+
87+ // <span style="white-space: nowrap;"> is recommended instead of deprecated <nobr></nobr>
88+ SPAN (
89+ at (style , "white-space: nowrap;" ),
90+ new Link .LinkBuilder ("Download" ).iconCls ("fa fa-download" ).href (downloadUrl ),
91+ HtmlString .NBSP ,
92+ new Link .LinkBuilder ("Skyline" ).href (docDetailsUrl ).clearClasses ()
93+ ).appendTo (out );
8694 }
8795
8896 @ Override
@@ -133,7 +141,7 @@ public boolean isFilterable()
133141 pspJobCol .setDisplayColumnFactory (colInfo -> new DataColumn (colInfo )
134142 {
135143 @ Override
136- public void renderGridCellContents (RenderContext ctx , Writer out ) throws IOException
144+ public void renderGridCellContents (RenderContext ctx , HtmlWriter out )
137145 {
138146 Integer runId = ctx .get (FieldKey .fromParts ("Id" ), Integer .class );
139147 if (runId == null )
@@ -150,7 +158,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
150158 ActionURL url = new ActionURL (LincsController .SubmitPspJobAction .class , getContainer ());
151159 url .addParameter ("runId" , runId );
152160
153- out .write (new Link .LinkBuilder (" [Submit Job]" ).href (url ).usePost (). toString () );
161+ out .write (new Link .LinkBuilder (" [Submit Job]" ).href (url ).usePost ());
154162 }
155163 return ;
156164 }
@@ -168,7 +176,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
168176 }
169177 ActionURL url = new ActionURL (LincsController .LincsPspJobDetailsAction .class , getContainer ());
170178 url .addParameter ("runId" , pspJob .getRunId ());
171- out .write (PageFlowUtil .link (text ).href (url ). toString () );
179+ out .write (PageFlowUtil .link (text ).href (url ));
172180 }
173181
174182 @ Override
@@ -290,7 +298,7 @@ private String getAnalyticsScript(String eventAction, String fileName, boolean a
290298 return null ;
291299 }
292300
293- private String externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType )
301+ private HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType )
294302 {
295303 String gctFileUrl = davUrl + "GCT/" + PageFlowUtil .encodePath (fileName );
296304 String morpheusUrl = getMorpheusUrl (gctFileUrl , assayType );
@@ -299,7 +307,9 @@ private String externalHeatmapViewerLink(String fileName, LincsModule.LincsAssay
299307 String onclickEvt = StringUtils .isBlank (analyticsScript ) ? "" : "onclick=\" " + analyticsScript + "\" " ;
300308
301309 String imgUrl = AppProps .getInstance ().getContextPath () + "/lincs/GENE-E_icon.png" ;
302- return "[ <a target=\" _blank\" " + onclickEvt + " href=\" " + morpheusUrl + "\" >View in Morpheus</a> <img src=" + imgUrl + " width=\" 13\" , height=\" 13\" /> ]" ;
310+
311+ // TODO: Should use a LinkBuilder, etc.
312+ return HtmlString .unsafe ("[ <a target=\" _blank\" " + onclickEvt + " href=\" " + morpheusUrl + "\" >View in Morpheus</a> <img src=" + imgUrl + " width=\" 13\" , height=\" 13\" /> ]" );
303313 }
304314
305315 private String getMorpheusUrl (String gctFileUrl , LincsModule .LincsAssay assayType )
@@ -323,7 +333,7 @@ private String getMorpheusUrl(String gctFileUrl, LincsModule.LincsAssay assayTyp
323333 }
324334
325335 @ Override
326- public void renderGridCellContents (RenderContext ctx , Writer out ) throws IOException
336+ public void renderGridCellContents (RenderContext ctx , HtmlWriter out )
327337 {
328338 if (getAssayType () == null )
329339 {
@@ -333,7 +343,7 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
333343 String fileName = ctx .get (getDisplayColumn ().getFieldKey (), String .class );
334344 if (fileName == null )
335345 {
336- out .write (" " );
346+ out .write (HtmlString . NBSP );
337347 return ;
338348 }
339349
@@ -355,23 +365,25 @@ public void renderGridCellContents(RenderContext ctx, Writer out) throws IOExcep
355365
356366 String actionName = (getLevel () == LincsModule .LincsLevel .Config ) ? "DownloadConfig" : "DownloadGCT" ;
357367 String analyticsScript = getAnalyticsScript (actionName , downloadFileName , true );
358- String morpheusUrl = externalHeatmapViewerLink (downloadFileName , getAssayType (), getLevel ());
368+ HtmlString morpheusUrl = externalHeatmapViewerLink (downloadFileName , getAssayType (), getLevel ());
359369 String downloadText = (getLevel () == LincsModule .LincsLevel .Config ) ? "CFG" : "GCT" ;
360- renderGridCell (out , analyticsScript , getGctDavUrlUnencoded (downloadFileName ), getGctDavUrl ( downloadFileName ), downloadText , morpheusUrl );
370+ renderGridCell (out , analyticsScript , getGctDavUrlUnencoded (downloadFileName ), downloadText , morpheusUrl );
361371 }
362372
363- private void renderGridCell (Writer out , String analyticsScript , String downloadUrl , String downloadUrlEncoded , String downloadText , String morpheusUrl ) throws IOException
373+ private void renderGridCell (HtmlWriter out , String analyticsScript , String downloadUrl , String downloadText , HtmlString morpheusUrl )
364374 {
365- out .write ("<nobr> " );
366- out .write (new Link .LinkBuilder ("Download" ).iconCls ("fa fa-download" ).href (downloadUrl ).onClick (analyticsScript ).toString ());
367- out .write (" " );
368- out .write (new Link .LinkBuilder (downloadText ).href (downloadUrl ).onClick (analyticsScript ).clearClasses ().toString ());
369- out .write (" " );
370- if (morpheusUrl != null )
371- {
372- out .write (" " + morpheusUrl + " " );
373- }
374- out .write ("</nobr>" );
375+ // <span style="white-space: nowrap;"> is recommended instead of deprecated <nobr></nobr>
376+ SPAN (
377+ at (style , "white-space: nowrap;" ),
378+ HtmlString .NBSP ,
379+ new Link .LinkBuilder ("Download" ).iconCls ("fa fa-download" ).href (downloadUrl ).onClick (analyticsScript ),
380+ HtmlString .NBSP ,
381+ new Link .LinkBuilder (downloadText ).href (downloadUrl ).onClick (analyticsScript ).clearClasses (),
382+ HtmlString .NBSP ,
383+ morpheusUrl != null ? HtmlString .NBSP : null ,
384+ morpheusUrl ,
385+ morpheusUrl != null ? HtmlString .NBSP : null
386+ ).appendTo (out );
375387 }
376388
377389 private boolean fileAvailable (Integer runId , String downloadFileName )
@@ -396,7 +408,7 @@ private boolean fileAvailable(Integer runId, String downloadFileName)
396408 }
397409 }
398410
399- String externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType , LincsModule .LincsLevel level )
411+ @ Nullable HtmlString externalHeatmapViewerLink (String fileName , LincsModule .LincsAssay assayType , LincsModule .LincsLevel level )
400412 {
401413 if (level == LincsModule .LincsLevel .Config )
402414 {
0 commit comments