use of org.eclipse.titan.log.viewer.readers.FilteredLogReader in project titan.EclipsePlug-ins by eclipse.
the class TextTableView 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 void restoreState() {
if (this.memento == null) {
return;
}
// this.problemDuringRestore = true; // TODO check the save and restore methods
// $NON-NLS-1$
this.memento = this.memento.getChild("selection");
if (this.memento == null) {
return;
}
try {
// get project
// $NON-NLS-1$
IMemento viewAttributes = this.memento.getChild("viewAttributes");
// $NON-NLS-1$
String projectName = viewAttributes.getString("projectName");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if ((project == null) || !project.exists() || !project.isOpen()) {
return;
}
// retrieve log file meta data
// $NON-NLS-1$
String propertyFilePath = viewAttributes.getString("propertyFile");
if (propertyFilePath == null) {
return;
}
File propertyFile = new File(propertyFilePath);
if (!propertyFile.exists()) {
return;
}
this.logFileMetaData = LogFileCacheHandler.logFileMetaDataReader(propertyFile);
// get log file
Path path = new Path(this.logFileMetaData.getProjectRelativePath());
IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if ((logFile == null) || !logFile.exists() || !logFile.getProject().getName().equals(project.getName())) {
return;
}
File file = logFile.getLocation().toFile();
// get file attributes to see if file has changed
// $NON-NLS-1$
String fileSizeString = viewAttributes.getString("fileSize");
long fileSize = 0;
if (fileSizeString != null) {
fileSize = Long.parseLong(fileSizeString);
}
// $NON-NLS-1$
String fileModificationString = viewAttributes.getString("fileModification");
long fileModification = 0;
if (fileModificationString != null) {
fileModification = Long.parseLong(fileModificationString);
}
if ((file.lastModified() != fileModification) || (file.length() != fileSize)) {
return;
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
return;
}
// create reader and set as input
this.filteredLogReader = new FilteredLogReader(LogFileReader.getReaderForLogFile(logFile));
this.cachedLogReader = new CachedLogReader(filteredLogReader);
// $NON-NLS-1$
this.selectedRow = viewAttributes.getInteger("selectedRow");
// $NON-NLS-1$
this.viewerWidth = viewAttributes.getInteger("viewWidth");
this.problemDuringRestore = false;
} catch (final IOException e) {
ErrorReporter.logExceptionStackTrace(e);
} catch (final ClassNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
}
this.memento = null;
}
use of org.eclipse.titan.log.viewer.readers.FilteredLogReader in project titan.EclipsePlug-ins by eclipse.
the class TextTableView method setInput.
/**
* Sets the given file as the input of the view. The content of the log file will be displayed.
* @param logFile The log file
* @throws IOException in case of file I/O errors
* @throws ClassNotFoundException if the log file meta data can not be found
*/
public void setInput(final IFile logFile, final int selection) throws IOException, ClassNotFoundException {
LogFileMetaData newLogFileMetaData = LogFileCacheHandler.logFileMetaDataReader(LogFileCacheHandler.getPropertyFileForLogFile(logFile));
final FilteredLogReader filteredReader = new FilteredLogReader(LogFileReader.getReaderForLogFile(logFile));
final CachedLogReader cachedReader = new CachedLogReader(filteredReader);
setInput(newLogFileMetaData, cachedReader, filteredReader, selection);
}
Aggregations