Changeset 7857


Ignore:
Timestamp:
Oct 20, 2020, 8:20:12 AM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2224: Files should be annotatable

Added support for annotations to file list, view and edit pages.

Location:
trunk/www/filemanager/files
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/filemanager/files/edit_file.jsp

    r7605 r7857  
    133133  %>
    134134  <base:page type="popup" title="<%=title%>" id="edit-page">
    135   <base:head scripts="tabcontrol-2.js,~files.js" styles="tabcontrol.css">
     135  <base:head scripts="tabcontrol-2.js,subtypes.js,~files.js" styles="tabcontrol.css">
    136136    <ext:scripts context="<%=jspContext%>" />
    137137    <ext:stylesheets context="<%=jspContext%>" />
     
    300300      </table>
    301301    </t:tab>
     302    <t:tab id="annotations" title="Annotations" helpid="annotations.edit">
     303      <jsp:include page="../../common/annotations/annotate_frameset.jsp">
     304        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     305        <jsp:param name="item_id" value="<%=itemId%>" />
     306        <jsp:param name="ID" value="<%=ID%>" />
     307      </jsp:include>
     308    </t:tab>
    302309    </t:tabcontrol>
    303310    </form>
  • trunk/www/filemanager/files/files.js

    r7703 r7857  
    4343      // Tab validation
    4444      TabControl.addTabValidator('settings.info', fileManager.validateFile);
     45      TabControl.addTabActivateListener('settings.annotations', fileManager.loadAnnotationsFrame);
    4546
    4647      // MIME type
     
    7980      Buttons.addClickHandler('moveOffline', fileManager.moveToLocation);
    8081     
     82      TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce);
    8183      TabControl.addTabActivateListener('main.history', History.loadOnce);
    8284    }
     
    387389    if (TabControl.validateActiveTab('settings'))
    388390    {
     391      Annotations.saveModifiedAnnotationsToForm(frm);
    389392      frm.submit();
    390393    }
     
    428431    }
    429432  }
     433 
     434  fileManager.loadAnnotationsFrame = function()
     435  {
     436    Annotations.autoLoadEditFrame(null, ItemSubtype.getSubtypeId('subtype_id'), null);
     437  }
     438
    430439
    431440  return fileManager;
  • trunk/www/filemanager/files/index.jsp

    r7703 r7857  
    236236      }
    237237     
     238      // Annotations tab
     239      Base.updateAnnotations(dc, file, file, request);
     240     
    238241      // OnSave extensions
    239242      invoker.render(OnSaveRenderer.ON_SAVE);
  • trunk/www/filemanager/files/list_files.jsp

    r7855 r7857  
    3535  import="net.sf.basedb.core.Directory"
    3636  import="net.sf.basedb.core.ItemSubtype"
     37  import="net.sf.basedb.core.AnnotationType"
    3738  import="net.sf.basedb.core.ItemQuery"
    3839  import="net.sf.basedb.core.ItemResultIterator"
     
    5455  import="net.sf.basedb.core.plugin.GuiContext"
    5556  import="net.sf.basedb.core.plugin.Plugin"
     57  import="net.sf.basedb.core.snapshot.AnnotationLoaderUtil"
     58  import="net.sf.basedb.core.snapshot.AnnotationTypeFilter"
     59  import="net.sf.basedb.core.snapshot.AnnotationSnapshot"
     60  import="net.sf.basedb.core.snapshot.AnnotationSetSnapshot"
     61  import="net.sf.basedb.core.snapshot.SnapshotManager"
    5662  import="net.sf.basedb.util.Enumeration"
    5763  import="net.sf.basedb.util.ShareableUtil"
     
    7480  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerUtil"
    7581  import="net.sf.basedb.clients.web.extensions.fileviewer.FileViewerContext"
     82  import="net.sf.basedb.clients.web.util.ProjectSpecificInfoFilter"
    7683  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
    7784  import="java.util.Iterator"
     
    104111ItemResultIterator<File> files = null;
    105112ItemResultIterator<Directory> directories = null;
     113List<AnnotationLoaderUtil> annotationLoaders = new ArrayList<AnnotationLoaderUtil>();
    106114try
    107115{
     
    113121  Unit bytes = UnitUtil.getUnit(dc, Quantity.STORAGE_SIZE, "B");
    114122  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
     123
     124  ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType);
     125  SnapshotManager manager = new SnapshotManager();
     126  ProjectSpecificInfoFilter psInfo = new ProjectSpecificInfoFilter();
     127  for (AnnotationType at : annotationTypeQuery.list(dc))
     128  {
     129    annotationLoaders.add(new AnnotationLoaderUtil(dc, manager, at));
     130  }
    115131
    116132  // Get all file types
     
    512528        datatype="string"
    513529      />
     530      <%
     531      for (AnnotationLoaderUtil loader : annotationLoaders)
     532      {
     533        AnnotationType at = loader.getAnnotationType();
     534        Formatter<Object> formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType());
     535        Enumeration<String, String> annotationEnum = null;
     536        if (at.isEnumeration())
     537        {
     538          annotationEnum = new Enumeration<String, String>();
     539          if (!at.getDisplayAsList()) annotationEnum.add("", "-none-");
     540          List<?> values = at.getValues();
     541          for (Object value : values)
     542          {
     543            String encoded = HTML.encodeTags(value.toString());
     544            annotationEnum.add(encoded, encoded);
     545          }
     546        }
     547        %>
     548        <tbl:columndef
     549          id="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+at.getId()%>"
     550          title="<%=HTML.encodeTags(at.getName())+(loader.isSearchingInheritedAnnotations() ? " [I]" : " [A]")%>"
     551          property="<%=(loader.isSearchingInheritedAnnotations() ? "##" : "#")+at.getId()%>"
     552          annotation="true"
     553          datatype="<%=at.getValueType().getStringValue()%>"
     554          enumeration="<%=annotationEnum%>"
     555          smartenum="<%=at.getDisplayAsList() %>"
     556          sortable="<%=at.getMultiplicity() == 1 && !loader.isSearchingInheritedAnnotations()%>"
     557          filterable="true"
     558          exportable="true"
     559          formatter="<%=formatter%>"
     560          unit="<%=at.getDefaultUnit()%>"
     561        />
     562        <%
     563      }
     564      %>
    514565      <tbl:columndef
    515566        id="xt-columns"
     
    10021053                  %>
    10031054                </tbl:cell>
     1055                <%
     1056                if (item.isAnnotated())
     1057                {
     1058                  AnnotationSetSnapshot snapshot = manager.getSnapshot(dc, item.getAnnotationSet().getId());
     1059                  for (AnnotationLoaderUtil loader : annotationLoaders)
     1060                  {
     1061                    %>
     1062                    <tbl:cell
     1063                      column="<%=(loader.isSearchingInheritedAnnotations() ? "ia" : "at")+loader.getId()%>"
     1064                      ><%
     1065                      if (loader.find(snapshot, psInfo.reset()))
     1066                      {
     1067                        %><tbl:cellvalue
     1068                          list="<%=loader.getValues()%>"
     1069                          suffix="<%=loader.getUnitSymbol()%>"
     1070                          clazz="<%=psInfo.overridesDefaultAnnotation() ? "ps-annotation" : null%>"
     1071                        /><%
     1072                      }
     1073                      %></tbl:cell>
     1074                    <%
     1075                  }
     1076                }
     1077                %>
    10041078                <tbl:xt-cells dc="<%=dc%>" item="<%=item%>">
    10051079                  <tbl:cell column="xt-columns" />
  • trunk/www/filemanager/files/view_file.jsp

    r7855 r7857  
    350350      </jsp:include>
    351351    </t:tab>
     352    <t:tab id="annotations" title="Annotations"
     353      tooltip="View annotation values" clazz="white">
     354      <jsp:include page="../../common/annotations/list_frameset.jsp">
     355        <jsp:param name="item_type" value="<%=itemType.name()%>" />
     356        <jsp:param name="item_id" value="<%=itemId%>" />
     357        <jsp:param name="ID" value="<%=ID%>" />
     358      </jsp:include>
     359    </t:tab>
     360   
    352361    <t:tab id="history" title="History"
    353362      tooltip="Displays a log with the history of this item"
Note: See TracChangeset for help on using the changeset viewer.