Changeset 7761


Ignore:
Timestamp:
Nov 27, 2019, 3:23:27 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2199: Implement a "File viewer" extension point

Implemented in the any-to-any lists.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/net/sf/basedb/clients/web/Base.java

    r7759 r7761  
    17371737      {
    17381738        link += " <span class=\"file-actions\">[<span title=\"This file is offline\">" +
    1739             "<img src=\"" + root + "images/offline.png\" alt=\"offline\"></span>";
     1739            "<img src=\"" + root + "images/offline.png\" alt=\"offline\">]</span>";
    17401740      }
    17411741    }
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/fileviewer/FileViewerUtil.java

    r7760 r7761  
    6262 
    6363  /**
    64     Rended the extensions with the current file context information.
     64    Render the extensions with the current file context information
     65    and write it to the JSP output.
    6566  */
    6667  public void render()
    6768    throws IOException
     69  {
     70    String result = renderAsString();
     71    if (result.length() > 0)
     72    {
     73      jspContext.getOut().write(result);
     74    }
     75  }
     76 
     77  /**
     78    Render the extensions with the current file context information
     79    and return it as a string. Returns an empty string if there are no
     80    actions.
     81  */
     82  public String renderAsString()
    6883  {
    6984    // Need to repeat this since to make sure the correct context is always used
     
    7590    fileActions.renderDefault();
    7691    jspContext.getPageContext().popBody();
    77     String result = actions.toString();
    7892   
    79     // Now, write the final output to the JSP
    80     if (result != null && result.length() > 0)
     93    String result = "";
     94    if (actions.getBuffer().length() > 0)
    8195    {
    82       jspContext.getOut().write("<span class=\"file-actions\">" + prefix + result + suffix + "</span>");
     96      result = "<span class=\"file-actions\">" + prefix + actions.toString() + suffix + "</span>";
    8397    }
     98    return result;
    8499  }
    85100 
  • trunk/www/common/anytoany/list_anytoany.jsp

    r7604 r7761  
    5353  import="net.sf.basedb.clients.web.extensions.list.ListColumnAction"
    5454  import="net.sf.basedb.clients.web.extensions.list.ListColumnUtil"
     55  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerContext"
     56  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerUtil"
    5557  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
    5658  import="java.util.List"
     
    8486  ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext);
    8587  ExtensionsInvoker<ListColumnAction<AnyToAny,?>> columnsInvoker = ListColumnUtil.useExtensions(jspContext);
     88  FileViewerContext fileContext = FileViewerContext.anyToAny(item);
     89  FileViewerUtil fileViewer = new FileViewerUtil(jspContext, fileContext);
    8690  %>
    8791  <base:page type="include">
    8892  <base:head scripts="/common/anytoany/list.js" />
    8993  <base:body>
     94    <ext:scripts context="<%=jspContext%>" />
    9095    <base:section
    9196      id="anytoany"
     
    179184             
    180185              String toLink = "";
    181               if (to instanceof File)
    182               {
    183                 File toFile = (File)to;
    184                 toLink = Base.getLinkedFile(ID, toFile, false, true, true, root);
    185               }
    186               else if (to instanceof Nameable)
     186              if (to instanceof Nameable)
    187187              {
    188188                Nameable nameable = (Nameable)to;
     
    204204              {
    205205                toLink = Base.getLink(ID, to.toString(), to.getType(), to.getId(), true);
     206              }
     207              if (to instanceof File)
     208              {
     209                File toFile = (File)to;
     210                fileContext.setCurrentAnyToAny(toFile, ata);
     211                toLink += " " + fileViewer.renderAsString();
    206212              }
    207213              if (to instanceof Subtypable)
Note: See TracChangeset for help on using the changeset viewer.