@@ -111,7 +111,7 @@ public class ResultsView extends ViewPart implements ISelectionListener {
111
111
private static final String RESULTS_EMPTY_CONTENT_DESC = "None selected." ;
112
112
private static final String EMPTY_RESULTS = "No results selected." ;
113
113
private static final String ERR_MSG_IO_ERROR = "An I/O error occured while reading the file '%s'." ;
114
- private static final String ERR_MSG_MISSING_REPORT = "Could not find the spotter report file ." ;
114
+ private static final String ERR_MSG_MISSING_REPORT = "Either file is missing or report is not set ." ;
115
115
private static final String ERR_MSG_MISSING_SER_FILE = "Could not find the spotter serialization file." ;
116
116
117
117
private static final String LABEL_NONE_SELECTED = "<none selected>" ;
@@ -587,6 +587,7 @@ private void updateTabs() {
587
587
String contentDescription = String .format (RESULTS_CONTENT_DESC_TEMPLATE , runResultItem .getText (),
588
588
runResultItem .getProject ().getName ());
589
589
setContentDescription (contentDescription );
590
+ updateResultsContainer ();
590
591
updateHierarchy ();
591
592
updateReport ();
592
593
}
@@ -614,25 +615,22 @@ private void resetReport() {
614
615
textReport .setText (EMPTY_RESULTS );
615
616
}
616
617
617
- private void updateHierarchy () {
618
+ private void updateResultsContainer () {
618
619
String filename = FileManager .DEFAULT_RESULTS_DIR_NAME + File .separator + runResultItem .getText ()
619
620
+ File .separator + ResultsLocationConstants .RESULTS_SERIALIZATION_FILE_NAME ;
620
621
IFile file = runResultItem .getProject ().getFile (filename );
621
- ExtensionItem input = null ;
622
+ resultsContainer = null ;
622
623
try {
623
624
if (!file .isSynchronized (IResource .DEPTH_ZERO )) {
624
625
file .refreshLocal (IResource .DEPTH_ZERO , null );
625
626
}
626
627
BufferedInputStream bufferedInStream = new BufferedInputStream (file .getContents ());
627
628
ObjectInputStream objectIn = new ObjectInputStream (bufferedInStream );
629
+
628
630
resultsContainer = (ResultsContainer ) objectIn .readObject ();
631
+
629
632
objectIn .close ();
630
633
bufferedInStream .close ();
631
-
632
- XPerformanceProblem root = resultsContainer .getRootProblem ();
633
- if (root != null ) {
634
- input = HierarchyEditor .createPerformanceProblemHierarchy (runResultItem .getProject ().getName (), root );
635
- }
636
634
} catch (CoreException e ) {
637
635
resultsContainer = null ;
638
636
String text = ERR_MSG_MISSING_SER_FILE + " (" + filename + ")" ;
@@ -643,48 +641,37 @@ private void updateHierarchy() {
643
641
String text = String .format (ERR_MSG_IO_ERROR , filename );
644
642
LOGGER .error (text + (e .getMessage () != null ? " (" + e .getMessage () + ")" : "" ));
645
643
DialogUtils .openWarning (RESULTS_VIEW_TITLE , text );
646
- } finally {
647
- imageProvider .setResultsContainer (resultsContainer );
648
- if (input == null ) {
649
- input = new ExtensionItem ();
644
+ }
645
+ }
646
+
647
+ private void updateHierarchy () {
648
+ ExtensionItem input = null ;
649
+
650
+ if (resultsContainer != null ) {
651
+ XPerformanceProblem root = resultsContainer .getRootProblem ();
652
+ if (root != null ) {
653
+ input = HierarchyEditor .createPerformanceProblemHierarchy (runResultItem .getProject ().getName (), root );
650
654
}
651
- hierarchyTreeViewer .setInput (input );
652
- hierarchyTreeViewer .expandAll ();
653
655
}
656
+
657
+ imageProvider .setResultsContainer (resultsContainer );
658
+ if (input == null ) {
659
+ input = new ExtensionItem ();
660
+ }
661
+ hierarchyTreeViewer .setInput (input );
662
+ hierarchyTreeViewer .expandAll ();
654
663
}
655
664
656
665
private void updateReport () {
657
- String filename = FileManager .DEFAULT_RESULTS_DIR_NAME + File .separator + runResultItem .getText ()
658
- + File .separator + ResultsLocationConstants .TXT_REPORT_FILE_NAME ;
659
- IFile file = runResultItem .getProject ().getFile (filename );
660
- StringBuilder sb = new StringBuilder ();
661
- try {
662
- if (!file .isSynchronized (IResource .DEPTH_ZERO )) {
663
- file .refreshLocal (IResource .DEPTH_ZERO , null );
664
- }
665
- BufferedInputStream bufferedInStream = new BufferedInputStream (file .getContents ());
666
- int readByte ;
667
- while ((readByte = bufferedInStream .read ()) != -1 ) {
668
- sb .append ((char ) readByte );
669
- }
670
- bufferedInStream .close ();
671
- textReport .setText (sb .toString ());
672
- } catch (CoreException e ) {
673
- String text = ERR_MSG_MISSING_REPORT + " (" + filename + ")" ;
674
- LOGGER .error (text + (e .getMessage () != null ? " (" + e .getMessage () + ")" : "" ));
675
- textReport .setText (text );
676
- DialogUtils .openWarning (RESULTS_VIEW_TITLE , text );
677
- } catch (IOException e ) {
678
- String text = String .format (ERR_MSG_IO_ERROR , filename );
679
- LOGGER .error (text + (e .getMessage () != null ? " (" + e .getMessage () + ")" : "" ));
680
- textReport .setText (text );
681
- DialogUtils .openWarning (RESULTS_VIEW_TITLE , text );
666
+ if (resultsContainer != null && resultsContainer .getReport () != null ) {
667
+ textReport .setText (resultsContainer .getReport ());
668
+ } else {
669
+ textReport .setText (ERR_MSG_MISSING_REPORT );
682
670
}
683
671
}
684
672
685
673
private String getCurrentResourceFolder () {
686
- String projectRelativeRunPath = FileManager .DEFAULT_RESULTS_DIR_NAME + File .separator
687
- + runResultItem .getText ();
674
+ String projectRelativeRunPath = FileManager .DEFAULT_RESULTS_DIR_NAME + File .separator + runResultItem .getText ();
688
675
IFolder folder = runResultItem .getProject ().getFolder (projectRelativeRunPath );
689
676
String currentRunFolder = folder .getLocation ().toString () + "/" ;
690
677
String subDirPath = getSubDirPathForProblem (currentSelectedProblem );
0 commit comments