use of org.eclipse.titan.log.viewer.views.details.StatisticalData in project titan.EclipsePlug-ins by eclipse.
the class StatisticalView method restoreState.
/**
* Called in the view life-cycle restore chain
* Reads back all view data if memento has been set
*
* The restore is very restricted an checks that the
* <li> Project still exists and is open
* <li> The file is within the project
* <li> The file size and file date has not changed
*/
private List<StatisticalData> restoreState() {
if (this.memento == null) {
return new ArrayList<StatisticalData>();
}
// $NON-NLS-1$
this.memento = this.memento.getChild("selection");
if (this.memento == null) {
return new ArrayList<StatisticalData>();
}
List<StatisticalData> tmpStatisticalDataVector = new ArrayList<StatisticalData>();
try {
// get project
// $NON-NLS-1$
IMemento[] viewAttributes = this.memento.getChildren("viewAttributes");
for (IMemento viewAttribute : viewAttributes) {
// $NON-NLS-1$
String projectName = viewAttribute.getString("projectName");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if ((project == null) || !project.exists() || !project.isOpen()) {
return new ArrayList<StatisticalData>();
}
// retrieve log file meta data
// $NON-NLS-1$
String propertyFilePath = viewAttribute.getString("propertyFile");
if (propertyFilePath == null) {
return new ArrayList<StatisticalData>();
}
File propertyFile = new File(propertyFilePath);
if (!propertyFile.exists()) {
return new ArrayList<StatisticalData>();
}
LogFileMetaData tmpLogFileMetaData = LogFileCacheHandler.logFileMetaDataReader(propertyFile);
// get log file
Path path = new Path(tmpLogFileMetaData.getProjectRelativePath());
IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if ((logFile == null) || !logFile.exists() || !logFile.getProject().getName().equals(project.getName())) {
return new ArrayList<StatisticalData>();
}
File file = logFile.getLocation().toFile();
// get file attributes to see if file has changed
// $NON-NLS-1$
String fileSizeString = viewAttribute.getString("fileSize");
long fileSize = 0;
if (fileSizeString != null) {
fileSize = Long.parseLong(fileSizeString);
}
// $NON-NLS-1$
String fileModificationString = viewAttribute.getString("fileModification");
long fileModification = 0;
if (fileModificationString != null) {
fileModification = Long.valueOf(fileModificationString);
}
if ((file.lastModified() != fileModification) || (file.length() != fileSize) || LogFileCacheHandler.hasLogFileChanged(logFile)) {
return new ArrayList<StatisticalData>();
}
// create reader and set as input
this.reader = new CachedLogReader(LogFileReader.getReaderForLogFile(logFile));
TestCaseExtractor extractor = new TestCaseExtractor();
extractor.extractTestCasesFromIndexedLogFile(logFile);
StatisticalData statisticalData = new StatisticalData(tmpLogFileMetaData, extractor.getTestCases(), reader);
tmpStatisticalDataVector.add(statisticalData);
}
return tmpStatisticalDataVector;
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
} finally {
this.memento = null;
}
return new ArrayList<StatisticalData>();
}
Aggregations