Changeset 7759


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

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

Added support for changing the HTML tag used by the CompactButtonRenderer. The default value is <a>.

The file action extension point now uses <span> instead.

Added some styling and changed the Base.getFileLinks() method to use the same HTML structure.

Location:
trunk
Files:
6 edited

Legend:

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

    r7738 r7759  
    17301730    if (l == Location.OFFLINE)
    17311731    {
    1732       link += " [offline]";
     1732      if (root == null)
     1733      {
     1734        link += " [offline]";
     1735      }
     1736      else
     1737      {
     1738        link += " <span class=\"file-actions\">[<span title=\"This file is offline\">" +
     1739            "<img src=\"" + root + "images/offline.png\" alt=\"offline\"></span>";
     1740      }
    17331741    }
    17341742    else if (l.isDownloadable())
     
    17401748      if (root != null)
    17411749      {
    1742         viewIcon = "<img src=\"" + root + "images/view.png" + "\" alt=\"view\">";
    1743         downloadIcon = "<img src=\"" + root + "images/download.png" + "\" alt=\"download\">";
    1744         separator = "&nbsp;";
    1745       }
    1746       link += "&nbsp;<span style=\"white-space: nowrap;\">[<span class=\"link auto-init\" data-auto-init=\"view-file\" data-file-id=\"" + file.getId() + "\"" +
     1750        viewIcon = "<img src=\"" + root + "images/view.png\" alt=\"view\">";
     1751        downloadIcon = "<img src=\"" + root + "images/download.png\" alt=\"download\">";
     1752        separator = "";
     1753      }
     1754      link += " <span class=\"file-actions\">[<span class=\"link auto-init\" data-auto-init=\"view-file\" data-file-id=\"" + file.getId() + "\"" +
    17471755        " title=\"View the contents of this file (" + bytes + ")\">" + viewIcon + "</span>" +
    17481756        separator +
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/fileviewer/FileViewerUtil.java

    r7757 r7759  
    6868    if (result != null && result.length() > 0)
    6969    {
    70       jspContext.getOut().write("[" + result + "]");
     70      jspContext.getOut().write("<span class=\"file-actions\">[" + result + "]</span>");
    7171    }
    7272  }
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/CompactButtonRenderer.java

    r6881 r7759  
    4343
    4444  private JspContext context;
     45  private String buttonTag = "a";
    4546 
    4647  public CompactButtonRenderer(JspContext context)
    4748  {
    4849    this.context = context;
     50  }
     51 
     52  /**
     53    Set the HTML tag to use for the "button". The default is 'a'.
     54    @since 3.16
     55  */
     56  public void setButtonTag(String tag)
     57  {
     58    this.buttonTag = tag;
     59  }
     60 
     61  /**
     62    Get the HTML tag to use for the "button". The default is 'a'.
     63    @since 3.16
     64  */
     65  public String getButtonTag()
     66  {
     67    return buttonTag;
    4968  }
    5069 
     
    7089    try
    7190    {
    72       out.write("<a");
     91      String tag = getButtonTag();
     92     
     93      out.write("<"+tag);
    7394      if (btn.getId() != null) out.write(" id=\"" + btn.getId() + "\"");
    7495      if (btn.getClazz() != null) out.write(" class=\"" + btn.getClazz() + "\"");
     
    93114      out.write(" alt=\"" + HTML.encodeTags(btn.getTitle()) + "\"");
    94115      if (btn.getIcon() != null) out.write(" src=\"" + btn.getIcon() + "\"");
    95       out.write("></a>");
     116      out.write("></" + tag + ">");
    96117    }
    97118    catch (IOException ex)
  • trunk/src/clients/web/net/sf/basedb/clients/web/extensions/toolbar/CompactButtonRendererFactory.java

    r6875 r7759  
    3838{
    3939
     40  private String buttonTag;
     41 
    4042  public CompactButtonRendererFactory()
    4143  {}
     
    4446  public CompactButtonRenderer getRenderer(InvokationContext<? extends ButtonAction> context)
    4547  {
    46     return new CompactButtonRenderer((JspContext)context.getClientContext());
     48    CompactButtonRenderer renderer = new CompactButtonRenderer((JspContext)context.getClientContext());
     49    renderer.setButtonTag(getButtonTag());
     50    return renderer;
    4751  }
    4852
     53  /**
     54    Set the HTML tag to use for the "button". The default is 'a'.
     55    @since 3.16
     56  */
     57  public void setButtonTag(String tag)
     58  {
     59    this.buttonTag = tag;
     60  }
     61 
     62  /**
     63    Get the HTML tag to use for the "button". The default is 'a'.
     64    @since 3.16
     65  */
     66  public String getButtonTag()
     67  {
     68    return buttonTag;
     69  }
     70 
    4971}
  • trunk/src/clients/web/web-extensions.xml

    r7757 r7759  
    156156    <renderer-factory override="true">
    157157      <factory-class>net.sf.basedb.clients.web.extensions.toolbar.CompactButtonRendererFactory</factory-class>
     158      <parameters>
     159        <button-tag>span</button-tag>
     160      </parameters>
    158161    </renderer-factory>
    159162    <name>File viewer</name>
  • trunk/www/include/styles/main.css

    r7604 r7759  
    707707{
    708708  border: 0px;
     709}
     710
     711.file-actions
     712{
     713  white-space: nowrap;
     714}
     715
     716.file-actions > span + span
     717{
     718  padding-left: 2px;
    709719}
    710720
Note: See TracChangeset for help on using the changeset viewer.