Changeset 2939
- Timestamp:
- Nov 20, 2006, 4:23:40 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/core/Project.java
r2928 r2939 33 33 34 34 import java.util.ArrayList; 35 import java.util.HashMap;36 35 import java.util.HashSet; 37 36 import java.util.List; 38 import java.util.Map;39 37 import java.util.Set; 40 38 import java.util.Collections; … … 86 84 */ 87 85 public static final Item TYPE = Item.PROJECT; 88 89 // public static final String DEFAULT_SCANNING_PROTOCOL = "default_scanning_protocol"; 90 // public static final String DEFAULT_SAMPLING_PROTOCOL = "default_sampling_protocol"; 91 // public static final String DEFAULT_EXTRACTING_PROTOCOL = "default_extracting_protocol"; 92 // public static final String DEFAULT_LABELING_PROTOCOL = "default_labeling_protocol"; 93 // public static final String DEFAULT_HYBRIDIZATION_PROTOCOL = "default_hybridization_protocol"; 94 // public static final String DEFAULT_FEATURE_EXTRACTION_PROTOCOL = "default_feature_extraction_protocol"; 95 // public static final String DEFAULT_POOLING_PROTOCOL = "default_pooling_protocol"; 96 // public static final String DEFAULT_PRINTING_PROTOCOL = "default_printing_protocol"; 97 // public static final String DEFAULT_SOFTWARE = "default_software"; 98 // public static final String DEFAULT_ARRAYDESIGN = "default_arraydesign"; 99 // public static final String DEFAULT_HYBRIDIZATION_HARDWARE = "default_hybridization_hardware"; 100 // public static final String DEFAULT_SCANNER_HARDWARE = "default_scanner_hardware"; 101 // public static final String DEFAULT_PRINTROBOT_HARDWARE = "default_print_robot_hardware"; 102 // 103 // private static final List<String> defaultNames = null; 104 // 86 105 87 /** 106 88 This filter will limit a query to only return projects … … 469 451 470 452 /** 471 Sets default item.453 Sets item as default for project. 472 454 473 455 @param dc The <code>DbControl</code> which will be used for 474 456 permission checking and database access. 475 @param defaultItem The {@link net.sf.basedb.core.BasicItem} to set as default. 457 @param defaultItem The {@link net.sf.basedb.core.BasicItem} to set as default. 458 Use null when to remove a default value. 459 @param defaultType The {@link Default} to be set. 476 460 */ 477 461 public void setDefaultItem(DbControl dc, BasicItem defaultItem, Default defaultType) … … 480 464 if (defaultItem == null) 481 465 { 482 AnyToAny.unlinkFrom(dc, this, defaultType.getName());466 AnyToAny.unlinkFrom(dc, this, lnkName); 483 467 } 484 468 else … … 493 477 494 478 /** 495 Gets the project's default item of a certain <code>itemType</code>.479 Gets the project's default item of a certain itemType defined in <code>defaultType</code>. 496 480 If no item of the specified type is found this will return Null 497 481 498 482 @param dc The <code>DbControl</code> which will be used for 499 483 permission checking and database access. 500 @param itemType The {@linknet.sf.basedb.core.Item} type is expected to be.. 501 @param linkName The link name that the default item has been saved as. 502 @return A BasicItem or null if no item of <code>itemType. 484 @param defaultType The project's <code>Default</code> to get. 485 @return A BasicItem or null if no item was found. 503 486 */ 504 487 public BasicItem getDefaultItem(DbControl dc, Default defaultType) … … 589 572 590 573 public enum Default 591 { 574 { 575 SOFTWARE("default_software", "Software", Item.SOFTWARE, null), 576 ARRAYDESIGN("default_arraydesign", "Array design", Item.ARRAYDESIGN, null), 577 HYBRIDIZATION_HARDWARE("default_hybridization_hardware", "Hybridization station", Item.HARDWARE, HardwareType.HYBRIDIZATION_STATION), 578 SCANNER_HARDWARE("default_scanner_hardware", "Scanner", Item.HARDWARE, HardwareType.SCANNER), 579 PRINTROBOT_HARDWARE("default_print_robot_hardware", "Print robot", Item.HARDWARE, HardwareType.PRINT_ROBOT), 592 580 SCANNING_PROTOCOL("default_scanning_protocol", "Scanning protocol", Item.PROTOCOL, ProtocolType.SCANNING), 593 581 SAMPLING_PROTOCOL("default_sampling_protocol", "Sampling protocol", Item.PROTOCOL, ProtocolType.SAMPLING), … … 595 583 LABELING_PROTOCOL("default_labeling_protocol", "Labeling protocol", Item.PROTOCOL, ProtocolType.LABELING), 596 584 HYBRIDIZATION_PROTOCOL("default_hybridization_protocol", "Hybridization protocol", Item.PROTOCOL, ProtocolType.HYBRIDIZATION), 597 FEATURE_EXTRACTION_PROTOCOL("default_feature_extraction_protocol", "Feat ureextraction protocol", Item.PROTOCOL, ProtocolType.FEATURE_EXTRACTION),585 FEATURE_EXTRACTION_PROTOCOL("default_feature_extraction_protocol", "Feat. extraction protocol", Item.PROTOCOL, ProtocolType.FEATURE_EXTRACTION), 598 586 POOLING_PROTOCOL("default_pooling_protocol", "Pooling protocol", Item.PROTOCOL, ProtocolType.POOLING), 599 PRINTING_PROTOCOL("default_printing_protocol", "Printing protocol", Item.PROTOCOL, ProtocolType.PRINTING), 600 SOFTWARE("default_software", "Software", Item.SOFTWARE, null), 601 ARRAYDESIGN("default_arraydesign", "Array design", Item.ARRAYDESIGN, null), 602 HYBRIDIZATION_HARDWARE("default_hybridization_hardware", "Hybridization station", Item.HARDWARE, HardwareType.HYBRIDIZATION_STATION), 603 SCANNER_HARDWARE("default_scanner_hardware", "Scanner", Item.HARDWARE, HardwareType.SCANNER), 604 PRINTROBOT_HARDWARE("default_print_robot_hardware", "Print robot", Item.HARDWARE, HardwareType.PRINT_ROBOT); 587 PRINTING_PROTOCOL("default_printing_protocol", "Printing protocol", Item.PROTOCOL, ProtocolType.PRINTING); 605 588 606 589 private String name; … … 609 592 private String type; 610 593 611 // private static final Map<String, String>typeMapping = new HashMap<String, String>();612 // private static final Map<Item, String>itemMapping = new HashMap<Item, String>();613 614 // static615 // {616 // for (Default d : Default.values())617 // {618 // String s = null;619 // if (d.getType() != null)620 // {621 // s = typeMapping.put(d.getType(), d.getName());622 // assert s == null : "Another name for type "+d.getType()+" already exists: " + s;623 // }624 // if (d.getItemType() != null)625 // {626 // s = itemMapping.put(d.getItemType(), d.getName());627 // assert s == null : "Another name for item "+d.getItemType()+" already exists: " + s;628 // }629 // }630 // }631 632 594 private Default(String name, String shortName, Item itemType, String type) 633 595 { … … 657 619 return type; 658 620 } 659 //660 // public static String fromType(String type)661 // {662 // String s;663 // s = typeMapping.get(type);664 // assert s != null : "name == null for type " + type;665 // return s;666 // }667 //668 // public static String fromItem(Item itemType)669 // {670 // String s;671 // s = itemMapping.get(itemType);672 // assert s != null : "name == null for item " + itemType.toString();673 // return s;674 // }675 621 } 676 622 } -
trunk/www/include/scripts/main.js
r2907 r2939 369 369 this.controllers['BIOSOURCE'] = { url:'biomaterials/biosources/index.jsp', width:800, height:500 }; 370 370 this.controllers['MESSAGE'] = { url:'my_base/messages/index.jsp', width:600, height:420, popup:true, edit:false }; 371 this.controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:5 40, height:400 };371 this.controllers['PROJECT'] = { url:'my_base/projects/index.jsp', width:570, height:400 }; 372 372 this.controllers['FILE'] = { url:'filemanager/index.jsp', width:500, height:360 }; 373 373 this.controllers['DIRECTORY'] = { url:'filemanager/directories/index.jsp', width:450, height:340, xpopup:true }; -
trunk/www/my_base/projects/edit_project.jsp
r2928 r2939 27 27 --%> 28 28 <%@ page 29 import="net.sf.basedb.core.ArrayDesign" 29 30 import="net.sf.basedb.core.SessionControl" 30 31 import="net.sf.basedb.core.BasicItem" 31 32 import="net.sf.basedb.core.DbControl" 33 import="net.sf.basedb.core.Hardware" 32 34 import="net.sf.basedb.core.Item" 33 35 import="net.sf.basedb.core.ItemContext" … … 35 37 import="net.sf.basedb.core.Permission" 36 38 import="net.sf.basedb.core.Project" 39 import="net.sf.basedb.core.Protocol" 37 40 import="net.sf.basedb.core.User" 38 41 import="net.sf.basedb.core.Group" … … 40 43 import="net.sf.basedb.core.ItemResultList" 41 44 import="net.sf.basedb.core.PermissionDeniedException" 45 import="net.sf.basedb.core.Software" 42 46 import="net.sf.basedb.core.BaseException" 43 47 import="net.sf.basedb.core.query.Orders" … … 91 95 // Query to retrieve user members 92 96 ItemQuery<User> userQuery = null; 97 98 // Load recently used items 99 List<Protocol> recentProtocol = (List<Protocol>)cc.getRecent(dc, Item.PROTOCOL); 100 List<Software> recentSoftware = (List<Software>)cc.getRecent(dc, Item.SOFTWARE); 101 List<Hardware> recentHardware = (List<Hardware>)cc.getRecent(dc, Item.HARDWARE); 102 List<ArrayDesign> recentArrayDesign = (List<ArrayDesign>)cc.getRecent(dc, Item.ARRAYDESIGN); 103 93 104 94 105 if (itemId == 0) … … 119 130 120 131 <base:page type="popup" title="<%=title%>"> 121 <base:head scripts="tabcontrol.js,linkitems.js " styles="tabcontrol.css,parameters.css">132 <base:head scripts="tabcontrol.js,linkitems.js,parameters.js" styles="tabcontrol.css,parameters.css"> 122 133 <script language="JavaScript"> 123 134 // Validate the "Project" tab … … 170 181 for (Project.Default d : Project.Default.values()) 171 182 { 183 BasicItem defaultValue = null; 184 int valueId = 0; 172 185 String icon = ""; 173 186 if (project != null) 174 187 { 175 BasicItemdefaultValue = project.getDefaultItem(dc, d);188 defaultValue = project.getDefaultItem(dc, d); 176 189 if (defaultValue != null) 177 190 { 191 valueId = defaultValue.getId(); 178 192 icon = "notrequired_values.gif"; 179 193 } … … 191 205 sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+d.getShortName()+"\">"); 192 206 sb.append(icon+"<span class=\"label\">"+d.getShortName()+"</span></div>\n"); 193 } 207 %> 208 var values = new Array(); 209 values[values.length] = <%=valueId%>; 210 var di = new Parameter('<%=d.getName()%>', '<%=HTML.javaScriptEncode(d.getShortName())%>', 1, false, false, values); 211 <% 212 } 213 // TODO Set default RawDataType 194 214 %> 195 215 } … … 226 246 } 227 247 %> 228 } 229 var oldValueDiv; 230 function defaultItemOnClick(defaultname) 231 { 232 233 } 248 } 234 249 function correctPermissions(checked) 235 250 { … … 357 372 Link.addItem(document.forms['project'].members, item); 358 373 } 374 var oldValueDiv; 375 function defaultItemOnClick(defaultName) 376 { 377 var frm = document.forms['project']; 378 if (oldValueDiv) Main.hide(oldValueDiv); 379 380 var pp = Parameters.allParameters['ID'+defaultName]; 381 setSelectedParameter(pp, defaultName); 382 oldValueDiv = 'value_'+pp.name+'_div'; 383 Main.show(oldValueDiv); 384 385 var valueElement = frm['value_'+pp.name]; 386 if (valueElement.focus) valueElement.focus(); 387 388 389 } 390 var selectedParameter = null; 391 var selectedParameterName = null; 392 function getSelectedParameter() 393 { 394 return selectedParameter; 395 } 396 function setSelectedParameter(parameter, name) 397 { 398 if (selectedParameter != null) 399 { 400 Main.removeClass(document.getElementById('prompt_'+selectedParameter.name), 'selected'); 401 } 402 selectedParameter = parameter; 403 selectedParameterName = name; 404 if (selectedParameter != null) 405 { 406 Main.addClass(document.getElementById('prompt_'+selectedParameter.name), 'selected'); 407 } 408 } 409 function updateSelectedStyle() 410 { 411 var pp = getSelectedParameter(); 412 var icon = document.getElementById('icon_'+pp.name); 413 var gif = getRoot()+'images/'; 414 if (pp.values[0] == 0) 415 { 416 gif += 'notrequired_novalues.gif'; 417 } 418 else 419 { 420 gif += 'notrequired_values.gif'; 421 } 422 icon.src = gif; 423 } 424 function defaultItemOnChange(value) 425 { 426 var pp = getSelectedParameter(); 427 if (value == null || value == '') 428 { 429 pp.removeValue(0); 430 } 431 else 432 { 433 pp.updateValue(0, value); 434 } 435 updateSelectedStyle(); 436 } 437 function selectDefaultItemOnClick(url) 438 { 439 var frm = document.forms['project']; 440 var select_id = 'value_' + getSelectedParameter().name; 441 var selectlist = frm[select_id]; 442 if (selectlist.length > 1) 443 { 444 var id = Math.abs(parseInt(selectlist[1].value)); 445 url += '&item_id='+id; 446 } 447 Main.openPopup(url, 'SelectDefaultItem', 1000, 700); 448 } 449 function setDefaultItemCallback(id, name) 450 { 451 var frm = document.forms['project']; 452 var select_id = 'value_' + getSelectedParameter().name; 453 var selectlist = frm[select_id]; 454 if (selectlist.length < 2) 455 { 456 Forms.addListOption(selectlist, 1, new Option()); 457 } 458 selectlist[1].value = id; 459 selectlist[1].text = name; 460 selectlist.selectedIndex = 1; 461 defaultItemOnChange(selectlist[1].value); 462 } 359 463 function removeOnClick() 360 464 { … … 442 546 <tr valign="top"> 443 547 <td width="50%"> 444 <b>Values</b><br>445 <div class="parameterlist" style="height: <%=(int)(scale*230)%>px; margin-top: 4px;">446 <%=sb.toString()%>447 </div>448 <base:icon image="hasvalues.gif" /> = Has value548 <b>Project default items</b><br> 549 <div class="parameterlist" style="height: <%=(int)(scale*230)%>px; margin-top: 4px;"> 550 <%=sb.toString()%> 551 </div> 552 <base:icon image="hasvalues.gif" /> = Has value 449 553 </td> 450 554 <td width="50%"> 451 555 <br> 556 <% 557 for (Project.Default d : Project.Default.values()) 558 { 559 String inputName = "value_" + d.getName(); 560 if (d.getItemType() != null) 561 { 562 String selectDefaultItemOnClick = ""; 563 String defaultItemOnChange = ""; 564 List recentItems = null; 565 BasicItem currentItem = project != null ? project.getDefaultItem(dc, d) : null; 566 boolean readCurrentItem = sc.hasPermission(Permission.READ, d.getItemType()); 567 if (d.getItemType() == Item.PROTOCOL) 568 { 569 int typeId = SystemItems.getId(d.getType()); 570 String url = "'../../admin/protocols/index.jsp?ID=" + ID + 571 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:protocolType=" + typeId + "'"; 572 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 573 recentItems = recentProtocol; 574 } 575 else if (d.getItemType() == Item.HARDWARE) 576 { 577 int typeId = SystemItems.getId(d.getType()); 578 String url = "'../../admin/hardware/index.jsp?ID=" + ID + 579 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback&filter:INT:hardwareType=" + typeId + "'"; 580 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 581 } 582 else if (d.getItemType() == Item.SOFTWARE) 583 { 584 String url = "'../../admin/software/index.jsp?ID=" + ID + 585 "&cmd=UpdateContext&mode=selectone&callback=setDefaultItemCallback'"; 586 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 587 } 588 else if (d.getItemType() == Item.ARRAYDESIGN) 589 { 590 String url = "'../../lims/arraydesigns/index.jsp?ID=" + ID + 591 "&mode=selectone&callback=setDefaultItemCallback'"; 592 selectDefaultItemOnClick = "selectDefaultItemOnClick(" + url + ")"; 593 } 594 %> 595 <div id="<%=inputName%>_div" style="display: none;"> 596 <table> 597 <tr> 598 <td class="prompt"><%=d.getShortName()%></td> 599 </tr> 600 601 <tr> 602 <td> 603 <base:select 604 id="<%=inputName%>" 605 clazz="selectionlist" 606 required="false" 607 current="<%=currentItem%>" 608 denied="<%=!readCurrentItem%>" 609 recent="<%=recentItems%>" 610 newitem="<%=project == null%>" 611 onselect="<%=selectDefaultItemOnClick%>" 612 onchange = 'defaultItemOnChange(this[this.selectedIndex].value)' 613 /> 614 </td> 615 </tr> 616 </table> 617 </div> 618 <% 619 } 620 } 621 %> 452 622 </td> 453 623 </tr> -
trunk/www/my_base/projects/index.jsp
r2918 r2939 26 26 --%> 27 27 <%@ page 28 import="net.sf.basedb.core.BasicItem" 28 29 import="net.sf.basedb.core.SessionControl" 29 30 import="net.sf.basedb.core.DbControl" … … 166 167 } 167 168 } 169 170 // Default tab 171 for (Project.Default d : Project.Default.values()) 172 { 173 String selectDefault = "value_"+d.getName(); 174 int selectId = Values.getInt(request.getParameter(selectDefault), -1); 175 if (selectId >= 0) 176 { 177 BasicItem item = null; 178 item = selectId == 0 ? null : d.getItemType().getById(dc, selectId); 179 project.setDefaultItem(dc, item, d); 180 } 181 } 168 182 169 183 dc.commit();
Note: See TracChangeset
for help on using the changeset viewer.