Changeset 5714
- Timestamp:
- Sep 5, 2011, 2:10:42 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/clients/web/net/sf/basedb/clients/web/Base.java
r5713 r5714 32 32 import net.sf.basedb.core.File; 33 33 import net.sf.basedb.core.FileSet; 34 import net.sf.basedb.core.FileSetMember;35 34 import net.sf.basedb.core.FileStoreEnabled; 36 35 import net.sf.basedb.core.ItemSubtype; 37 36 import net.sf.basedb.core.Location; 38 import net.sf.basedb.core.Path;39 37 import net.sf.basedb.core.Platform; 40 38 import net.sf.basedb.core.PlatformVariant; … … 1466 1464 { 1467 1465 String param = names.nextElement(); 1468 if (param.startsWith("datafile.")) 1469 { 1470 /* 1471 int dataFileTypeId = Values.getInt(param.substring(9)); 1472 DataFileType dft = DataFileType.getById(dc, dataFileTypeId); 1473 String filePath = Values.getStringOrNull(request.getParameter(param)); 1474 if (fileSet == null) fileSet = item.getFileSet(); 1475 if (filePath == null) 1476 { 1477 // TODO #1604 1478 // fileSet.removeMember(dft); 1479 } 1480 else 1481 { 1482 File file = File.getByPath(dc, new Path(filePath, Path.Type.FILE), false); 1483 fileSet.setMember(file, dft); 1484 if (cc != null) 1485 { 1486 cc.setRecent(file, dft.getExternalId(), maxRecent); 1487 } 1488 } 1489 */ 1490 } 1491 else if (param.startsWith("setfile.")) 1466 if (param.startsWith("setfile.")) 1492 1467 { 1493 1468 int dataFileTypeId = Values.getInt(param.substring(8)); … … 1520 1495 else if (param.startsWith("removefile.")) 1521 1496 { 1522 FileSetMember member = FileSetMember.getById(dc, Values.getInt(request.getParameter(param))); 1497 int dataFileTypeId = Values.getInt(param.substring(11)); 1498 Integer[] fileId = Values.getInt(request.getParameterValues(param)); 1499 DataFileType dft = DataFileType.getById(dc, dataFileTypeId); 1523 1500 if (fileSet == null) fileSet = item.getFileSet(); 1524 fileSet.removeMember(member); 1501 for (Integer id : fileId) 1502 { 1503 File file = File.getById(dc, id); 1504 fileSet.removeMember(file, dft); 1505 } 1525 1506 } 1526 1507 } 1527 1508 if (validate) 1528 1509 { 1510 if (fileSet == null) fileSet = item.getFileSet(); 1529 1511 fileSet.validate(dc); 1530 1512 } -
trunk/src/core/net/sf/basedb/core/FileSet.java
r5713 r5714 444 444 } 445 445 446 447 /** 448 Remove a file as a member from the file set. 449 450 @param file The file to remove 451 @param type The type of the file 452 @return TRUE if a member was removed, FALSE if not 453 @throws InvalidUseOfNullException If file or type is null 454 @throws PermissionDeniedException If the logged in user doesn't 455 have write permission for this file set 456 @since 3.0 457 */ 458 public boolean removeMember(File file, DataFileType type) 459 { 460 checkPermission(Permission.WRITE); 461 if (file == null) throw new InvalidUseOfNullException("file"); 462 if (type == null) throw new InvalidUseOfNullException("type"); 463 464 DbControl dc = getDbControl(); 465 int typeId = type.getId(); 466 int fileId = file.getId(); 467 Iterator<FileSetMemberData> it = getData().getMembers().iterator(); 468 // Keep track of removed members so that we can invoke metadata extensions 469 List<ValidatingFileSetMember> removed = new ArrayList<ValidatingFileSetMember>(); 470 while (it.hasNext()) 471 { 472 FileSetMemberData member = it.next(); 473 if (member.getDataFileType().getId() == typeId && member.getFile().getId() == fileId) 474 { 475 it.remove(); 476 if (member.getId() > 0) 477 { 478 FileSetMember m = dc.getItem(FileSetMember.class, member); 479 dc.deleteItem(m); 480 removed.add(new ValidatingFileSetMember(m)); 481 } 482 } 483 } 484 if (removed.size() > 0) 485 { 486 // Create context and invoke the extensions system 487 ExtensionsInvoker<ValidationAction> invoker = getInvoker(dc); 488 489 // Reset the metadata 490 invoker.render(new ResetMetadataRenderer(removed)); 491 } 492 return removed.size() > 0; 493 } 494 495 446 496 /** 447 497 Remove all member files of the given type. … … 469 519 { 470 520 it.remove(); 471 FileSetMember m = dc.getItem(FileSetMember.class, member); 472 dc.deleteItem(m); 473 removed.add(new ValidatingFileSetMember(m)); 521 if (member.getId() > 0) 522 { 523 FileSetMember m = dc.getItem(FileSetMember.class, member); 524 dc.deleteItem(m); 525 removed.add(new ValidatingFileSetMember(m)); 526 } 474 527 } 475 528 } -
trunk/www/common/datafiles/select_files.jsp
r5713 r5714 165 165 { 166 166 // IE. 167 div.onclick = hideVisibleRecentFilesDiv; 168 } 169 167 document.body.onclick = hideVisibleRecentFilesDiv; 168 } 170 169 } 171 170 172 171 var lastFileTypeId; 173 var updateCheckboxes= false;174 function addFilesOnClick(fileTypeId, extension, updateCheck)172 var lastHasValidator = false; 173 function addFilesOnClick(fileTypeId, extension, hasValidator) 175 174 { 176 175 var frm = document.forms['datafiles']; 177 updateCheckboxes = updateCheck;178 176 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectMultiple&callback=addFileCallback'; 179 177 if (extension) … … 186 184 } 187 185 lastFileTypeId = fileTypeId; 186 lastHasValidator = hasValidator; 188 187 Main.openPopup(url, 'SelectFile', 1000, 700); 189 188 } 190 189 function addFileCallback(fileId, path) 191 190 { 192 addFile(lastFileTypeId, fileId, path); 193 } 194 function removeFilesOnClick(inputName, updateCheck) 195 { 196 } 197 198 function browseOnClick(fileTypeId, extension, updateCheck) 191 addFile(lastFileTypeId, fileId, path, lastHasValidator); 192 } 193 194 function browseOnClick(fileTypeId, extension, hasValidator) 199 195 { 200 196 var frm = document.forms['datafiles']; 201 updateCheckboxes = updateCheck;202 197 var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback'; 203 198 if (extension) … … 210 205 } 211 206 lastFileTypeId = fileTypeId; 207 lastHasValidator = hasValidator; 212 208 Main.openPopup(url, 'SelectFile', 1000, 700); 213 209 } 214 210 function setFileCallback(fileId, path) 215 211 { 216 setFile(lastFileTypeId, fileId, path );217 } 218 function setFile(fileTypeId, fileId, path )212 setFile(lastFileTypeId, fileId, path, lastHasValidator); 213 } 214 function setFile(fileTypeId, fileId, path, hasValidator) 219 215 { 220 216 var frm = document.forms['datafiles']; 221 document.getElementById('filelist.'+fileTypeId+'.file').innerHTML = path; 217 var fileDiv = document.getElementById('filelist.'+fileTypeId+'.file'); 218 if (fileId) 219 { 220 fileDiv.innerHTML = '<div id="filelist.'+fileTypeId+'.'+fileId+'">'+path+'</div>'; 221 } 222 else 223 { 224 fileDiv.innerHTML = ''; 225 } 226 if (hasValidator) frm['datafiles.validate'].checked = true; 222 227 new FileAction('setfile', fileTypeId, fileId); 223 228 } 224 function addFile(fileTypeId, fileId, path) 225 { 229 function addFile(fileTypeId, fileId, path, hasValidator) 230 { 231 var frm = document.forms['datafiles']; 226 232 var fileDiv = document.getElementById('filelist.'+fileTypeId+'.'+fileId); 227 233 if (fileDiv) return; … … 229 235 fileDiv = document.createElement('div'); 230 236 fileDiv.id = 'filelist.'+fileTypeId+'.'+fileId; 231 fileDiv.innerHTML = path; 237 var html = path + ' <img border=0 class="icon" style="cursor: pointer;" title="Remove this file" '; 238 html += ' onclick="removeFileOnClick(event, '+fileTypeId+','+fileId+','+hasValidator+')" src="/trunk/images/remove.png">'; 239 fileDiv.innerHTML = html; 232 240 document.getElementById('filelist.'+fileTypeId+'.file').appendChild(fileDiv); 233 Main.hide('filelist.'+fileTypeId+'.0');241 if (hasValidator) frm['datafiles.validate'].checked = true; 234 242 new FileAction('addfile', fileTypeId, fileId); 235 243 } 236 function removeOnClick(fileTypeId, updateCheck) 237 { 238 document.getElementById('filelist.'+fileTypeId+'.file').innerHTML = '<i>- not selected -</i>'; 239 new FileAction('setfile', fileTypeId, 0); 240 } 241 242 /* 243 function fileOnChange(inputName, updateCheckbox) 244 function removeFileOnClick(event, fileTypeId, fileId, hasValidator) 244 245 { 245 246 var frm = document.forms['datafiles']; 246 var validateCheckbox = frm['datafiles.validate']; 247 248 // Check boxes should be updated if the data file type 249 //supports validation or metadata-extraction 250 if (updateCheckbox) 251 { 252 if (frm[inputName].value != '' || frm[inputName].length > 0) 253 { 254 // Data filetype supports validation 255 if (validateCheckbox) 256 { 257 if (validateCheckbox.disabled) validateCheckbox.disabled = false; 258 validateCheckbox.checked = "1"; 259 } 260 } 261 } 262 } 263 */ 264 265 function writeFileActions() 266 { 267 Main.debug(fileActions.length, true); 268 for (var i = 0; i < fileActions.length; i++) 269 { 270 var action = fileActions[i]; 271 Main.debug(action.action + ':' + action.fileTypeId + '='+action.fileId); 247 var fileDiv = document.getElementById('filelist.'+fileTypeId+'.'+fileId); 248 document.getElementById('filelist.'+fileTypeId+'.file').removeChild(fileDiv); 249 if (hasValidator) frm['datafiles.validate'].checked = true; 250 new FileAction('removefile', fileTypeId, fileId); 251 if (event.stopPropagation) 252 { 253 event.stopPropagation(); 254 } 255 else 256 { 257 event.cancelBubble = true; 272 258 } 273 259 } … … 280 266 this.fileId = fileId; 281 267 282 if (action == 'setfile') 283 { 284 for (var i = 0; i < fileActions.length; i++) 268 269 for (var i = fileActions.length-1; i >= 0; i--) 270 { 271 var other = fileActions[i]; 272 273 var remove = false; 274 if (action == 'setfile') 285 275 { 286 var other = fileActions[i]; 287 if (other.action == this.action && other.fileTypeId == this.fileTypeId) 288 { 289 fileActions[i] = this; 290 return; 291 } 276 // Remove all other actions for the given file type 277 remove = other.fileTypeId == this.fileTypeId; 292 278 } 293 fileActions[fileActions.length] = this; 294 } 295 else if (action == 'addfile') 296 { 297 for (var i = 0; i < fileActions.length; i++) 279 else 298 280 { 299 var other = fileActions[i]; 300 if (other.action == this.action && other.fileTypeId == this.fileTypeId && other.fileId == this.fileId) 301 { 302 return; 303 } 281 // Remove all other actions for the given file type+file 282 remove = other.fileTypeId == this.fileTypeId && other.fileId == this.fileId; 304 283 } 305 fileActions[fileActions.length] = this; 306 } 307 } 308 309 function writeFileActionsToForm(frm) 310 { 311 alert(fileActions.length); 284 if (remove) fileActions.splice(i, 1); 285 } 286 287 fileActions[fileActions.length] = this; 288 } 289 290 function writeFileActionsToForm(toForm) 291 { 292 var frm = document.forms['datafiles']; 293 Forms.createHidden(toForm, 'datafiles.validate', frm['datafiles.validate'].checked ? 1 : 0); 312 294 for (var i = 0; i < fileActions.length; i++) 313 295 { 314 296 var action = fileActions[i]; 315 Forms.createHidden( frm, action.action + '.' + action.fileTypeId, action.fileId);297 Forms.createHidden(toForm, action.action + '.' + action.fileTypeId, action.fileId); 316 298 } 317 299 } … … 334 316 335 317 visibleRecentFilesDiv = recentDiv; 336 event.cancelBubble = true; 337 event.stopPropagation(); 338 } 339 340 function selectRecentFile(fileTypeId, fileId) 318 if (event.stopPropagation) 319 { 320 event.stopPropagation(); 321 } 322 else 323 { 324 event.cancelBubble = true; 325 } 326 } 327 328 function selectRecentFile(fileTypeId, fileId, allowMultiple, hasValidator) 341 329 { 342 330 var path = document.getElementById('recentfile.'+fileTypeId+'.'+fileId).innerHTML; 343 setFile(fileTypeId, fileId, path); 331 if (allowMultiple) 332 { 333 addFile(fileTypeId, fileId, path, hasValidator); 334 } 335 else 336 { 337 setFile(fileTypeId, fileId, path, hasValidator); 338 } 344 339 } 345 340 … … 372 367 } 373 368 .filelist .file { 374 369 cursor: pointer; 375 370 } 376 371 .filelist .required { … … 392 387 .recentfiles .recentfile { 393 388 padding: 2px; 394 border-bottom: 1px dotted #e0e0e0; 389 background: #f0f0f0; 390 border-bottom: 1px dotted #d0d0d0; 395 391 } 396 392 .recentfiles .recentfile:hover { 397 393 cursor: pointer; 398 background: # e0e0e0;394 background: #d0d0d0; 399 395 padding: 2px; 396 } 397 .filelist .member { 398 xbackground: #ff0000; 400 399 } 401 400 </style> … … 406 405 <div id="filelist" class="filelist" style="height: <%=(int)(scale*320)%>px; width:100%"> 407 406 <% 408 boolean hasNonPlatformFiles = true;407 boolean hasNonPlatformFiles = false; 409 408 boolean activateCheckBoxes = false; 410 boolean validationSupport = true;409 boolean validationSupport = false; 411 410 if (fileTypes.size() == 0) 412 411 { … … 464 463 String extension = dft.getExtension(); 465 464 boolean hasValidator = dft.hasActiveValidator(dc); 466 boolean affectCheckboxes = hasValidator;467 465 validationSupport |= hasValidator; 468 466 List<FileSetMember> files = members.get(dft); … … 470 468 %> 471 469 <tr class="item <%=isRequired ? "required" : "" %>" 472 id="filelist.<%=dftId%>" 473 onclick="itemOnClick(<%=dftId%>)"> 474 <td class="filetype" 470 id="filelist.<%=dftId%>"> 471 <td class="filetype" valign="top" 475 472 id="filelist.<%=dftId%>.label" 476 473 title="<%=fullLabel == label ? "" : HTML.encodeTags(fullLabel)%>" … … 481 478 hasNonPlatformFiles = true; 482 479 %> 483 <base:icon image="warning.gif" tooltip="This file is not part of the platform/subtype" /> 480 <base:icon image="warning.gif" 481 tooltip="This file is not part of the platform/subtype" /> 484 482 <% 485 483 } 486 484 %> 487 485 </td> 488 <td class="file" id="filelist.<%=dftId%>.file"> 486 <td class="file" id="filelist.<%=dftId%>.file" 487 onclick="<%="recentFilesOnClick(event, " + dftId + ")"%>"> 489 488 <% 490 if (files == null || files.size() == 0) 491 { 492 %> 493 <div id="filelist.<%=dftId%>.0"> 494 <i>- not selected -</i> 495 </div> 496 <% 497 } 498 else 489 if (files != null && files.size() > 0) 499 490 { 500 491 for (FileSetMember fm : files) … … 502 493 File file = fm.getFile(); 503 494 %> 504 <div id="filelist.<%=dftId%>.<%=file.getId() %>">495 <div id="filelist.<%=dftId%>.<%=file.getId()%>" class="member"> 505 496 <%=file.getPath() %> 497 <base:icon image="remove.png" visible="<%=allowMultiple %>" 498 tooltip="Remove this file" 499 onclick="<%="removeFileOnClick(event, " + dftId + "," + file.getId() + "," + hasValidator + ")" %>" 500 /> 506 501 </div> 507 502 <% … … 518 513 onclick="<%="recentFilesOnClick(event, " + dftId + ")"%>" 519 514 /> 520 <div id="recentfiles.<%=dftId%>" style="display: none;" class="recentfiles"> 515 <div id="recentfiles.<%=dftId%>" style="display: none;" class="recentfiles"> 516 <div class="recentfile" 517 onclick="selectRecentFile(<%=dftId%>, 0, false, <%=hasValidator%>)" 518 id="recentfile.<%=dftId%>.0" 519 ><i>- clear -</i></div> 520 <% 521 for (File recent : recentFiles) 522 { 523 %> 521 524 <div class="recentfile" 522 onclick="selectRecentFile(<%=dftId%>, 0)"523 id="recentfile.<%=dftId%>. 0"524 >< i>- not selected -</i></div>525 onclick="selectRecentFile(<%=dftId%>, <%=recent.getId()%>, <%=allowMultiple ? 1 : 0 %>, <%=hasValidator%>)" 526 id="recentfile.<%=dftId%>.<%=recent.getId()%>" 527 ><%=HTML.encodeTags(recent.getPath().toString())%></div> 525 528 <% 526 for (File recent : recentFiles) 527 { 528 %> 529 <div class="recentfile" 530 onclick="selectRecentFile(<%=dftId%>, <%=recent.getId()%>)" 531 id="recentfile.<%=dftId%>.<%=recent.getId()%>" 532 ><%=HTML.encodeTags(recent.getPath().toString())%></div> 533 <% 534 } 535 %> 536 </div> 529 } 530 %> 531 </div> 537 532 </td> 538 533 <td class="fileaction"> 539 534 <base:icon image="add.png" 540 onclick="<%="addFilesOnClick("+dftId+", '" + HTML.javaScriptEncode(extension) + "', "+ affectCheckboxes+ ")"%>"535 onclick="<%="addFilesOnClick("+dftId+", '" + HTML.javaScriptEncode(extension) + "', "+ hasValidator + ")"%>" 541 536 visible="<%=allowMultiple %>" 542 537 /> 543 538 <base:icon image="browse.png" 544 onclick="<%="browseOnClick("+dftId+", '" + HTML.javaScriptEncode(extension) + "', "+ affectCheckboxes+ ")"%>"539 onclick="<%="browseOnClick("+dftId+", '" + HTML.javaScriptEncode(extension) + "', "+ hasValidator + ")"%>" 545 540 visible="<%=!allowMultiple%>" 546 541 /> 547 542 </td> 548 <!--549 <td class="fileaction">550 <base:icon image="remove.png"551 id="remove"552 onclick="<%="removeOnClick("+dftId+", "+ affectCheckboxes + ")"%>"553 visible="<%=!allowMultiple %>"554 />555 </td>556 -->557 543 </tr> 558 544 <% … … 573 559 { 574 560 %> 575 <b>Validate</b> 576 <input type="checkbox" value="1" disabled name="datafiles.validate"> 561 <span title="Enabled this check box to validate and extract metadata from selected files"> 562 <b>Validate files</b> 563 <input type="checkbox" value="1" name="datafiles.validate"> 564 </span> 577 565 <% 578 566 } … … 606 594 </table> 607 595 </form> 608 <a href="javascript:writeFileActions()">See</a>609 596 </base:body> 610 597 </base:page> -
trunk/www/include/scripts/main.js
r5685 r5714 1981 1981 // Only a single item in the list 1982 1982 radio.checked = radio.value == value && !radio.disabled; 1983 returnValue = 0; 1983 1984 } 1984 1985 return returnValue; -
trunk/www/include/scripts/platforms.js
r5698 r5714 42 42 43 43 44 this.addDataFilesToForm = function(theFrame, frm)45 {46 var dataFilesFrm = theFrame.document.forms['datafiles'];47 for (var i = 0; i < dataFilesFrm.length; i++)48 {49 var input = dataFilesFrm[i];50 if (!input.disabled)51 {52 if (input.type == 'text')53 {54 Forms.createHidden(frm, input.name, input.value);55 }56 else if (input.type == 'checkbox')57 {58 Forms.createHidden(frm, input.name, input.checked ? input.value : '');59 }60 }61 }62 }63 64 44 this.getPlatformById = function(id) 65 45 { -
trunk/www/include/scripts/table.js
r5713 r5714 418 418 { 419 419 var index = Forms.checkRadio(frm.item_id, itemId); 420 returnFunction(frm.item_id [index]);420 returnFunction(frm.item_id.length ? frm.item_id[index] : frm.item_id); 421 421 } 422 422 else if (mode == 'selectmultiple' || mode == 'selectmultiplenobuttons') -
trunk/www/lims/arraydesigns/edit_design.jsp
r5687 r5714 109 109 catch (Throwable t) 110 110 {} 111 if (currentPlatform == null && defaultPlatforms .size() > 0)111 if (currentPlatform == null && defaultPlatforms != null && defaultPlatforms.size() > 0) 112 112 { 113 113 currentPlatform = defaultPlatforms.get(0); 114 114 } 115 if (currentVariant == null && defaultVariants .size() > 0)115 if (currentVariant == null && defaultVariants != null && defaultVariants.size() > 0) 116 116 { 117 117 currentVariant = defaultVariants.get(0); … … 199 199 if (dataFilesLoaded) 200 200 { 201 Platforms.addDataFilesToForm(frames.datafiles,frm);201 frames.datafiles.writeFileActionsToForm(frm); 202 202 } 203 203 frm.submit(); -
trunk/www/views/derivedbioassays/edit_bioassay.jsp
r5713 r5714 297 297 if (dataFilesLoaded) 298 298 { 299 //Platforms.addDataFilesToForm(frames.datafiles, frm);300 299 frames.datafiles.writeFileActionsToForm(frm); 301 300 } -
trunk/www/views/rawbioassays/edit_rawbioassay.jsp
r5712 r5714 354 354 if (dataFilesLoaded) 355 355 { 356 Platforms.addDataFilesToForm(frames.datafiles,frm);356 frames.datafiles.writeFileActionsToForm(frm); 357 357 } 358 358 frm.submit();
Note: See TracChangeset
for help on using the changeset viewer.