Changeset 7757


Ignore:
Timestamp:
Nov 27, 2019, 9:34:49 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

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

Started to re-implement the "View" and "Download" actions as extensions.

Location:
trunk
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/clients/web/web-extensions.xml

    r7756 r7757  
    274274  </extension>
    275275 
    276  
     276  <extension
     277    id="view-and-download-file"
     278    extends="net.sf.basedb.clients.web.file-viewer"
     279    >
     280    <index>1</index>
     281    <about>
     282      <name>View and download files</name>
     283      <description>
     284        Add view and download icons to all files.
     285      </description>     
     286    </about>
     287    <action-factory>
     288      <factory-class>
     289        net.sf.basedb.clients.web.extensions.fileviewer.ViewAndDownloadActionFactory
     290      </factory-class>
     291    </action-factory>
     292  </extension>
    277293 
    278294</extensions>
  • trunk/www/common/datafiles/list_files.jsp

    r6143 r7757  
    2727  import="net.sf.basedb.core.DbControl"
    2828  import="net.sf.basedb.core.Item"
     29  import="net.sf.basedb.core.BasicItem"
    2930  import="net.sf.basedb.core.ItemContext"
     31  import="net.sf.basedb.core.plugin.GuiContext"
    3032  import="net.sf.basedb.core.Permission"
    3133  import="net.sf.basedb.core.Platform"
     
    5052  import="net.sf.basedb.core.query.Hql"
    5153  import="net.sf.basedb.util.NameableComparator"
     54  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    5255  import="net.sf.basedb.clients.web.Base"
    5356  import="net.sf.basedb.clients.web.util.HTML"
    5457  import="net.sf.basedb.util.formatter.Formatter"
    5558  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
     59  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
     60  import="net.sf.basedb.clients.web.extensions.JspContext"
     61  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerContext"
     62  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerUtil"
    5663  import="net.sf.basedb.util.Values"
    5764  import="java.util.Map"
     
    6572<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
    6673<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
     74<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
    6775<%!
    6876
     
    214222    }
    215223  }
     224 
     225  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, new GuiContext(itemType, GuiContext.Type.ITEM), null);
     226  FileViewerContext fileContext = FileViewerContext.dataFile((BasicItem)item);
     227  FileViewerUtil fileViewer = new FileViewerUtil(jspContext, fileContext);
    216228  %>
    217229  <base:page type="include">
    218230  <base:body>
     231  <ext:scripts context="<%=jspContext%>" />
    219232    <base:section
    220233      id="datafiles"
     
    353366                    visible="<%=file != null && file.isRemoved()%>"
    354367                  />
    355                   <%=Base.getLinkedFile(ID, file, !readFile, true, true, root)%>
     368                  <%=Base.getLinkedName(ID, file, !readFile, true)%>
    356369                  <%
     370                  if (file != null)
     371                  {
     372                    fileContext.setCurrentDataFile(file, dft, member);
     373                    fileViewer.render();
     374                  }
    357375                  if (parent != null)
    358376                  {
Note: See TracChangeset for help on using the changeset viewer.