Changeset 6694
- Timestamp:
- Jan 26, 2015, 3:41:25 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/SimpleProgressReporter.java
r6127 r6694 40 40 private String message; 41 41 private int percent; 42 private Throwable error; 42 43 43 44 … … 85 86 return percent; 86 87 } 88 89 /** 90 Set an error that happened while processing some action that 91 was reported via this progress reporter. 92 @since 3.5 93 */ 94 public void setError(Throwable error) 95 { 96 this.error = error; 97 } 98 99 /** 100 Get error that happened while processing some action that 101 was reported via this progress reporter. 102 @since 3.5 103 */ 104 public Throwable getError() 105 { 106 return error; 107 } 87 108 } -
trunk/www/common/annotations/index.jsp
r6192 r6694 29 29 import="net.sf.basedb.core.ItemContext" 30 30 import="net.sf.basedb.core.BasicItem" 31 import="net.sf.basedb.core.AnnotatedItem" 31 32 import="net.sf.basedb.core.Annotation" 32 33 import="net.sf.basedb.core.AnnotationType" 33 34 import="net.sf.basedb.core.Annotatable" 35 import="net.sf.basedb.core.ItemSubtype" 34 36 import="net.sf.basedb.core.BaseException" 37 import="net.sf.basedb.core.SimpleProgressReporter" 38 import="net.sf.basedb.core.snapshot.SnapshotManager" 39 import="net.sf.basedb.util.annotations.RunnableInheritAnnotationsManager" 40 import="net.sf.basedb.util.annotations.InheritAnnotationsManager" 41 import="net.sf.basedb.util.annotations.InheritSpecification" 35 42 import="net.sf.basedb.clients.web.Base" 36 43 import="net.sf.basedb.clients.web.WebException" 37 44 import="net.sf.basedb.util.Values" 38 45 import="net.sf.basedb.clients.web.util.HTML" 46 import="java.util.Set" 47 import="java.util.List" 48 import="java.util.ArrayList" 49 50 39 51 %> 40 52 <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> … … 82 94 message = "Annotations saved"; 83 95 } 96 else if ("BatchInherit".equals(cmd)) 97 { 98 final Item itemType = Item.valueOf(request.getParameter("item_type")); 99 final String subContext = Values.getString(request.getParameter("subcontext"), ""); 100 final ItemContext cc = sc.getCurrentContext(itemType, subContext); 101 102 newDc = sc.newDbControl(); 103 104 Set<AnnotatedItem> items = (Set<AnnotatedItem>)cc.getObject("AnnotatedItems"); 105 cc.removeObject("AnnotatedItems"); 106 107 RunnableInheritAnnotationsManager manager = new RunnableInheritAnnotationsManager(sc); 108 manager.addAllItems(items); 109 110 for (Integer atId : Values.getInt(request.getParameter("annotationTypes").split(","))) 111 { 112 AnnotationType at = AnnotationType.getById(newDc, atId); 113 InheritSpecification spec = new InheritSpecification(at); 114 String action = request.getParameter("action_"+atId); 115 116 if ("remove".equals(action)) 117 { 118 spec.setRemove(true); 119 } 120 else 121 { 122 int subtypeId = Values.getInt(request.getParameter("from_"+atId)); 123 boolean noDup = Values.getBoolean(request.getParameter("nodup_"+atId)); 124 boolean replaceExisting = Values.getBoolean(request.getParameter("replace_"+atId)); 125 if (subtypeId != 0) 126 { 127 spec.setItemSubtype(ItemSubtype.getById(newDc, subtypeId)); 128 } 129 spec.setNoDuplicates(noDup); 130 spec.setReplaceExisting(replaceExisting); 131 } 132 manager.addSpecification(spec); 133 134 //System.out.println("at:" + atId + "; " + action + "; from=" + from + "; noDup="+noDup + "; replace="+replaceExisting); 135 } 136 newDc.commit(); 137 138 SimpleProgressReporter progress = new SimpleProgressReporter(null); 139 sc.setSessionSetting("progress.inherit-annotations", progress); 140 manager.setProgressReporter(progress); 141 new Thread(manager).start(); 142 143 redirect = "../../common/progress_reporter.jsp?ID="+ID+ 144 "&progress=inherit-annotations&title=Inheriting annotations to " + items.size() + " items"; 145 146 } 84 147 else 85 148 { -
trunk/www/common/progress_reporter.js
r6203 r6694 34 34 35 35 var percentDone = Data.int(document.body, 'percent-done'); 36 setTimeout(percentDone < 100 ? progress.reload : App.closeWindow, 1500); 36 var isError = Data.int(document.body, 'is-error'); 37 if (!isError) 38 { 39 setTimeout(percentDone < 100 ? progress.reload : App.closeWindow, 1500); 40 } 41 else 42 { 43 Doc.addClass('progress-bar', 'failed'); 44 Doc.hide('info'); 45 } 37 46 } 38 47 -
trunk/www/common/progress_reporter.jsp
r6607 r6694 41 41 String message = null; 42 42 int percentDone = 0; 43 boolean isError = false; 43 44 if (progress != null) 44 45 { … … 53 54 { 54 55 sc.setSessionSetting("progress." + progressName, null); 56 isError = progress.getError() != null; 55 57 } 56 58 %> 57 59 <base:page type="popup" title="<%=title%>"> 58 60 <base:head styles="progressbar.css" scripts="~progress_reporter.js" /> 59 <base:body data-percent-done="<%=percentDone %>" >61 <base:body data-percent-done="<%=percentDone %>" data-is-error="<%=isError ? 1 : 0 %>"> 60 62 <h1><%=title%></h1> 61 63 <div class="content"> 62 64 63 65 <table class="fullcc bg-filled-50 bottomborder"><tr><td> 64 <table class="progressbar" style="margin: auto;" >66 <table class="progressbar" style="margin: auto;" id="progress-bar"> 65 67 <tr> 66 68 <td> … … 78 80 <br><br> 79 81 80 <div align="center" >82 <div align="center" id="info"> 81 83 <i>Closing this window will NOT abort the process</i> 82 84 </div> -
trunk/www/include/scripts/main-2.js
r6684 r6694 1154 1154 var regexp = Data.get(target, 'regexp'); 1155 1155 Table.setOwnerOfItems(tableId, regexp); 1156 } 1157 1158 /** 1159 Event handler that opens the 'Batch inherit anntations' dialog 1160 for all selected items in a table. Usually attached to 1161 an 'Inherit annotations' button on a list page. The table id must be specifed 1162 in the 'data-table-id' attribute. 1163 */ 1164 buttons.inheritAnnotations = function(event) 1165 { 1166 var target = event.currentTarget; 1167 var tableId = Data.get(target, 'table-id'); 1168 var regexp = Data.get(target, 'regexp'); 1169 Table.inheritAnnotations(tableId, regexp); 1156 1170 } 1157 1171 … … 2739 2753 label when the checkbox/radiobutton is disabled 2740 2754 */ 2741 internal.linkCheckboxesWithLabels = function() 2742 { 2743 var labels = document.getElementsByTagName('label'); 2755 forms.linkCheckboxesWithLabels = function(element) 2756 { 2757 if (!element) element = document; 2758 var labels = element.getElementsByTagName('label'); 2744 2759 if (labels.length > 0) 2745 2760 { … … 2792 2807 } 2793 2808 2794 Doc.addFinalizer( internal.linkCheckboxesWithLabels);2809 Doc.addFinalizer(forms.linkCheckboxesWithLabels); 2795 2810 2796 2811 return forms; -
trunk/www/include/scripts/table.js
r6689 r6694 616 616 617 617 /** 618 Open a popup dialog that allows a user to bathc inherit annotations 619 to all items that are selected in the given table. 620 @param tableDiv The ID or main table element 621 @param regexp An optional regular expression matching the names 622 of checkboxes that can be selected, if not specified it matches 623 checkboxes with numeric names (eg. the name is the id of the item 624 in the table) 625 */ 626 table.inheritAnnotations = function(tableDiv, regexp) 627 { 628 tableDiv = Doc.element(tableDiv); 629 if (!table.checkIfSelected(tableDiv, regexp)) 630 { 631 return; 632 } 633 table.submitToPopup(tableDiv, 'InheritAnnotations', 750, 500); 634 } 635 636 637 /** 618 638 Open a popup window for selecting a plug-in that can run in the 619 639 current list context -
trunk/www/views/rawbioassays/bioassays.js
r6389 r6694 102 102 Buttons.addClickHandler('btnShareItems', Buttons.shareItems, tableAttributes); 103 103 Buttons.addClickHandler('btnSetOwner', Buttons.setOwnerOfItems, tableAttributes); 104 Buttons.addClickHandler('btnInheritAnnotations', Buttons.inheritAnnotations, tableAttributes); 104 105 Buttons.addClickHandler('btnColumns', Buttons.configureColumns, tableAttributes); 105 106 Buttons.addClickHandler('btnExport', Buttons.runListPlugin, tableAttributes); -
trunk/www/views/rawbioassays/index.jsp
r6600 r6694 49 49 import="net.sf.basedb.core.ItemResultIterator" 50 50 import="net.sf.basedb.core.OwnedItem" 51 import="net.sf.basedb.core.AnnotatedItem" 51 52 import="net.sf.basedb.core.Permission" 52 53 import="net.sf.basedb.core.ItemContext" … … 497 498 redirect = "../../common/ownership/ownership.jsp?ID="+ID+"&item_type="+itemType.name(); 498 499 } 500 else if ("InheritAnnotations".equals(cmd)) 501 { 502 // Change owner of items selected on a list page 503 dc = sc.newDbControl(); 504 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 505 Set<AnnotatedItem> items = new HashSet<AnnotatedItem>(); 506 for (Integer id : cc.getSelected()) 507 { 508 if (id != null) items.add((AnnotatedItem)itemType.getById(dc, id)); 509 } 510 dc.close(); 511 cc.setObject("AnnotatedItems", items); 512 redirect = "../../common/annotations/batch_inherit.jsp?ID="+ID+"&item_type="+itemType.name(); 513 } 499 514 else if ("ExportItems".equals(cmd)) 500 515 { -
trunk/www/views/rawbioassays/list_rawbioassays.jsp
r6689 r6694 407 407 { 408 408 AnnotationType at = loader.getAnnotationType(); 409 Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); 409 410 Enumeration<String, String> annotationEnum = null; 410 411 if (at.isEnumeration()) … … 430 431 filterable="true" 431 432 exportable="true" 433 formatter="<%=formatter%>" 432 434 unit="<%=at.getDefaultUnit()%>" 433 435 /> … … 499 501 tooltip="Create a new experiment from the selected raw bioassays" 500 502 visible="<%=sc.hasPermission(Permission.CREATE, Item.EXPERIMENT)%>" 503 /> 504 <tbl:button 505 id="btnInheritAnnotations" 506 image="inherit.png" 507 title="Inherit annotations…" 508 tooltip="Batch inherit annotations from parent items" 501 509 /> 502 510 <tbl:button
Note: See TracChangeset
for help on using the changeset viewer.