Changeset 6945


Ignore:
Timestamp:
Sep 4, 2015, 11:19:58 AM (6 years ago)
Author:
Nicklas Nordborg
Message:

References #1941: Store experimental factor values as part experiments

Implemented support for syncing/cloning/deleting annotations in batch by selecting multiple annotations in one go.

New icons for inherited annotations depending on inherited/cloned/sync status.

Location:
trunk
Files:
4 added
4 edited

Legend:

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

    r6943 r6945  
    14551455          a = Annotation.getById(dc, annotationId.intValue());
    14561456         
    1457           if (a.getSource() != source)
     1457          if ("DELETE".equals(modifyType))
    14581458          {
    1459             // Convert between inherited<->cloned
    1460             a = a.getAnnotationSet().inheritAnnotation(a.getInheritedFrom(), source == Annotation.Source.CLONED);
    1461             if ("CONVERTED".equals(modifyType)) continue; // Only converted between types
     1459            if (source == Annotation.Source.PRIMARY)
     1460            {
     1461              newAs.removeAnnotation(at);
     1462            }
     1463            else
     1464            {
     1465              newAs.removeInheritedAnnotation(a);
     1466            }
     1467            continue;
    14621468          }
    1463           else if (source == Annotation.Source.CLONED && "SYNCED".equals(modifyType))
     1469          else if ("SYNCED".equals(modifyType) && source == Annotation.Source.CLONED)
    14641470          {
    14651471            // Sync a cloned annotation
    14661472            a.resyncCloned();
    14671473            continue;
     1474          }
     1475          else if (a.getSource() != source)
     1476          {
     1477            // Convert between inherited<->cloned
     1478            a = newAs.inheritAnnotation(a.getInheritedFrom(), source == Annotation.Source.CLONED);
     1479            if ("CONVERTED".equals(modifyType)) continue; // Only converted between types
    14681480          }
    14691481         
  • trunk/www/common/annotations/annotate.js

    r6943 r6945  
    3030  var SYNCED = 'SYNCED';
    3131  var CONVERTED = 'CONVERTED';
     32  var DELETE = 'DELETE';
    3233 
    3334  var annotations;
     
    9899   
    99100    // Sync modified clone
    100     Events.addEventHandler('sync-modified', 'click', annotate.syncClone);
     101    Events.addEventHandler('sync-modified', 'click', annotate.syncSelectedClone);
     102    Buttons.addClickHandler('btnSync', annotate.syncAllCheckedClones);
     103   
    101104    // Convert inherited annotation to cloned
    102     Events.addEventHandler('convert-to-cloned', 'click', annotate.convertToCloned);
    103     Events.addEventHandler('convert-to-inherited', 'click', annotate.convertToInherited);
     105    Events.addEventHandler('convert-to-cloned', 'click', annotate.convertSelectedToCloned);
     106    Buttons.addClickHandler('btnClone', annotate.convertAllCheckedToCloned);
     107   
     108    Buttons.addClickHandler('btnDeclone', annotate.convertAllCheckedToInherited);
     109   
     110    // Delete an inherited/cloned annotation
     111    Buttons.addClickHandler('btnDelete', annotate.deleteAllChecked);
    104112   
    105113    // Select the initial annotation
     
    142150   
    143151    var html = '';
    144     var icon = entry.source != 'PRIMARY' || ann.values.length > 0 ? 'notrequired_values.png' : 'notrequired_novalues.png';
    145    
     152    var icon = annotate.getIcon(entry);
     153   
     154    html += '<input type="checkbox" style="float: right;" id="check.'+entry.id+'">';
    146155    html += '<span class="icon">';
    147156    html += '<img id="icon.'+entry.id+'" src="../../images/'+icon+'">';
     
    674683
    675684  /**
     685    Call the given method for all annotations that
     686    have been checked. The method must take a single
     687    parameter which is the entry object with the
     688    annotation information.
     689    @return The return value of the method when called
     690      on the current selected annotation or null if the
     691      selected annotation is not checked
     692   */
     693  annotate.forAllChecked = function(method)
     694  {
     695    var returnValue = null;
     696    var numChecked = 0;
     697    for (var i = 0; i < annotations.length; i++)
     698    {
     699      var entry = annotations[i];
     700      if (Doc.element('check.'+entry.id).checked)
     701      {
     702        numChecked++;
     703        var rv = method.call(null, entry);
     704        if (entry == selectedAnnotation) returnValue = rv;
     705      }
     706    }
     707    if (numChecked == 0)
     708    {
     709      Forms.showNotification('annotation-list', 'Please select annotations first...', null, 'pointer-left');
     710    }
     711    return returnValue;
     712  }
     713 
     714  /**
     715    Synchronizes checked CLONED annotations.
     716  */
     717  annotate.syncAllCheckedClones = function()
     718  {
     719    if (annotate.forAllChecked(annotate.syncClone))
     720    {
     721      annotate.selectAnnotation(selectedAnnotation.id);
     722    }
     723  }
     724 
     725  /**
     726    Synchronizes the currently selected CLONED annotation
     727   */
     728  annotate.syncSelectedClone = function()
     729  {
     730    annotate.syncClone(selectedAnnotation);
     731    annotate.selectAnnotation(selectedAnnotation.id);
     732  }
     733 
     734  /**
    676735    Syncs a cloned value with the parent items value.
    677   */
    678   annotate.syncClone = function()
    679   {
    680     if (!selectedAnnotation || selectedAnnotation.source != 'CLONED') return;
    681    
    682     annotate.setMultipleValues(selectedAnnotation, selectedAnnotation.inherited.values);
    683     annotate.setUnit(selectedAnnotation, selectedAnnotation.inherited.unit);
    684     selectedAnnotation.annotation.lastUpdate = selectedAnnotation.inherited.lastUpdate;
    685     selectedAnnotation.modified = SYNCED;
    686    
     736    @returns TRUE if the entry was synced, FALSE if not.
     737  */
     738  annotate.syncClone = function(entry)
     739  {
     740    if (entry.source != 'CLONED') return false;
     741    if (!entry.inherited) return false;
     742   
     743    annotate.setMultipleValues(entry, entry.inherited.values);
     744    annotate.setUnit(entry, entry.inherited.unit);
     745    entry.annotation.lastUpdate = entry.inherited.lastUpdate;
     746    entry.modified = SYNCED;
     747    annotate.updateIcon(entry);
     748   
     749    return true;
     750  }
     751 
     752 
     753  /**
     754    Converts checked INHERITED annotations to CLONED annotations.
     755  */
     756  annotate.convertAllCheckedToCloned = function()
     757  {
     758    if (annotate.forAllChecked(annotate.convertToCloned))
     759    {
     760      annotate.selectAnnotation(selectedAnnotation.id);
     761    }
     762  }
     763
     764  /**
     765    Converts the selected annotation to a CLONED annotation.
     766  */
     767  annotate.convertSelectedToCloned = function()
     768  {
     769    annotate.convertToCloned(selectedAnnotation);
    687770    annotate.selectAnnotation(selectedAnnotation.id);
    688771  }
    689  
     772
    690773  /**
    691774    Converts an INHERITED annotation to a CLONED annotation.
    692775  */
    693   annotate.convertToCloned = function()
    694   {
    695     if (!selectedAnnotation || selectedAnnotation.source != 'INHERITED') return;
    696    
    697     var ann = selectedAnnotation.annotation;
    698     var inherited = selectedAnnotation.inherited;
    699    
    700     selectedAnnotation.source = 'CLONED';
    701     selectedAnnotation.modified = CONVERTED;
     776  annotate.convertToCloned = function(entry)
     777  {
     778    if (entry.source != 'INHERITED') return false;
     779   
     780    var ann = entry.annotation;
     781    var inherited = entry.inherited;
     782   
     783    entry.source = 'CLONED';
     784    entry.modified = CONVERTED;
    702785    ann.values = inherited.values;
    703786    ann.unit = inherited.unit;
    704     annotate.selectAnnotation(selectedAnnotation.id);
     787    annotate.updateIcon(entry);
     788
     789    return true;
     790  }
     791
     792  /**
     793    Converts checked CLONED annotations to INHERITED annotations.
     794  */
     795  annotate.convertAllCheckedToInherited = function()
     796  {
     797    if (annotate.forAllChecked(annotate.convertToInherited))
     798    {
     799      annotate.selectAnnotation(selectedAnnotation.id);
     800    }
    705801  }
    706802
     
    708804    Converts a CLONED annotation to an INHERITED annotation.
    709805  */
    710   annotate.convertToInherited = function()
    711   {
    712     if (!selectedAnnotation || selectedAnnotation.source != 'CLONED') return;
    713    
    714     var ann = selectedAnnotation.annotation;
    715     var inherited = selectedAnnotation.inherited;
    716    
    717     selectedAnnotation.source = 'INHERITED';
    718     selectedAnnotation.modified = CONVERTED;
     806  annotate.convertToInherited = function(entry)
     807  {
     808    if (entry.source != 'CLONED') return false;
     809   
     810    var ann = entry.annotation;
     811    var inherited = entry.inherited;
     812   
     813    entry.source = 'INHERITED';
     814    entry.modified = CONVERTED;
    719815    ann.values = [];
    720816    ann.unit = null;
    721     annotate.selectAnnotation(selectedAnnotation.id);
    722   }
    723 
     817    annotate.updateIcon(entry);
     818    return true;
     819  }
     820
     821  annotate.deleteAllChecked = function()
     822  {
     823    if (annotate.forAllChecked(annotate.deleteAnnotation))
     824    {
     825      annotate.selectAnnotation(selectedAnnotation.source == 'PRIMARY' ? selectedAnnotation.id : null);
     826    }
     827  }
     828 
     829  annotate.deleteAnnotation = function(entry)
     830  {
     831    App.debug(entry.id);
     832    entry.modified = DELETE;
     833    if (entry.source == 'PRIMARY')
     834    {
     835      entry.annotation.values = [];
     836      entry.annotation.unit = null;
     837      annotate.updateIcon(entry);
     838    }
     839    else
     840    {
     841      Doc.hide(entry.id);
     842    }
     843    return true;
     844  }
    724845 
    725846  /*
     
    796917  */
    797918 
     919 
     920  annotate.getIcon = function(entry)
     921  {
     922    var icon;
     923    var ann = entry.annotation;
     924   
     925    if (entry.source == 'PRIMARY')
     926    {
     927      // 'x' for has values, empty otherwise
     928      icon = (ann && ann.values.length > 0) ? 'notrequired_values.png' : 'notrequired_novalues.png';
     929    }
     930    else if (entry.source == 'INHERITED')
     931    {
     932      // Always the same 'x' with an anchor
     933      icon = 'inherited.png'
     934    }
     935    else
     936    {
     937      // Cloned annotations
     938      if (!entry.inherited)
     939      {
     940        // No parent item
     941        icon = 'cloned-noparent.png';
     942      }
     943      else if (entry.inherited.lastUpdate > ann.lastUpdate)
     944      {
     945        // The parent annotation has been updated
     946        icon = 'cloned-outofsync.png';
     947      }
     948      else
     949      {
     950        icon = 'cloned.png';
     951      }
     952    }
     953    return icon;
     954  }
     955 
    798956  /**
    799957    Update the icon for the annotation. The icon is different depending on if
     
    802960  annotate.updateIcon = function(entry)
    803961  {
    804     var icon;
    805     var ann = entry.annotation;
    806    
    807     if (entry.source != 'PRIMARY' || (ann && ann.values.length > 0))
    808     {
    809       icon = ann.required ? 'required_values.png' : 'notrequired_values.png';
    810     }
    811     else
    812     {
    813       icon = ann.required ? 'required_novalues.png' : 'notrequired_novalues.png';
    814     }
     962    var icon = annotate.getIcon(entry);
    815963    var img = Doc.element('icon.'+entry.id);
    816964    img.src = App.getRoot()+'images/'+icon;
     
    8611009    }
    8621010   
    863     //alert(JSON.stringify(modified));
     1011    alert(JSON.stringify(modified));
    8641012   
    8651013    if (frm.modifiedAnnotations)
  • trunk/www/common/annotations/annotate.jsp

    r6943 r6945  
    7373%>
    7474<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
     75<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
    7576<%!
    7677private JSONObject makeJSON(DbControl dc, AnnotationType at, Annotation a, boolean isProtocolParameter, Set<AnnotationTypeCategory> allCategories)
     
    415416  %>
    416417  <base:page type="<%=standalone ? "popup" : "iframe"%>" title="<%=title%>">
    417   <base:head scripts="~annotate.js" styles="parameters.css">
     418  <base:head scripts="~annotate.js" styles="parameters.css,toolbar.css">
    418419  <style>
    419420  .first-primary:before
     
    435436  }
    436437 
     438 
     439  .parameterlist .param
     440  {
     441    padding-right: 20px;
     442  }
     443  .parameterlist .param.selected
     444  {
     445    padding-right: 20px;
     446  }
     447  .parameterlist .param:hover
     448  {
     449    padding-right: 18px;
     450  }
     451 
     452  .parameterlist .param input
     453  {
     454    position: absolute;
     455    right: 1px;
     456    margin-top: 1px;
     457  }
     458 
    437459  #selected-name
    438460  {
     
    503525  }
    504526 
    505   #inherited-modified, #inherited-clone, #cloned-inherit
     527  #inherited-modified, #inherited-clone
    506528  {
    507529    display: none;
     
    514536 
    515537  #selected-container.INHERITED #inherited-clone
    516   {
    517     display: inline;
    518   }
    519 
    520   #selected-container.CLONED #cloned-inherit
    521538  {
    522539    display: inline;
     
    648665       
    649666        <div id="annotation-list" class="absolutefull parameterlist topborder"
    650           style="top: 2em; bottom: 3em;">
     667          style="top: 2em; bottom: 6em;">
    651668          <div class="first-primary"></div>
    652669          <%
     
    661678          %>
    662679        </div>
    663         <div class="absolutefull topborder" style="top: auto; bottom: 0px; height: 3em;">
    664           <table style="height: 100%; margin:auto;"><tr><td>
     680        <div class="absolutefull topborder" style="top: auto; bottom: 0em; height: 7em;">
     681          <tbl:toolbar subclass="bottomborder">
     682            <tbl:button id="btnDelete" title="Delete" image="remove.png" />
     683            <tbl:button id="btnAdd" title="Add" image="add.png" />
     684          </tbl:toolbar>
     685          <tbl:toolbar subclass="bottomborder">
     686            <tbl:button id="btnSync" title="Sync" image="refresh.png" />
     687            <tbl:button id="btnClone" title="Clone" image="copy.png" />
     688            <tbl:button id="btnDeclone" title="De-clone" />
     689          </tbl:toolbar>
     690          <table style="height: 3em; margin:auto;"><tr><td>
    665691          <base:icon image="hasvalues.png" /> = has value(s)<br>
    666692          <base:icon image="parameter.png" /> = protocol parameter
     
    712738            <span id="inherited-modified">(modified; <span id="sync-modified" class="link" title="Synchronize the annotation values with the parent item">sync</span>)</span>
    713739            <span id="inherited-clone">(<span id="convert-to-cloned" class="link" title="Clone the annotation values from the parent">clone</span>)</span>
    714             <span id="cloned-inherit">(<span id="convert-to-inherited" class="link" title="Removed the cloned values from this item">remove clone</span>)</span>
    715740          </div>
    716741                   
    717           <div id="inherited-missing">
     742          <div id="inherited-missing" class="bg-filled-100">
    718743            Cloned from an unknown item.
    719744          </div>
  • trunk/www/include/styles/parameters.css

    r6617 r6945  
    5151{
    5252  font-weight: bold;
    53   padding: 1px 5px 1px 2px;
     53  padding: 1px 2px 1px 2px;
    5454  margin: 1px 0 -1px 0;
    5555  border-radius: 0;
Note: See TracChangeset for help on using the changeset viewer.