Changeset 3847
- Timestamp:
- Oct 17, 2007, 7:52:56 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Project.java
r3679 r3847 665 665 POOLING_PROTOCOL("default_pooling_protocol", "Pooling protocol", Item.PROTOCOL, ProtocolType.POOLING), 666 666 PRINTING_PROTOCOL("default_printing_protocol", "Printing protocol", Item.PROTOCOL, ProtocolType.PRINTING), 667 RAW_DATA_TYPE("default_raw_data_type", "Raw data type", null, null); 667 RAW_DATA_TYPE("default_raw_data_type", "Raw data type", null, null), 668 PLATFORM("default_platform", "Platform", Item.PLATFORM, null), 669 PLATFORM_VARIANT("default_variant", "Variant", Item.PLATFORMVARIANT, null); 668 670 669 671 private String name; -
trunk/src/core/net/sf/basedb/core/RawDataTypes.java
r3820 r3847 266 266 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 267 267 "GET_PLATFORMVARIANT_FOR_EXTERNAL_ID"); 268 query.setString("externalId", id.substring( 9));268 query.setString("externalId", id.substring(8)); 269 269 PlatformVariantData variant = HibernateUtil.loadData(PlatformVariantData.class, query); 270 270 if (variant == null || !variant.isFileOnly()) return null; -
trunk/www/include/scripts/main.js
r3820 r3847 397 397 this.controllers['BIOSOURCE'] = { url:'biomaterials/biosources/index.jsp', width:800, height:500 }; 398 398 this.controllers['MESSAGE'] = { url:'my_base/messages/index.jsp', width:600, height:420, popup:true, edit:false }; 399 this.controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width: 570, height:400 };399 this.controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:600, height:460 }; 400 400 this.controllers['FILE'] = { url:'filemanager/index.jsp', width:500, height:360 }; 401 401 this.controllers['DIRECTORY'] = { url:'filemanager/directories/index.jsp', width:500, height:360, xpopup:true }; -
trunk/www/my_base/projects/edit_project.jsp
r3679 r3847 39 39 import="net.sf.basedb.core.Project" 40 40 import="net.sf.basedb.core.Protocol" 41 import="net.sf.basedb.core.Platform" 42 import="net.sf.basedb.core.PlatformVariant" 41 43 import="net.sf.basedb.core.User" 42 44 import="net.sf.basedb.core.Group" … … 105 107 List<ArrayDesign> recentArrayDesign = (List<ArrayDesign>)cc.getRecent(dc, Item.ARRAYDESIGN); 106 108 109 boolean deniedPlatform = false; 110 Platform currentPlatform = null; 111 PlatformVariant currentVariant = null; 107 112 108 113 if (itemId == 0) … … 117 122 title = "Edit project -- " + HTML.encodeTags(project.getName()); 118 123 124 try 125 { 126 currentPlatform = (Platform)project.getDefaultItem(dc, Project.Default.PLATFORM); 127 currentVariant = (PlatformVariant)project.getDefaultItem(dc, Project.Default.PLATFORM_VARIANT); 128 } 129 catch (PermissionDeniedException ex) 130 { 131 deniedPlatform = true; 132 } 133 119 134 groupQuery = project.getGroups(); 120 135 groupQuery.order(Orders.asc(Hql.property("name"))); … … 126 141 throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); 127 142 } 128 final StringBuilder sb = new StringBuilder(); 143 RawDataType currentRawDataType = project != null ? 144 project.getDefaultRawDataType() : null; 129 145 146 ItemQuery<Platform> platformQuery = Platform.getQuery(); 147 platformQuery.order(Orders.asc(Hql.property("name"))); 148 platformQuery.setCacheResult(true); 149 ItemResultList<Platform> platforms = platformQuery.list(dc); 150 151 ItemQuery<PlatformVariant> variantQuery = PlatformVariant.getQuery(); 152 variantQuery.order(Orders.asc(Hql.property("name"))); 153 variantQuery.setCacheResult(true); 154 ItemResultList<PlatformVariant> variants = variantQuery.list(dc); 155 156 Set<Project.Default> ignore = EnumSet.of( 157 Project.Default.PLATFORM, Project.Default.PLATFORM_VARIANT, 158 Project.Default.RAW_DATA_TYPE); 159 160 final StringBuilder sb = new StringBuilder(); 130 161 final String clazz = "class=\"text\""; 131 162 final String requiredClazz = "class=\"text required\""; … … 133 164 134 165 <base:page type="popup" title="<%=title%>"> 135 <base:head scripts="tabcontrol.js,linkitems.js,parameters.js " styles="tabcontrol.css,parameters.css">166 <base:head scripts="tabcontrol.js,linkitems.js,parameters.js,platforms.js" styles="tabcontrol.css,parameters.css"> 136 167 <script language="JavaScript"> 137 168 // Validate the "Project" tab … … 176 207 } 177 208 %> 209 initPlatforms(<%=currentPlatform == null ? 0 : currentPlatform.getId()%>, <%=currentVariant == null ? 0 : currentVariant.getId()%>); 178 210 initMembers(); 179 211 initDefaults(); 212 platformOnChange(); 213 } 214 function initPlatforms(platformId, variantId) 215 { 216 <% 217 for (Platform p : platforms) 218 { 219 RawDataType rdt = p.isFileOnly() ? null : p.getRawDataType(); 220 %> 221 var p<%=p.getId()%> = new Platform(<%=p.getId()%>, '<%=HTML.javaScriptEncode(p.getExternalId())%>', '<%=HTML.javaScriptEncode(p.getName())%>', <%=p.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>'); 222 <% 223 } 224 for (PlatformVariant v : variants) 225 { 226 RawDataType rdt = v.isFileOnly() ? null : v.getRawDataType(); 227 Platform p = v.getPlatform(); 228 %> 229 var v<%=v.getId()%> = new Variant(p<%=p.getId()%>, <%=v.getId()%>, '<%=HTML.javaScriptEncode(v.getExternalId())%>', '<%=HTML.javaScriptEncode(v.getName())%>', <%=v.isFileOnly()%>, '<%=rdt == null ? "" : rdt.getId()%>'); 230 <% 231 } 232 %> 233 var frm = document.forms['project']; 234 Platforms.populateList(frm.platform, platformId, variantId); 180 235 } 181 236 function initDefaults() 182 237 { 183 238 <% 239 // Platform/variant/raw data type 240 String icon = currentPlatform == null && currentVariant == null && currentRawDataType == null ? 241 "notrequired_novalues.gif" : "notrequired_values.gif"; 242 icon = "<span class=\"icon\"><img id=\"icon_default_platform\" src=\"../../images/"+icon+"\"></span>"; 243 sb.append("<div class=\"param\" id=\"prompt_default_platform\" onclick=\"defaultItemOnClick('default_platform')\""); 244 sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\"Platform / raw data type\">"); 245 sb.append(icon+"<span class=\"label\">Platform / raw data type</span></div>\n"); 184 246 for (Project.Default d : Project.Default.values()) 185 247 { … … 187 249 var values = new Array(); 188 250 <% 189 Stringicon = "";251 icon = ""; 190 252 if (project != null) 191 253 { … … 210 272 { 211 273 RawDataType rdt = project.getDefaultRawDataType(); 212 String strValueId = " 0";274 String strValueId = ""; 213 275 if (rdt != null) 214 276 { … … 229 291 icon = "notrequired_novalues.gif"; 230 292 } 231 icon = "<span class=\"icon\"><img id=\"icon_"+d.getName()+"\" src=\"../../images/"+icon+"\"></span>"; 232 sb.append("<div class=\"param\" id=\"prompt_"+d.getName()+"\" onclick=\"defaultItemOnClick('"+d.getName()+"')\""); 233 sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+d.getShortName()+"\">"); 234 sb.append(icon+"<span class=\"label\">"+d.getShortName()+"</span></div>\n"); 293 if (!ignore.contains(d)) 294 { 295 icon = "<span class=\"icon\"><img id=\"icon_"+d.getName()+"\" src=\"../../images/"+icon+"\"></span>"; 296 sb.append("<div class=\"param\" id=\"prompt_"+d.getName()+"\" onclick=\"defaultItemOnClick('"+d.getName()+"')\""); 297 sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+d.getShortName()+"\">"); 298 sb.append(icon+"<span class=\"label\">"+d.getShortName()+"</span></div>\n"); 299 } 235 300 %> 236 301 var di = new Parameter('<%=d.getName()%>', '<%=HTML.javaScriptEncode(d.getShortName())%>', 1, false, false, values); … … 403 468 if (oldValueDiv) Main.hide(oldValueDiv); 404 469 405 var pp = Parameters.allParameters['ID'+defaultName]; 470 var pp = Parameters.allParameters['ID'+defaultName]; 406 471 setSelectedParameter(pp, defaultName); 407 472 oldValueDiv = 'value_'+pp.name+'_div'; 408 473 Main.show(oldValueDiv); 409 410 var valueElement = frm['value_'+pp.name];411 if (valueElement.focus) valueElement.focus();412 413 414 474 } 415 475 var selectedParameter = null; … … 491 551 } 492 552 553 function platformOnChange() 554 { 555 var frm = document.forms['project']; 556 var platform = Platforms.getSelectedPlatform(frm.platform); 557 var variant = Platforms.getSelectedVariant(frm.platform); 558 var fileOnly = (variant != null && variant.fileOnly) || 559 (variant == null && platform != null && platform.fileOnly); 560 var rawDataType = null; 561 if (variant != null) 562 { 563 rawDataType = variant.rawDataType; 564 } 565 else if (platform != null) 566 { 567 rawDataType = platform.rawDataType; 568 } 569 if (frm.rawdatatype[frm.rawdatatype.length - 1].value == '') 570 { 571 frm.rawdatatype[frm.rawdatatype.length - 1] = null; 572 } 573 if (fileOnly) 574 { 575 frm.rawdatatype.disabled = true; 576 frm.rawdatatype[frm.rawdatatype.length] = new Option('- file only -', ''); 577 frm.rawdatatype.selectedIndex = frm.rawdatatype.length - 1; 578 } 579 else if (rawDataType) 580 { 581 frm.rawdatatype.disabled = true; 582 Forms.selectListOption(frm.rawdatatype, rawDataType); 583 } 584 else 585 { 586 frm.rawdatatype.disabled = false; 587 rawDataType = frm.rawdatatype[frm.rawdatatype.selectedIndex].value; 588 } 589 var icon = document.getElementById('icon_default_platform'); 590 var gif = getRoot()+'images/'; 591 if (!platform && !variant && !rawDataType) 592 { 593 gif += 'notrequired_novalues.gif'; 594 } 595 else 596 { 597 gif += 'notrequired_values.gif'; 598 } 599 icon.src = gif; 600 } 601 602 function rawDataTypeOnChange() 603 { 604 platformOnChange(); 605 } 493 606 </script> 494 607 </base:head> … … 499 612 500 613 <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> 501 <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale* 280)+"px;"%>"614 <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*320)+"px;"%>" 502 615 position="bottom" remember="<%=project != null%>"> 503 616 <t:tab id="info" title="Project" validate="validateProject()" helpid="project.edit"> … … 572 685 <td width="40%"> 573 686 <b>Project defaults</b><br> 574 <div class="parameterlist" style="height: <%=(int)(scale*2 30)%>px; width:<%=(int)(scale*200)%>px; margin-top: 4px;">687 <div class="parameterlist" style="height: <%=(int)(scale*260)%>px; width:<%=(int)(scale*200)%>px; margin-top: 4px;"> 575 688 <%=sb.toString()%> 576 689 </div> … … 579 692 <td width="60%"> 580 693 <br> 694 695 <div id="value_default_platform_div" style="display: none"> 696 <table> 697 <tr> 698 <td class="prompt">Platform</td> 699 </tr> 700 <tr> 701 <td> 702 <select name="platform" onchange="platformOnChange()"> 703 <option value="">- none -</option> 704 </select> 705 </td> 706 </tr> 707 <tr> 708 <td class="prompt">Raw data type</td> 709 </tr> 710 <tr> 711 <td> 712 <select name="rawdatatype" onchange="rawDataTypeOnChange()"> 713 <option value="">- none -</option> 714 <% 715 for (RawDataType rdt : RawDataTypes.getRawDataTypes()) 716 { 717 if (rdt.isStoredInDb()) 718 { 719 String selected = rdt.equals(currentRawDataType) ? "selected" : ""; 720 %> 721 <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%> 722 <% 723 } 724 } 725 %> 726 </select> 727 </td> 728 </tr> 729 </table> 730 </div> 731 581 732 <% 582 733 for (Project.Default d : Project.Default.values()) 583 734 { 584 String inputName = "value_" + d.getName(); 585 %> 586 <div id="<%=inputName%>_div" style="display: none;"> 587 <table> 588 <tr> 589 <td class="prompt"><%=d.getShortName()%></td> 590 </tr> 591 <% 592 if (d.getItemType() != null) 593 { 594 String selectDefaultItemOnClick = ""; 595 String defaultItemOnChange = ""; 596 List recentItems = null; 597 boolean readCurrentItem = true; 598 BasicItem currentItem = null; 599 try 600 { 601 currentItem = project != null ? project.getDefaultItem(dc, d) : null; 602 } 603 catch (PermissionDeniedException ex) 604 { 605 readCurrentItem = false; 606 } 607 608 if (d.getItemType() == Item.PROTOCOL) 609 { 610 int typeId = SystemItems.getId(d.getType()); 611 String url = "'../../admin/protocols/index.jsp?ID=" + ID + 612 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; 613 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 614 recentItems = recentProtocol; 615 } 616 else if (d.getItemType() == Item.HARDWARE) 617 { 618 int typeId = SystemItems.getId(d.getType()); 619 String url = "'../../admin/hardware/index.jsp?ID=" + ID + 620 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; 621 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 622 recentItems = recentHardware; 623 } 624 else if (d.getItemType() == Item.SOFTWARE) 625 { 626 String url = "'../../admin/software/index.jsp?ID=" + ID + 627 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; 628 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 629 recentItems = recentSoftware; 630 } 631 else if (d.getItemType() == Item.ARRAYDESIGN) 632 { 633 String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + 634 "&mode=selectone&callback=setDefaultItemCallback'"; 635 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 636 recentItems = recentArrayDesign; 637 } 638 %> 735 String inputName = "value_" + d.getName(); 736 if (!ignore.contains(d)) 737 { 738 %> 739 <div id="<%=inputName%>_div" style="display: none;"> 740 <table> 639 741 <tr> 640 <td> 641 <base:select 642 id="<%=inputName%>" 643 clazz="selectionlist" 644 required="false" 645 current="<%=currentItem%>" 646 denied="<%=!readCurrentItem%>" 647 recent="<%=recentItems%>" 648 newitem="<%=project == null%>" 649 onselect="<%=selectDefaultItemOnClick%>" 650 onchange = 'defaultValueOnChange(this[this.selectedIndex].value)' 651 /> 652 </td> 653 </tr> 654 <% 655 } 656 else if (d == Project.Default.RAW_DATA_TYPE) 657 { 658 RawDataType currentDefaultRawDataType = project != null ? project.getDefaultRawDataType() : null; 659 %> 660 <tr> 661 <td> 662 <div id="<%=inputName%>" class="selectionlist"> 663 <table border="0" cellspacing="0" cellpadding="0"> 664 <tr><td> 665 <select name="<%=inputName%>" onchange="defaultValueOnChange(this[this.selectedIndex].value)"> 666 <option value="0">- none -</option> 667 <% 668 for (RawDataType rdt : RawDataTypes.getRawDataTypes()) 669 { 670 String selected = rdt.equals(currentDefaultRawDataType) ? "selected" : ""; 671 %> 672 <option value="<%=rdt.getId()%>" <%=selected%>><%=rdt.getName()%></option> 673 <% 674 } 675 %> 676 </select> 677 </td></tr> 678 </table> 679 </div> 680 </td> 742 <td class="prompt"><%=d.getShortName()%></td> 681 743 </tr> 682 744 <% 683 } 684 %> 685 </table> 686 </div> 687 <% 745 if (d.getItemType() != null) 746 { 747 String selectDefaultItemOnClick = ""; 748 String defaultItemOnChange = ""; 749 List recentItems = null; 750 boolean readCurrentItem = true; 751 BasicItem currentItem = null; 752 try 753 { 754 currentItem = project != null ? project.getDefaultItem(dc, d) : null; 755 } 756 catch (PermissionDeniedException ex) 757 { 758 readCurrentItem = false; 759 } 760 761 if (d.getItemType() == Item.PROTOCOL) 762 { 763 int typeId = SystemItems.getId(d.getType()); 764 String url = "'../../admin/protocols/index.jsp?ID=" + ID + 765 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; 766 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 767 recentItems = recentProtocol; 768 } 769 else if (d.getItemType() == Item.HARDWARE) 770 { 771 int typeId = SystemItems.getId(d.getType()); 772 String url = "'../../admin/hardware/index.jsp?ID=" + ID + 773 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; 774 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 775 recentItems = recentHardware; 776 } 777 else if (d.getItemType() == Item.SOFTWARE) 778 { 779 String url = "'../../admin/software/index.jsp?ID=" + ID + 780 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; 781 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 782 recentItems = recentSoftware; 783 } 784 else if (d.getItemType() == Item.ARRAYDESIGN) 785 { 786 String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + 787 "&mode=selectone&callback=setDefaultItemCallback'"; 788 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 789 recentItems = recentArrayDesign; 790 } 791 %> 792 <tr> 793 <td> 794 <base:select 795 id="<%=inputName%>" 796 clazz="selectionlist" 797 required="false" 798 current="<%=currentItem%>" 799 denied="<%=!readCurrentItem%>" 800 recent="<%=recentItems%>" 801 newitem="<%=project == null%>" 802 onselect="<%=selectDefaultItemOnClick%>" 803 onchange = 'defaultValueOnChange(this[this.selectedIndex].value)' 804 /> 805 </td> 806 </tr> 807 <% 808 } 809 %> 810 </table> 811 </div> 812 <% 813 } 688 814 } 689 815 %> -
trunk/www/my_base/projects/index.jsp
r3679 r3847 35 35 import="net.sf.basedb.core.User" 36 36 import="net.sf.basedb.core.Group" 37 import="net.sf.basedb.core.Platform" 38 import="net.sf.basedb.core.PlatformVariant" 37 39 import="net.sf.basedb.core.ItemQuery" 38 40 import="net.sf.basedb.core.ItemResultIterator" … … 172 174 173 175 // Default tab 176 177 Platform platform = null; 178 PlatformVariant variant = null; 179 RawDataType rdt = null; 180 if (request.getParameter("platform") != null) 181 { 182 String[] pv = request.getParameter("platform").split(":"); 183 int platformId = Values.getInt(pv[0], -1); 184 int variantId = pv.length > 1 ? Values.getInt(pv[1], -1) : -1; 185 if (platformId > 0) platform = Platform.getById(dc, platformId); 186 if (variantId > 0) variant = PlatformVariant.getById(dc, variantId); 187 } 188 if (variant != null) rdt = variant.getRawDataType(); 189 if (rdt == null && platform != null) rdt = platform.getRawDataType(); 190 if (rdt == null) rdt = RawDataTypes.getRawDataType( request.getParameter("rawdatatype")); 191 project.setDefaultItem(dc, platform, Project.Default.PLATFORM); 192 project.setDefaultItem(dc, variant, Project.Default.PLATFORM_VARIANT); 193 project.setDefaultRawDataType(rdt); 194 174 195 for (Project.Default d : Project.Default.values()) 175 196 { … … 184 205 } 185 206 } 186 else if (d == Project.Default.RAW_DATA_TYPE) 187 { 188 String selectId = request.getParameter(selectDefault); 189 if (selectId != null && selectId.length() > 0) 190 { 191 RawDataType rdt = selectId.equals("0") ? null :RawDataTypes.getRawDataType(selectId); 192 project.setDefaultRawDataType(rdt); 193 } 194 } 195 } 196 207 } 208 197 209 dc.commit(); 198 210 cc.removeObject("item"); -
trunk/www/my_base/projects/view_project.jsp
r3679 r3847 319 319 boolean readDefaultValue = true; 320 320 String defaultName = d.getShortName(); 321 String value = "";321 String value = null; 322 322 if (d.getItemType() != null) 323 323 { … … 340 340 { 341 341 RawDataType rdt = project.getDefaultRawDataType(); 342 value = rdt != null ? rdt.getName() : "";342 value = rdt != null ? rdt.getName() : null; 343 343 } 344 if (value .length() > 0)344 if (value != null) 345 345 { 346 346 %>
Note: See TracChangeset
for help on using the changeset viewer.