Changeset 3947
- Timestamp:
- Nov 4, 2010, 4:08:34 PM (13 years ago)
- Location:
- trunk/client/servlet/src/org/proteios
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/servlet/src/org/proteios/action/file/InspectActiveSpectrumFile.java
r3945 r3947 1 1 /* 2 2 $Id$ 3 3 4 4 Copyright (C) 2009 Gregory Vincic 5 5 6 6 This file is part of Proteios. 7 7 Available at http://www.proteios.org/ 8 8 9 9 Proteios is free software; you can redistribute it and/or modify it 10 10 under the terms of the GNU General Public License as published by 11 11 the Free Software Foundation; either version 2 of the License, or 12 12 (at your option) any later version. 13 13 14 14 Proteios is distributed in the hope that it will be useful, but 15 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 17 General Public License for more details. 18 18 19 19 You should have received a copy of the GNU General Public License 20 20 along with this program; if not, write to the Free Software … … 85 85 private int itemsFrom = 0; 86 86 private boolean pageSelectedFromScroller = false; 87 87 88 88 /** 89 89 * Get the max number of results to show in list. … … 95 95 return this.maxResults; 96 96 } 97 97 98 98 /** 99 99 * Set the max number of results to show in list. … … 106 106 this.maxResults = maxResults; 107 107 } 108 108 109 109 /** 110 110 * Get the item number to start from in the list. … … 116 116 return this.itemsFrom; 117 117 } 118 118 119 119 /** 120 120 * Set the item number to start from in the list. … … 127 127 this.itemsFrom = itemsFrom; 128 128 } 129 129 130 130 /** 131 131 * Get flag indicating that page is selected from scroller. … … 137 137 return this.pageSelectedFromScroller; 138 138 } 139 139 140 140 /** 141 141 * Set flag indicating that page is selected from scroller. … … 148 148 this.pageSelectedFromScroller = pageSelectedFromScroller; 149 149 } 150 150 151 151 @Override 152 152 protected void runMe() … … 247 247 { 248 248 peakListTable.add(new Column("SpectrumIdOrderNumber3")); 249 /* Special fix to get to the right spectrum id if it is from an MGF title*/ 250 if (spectrumId != null && spectrumIdReader instanceof MgfFileReader) 249 // Special fix to get to the right spectrum id if it is from an MGF title 250 if (spectrumId != null && spectrumIdReader instanceof MgfFileReader) 251 { 252 if (!spectrumId.matches("^d+(\\s-\\s.*)?")) 251 253 { 252 if (!spectrumId.matches("^d+(\\s-\\s.*)?")) 254 spectrumId = spectrumId.trim(); 255 for (String s : spectrumIds) 253 256 { 254 spectrumId = spectrumId.trim(); 255 for (String s : spectrumIds) 257 String toMatch = s.substring(s.indexOf("-") + 2) 258 .trim(); 259 if (spectrumId.equals(toMatch)) 256 260 { 257 String toMatch = s.substring(s.indexOf("-") + 2) 258 .trim(); 259 if (spectrumId.equals(toMatch)) 261 log.debug("Found spectrum:"+s); 262 spectrumId = s; 263 setSessionAttribute(PlotFileSpectrum.VSPECTRUMID.getName(), spectrumId); 264 break; 265 } 266 } 267 } 268 } 269 } 270 else 271 { 272 peakListTable.add(new Column("Spectrum id")); 273 } 274 } 275 if (spectrumIds != null) 276 { 277 log.debug("spectrumIds.size() = " + spectrumIds.size()); 278 // Fetch scroller page selected 279 restoreScrollerState(); 280 log 281 .debug("getItemsFrom() = " + getItemsFrom() + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 282 if (!isPageSelectedFromScroller()) 283 { 284 // Adjust scroller page to include selected spectrum 285 if (spectrumId != null && !spectrumId.equals("")) 286 { 287 // find start of scroller page including selected spectrum 288 Integer currentIndex = fetchStringListItemIndex(spectrumId, 289 spectrumIds); 290 log.debug("currentIndex = " + currentIndex); 291 if (currentIndex != null && currentIndex >= 0) 292 { 293 int pageNo = currentIndex / getMaxResults(); 294 int tempStart = pageNo * getMaxResults(); 295 log 296 .debug("currentIndex = " + currentIndex + " pageNo = " + pageNo + " tempStart = " + tempStart); 297 // Set start index for displayed list 298 setItemsFrom(tempStart); 299 } 300 } 301 } 302 // Add scroller 303 int count = spectrumIds.size(); 304 if (count > getMaxResults()) 305 { 306 Scroller scroller = new Scroller(); 307 scroller.setFrom(getItemsFrom()); 308 scroller.setMax(getMaxResults()); 309 scroller.setTotalCount(count); 310 scroller.setScrollActionId(getActionFactory().getId( 311 ScrollTo.class)); 312 scroller.setTableConfActionId(getActionFactory().getId( 313 InspectActiveSpectrumFile.class)); 314 scroller.setDisplayActionId(getActionFactory().getId( 315 InspectActiveSpectrumFile.class)); 316 // scroller.put(FormFactory.VCLASSNAME, itemClass.getName()); 317 log.debug("scroller ScrollActionId = \"" + getActionFactory() 318 .getId(ScrollTo.class) + "\""); 319 log 320 .debug("scroller TableConfActionId = \"" + getActionFactory() 321 .getId(InspectActiveSpectrumFile.class) + "\""); 322 log.debug("scroller.getDisplayActionId() = \"" + scroller 323 .getDisplayActionId() + "\""); 324 // Add scroller to table 325 peakListTable.setScroller(scroller); 326 } 327 // Add scroller data 328 log.debug("getItemsFrom() = " + getItemsFrom()); 329 log.debug("getMaxResults() = " + getMaxResults()); 330 int scrollFrom = getItemsFrom(); 331 int scrollMaxResults = getMaxResults(); 332 TextField<Integer> scrollFromField = new TextField<Integer>( 333 Scroller.VFROM); 334 TextField<Integer> scrollMaxResultsField = new TextField<Integer>( 335 Scroller.VMAXRESULT); 336 scrollFromField.setValue(scrollFrom); 337 scrollMaxResultsField.setValue(scrollMaxResults); 338 peakListTable.add(scrollFromField); 339 peakListTable.add(scrollMaxResultsField); 340 // 341 // Add spectrum id field 342 TextField<String> spectrumIdField = new TextField<String>( 343 PlotFileSpectrum.VSPECTRUMID); 344 spectrumIdField.setHidden(true); 345 spectrumIdField.setValue(spectrumId); 346 peakListTable.add(spectrumIdField); 347 // 348 // Add mass cut-off low string field 349 TextField<String> massCutOffLowStrField = new TextField<String>( 350 PlotFileSpectrum.VMASSCUTOFFLOWSTR); 351 massCutOffLowStrField.setHidden(true); 352 massCutOffLowStrField.setValue(massCutoffLowStr); 353 peakListTable.add(massCutOffLowStrField); 354 // 355 // Add mass cut-off high string field 356 TextField<String> massCutOffHighStrField = new TextField<String>( 357 PlotFileSpectrum.VMASSCUTOFFHIGHSTR); 358 massCutOffHighStrField.setHidden(true); 359 massCutOffHighStrField.setValue(massCutoffHighStr); 360 peakListTable.add(massCutOffHighStrField); 361 // 362 // Add keep original spectrum flag field 363 TextField<Boolean> keepOriginalSpectrumField = new TextField<Boolean>( 364 VKEEPORIGINALSPECTRUM); 365 keepOriginalSpectrumField.setHidden(true); 366 keepOriginalSpectrumField.setValue(keepOriginalSpectrum); 367 peakListTable.add(keepOriginalSpectrumField); 368 // 369 // Create spectrum list to display 370 int itemStart = getItemsFrom(); 371 int itemStop = getItemsFrom() + getMaxResults(); 372 for (int i = itemStart; (i < spectrumIds.size() && i < itemStop); i++) 373 { 374 // log.debug("spectrumIds.get(" + i + ") = \"" + 375 // spectrumIds.get(i) + "\""); 376 // Add data 377 Row row = new Row(i); 378 row.addCell(new Cell<String>(spectrumIds.get(i))); 379 // Configure on-click row action to re-run this action with new 380 // spectrum id 381 ActionLink rowAction = getActionFactory().getActionLink( 382 InspectActiveSpectrumFile.class, "View"); 383 rowAction.addParameter(VSPECTRUMFILEID, fileId); 384 rowAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 385 spectrumIds.get(i)); 386 row.setActionLink(rowAction); 387 peakListTable.addRow(row); 388 } 389 // Show first spectrum as default 390 if (spectrumId == null || spectrumId.equals("")) 391 { 392 if (spectrumIds != null && spectrumIds.size() > 0) 393 { 394 // Plot first spectrum 395 spectrumId = spectrumIds.get(0); 396 } 397 } 398 } 399 /*********************************************************************** 400 * Spectrum plot 401 */ 402 PlotFileSpectrum plotFileSpectrum = new PlotFileSpectrum(); 403 ImageMap imageMap; 404 Image plotOriginal = null; 405 if (keepOriginalSpectrum) 406 { 407 plotOriginal = new Image(); 408 ActionLink viewOriginalAction = getActionFactory().getActionLink( 409 PlotFileSpectrum.class, "ViewOriginal"); 410 viewOriginalAction.addParameter(FormFactory.VID, fileId); 411 viewOriginalAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 412 spectrumId); 413 plotOriginal.setViewAction(viewOriginalAction); 414 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT); 415 plotOriginal.setWidth(PlotFileSpectrum.WIDTH); 416 // Add mass annotation image map 417 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, 418 fileId, spectrumId, (String) null, (String) null); 419 plotOriginal.setImageMap(imageMap); 420 } 421 Image plot = new Image(); 422 ActionLink viewAction = getActionFactory().getActionLink( 423 PlotFileSpectrum.class, "View"); 424 viewAction.addParameter(FormFactory.VID, fileId); 425 viewAction.addParameter(PlotFileSpectrum.VSPECTRUMID, spectrumId); 426 viewAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR, 427 massCutoffLowStr); 428 viewAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR, 429 massCutoffHighStr); 430 plot.setViewAction(viewAction); 431 plot.setHeight(PlotFileSpectrum.HEIGHT); 432 plot.setWidth(PlotFileSpectrum.WIDTH); 433 // Add mass annotation image map 434 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, fileId, 435 spectrumId, massCutoffLowStr, massCutoffHighStr); 436 plot.setImageMap(imageMap); 437 /*********************************************************************** 438 * Spectrum iteration buttons 439 */ 440 Form spectrumIterationForm = new Form("spectrumIterationForm"); 441 spectrumIterationForm.setTitle("spectrumIterationForm"); 442 Fieldset spectrumIterationFS = new Fieldset(); 443 spectrumIterationFS.setTitle("SpectrumIteration"); 444 spectrumIterationForm.addFieldset(spectrumIterationFS); 445 Toolbar spectrumIterationToolbar = new Toolbar(); 446 spectrumIterationForm.setToolbar(spectrumIterationToolbar); 447 // 448 // Add button for previous spectrum 449 String previousSpectrumId = fetchPreviousListItem(spectrumId, 450 spectrumIds); 451 log.debug("previousSpectrumId = \"" + previousSpectrumId + "\""); 452 ActionLink previousSpectrumAction = getActionLink( 453 InspectActiveSpectrumFile.class, "PreviousSpectrum"); 454 previousSpectrumAction.addParameter(FormFactory.VID, fileId); 455 previousSpectrumAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 456 previousSpectrumId); 457 previousSpectrumAction.addParameter(VKEEPORIGINALSPECTRUM, true); 458 if (previousSpectrumId == null) 459 { 460 previousSpectrumAction.disable(); 461 } 462 spectrumIterationToolbar.add(previousSpectrumAction); 463 // 464 // Add button for next spectrum 465 String nextSpectrumId = fetchNextListItem(spectrumId, spectrumIds); 466 log.debug("nextSpectrumId = \"" + nextSpectrumId + "\""); 467 ActionLink nextSpectrumAction = getActionLink( 468 InspectActiveSpectrumFile.class, "NextSpectrum"); 469 nextSpectrumAction.addParameter(FormFactory.VID, fileId); 470 nextSpectrumAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 471 nextSpectrumId); 472 nextSpectrumAction.addParameter(VKEEPORIGINALSPECTRUM, true); 473 if (nextSpectrumId == null) 474 { 475 nextSpectrumAction.disable(); 476 } 477 spectrumIterationToolbar.add(nextSpectrumAction); 478 /*********************************************************************** 479 * Spectrum mass range selection form 480 */ 481 Form massRangeSelectionForm = getFormFactory().getSpectrumMassRangeSelectionForm(massCutoffLowStr, 482 massCutoffHighStr, spectrumId); 483 Toolbar toolbar = new Toolbar(); 484 massRangeSelectionForm.setToolbar(toolbar); 485 // 486 ActionLink zoomWithOriginalAction = getActionLink( 487 InspectActiveSpectrumFile.class, "ZoomedAndOriginalSpectrum"); 488 zoomWithOriginalAction.addParameter(FormFactory.VID, fileId); 489 zoomWithOriginalAction.addParameter(VKEEPORIGINALSPECTRUM, true); 490 toolbar.add(zoomWithOriginalAction); 491 // 492 ActionLink zoomAction = getActionLink(InspectActiveSpectrumFile.class, 493 "ZoomedSpectrum"); 494 zoomAction.addParameter(FormFactory.VID, fileId); 495 zoomAction.addParameter(VKEEPORIGINALSPECTRUM, false); 496 toolbar.add(zoomAction); 497 /*********************************************************************** 498 * Spectrum properties 499 */ 500 SpectrumInterface spectrum = null; 501 Form propertiesForm = null; 502 if (file != null) 503 { 504 // Get new list file reader 505 PeakListFileInterface peakListFileReader = spectrumFileReaderFactory 506 .fetchPeakListFileReader(file); 507 if (peakListFileReader != null && spectrumId != null) 508 { 509 spectrum = peakListFileReader.getSpectrum(spectrumId); 510 } 511 // Spectrum properties form 512 propertiesForm = getFormFactory().getSpectrumPropertiesForm(file, 513 spectrumId, spectrum); 514 } 515 /*********************************************************************** 516 * Spectrum file instrument data 517 */ 518 List<SpectrumFileInstrumentInterface> spectrumFileInstrumentList = null; 519 Form instrumentForm = null; 520 if (file != null) 521 { 522 // Get new spectrum file instrument reader 523 SpectrumFileInstrumentReaderInterface spectrumFileInstrumentReader = spectrumFileReaderFactory 524 .fetchSpectrumFileInstrumentReader(file); 525 if (spectrumFileInstrumentReader != null) 526 { 527 spectrumFileInstrumentList = spectrumFileInstrumentReader 528 .getSpectrumFileInstrumentList(); 529 } 530 // Spectrum file instrument form 531 instrumentForm = getSpectrumFileInstrumentForm(spectrumFileInstrumentList); 532 } 533 /*********************************************************************** 534 * Spectrum file contact data 535 */ 536 SpectrumFileContactInterface spectrumContact = null; 537 Form contactForm = null; 538 if (file != null) 539 { 540 // Get new spectrum file contact reader 541 SpectrumFileContactReaderInterface spectrumFileContactReader = spectrumFileReaderFactory 542 .fetchSpectrumFileContactReader(file); 543 if (spectrumFileContactReader != null) 544 { 545 spectrumContact = spectrumFileContactReader 546 .getSpectrumContact(); 547 } 548 // Spectrum file contacts form 549 contactForm = getSpectrumFileContactForm(spectrumContact); 550 } 551 /*********************************************************************** 552 * Layout 553 */ 554 // GridLayout layout = getLayoutFactory().getGridLayout(1, 2, 1, 1); 555 RowLayout layout = getLayoutFactory().getRowLayout(); 556 // Adapt title to file type 557 String titleHeader = spectrumFileReaderFactory 558 .fetchFileTypeTitleString(file); 559 Title title = new Title(titleHeader); 560 title.setSubtitle("" + file.getName() + " [" + fileId + "]"); 561 layout.add(title); 562 // Row container for plot and properties form 563 RowContainer rc = new RowContainer(); 564 if (plotOriginal != null) 565 { 566 rc.add(plotOriginal); 567 } 568 rc.add(plot); 569 rc.add(spectrumIterationForm); 570 rc.add(massRangeSelectionForm); 571 rc.add(propertiesForm); 572 if (instrumentForm != null) 573 { 574 rc.add(instrumentForm); 575 } 576 if (contactForm != null) 577 { 578 rc.add(contactForm); 579 } 580 // 581 ColumnContainer cc = new ColumnContainer(); 582 cc.add(peakListTable); 583 if (plot != null || propertiesForm != null) 584 { 585 cc.add(rc); 586 } 587 layout.add(cc); 588 // 589 setLayout(layout); 590 log.debug("End"); 591 } 592 593 /** 594 * Fetch index for item from from string list. 595 * 596 * @param currentItem String The current item. 597 * @param inList List<String> The string list to use. 598 * @return Integer The index for the item, or null if none. 599 */ 600 public Integer fetchStringListItemIndex(String currentItem, 601 List<String> inList) 602 { 603 log.debug("currentItem = \"" + currentItem + "\""); 604 if (currentItem == null || inList == null) 605 { 606 return null; 607 } 608 log.debug("inList.size() = " + inList.size()); 609 // Find current index 610 Integer currentIndex = null; 611 for (int i = 0; i < inList.size(); i++) 612 { 613 String item = (String) inList.get(i); 614 if (item != null) 615 { 616 if (item.equals(currentItem)) 617 { 618 currentIndex = i; 619 break; 620 } 621 } 622 } 623 log.debug("currentIndex = " + currentIndex); 624 return currentIndex; 625 } 626 627 /** 628 * Fetch previous list item from string list. 629 * 630 * @param currentItem String The current item. 631 * @param inList List<String> The string list to use. 632 * @return String The previous item, or null if none. 633 */ 634 public String fetchPreviousListItem(String currentItem, List<String> inList) 635 { 636 log.debug("currentItem = \"" + currentItem + "\""); 637 if (currentItem == null || inList == null) 638 { 639 return null; 640 } 641 log.debug("inList.size() = " + inList.size()); 642 // Find current index 643 int currentIndex = -1; 644 for (int i = 0; i < inList.size(); i++) 645 { 646 String item = (String) inList.get(i); 647 if (item != null) 648 { 649 if (item.equals(currentItem)) 650 { 651 currentIndex = i; 652 break; 653 } 654 } 655 } 656 log.debug("currentIndex = " + currentIndex); 657 // Find previous item 658 String previousItem = null; 659 if (currentIndex > 0) 660 { 661 previousItem = (String) inList.get(currentIndex - 1); 662 } 663 log.debug("previousItem = \"" + previousItem + "\""); 664 return previousItem; 665 } 666 667 /** 668 * Fetch next list item from string list. 669 * 670 * @param currentItem String The current item. 671 * @param inList List<String> The string list to use. 672 * @return String The next item, or null if none. 673 */ 674 public String fetchNextListItem(String currentItem, List<String> inList) 675 { 676 log.debug("currentItem = \"" + currentItem + "\""); 677 if (currentItem == null || inList == null) 678 { 679 return null; 680 } 681 log.debug("inList.size() = " + inList.size()); 682 // Find current index 683 int currentIndex = -1; 684 for (int i = 0; i < inList.size(); i++) 685 { 686 String item = (String) inList.get(i); 687 if (item != null) 688 { 689 if (item.equals(currentItem)) 690 { 691 currentIndex = i; 692 break; 693 } 694 } 695 } 696 log.debug("currentIndex = " + currentIndex); 697 // Find next item 698 String nextItem = null; 699 if (currentIndex < (inList.size() - 1)) 700 { 701 nextItem = (String) inList.get(currentIndex + 1); 702 } 703 log.debug("nextItem = \"" + nextItem + "\""); 704 return nextItem; 705 } 706 707 /** 708 * Restores table scroller settings (stored as valid parameters). 709 */ 710 private void restoreScrollerState() 711 throws InvalidParameterValue 712 { 713 // Get scroller data from valid parameters set to table 714 Integer scrollFrom = getValidInteger(Scroller.VFROM); 715 Integer scrollMaxResults = getValidInteger(Scroller.VMAXRESULT); 716 // Update scroller settings 717 if (scrollFrom != null) 718 { 719 setItemsFrom(scrollFrom); 720 setPageSelectedFromScroller(true); 721 } 722 if (scrollMaxResults != null) 723 { 724 setMaxResults(scrollMaxResults); 725 } 726 log 727 .debug("scrollFrom = " + scrollFrom + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 728 log.debug("scrollMaxResults = " + scrollMaxResults); 729 } 730 731 /** 732 Returns a form with spectrum file instrument data for a spectrum file. 733 734 @param spectrumFileInstrumentList List<SpectrumFileInstrumentInterface> 735 Spectrum file instrument list. 736 @return Form for displaying spectrum file instrument data. 737 */ 738 public Form getSpectrumFileInstrumentForm( 739 List<SpectrumFileInstrumentInterface> spectrumFileInstrumentList) 740 { 741 if (spectrumFileInstrumentList == null || spectrumFileInstrumentList 742 .size() == 0) 743 { 744 return null; 745 } 746 /*********************************************************************** 747 Instrument fieldset 748 */ 749 Fieldset instrumentFS = new Fieldset(); 750 int instrumentNo = 0; 751 for (SpectrumFileInstrumentInterface spectrumFileInstrument : spectrumFileInstrumentList) 752 { 753 instrumentNo++; 754 List<StringPairInterface> dataList; 755 /* 756 Name field. 757 */ 758 Table instrumentGeneralTable = new Table( 759 "InstrumentGeneralInformation"); 760 // Only print table header for first table 761 if (instrumentNo == 1) 762 { 763 instrumentGeneralTable.setTitle("InstrumentInformation"); 764 } 765 // instrumentGeneralTable.add(new Column<String>("Property")); 766 instrumentGeneralTable.add(new Column<String>("InstrumentGeneral")); 767 instrumentGeneralTable.add(new Column<String>("Value")); 768 String instrumentName = null; 769 if (spectrumFileInstrument != null) 770 { 771 instrumentName = spectrumFileInstrument.getInstrumentName(); 772 } 773 instrumentGeneralTable.addRow(new PropertyRow(0, "InstrumentName", instrumentName, null)); 774 /* 775 Serial No field. 776 */ 777 String instrumentSerialNo = null; 778 if (spectrumFileInstrument != null) 779 { 780 instrumentSerialNo = spectrumFileInstrument 781 .getInstrumentSerialNo(); 782 } 783 instrumentGeneralTable.addRow(new PropertyRow(0, "InstrumentSerialNo", instrumentSerialNo, null)); 784 instrumentFS.add(instrumentGeneralTable); 785 /* 786 Source field. 787 */ 788 Table sourceTable = new Table("SourceInformation"); 789 // sourceTable.setTitle("SourceInformation"); 790 // sourceTable.add(new Column<String>("Property")); 791 sourceTable.add(new Column<String>("SourceInformation")); 792 sourceTable.add(new Column<String>("Value")); 793 dataList = spectrumFileInstrument.getSource(); 794 if (dataList != null) 795 { 796 for (int i = 0; i < dataList.size(); i++) 797 { 798 StringPairInterface data = dataList.get(i); 799 if (data != null) 800 { 801 String name = data.getName(); 802 String value = data.getValue(); 803 if (name != null && !name.equals("")) 804 { 805 sourceTable.addRow(new PropertyRow(0, name, value, null)); 806 } 807 } 808 } 809 } 810 instrumentFS.add(sourceTable); 811 /* 812 AnalyzerList field. 813 */ 814 List<SpectrumFileAnalyzerInterface> analyzerList = spectrumFileInstrument 815 .getAnalyzers(); 816 if (analyzerList != null) 817 { 818 for (int j = 0; j < analyzerList.size(); j++) 819 { 820 Table analyzerTable = new Table("AnalyzerListInformation"); 821 /* 822 // Only add table title header for first table if (j == 823 0) { analyzerTable.setTitle("AnalyzerListInformation"); } 824 */ 825 // analyzerTable.add(new Column<String>("Property")); 826 analyzerTable 827 .add(new Column<String>("AnalyzerInformation")); 828 analyzerTable.add(new Column<String>("Value")); 829 SpectrumFileAnalyzerInterface analyzer = analyzerList 830 .get(j); 831 if (analyzer != null) 832 { 833 dataList = analyzer.getAnalyzer(); 834 if (dataList != null) 835 { 836 for (int i = 0; i < dataList.size(); i++) 837 { 838 StringPairInterface data = dataList.get(i); 839 if (data != null) 260 840 { 261 log.debug("Found spectrum:"+s); 262 spectrumId = s; 263 setSessionAttribute(PlotFileSpectrum.VSPECTRUMID.getName(), spectrumId); 264 break; 841 String name = data.getName(); 842 String value = data.getValue(); 843 if (name != null && !name.equals("")) 844 { 845 analyzerTable.addRow(new PropertyRow(0, name, value, null)); 846 } 265 847 } 266 848 } 267 849 } 268 850 } 851 instrumentFS.add(analyzerTable); 269 852 } 270 else 853 } 854 /* 855 Detector field. 856 */ 857 Table detectorTable = new Table("DetectorInformation"); 858 // detectorTable.setTitle("DetectorInformation"); 859 // detectorTable.add(new Column<String>("Property")); 860 detectorTable.add(new Column<String>("DetectorInformation")); 861 detectorTable.add(new Column<String>("Value")); 862 dataList = spectrumFileInstrument.getDetector(); 863 if (dataList != null) 864 { 865 for (int i = 0; i < dataList.size(); i++) 271 866 { 272 peakListTable.add(new Column("Spectrum id")); 273 } 274 } 275 if (spectrumIds != null) 276 { 277 log.debug("spectrumIds.size() = " + spectrumIds.size()); 278 // Fetch scroller page selected 279 restoreScrollerState(); 280 log 281 .debug("getItemsFrom() = " + getItemsFrom() + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 282 if (!isPageSelectedFromScroller()) 283 { 284 // Adjust scroller page to include selected spectrum 285 if (spectrumId != null && !spectrumId.equals("")) 867 StringPairInterface data = dataList.get(i); 868 if (data != null) 286 869 { 287 // find start of scroller page including selected spectrum 288 Integer currentIndex = fetchStringListItemIndex(spectrumId, 289 spectrumIds); 290 log.debug("currentIndex = " + currentIndex); 291 if (currentIndex != null && currentIndex >= 0) 870 String name = data.getName(); 871 String value = data.getValue(); 872 if (name != null && !name.equals("")) 292 873 { 293 int pageNo = currentIndex / getMaxResults(); 294 int tempStart = pageNo * getMaxResults(); 295 log 296 .debug("currentIndex = " + currentIndex + " pageNo = " + pageNo + " tempStart = " + tempStart); 297 // Set start index for displayed list 298 setItemsFrom(tempStart); 874 detectorTable.addRow(new PropertyRow(0, name, value, null)); 299 875 } 300 876 } 301 877 } 302 // Add scroller 303 int count = spectrumIds.size(); 304 if (count > getMaxResults()) 878 } 879 instrumentFS.add(detectorTable); 880 /* 881 Additional field. 882 */ 883 Table additionalTable = new Table("AdditionalInformation"); 884 additionalTable.add(new Column<String>("AdditionalInformation")); 885 additionalTable.add(new Column<String>("Value")); 886 dataList = spectrumFileInstrument.getAdditional(); 887 if (dataList != null) 888 { 889 for (int i = 0; i < dataList.size(); i++) 305 890 { 306 Scroller scroller = new Scroller(); 307 scroller.setFrom(getItemsFrom()); 308 scroller.setMax(getMaxResults()); 309 scroller.setTotalCount(count); 310 scroller.setScrollActionId(getActionFactory().getId( 311 ScrollTo.class)); 312 scroller.setTableConfActionId(getActionFactory().getId( 313 InspectActiveSpectrumFile.class)); 314 scroller.setDisplayActionId(getActionFactory().getId( 315 InspectActiveSpectrumFile.class)); 316 // scroller.put(FormFactory.VCLASSNAME, itemClass.getName()); 317 log.debug("scroller ScrollActionId = \"" + getActionFactory() 318 .getId(ScrollTo.class) + "\""); 319 log 320 .debug("scroller TableConfActionId = \"" + getActionFactory() 321 .getId(InspectActiveSpectrumFile.class) + "\""); 322 log.debug("scroller.getDisplayActionId() = \"" + scroller 323 .getDisplayActionId() + "\""); 324 // Add scroller to table 325 peakListTable.setScroller(scroller); 326 } 327 // Add scroller data 328 log.debug("getItemsFrom() = " + getItemsFrom()); 329 log.debug("getMaxResults() = " + getMaxResults()); 330 int scrollFrom = getItemsFrom(); 331 int scrollMaxResults = getMaxResults(); 332 TextField<Integer> scrollFromField = new TextField<Integer>( 333 Scroller.VFROM); 334 TextField<Integer> scrollMaxResultsField = new TextField<Integer>( 335 Scroller.VMAXRESULT); 336 scrollFromField.setValue(scrollFrom); 337 scrollMaxResultsField.setValue(scrollMaxResults); 338 peakListTable.add(scrollFromField); 339 peakListTable.add(scrollMaxResultsField); 340 // 341 // Add spectrum id field 342 TextField<String> spectrumIdField = new TextField<String>( 343 PlotFileSpectrum.VSPECTRUMID); 344 spectrumIdField.setHidden(true); 345 spectrumIdField.setValue(spectrumId); 346 peakListTable.add(spectrumIdField); 347 // 348 // Add mass cut-off low string field 349 TextField<String> massCutOffLowStrField = new TextField<String>( 350 PlotFileSpectrum.VMASSCUTOFFLOWSTR); 351 massCutOffLowStrField.setHidden(true); 352 massCutOffLowStrField.setValue(massCutoffLowStr); 353 peakListTable.add(massCutOffLowStrField); 354 // 355 // Add mass cut-off high string field 356 TextField<String> massCutOffHighStrField = new TextField<String>( 357 PlotFileSpectrum.VMASSCUTOFFHIGHSTR); 358 massCutOffHighStrField.setHidden(true); 359 massCutOffHighStrField.setValue(massCutoffHighStr); 360 peakListTable.add(massCutOffHighStrField); 361 // 362 // Add keep original spectrum flag field 363 TextField<Boolean> keepOriginalSpectrumField = new TextField<Boolean>( 364 VKEEPORIGINALSPECTRUM); 365 keepOriginalSpectrumField.setHidden(true); 366 keepOriginalSpectrumField.setValue(keepOriginalSpectrum); 367 peakListTable.add(keepOriginalSpectrumField); 368 // 369 // Create spectrum list to display 370 int itemStart = getItemsFrom(); 371 int itemStop = getItemsFrom() + getMaxResults(); 372 for (int i = itemStart; (i < spectrumIds.size() && i < itemStop); i++) 373 { 374 // log.debug("spectrumIds.get(" + i + ") = \"" + 375 // spectrumIds.get(i) + "\""); 376 // Add data 377 Row row = new Row(i); 378 row.addCell(new Cell<String>(spectrumIds.get(i))); 379 // Configure on-click row action to re-run this action with new 380 // spectrum id 381 ActionLink rowAction = getActionFactory().getActionLink( 382 InspectActiveSpectrumFile.class, "View"); 383 rowAction.addParameter(VSPECTRUMFILEID, fileId); 384 rowAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 385 spectrumIds.get(i)); 386 row.setActionLink(rowAction); 387 peakListTable.addRow(row); 388 } 389 // Show first spectrum as default 390 if (spectrumId == null || spectrumId.equals("")) 391 { 392 if (spectrumIds != null && spectrumIds.size() > 0) 891 StringPairInterface data = dataList.get(i); 892 if (data != null) 393 893 { 394 // Plot first spectrum 395 spectrumId = spectrumIds.get(0); 396 } 397 } 398 } 399 /*********************************************************************** 400 * Spectrum plot 401 */ 402 PlotFileSpectrum plotFileSpectrum = new PlotFileSpectrum(); 403 ImageMap imageMap; 404 Image plotOriginal = null; 405 if (keepOriginalSpectrum) 406 { 407 plotOriginal = new Image(); 408 ActionLink viewOriginalAction = getActionFactory().getActionLink( 409 PlotFileSpectrum.class, "ViewOriginal"); 410 viewOriginalAction.addParameter(FormFactory.VID, fileId); 411 viewOriginalAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 412 spectrumId); 413 plotOriginal.setViewAction(viewOriginalAction); 414 plotOriginal.setHeight(PlotFileSpectrum.HEIGHT); 415 plotOriginal.setWidth(PlotFileSpectrum.WIDTH); 416 // Add mass annotation image map 417 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, 418 fileId, spectrumId, (String) null, (String) null); 419 plotOriginal.setImageMap(imageMap); 420 } 421 Image plot = new Image(); 422 ActionLink viewAction = getActionFactory().getActionLink( 423 PlotFileSpectrum.class, "View"); 424 viewAction.addParameter(FormFactory.VID, fileId); 425 viewAction.addParameter(PlotFileSpectrum.VSPECTRUMID, spectrumId); 426 viewAction.addParameter(PlotFileSpectrum.VMASSCUTOFFLOWSTR, 427 massCutoffLowStr); 428 viewAction.addParameter(PlotFileSpectrum.VMASSCUTOFFHIGHSTR, 429 massCutoffHighStr); 430 plot.setViewAction(viewAction); 431 plot.setHeight(PlotFileSpectrum.HEIGHT); 432 plot.setWidth(PlotFileSpectrum.WIDTH); 433 // Add mass annotation image map 434 imageMap = plotFileSpectrum.fetchMassPeakAnnotationToolTips(dc, fileId, 435 spectrumId, massCutoffLowStr, massCutoffHighStr); 436 plot.setImageMap(imageMap); 437 /*********************************************************************** 438 * Spectrum iteration buttons 439 */ 440 Form spectrumIterationForm = new Form("spectrumIterationForm"); 441 spectrumIterationForm.setTitle("spectrumIterationForm"); 442 Fieldset spectrumIterationFS = new Fieldset(); 443 spectrumIterationFS.setTitle("SpectrumIteration"); 444 spectrumIterationForm.addFieldset(spectrumIterationFS); 445 Toolbar spectrumIterationToolbar = new Toolbar(); 446 spectrumIterationForm.setToolbar(spectrumIterationToolbar); 447 // 448 // Add button for previous spectrum 449 String previousSpectrumId = fetchPreviousListItem(spectrumId, 450 spectrumIds); 451 log.debug("previousSpectrumId = \"" + previousSpectrumId + "\""); 452 ActionLink previousSpectrumAction = getActionLink( 453 InspectActiveSpectrumFile.class, "PreviousSpectrum"); 454 previousSpectrumAction.addParameter(FormFactory.VID, fileId); 455 previousSpectrumAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 456 previousSpectrumId); 457 previousSpectrumAction.addParameter(VKEEPORIGINALSPECTRUM, true); 458 if (previousSpectrumId == null) 459 { 460 previousSpectrumAction.disable(); 461 } 462 spectrumIterationToolbar.add(previousSpectrumAction); 463 // 464 // Add button for next spectrum 465 String nextSpectrumId = fetchNextListItem(spectrumId, spectrumIds); 466 log.debug("nextSpectrumId = \"" + nextSpectrumId + "\""); 467 ActionLink nextSpectrumAction = getActionLink( 468 InspectActiveSpectrumFile.class, "NextSpectrum"); 469 nextSpectrumAction.addParameter(FormFactory.VID, fileId); 470 nextSpectrumAction.addParameter(PlotFileSpectrum.VSPECTRUMID, 471 nextSpectrumId); 472 nextSpectrumAction.addParameter(VKEEPORIGINALSPECTRUM, true); 473 if (nextSpectrumId == null) 474 { 475 nextSpectrumAction.disable(); 476 } 477 spectrumIterationToolbar.add(nextSpectrumAction); 478 /*********************************************************************** 479 * Spectrum mass range selection form 480 */ 481 Form massRangeSelectionForm = getFormFactory().getSpectrumMassRangeSelectionForm(massCutoffLowStr, 482 massCutoffHighStr, spectrumId); 483 Toolbar toolbar = new Toolbar(); 484 massRangeSelectionForm.setToolbar(toolbar); 485 // 486 ActionLink zoomWithOriginalAction = getActionLink( 487 InspectActiveSpectrumFile.class, "ZoomedAndOriginalSpectrum"); 488 zoomWithOriginalAction.addParameter(FormFactory.VID, fileId); 489 zoomWithOriginalAction.addParameter(VKEEPORIGINALSPECTRUM, true); 490 toolbar.add(zoomWithOriginalAction); 491 // 492 ActionLink zoomAction = getActionLink(InspectActiveSpectrumFile.class, 493 "ZoomedSpectrum"); 494 zoomAction.addParameter(FormFactory.VID, fileId); 495 zoomAction.addParameter(VKEEPORIGINALSPECTRUM, false); 496 toolbar.add(zoomAction); 497 /*********************************************************************** 498 * Spectrum properties 499 */ 500 SpectrumInterface spectrum = null; 501 Form propertiesForm = null; 502 if (file != null) 503 { 504 // Get new list file reader 505 PeakListFileInterface peakListFileReader = spectrumFileReaderFactory 506 .fetchPeakListFileReader(file); 507 if (peakListFileReader != null && spectrumId != null) 508 { 509 spectrum = peakListFileReader.getSpectrum(spectrumId); 510 } 511 // Spectrum properties form 512 propertiesForm = getFormFactory().getSpectrumPropertiesForm(file, 513 spectrumId, spectrum); 514 } 515 /*********************************************************************** 516 * Spectrum file instrument data 517 */ 518 List<SpectrumFileInstrumentInterface> spectrumFileInstrumentList = null; 519 Form instrumentForm = null; 520 if (file != null) 521 { 522 // Get new spectrum file instrument reader 523 SpectrumFileInstrumentReaderInterface spectrumFileInstrumentReader = spectrumFileReaderFactory 524 .fetchSpectrumFileInstrumentReader(file); 525 if (spectrumFileInstrumentReader != null) 526 { 527 spectrumFileInstrumentList = spectrumFileInstrumentReader 528 .getSpectrumFileInstrumentList(); 529 } 530 // Spectrum file instrument form 531 instrumentForm = getSpectrumFileInstrumentForm(spectrumFileInstrumentList); 532 } 533 /*********************************************************************** 534 * Spectrum file contact data 535 */ 536 SpectrumFileContactInterface spectrumContact = null; 537 Form contactForm = null; 538 if (file != null) 539 { 540 // Get new spectrum file contact reader 541 SpectrumFileContactReaderInterface spectrumFileContactReader = spectrumFileReaderFactory 542 .fetchSpectrumFileContactReader(file); 543 if (spectrumFileContactReader != null) 544 { 545 spectrumContact = spectrumFileContactReader 546 .getSpectrumContact(); 547 } 548 // Spectrum file contacts form 549 contactForm = getFormFactory().getSpectrumFileContactForm( 550 spectrumContact); 551 } 552 /*********************************************************************** 553 * Layout 554 */ 555 // GridLayout layout = getLayoutFactory().getGridLayout(1, 2, 1, 1); 556 RowLayout layout = getLayoutFactory().getRowLayout(); 557 // Adapt title to file type 558 String titleHeader = spectrumFileReaderFactory 559 .fetchFileTypeTitleString(file); 560 Title title = new Title(titleHeader); 561 title.setSubtitle("" + file.getName() + " [" + fileId + "]"); 562 layout.add(title); 563 // Row container for plot and properties form 564 RowContainer rc = new RowContainer(); 565 if (plotOriginal != null) 566 { 567 rc.add(plotOriginal); 568 } 569 rc.add(plot); 570 rc.add(spectrumIterationForm); 571 rc.add(massRangeSelectionForm); 572 rc.add(propertiesForm); 573 if (instrumentForm != null) 574 { 575 rc.add(instrumentForm); 576 } 577 if (contactForm != null) 578 { 579 rc.add(contactForm); 580 } 581 // 582 ColumnContainer cc = new ColumnContainer(); 583 cc.add(peakListTable); 584 if (plot != null || propertiesForm != null) 585 { 586 cc.add(rc); 587 } 588 layout.add(cc); 589 // 590 setLayout(layout); 591 log.debug("End"); 592 } 593 594 /** 595 * Fetch index for item from from string list. 596 * 597 * @param currentItem String The current item. 598 * @param inList List<String> The string list to use. 599 * @return Integer The index for the item, or null if none. 600 */ 601 public Integer fetchStringListItemIndex(String currentItem, 602 List<String> inList) 603 { 604 log.debug("currentItem = \"" + currentItem + "\""); 605 if (currentItem == null || inList == null) 606 { 607 return null; 608 } 609 log.debug("inList.size() = " + inList.size()); 610 // Find current index 611 Integer currentIndex = null; 612 for (int i = 0; i < inList.size(); i++) 613 { 614 String item = (String) inList.get(i); 615 if (item != null) 616 { 617 if (item.equals(currentItem)) 618 { 619 currentIndex = i; 620 break; 621 } 622 } 623 } 624 log.debug("currentIndex = " + currentIndex); 625 return currentIndex; 626 } 627 628 /** 629 * Fetch previous list item from string list. 630 * 631 * @param currentItem String The current item. 632 * @param inList List<String> The string list to use. 633 * @return String The previous item, or null if none. 634 */ 635 public String fetchPreviousListItem(String currentItem, List<String> inList) 636 { 637 log.debug("currentItem = \"" + currentItem + "\""); 638 if (currentItem == null || inList == null) 639 { 640 return null; 641 } 642 log.debug("inList.size() = " + inList.size()); 643 // Find current index 644 int currentIndex = -1; 645 for (int i = 0; i < inList.size(); i++) 646 { 647 String item = (String) inList.get(i); 648 if (item != null) 649 { 650 if (item.equals(currentItem)) 651 { 652 currentIndex = i; 653 break; 654 } 655 } 656 } 657 log.debug("currentIndex = " + currentIndex); 658 // Find previous item 659 String previousItem = null; 660 if (currentIndex > 0) 661 { 662 previousItem = (String) inList.get(currentIndex - 1); 663 } 664 log.debug("previousItem = \"" + previousItem + "\""); 665 return previousItem; 666 } 667 668 /** 669 * Fetch next list item from string list. 670 * 671 * @param currentItem String The current item. 672 * @param inList List<String> The string list to use. 673 * @return String The next item, or null if none. 674 */ 675 public String fetchNextListItem(String currentItem, List<String> inList) 676 { 677 log.debug("currentItem = \"" + currentItem + "\""); 678 if (currentItem == null || inList == null) 679 { 680 return null; 681 } 682 log.debug("inList.size() = " + inList.size()); 683 // Find current index 684 int currentIndex = -1; 685 for (int i = 0; i < inList.size(); i++) 686 { 687 String item = (String) inList.get(i); 688 if (item != null) 689 { 690 if (item.equals(currentItem)) 691 { 692 currentIndex = i; 693 break; 694 } 695 } 696 } 697 log.debug("currentIndex = " + currentIndex); 698 // Find next item 699 String nextItem = null; 700 if (currentIndex < (inList.size() - 1)) 701 { 702 nextItem = (String) inList.get(currentIndex + 1); 703 } 704 log.debug("nextItem = \"" + nextItem + "\""); 705 return nextItem; 706 } 707 708 /** 709 * Restores table scroller settings (stored as valid parameters). 710 */ 711 private void restoreScrollerState() 712 throws InvalidParameterValue 713 { 714 // Get scroller data from valid parameters set to table 715 Integer scrollFrom = getValidInteger(Scroller.VFROM); 716 Integer scrollMaxResults = getValidInteger(Scroller.VMAXRESULT); 717 // Update scroller settings 718 if (scrollFrom != null) 719 { 720 setItemsFrom(scrollFrom); 721 setPageSelectedFromScroller(true); 722 } 723 if (scrollMaxResults != null) 724 { 725 setMaxResults(scrollMaxResults); 726 } 727 log 728 .debug("scrollFrom = " + scrollFrom + " isPageSelectedFromScroller() = " + isPageSelectedFromScroller()); 729 log.debug("scrollMaxResults = " + scrollMaxResults); 730 } 731 732 /** 733 Returns a form with spectrum file instrument data for a spectrum file. 734 735 @param spectrumFileInstrumentList List<SpectrumFileInstrumentInterface> 736 Spectrum file instrument list. 737 @return Form for displaying spectrum file instrument data. 738 */ 739 public Form getSpectrumFileInstrumentForm( 740 List<SpectrumFileInstrumentInterface> spectrumFileInstrumentList) 741 { 742 if (spectrumFileInstrumentList == null || spectrumFileInstrumentList 743 .size() == 0) 744 { 745 return null; 746 } 747 /*********************************************************************** 748 Instrument fieldset 749 */ 750 Fieldset instrumentFS = new Fieldset(); 751 int instrumentNo = 0; 752 for (SpectrumFileInstrumentInterface spectrumFileInstrument : spectrumFileInstrumentList) 753 { 754 instrumentNo++; 755 List<StringPairInterface> dataList; 756 /* 757 Name field. 758 */ 759 Table instrumentGeneralTable = new Table( 760 "InstrumentGeneralInformation"); 761 // Only print table header for first table 762 if (instrumentNo == 1) 763 { 764 instrumentGeneralTable.setTitle("InstrumentInformation"); 765 } 766 // instrumentGeneralTable.add(new Column<String>("Property")); 767 instrumentGeneralTable.add(new Column<String>("InstrumentGeneral")); 768 instrumentGeneralTable.add(new Column<String>("Value")); 769 String instrumentName = null; 770 if (spectrumFileInstrument != null) 771 { 772 instrumentName = spectrumFileInstrument.getInstrumentName(); 773 } 774 instrumentGeneralTable.addRow(new PropertyRow(0, "InstrumentName", instrumentName, null)); 775 /* 776 Serial No field. 777 */ 778 String instrumentSerialNo = null; 779 if (spectrumFileInstrument != null) 780 { 781 instrumentSerialNo = spectrumFileInstrument 782 .getInstrumentSerialNo(); 783 } 784 instrumentGeneralTable.addRow(new PropertyRow(0, "InstrumentSerialNo", instrumentSerialNo, null)); 785 instrumentFS.add(instrumentGeneralTable); 786 /* 787 Source field. 788 */ 789 Table sourceTable = new Table("SourceInformation"); 790 // sourceTable.setTitle("SourceInformation"); 791 // sourceTable.add(new Column<String>("Property")); 792 sourceTable.add(new Column<String>("SourceInformation")); 793 sourceTable.add(new Column<String>("Value")); 794 dataList = spectrumFileInstrument.getSource(); 795 if (dataList != null) 796 { 797 for (int i = 0; i < dataList.size(); i++) 798 { 799 StringPairInterface data = dataList.get(i); 800 if (data != null) 894 String name = data.getName(); 895 String value = data.getValue(); 896 if (name != null && !name.equals("")) 801 897 { 802 String name = data.getName(); 803 String value = data.getValue(); 804 if (name != null && !name.equals("")) 805 { 806 sourceTable.addRow(new PropertyRow(0, name, value, null)); 807 } 898 additionalTable.addRow(new PropertyRow(0, name, value, null)); 808 899 } 809 900 } 810 901 } 811 instrumentFS.add(sourceTable); 812 /* 813 AnalyzerList field. 814 */ 815 List<SpectrumFileAnalyzerInterface> analyzerList = spectrumFileInstrument 816 .getAnalyzers(); 817 if (analyzerList != null) 818 { 819 for (int j = 0; j < analyzerList.size(); j++) 820 { 821 Table analyzerTable = new Table("AnalyzerListInformation"); 822 /* 823 // Only add table title header for first table if (j == 824 0) { analyzerTable.setTitle("AnalyzerListInformation"); } 825 */ 826 // analyzerTable.add(new Column<String>("Property")); 827 analyzerTable 828 .add(new Column<String>("AnalyzerInformation")); 829 analyzerTable.add(new Column<String>("Value")); 830 SpectrumFileAnalyzerInterface analyzer = analyzerList 831 .get(j); 832 if (analyzer != null) 833 { 834 dataList = analyzer.getAnalyzer(); 835 if (dataList != null) 836 { 837 for (int i = 0; i < dataList.size(); i++) 838 { 839 StringPairInterface data = dataList.get(i); 840 if (data != null) 841 { 842 String name = data.getName(); 843 String value = data.getValue(); 844 if (name != null && !name.equals("")) 845 { 846 analyzerTable.addRow(new PropertyRow(0, name, value, null)); 847 } 848 } 849 } 850 } 851 } 852 instrumentFS.add(analyzerTable); 853 } 854 } 855 /* 856 Detector field. 857 */ 858 Table detectorTable = new Table("DetectorInformation"); 859 // detectorTable.setTitle("DetectorInformation"); 860 // detectorTable.add(new Column<String>("Property")); 861 detectorTable.add(new Column<String>("DetectorInformation")); 862 detectorTable.add(new Column<String>("Value")); 863 dataList = spectrumFileInstrument.getDetector(); 864 if (dataList != null) 865 { 866 for (int i = 0; i < dataList.size(); i++) 867 { 868 StringPairInterface data = dataList.get(i); 869 if (data != null) 870 { 871 String name = data.getName(); 872 String value = data.getValue(); 873 if (name != null && !name.equals("")) 874 { 875 detectorTable.addRow(new PropertyRow(0, name, value, null)); 876 } 877 } 878 } 879 } 880 instrumentFS.add(detectorTable); 881 /* 882 Additional field. 883 */ 884 Table additionalTable = new Table("AdditionalInformation"); 885 additionalTable.add(new Column<String>("AdditionalInformation")); 886 additionalTable.add(new Column<String>("Value")); 887 dataList = spectrumFileInstrument.getAdditional(); 888 if (dataList != null) 889 { 890 for (int i = 0; i < dataList.size(); i++) 891 { 892 StringPairInterface data = dataList.get(i); 893 if (data != null) 894 { 895 String name = data.getName(); 896 String value = data.getValue(); 897 if (name != null && !name.equals("")) 898 { 899 additionalTable.addRow(new PropertyRow(0, name, value, null)); 900 } 901 } 902 } 903 } 904 instrumentFS.add(additionalTable); 905 } 906 /*********************************************************************** 907 Form 908 */ 909 Form form = new Form("InstrumentInformation"); 910 form.addFieldset(instrumentFS); 911 return form; 912 } 913 } 902 } 903 instrumentFS.add(additionalTable); 904 } 905 /*********************************************************************** 906 Form 907 */ 908 Form form = new Form("InstrumentInformation"); 909 form.addFieldset(instrumentFS); 910 return form; 911 } 912 913 /** 914 Returns a form with spectrum file contact data for a spectrum file. 915 916 @param spectrumContact Spectrum file contact 917 data. 918 @return Form for displaying spectrum file contact data. 919 */ 920 public Form getSpectrumFileContactForm( 921 SpectrumFileContactInterface spectrumContact) 922 { 923 if (spectrumContact == null) 924 { 925 return null; 926 } 927 /*********************************************************************** 928 Contact fieldset 929 */ 930 Fieldset contactFS = new Fieldset(); 931 // 932 Table contactTable = new Table("ContactInformation"); 933 contactTable.setTitle("ContactInformation"); 934 contactTable.add(new Column<String>("Property")); 935 contactTable.add(new Column<String>("Value")); 936 contactFS.add(contactTable); 937 /* 938 Name 939 */ 940 String name = null; 941 if (spectrumContact != null) 942 { 943 name = spectrumContact.getName(); 944 } 945 contactTable.addRow(new PropertyRow(0 , "Name", name)); 946 /* 947 Institution 948 */ 949 String institution = null; 950 if (spectrumContact != null) 951 { 952 institution = spectrumContact.getInstitution(); 953 } 954 contactTable.addRow( new PropertyRow(0, "Institution", institution)); 955 /* 956 ContactInfo 957 */ 958 String contactInfo = null; 959 if (spectrumContact != null) 960 { 961 contactInfo = spectrumContact.getContactInfo(); 962 } 963 contactTable.addRow( new PropertyRow(0, "ContactInfo", contactInfo)); 964 /* 965 Address 966 */ 967 String address = null; 968 if (spectrumContact != null) 969 { 970 address = spectrumContact.getAddress(); 971 } 972 contactTable.addRow( new PropertyRow(0, "Address", address)); 973 /* 974 URL 975 */ 976 String url = null; 977 if (spectrumContact != null) 978 { 979 url = spectrumContact.getUrl(); 980 } 981 contactTable.addRow( new PropertyRow(0, "URL", url)); 982 /* 983 Email 984 */ 985 String email = null; 986 if (spectrumContact != null) 987 { 988 email = spectrumContact.getEmail(); 989 } 990 contactTable.addRow( new PropertyRow(0, "Email", email)); 991 /*********************************************************************** 992 Form 993 */ 994 Form form = new Form("ContactInformation"); 995 form.addFieldset(contactFS); 996 return form; 997 } 998 999 } -
trunk/client/servlet/src/org/proteios/gui/form/FormFactory.java
r3946 r3947 1 1 /* 2 2 $Id$ 3 3 4 4 Copyright (C) 2006, 2007 Fredrik Levander, Gregory Vincic, Olle Mansson 5 5 6 6 Files are copyright by their respective authors. The contributions to 7 7 files where copyright is not explicitly stated can be traced with the 8 8 source code revision system. 9 9 10 10 This file is part of Proteios. 11 11 Available at http://www.proteios.org/ 12 12 13 13 proteios-2.x is free software; you can redistribute it and/or 14 14 modify it under the terms of the GNU General Public License 15 15 as published by the Free Software Foundation; either version 2 16 16 of the License, or (at your option) any later version. 17 17 18 18 Proteios is distributed in the hope that it will be useful, 19 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 21 GNU General Public License for more details. 22 22 23 23 You should have received a copy of the GNU General Public License 24 24 along with this program; if not, write to the Free Software … … 68 68 private HttpServletRequest request = null; 69 69 private SessionControl sc = null; 70 70 71 71 private Localizer locale = null; 72 72 private String forwardActionId = null; … … 160 160 private static final org.apache.log4j.Logger log = org.apache.log4j.LogManager 161 161 .getLogger("org.proteios.gui.form"); 162 162 163 163 public void setActionFactory(ActionFactory af) 164 164 { 165 165 this.actionFactory = af; 166 166 } 167 167 168 168 public String getForwardActionId() 169 169 { 170 170 return this.forwardActionId; 171 171 } 172 172 173 173 public void setForwardActionId(String forwardActionId) 174 174 { 175 175 this.forwardActionId = forwardActionId; 176 176 } 177 177 178 178 public HttpServletRequest getRequest() 179 179 { 180 180 return request; 181 181 } 182 182 183 183 public void setRequest(HttpServletRequest request) 184 184 { 185 185 this.request = request; 186 186 } 187 187 188 188 public void modifyForPopup(Fieldset fs) 189 189 { 190 190 actionFactory.modifyForPopup(fs); 191 191 } 192 192 193 193 private FileField newFileField() 194 194 { … … 197 197 return fileF; 198 198 } 199 199 200 200 public TextField<Integer> newIdField() 201 201 { … … 205 205 return idF; 206 206 } 207 207 208 208 public TextField<String> newValueField(String setValueMethodName, 209 209 Class<?> valueClass) … … 237 237 return valueF; 238 238 } 239 239 240 240 public TextField<Integer> newHiddenItemIdField() 241 241 { … … 243 243 return field; 244 244 } 245 245 246 246 private TextField<Integer> newHiddenIntegerField(VInteger vInteger) 247 247 { … … 250 250 return field; 251 251 } 252 252 253 253 private TextField<String> newHiddenStringField(VString vString) 254 254 { … … 257 257 return field; 258 258 } 259 259 260 260 public <D extends BasicItem<?>, E extends ProteiosAction<?>> Form getAnnotationsForm( 261 261 DbControl dc, D item, Class<E> forwardAction) … … 307 307 return form; 308 308 } 309 309 310 310 /** 311 311 @return Hidden … … 317 317 return field; 318 318 } 319 319 320 320 /** 321 321 Form for user preferences configuration settings. Arguments … … 323 323 holders for current values for the notification configuration and table 324 324 preferences configuration form fields. 325 325 326 326 @param nc NotificationConfiguration object (need not be stored in 327 327 database) with default field values. … … 341 341 return form; 342 342 } 343 343 344 344 /** 345 345 Fieldset for notification configuration settings. Argument 346 346 NotificationConfiguration is place holder for current values for the 347 347 notification configuration form fields. 348 348 349 349 @param nc NotificationConfiguration object (need not be stored in 350 350 database) with default field values. … … 398 398 return properties; 399 399 } 400 400 401 401 /** 402 402 Creates a select box for notification mode. 403 403 404 404 @param modeValue int Mode value for default selection. 405 405 @return Select<VInteger> Select box for notification mode selection … … 426 426 return modeS; 427 427 } 428 428 429 429 /** 430 430 Fieldset for table preferences configuration settings. Argument 431 431 TablePreferencesConfiguration is place holder for current values for the 432 432 table preferences configuration form fields. 433 433 434 434 @param tpc TablePreferencesConfiguration object (need not be stored in 435 435 database) with default field values. … … 461 461 return properties; 462 462 } 463 463 464 464 /** 465 465 Creates a select box for table preferences mode. 466 466 467 467 @param modeValue int Mode value for default selection. 468 468 @return Select<VInteger> Select box for table preferences mode selection … … 489 489 return modeS; 490 490 } 491 491 492 492 /** 493 493 @param a annotation … … 502 502 return sb.toString(); 503 503 } 504 504 505 505 /** 506 506 This will probably be removed when fixint #691 … … 601 601 return form; 602 602 } 603 603 604 604 /** 605 605 @param hit Current Hit … … 817 817 return form; 818 818 } 819 819 820 820 /** 821 821 Returns a form for selecting spectrum mass range limits. 822 822 823 823 @param massCutoffLow String The lower cutoff mass value. 824 824 @param massCutoffHigh String The upper cutoff mass value. … … 866 866 return form; 867 867 } 868 868 869 869 /** 870 870 Returns a form with spectrum properties for a spectrum obtained from a 871 871 spectrum file. 872 872 873 873 @param spectrumFile File Core file with spectrum. 874 874 @param spectrumId String Spectrum id string. … … 1078 1078 return form; 1079 1079 } 1080 1081 /** 1082 Returns a form with spectrum file contact data for a spectrum file. 1083 1084 @param spectrumContact Spectrum file contact 1085 data. 1086 @return Form for displaying spectrum file contact data. 1087 */ 1088 public Form getSpectrumFileContactForm( 1089 SpectrumFileContactInterface spectrumContact) 1090 { 1091 if (spectrumContact == null) 1092 { 1093 return null; 1094 } 1095 /*********************************************************************** 1096 Contact fieldset 1097 */ 1098 Fieldset contactFS = new Fieldset(); 1099 // 1100 Table contactTable = new Table("ContactInformation"); 1101 contactTable.setTitle("ContactInformation"); 1102 contactTable.add(new Column<String>("Property")); 1103 contactTable.add(new Column<String>("Value")); 1104 contactFS.add(contactTable); 1105 /* 1106 Name 1107 */ 1108 String name = null; 1109 if (spectrumContact != null) 1110 { 1111 name = spectrumContact.getName(); 1112 } 1113 contactTable.addRow(new PropertyRow(0 , "Name", name)); 1114 /* 1115 Institution 1116 */ 1117 String institution = null; 1118 if (spectrumContact != null) 1119 { 1120 institution = spectrumContact.getInstitution(); 1121 } 1122 contactTable.addRow( new PropertyRow(0, "Institution", institution)); 1123 /* 1124 ContactInfo 1125 */ 1126 String contactInfo = null; 1127 if (spectrumContact != null) 1128 { 1129 contactInfo = spectrumContact.getContactInfo(); 1130 } 1131 contactTable.addRow( new PropertyRow(0, "ContactInfo", contactInfo)); 1132 /* 1133 Address 1134 */ 1135 String address = null; 1136 if (spectrumContact != null) 1137 { 1138 address = spectrumContact.getAddress(); 1139 } 1140 contactTable.addRow( new PropertyRow(0, "Address", address)); 1141 /* 1142 URL 1143 */ 1144 String url = null; 1145 if (spectrumContact != null) 1146 { 1147 url = spectrumContact.getUrl(); 1148 } 1149 contactTable.addRow( new PropertyRow(0, "URL", url)); 1150 /* 1151 Email 1152 */ 1153 String email = null; 1154 if (spectrumContact != null) 1155 { 1156 email = spectrumContact.getEmail(); 1157 } 1158 contactTable.addRow( new PropertyRow(0, "Email", email)); 1159 /*********************************************************************** 1160 Form 1161 */ 1162 Form form = new Form("ContactInformation"); 1163 form.addFieldset(contactFS); 1164 return form; 1165 } 1166 1080 1167 1081 /** 1168 1082 Returns a form for adding spectrum file sample data for a spectrum file. 1169 1083 1170 1084 @param project Project The project in whose directory a new output 1171 1085 directory is created. … … 1257 1171 return form; 1258 1172 } 1259 1173 1260 1174 private <D extends Object> TextField<D> newTextField(String name, D value) 1261 1175 { … … 1266 1180 return field; 1267 1181 } 1268 1182 1269 1183 public Form getPeakListSetForm(PeakListSet pls) 1270 1184 { … … 1334 1248 return form; 1335 1249 } 1336 1250 1337 1251 private void addAnnotationsAsFields(Fieldset to, Annotatable item, 1338 1252 DbControl dc) … … 1349 1263 } 1350 1264 } 1351 1265 1352 1266 public Fieldset getProteinAssemblyFieldset(Project project) 1353 1267 { … … 1372 1286 return properties; 1373 1287 } 1374 1288 1375 1289 public Select<VString> selectLocalSampleIdWithAllOption(DbControl dc, 1376 1290 Project project) … … 1386 1300 return select; 1387 1301 } 1388 1302 1389 1303 private Select<VInteger> newSelectLabel(LabeledExtract le, DbControl dc) 1390 1304 { … … 1407 1321 return select; 1408 1322 } 1409 1323 1410 1324 /** 1411 1325 Creates and adds a hidden field with an Integer value to the given form. … … 1419 1333 form.getFieldsets().get(0).add(field); 1420 1334 } 1421 1335 1422 1336 /** 1423 1337 Creates and adds a hidden field with an Integer value to the given table. … … 1431 1345 table.add(field); 1432 1346 } 1433 1347 1434 1348 public Fieldset getUsedSampleFieldset(Sample sample) 1435 1349 { … … 1449 1363 return fs; 1450 1364 } 1451 1365 1452 1366 public Fieldset getUsedExtractFieldset(Extract extract) 1453 1367 { … … 1464 1378 return fs; 1465 1379 } 1466 1380 1467 1381 public Fieldset getUsedLabeledExtractFieldset(LabeledExtract extract) 1468 1382 { … … 1482 1396 return fs; 1483 1397 } 1484 1398 1485 1399 public Form getSecondaryLabeledExtractForm(LabeledExtract extract, 1486 1400 DbControl dc, LabeledExtract fromExtract) … … 1545 1459 return form; 1546 1460 } 1547 1461 1548 1462 public TextField<Float> newOriginalQuantityField() 1549 1463 { … … 1553 1467 return field; 1554 1468 } 1555 1469 1556 1470 public TextField<Float> newRemainingQuantityField(Float remainingQuantity) 1557 1471 { … … 1564 1478 return field; 1565 1479 } 1480 1481 private Localizer getLocale() 1482 { 1483 return locale; 1484 } 1485 1486 public void setLocale(Localizer locale) 1487 { 1488 this.locale = locale; 1489 } 1490 1491 //Cleaning up from here 1566 1492 1567 private Localizer getLocale()1568 {1569 return locale;1570 }1571 1572 public void setLocale(Localizer locale)1573 {1574 this.locale = locale;1575 }1576 1577 //Cleaning up from here1578 1579 1493 /** 1580 1494 Form for new Protocol item. The difference between calling … … 1587 1501 a convenient place holder for default values for the Protocol form 1588 1502 fields. 1589 1503 1590 1504 @param protocol Protocol object (need not be stored in database) with 1591 1505 default field values. … … 1672 1586 return form; 1673 1587 } 1674 1588 1675 1589 public Form getForm(Class<?> cls) 1676 1590 { … … 1762 1676 loginF.setDisabled(true); 1763 1677 fs.add(fs.size()-2, loginF); // After the itemId field 1764 1678 1765 1679 TextField<String> emailF = new EmailField(); 1766 1680 fs.add(fs.size()-1, emailF); 1767 1681 1768 1682 TextField<String> phoneF = new PhoneField(); 1769 1683 fs.add(phoneF); 1770 1684 1771 1685 TextField<String> addressF = new AddressField(); 1772 1686 fs.add(addressF); 1773 1687 1774 1688 TextField<String> organisationF = new OrganisationField(); 1775 1689 fs.add(organisationF); 1776 1690 1777 1691 if (obj != null) 1778 1692 { … … 2105 2019 return form; 2106 2020 } 2107 2021 2108 2022 /** 2109 2023 Creates a select box for protocols. If the class for which the protocol … … 2113 2027 if the protocol is tagged to be removed. However, no other protocols 2114 2028 tagged to be removed should be included in the list. 2115 2029 2116 2030 @param cls Class Class for which a protocol should be selected. 2117 2031 @param obj Object Optional object with attached protocol for setting … … 2220 2134 return protocolS; 2221 2135 } 2222 2136 2223 2137 public void setSc(SessionControl sc) 2224 2138 {
Note: See TracChangeset
for help on using the changeset viewer.