use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class RefreshMSCViewAction method run.
@Override
public void run() {
// Set current log file meta data
final LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
ExecutionModel model = this.mscView.getModel();
final PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(logFileMetaData.getProjectName());
if (preferences.getVisualOrderComponents().isEmpty()) {
// $NON-NLS-1$
String userE = Messages.getString("RefreshMSCViewAction.3");
TitanLogExceptionHandler.handleException(new UserException(userE));
return;
}
final IFile logFile = getSelectedLogFile(logFileMetaData);
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
// Check if the log file exists
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException(Messages.getString("RefreshMSCViewAction.1")));
return;
}
// Check if the log file has been modified
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return;
}
// Get log record index file for selected log file - No need to check is exists due to
// LogFileCacheHandler.hasLogFileChanged(logFile) returning false above
File logRecordIndexFile = LogFileCacheHandler.getLogRecordIndexFileForLogFile(logFile);
try {
// Read/parse log file
final TestCase tc = model.getTestCase();
final LogRecordIndex[] logRecordIndexes = LogFileCacheHandler.readLogRecordIndexFile(logRecordIndexFile, tc.getStartRecordNumber(), tc.getNumberOfRecords());
WorkspaceJob job = new WorkspaceJob("Loading log information") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
ExecutionModel model;
try {
model = parseLogFile();
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
TitanLogExceptionHandler.handleException(new TechnicalException(// $NON-NLS-1$
Messages.getString("RefreshMSCViewAction.5") + e.getMessage()));
return Status.CANCEL_STATUS;
}
final int firstRow = getFirstRow(model, preferences);
final ExecutionModel finalModel = model;
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
RefreshMSCViewAction.this.mscView.setModel(finalModel, firstRow);
}
});
return Status.OK_STATUS;
}
private ExecutionModel parseLogFile() throws TechnicalException {
ExecutionModel model;
if (logFileMetaData.getExecutionMode() == null) {
throw new TechnicalException("Error while parsing of the log file: ExecutionMode is null");
}
try {
// re-parse tc
Parser parser = new Parser(logFileMetaData);
model = parser.preParse(tc, logRecordIndexes, preferences, mscView.getFilterPattern(), null);
} catch (IOException e) {
throw new TechnicalException("Error while parsing of the log file");
} catch (ParseException e) {
throw new TechnicalException("Error while parsing of the log file");
}
return model;
}
};
job.schedule();
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace("Error while parsing of the log file", e);
TitanLogExceptionHandler.handleException(new TechnicalException(e.getMessage()));
}
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class StatisticalView method saveState.
@Override
public void saveState(final IMemento memento) {
// do not save empty views
if (this.reader == null) {
return;
}
// $NON-NLS-1$
IMemento tempMemento = memento.createChild("selection");
try {
IMemento[] viewAttributes = new IMemento[this.statisticalDataVector.size()];
for (int i = 0; i < this.statisticalDataVector.size(); i++) {
// $NON-NLS-1$
IMemento viewAttribute = tempMemento.createChild("viewAttributes");
StatisticalData statisticData = this.statisticalDataVector.get(i);
LogFileMetaData logFileMetaData = statisticData.getLogFileMetaData();
// $NON-NLS-1$
viewAttribute.putString("projectName", logFileMetaData.getProjectName());
// save state about log file
Path filePath = new Path(logFileMetaData.getProjectRelativePath());
IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
if ((logFile != null) && logFile.exists()) {
// add property file to the memento
// $NON-NLS-1$
viewAttribute.putString("propertyFile", LogFileCacheHandler.getPropertyFileForLogFile(logFile).getAbsolutePath());
File aLogFile = logFile.getLocation().toFile();
// $NON-NLS-1$
viewAttribute.putString("fileSize", String.valueOf(aLogFile.length()));
// $NON-NLS-1$
viewAttribute.putString("fileModification", String.valueOf(aLogFile.lastModified()));
}
viewAttributes[i] = viewAttribute;
}
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData 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);
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class OpenSourceViewMenuAction method run.
@Override
public void run() {
if (this.eventSelection == null) {
return;
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
LogFileMetaData logFileMetaData;
logFileMetaData = this.view.getLogFileMetaData();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject(logFileMetaData.getProjectName());
IFile logFile = project.getFile(logFileMetaData.getProjectRelativePath().substring(logFileMetaData.getProjectName().length() + 1));
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException("The log file could not be found.\n Please perform the Open Text Table action again."));
return;
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return;
}
EventObject eventObject = this.eventSelection.getEventObject();
String testCase = this.eventSelection.getTestCaseName();
if ((eventObject == null) || (testCase == null)) {
return;
}
// get value
LogRecord logrecord;
try {
logrecord = ValueReader.getInstance().readLogRecordFromLogFile(logFileMetaData.getFilePath(), eventObject);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
return;
}
SourceInformation sourceInformation = null;
try {
sourceInformation = SourceInformation.createInstance(logrecord.getSourceInformation());
} catch (InvalidSourceInformationException e) {
if (!silent) {
String setting = logFileMetaData.getOptionsSettings("SourceInfoFormat");
if (setting == null) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(null, "Error opening source", // $NON-NLS-1$
"This log file is not generated with source location information inserted. And it really does not seem to contain source location information");
}
});
} else {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// $NON-NLS-1$
MessageDialog.openError(null, "Error opening source", "This log record does not seem to contain source location information");
}
});
}
}
return;
}
final String fileName = sourceInformation.getSourceFileName();
if (fileName == null) {
view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The name of the target file could not be extracted");
return;
}
IFile targetFile;
if (lastFilename != null && lastFilename.equals(fileName) && lastPath != null) {
IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(lastPath);
if (files.length == 0) {
view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + lastFilename + "' could not be found");
setLastFilename(null);
return;
}
targetFile = files[0];
} else {
targetFile = OpenSourceAction.findSourceFile(project, fileName);
if (targetFile == null) {
view.getViewSite().getActionBars().getStatusLineManager().setErrorMessage("The file `" + fileName + "' could not be found");
return;
}
setLastFilename(fileName);
setLastPath(targetFile.getLocationURI());
}
OpenSourceAction.openEditor(targetFile, sourceInformation.getLineNumber(), view, forceEditorOpening);
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class OpenValueViewMenuAction method run.
@Override
public void run() {
if (this.eventSelection == null) {
return;
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
LogFileMetaData logFileMetaData;
if (this.view instanceof MSCView) {
logFileMetaData = ((MSCView) this.view).getLogFileMetaData();
} else if (this.view instanceof TextTableView) {
logFileMetaData = ((TextTableView) this.view).getLogFileMetaData();
} else {
return;
}
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject(logFileMetaData.getProjectName());
IFile logFile = project.getFile(logFileMetaData.getProjectRelativePath().substring(logFileMetaData.getProjectName().length() + 1));
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
if (this.view instanceof TextTableView) {
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException("The log file could not be found.\n Please perform the Open Text Table action again."));
} else {
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewMenuAction.1")));
}
return;
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return;
}
DetailsView detailsview = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
if (detailsview == null && !forceEditorOpening) {
return;
}
if (forceEditorOpening) {
try {
detailsview = (DetailsView) activePage.showView(Constants.DETAILS_VIEW_ID);
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.1") + e.getMessage()));
return;
}
}
// pass log file meta data
detailsview.setLogFileMetaData(logFileMetaData);
EventObject eventObject = this.eventSelection.getEventObject();
String testCase = this.eventSelection.getTestCaseName();
if ((eventObject == null) || (testCase == null)) {
return;
}
// get value
LogRecord logrecord;
try {
logrecord = ValueReader.getInstance().readLogRecordFromLogFile(logFileMetaData.getFilePath(), eventObject);
} catch (final IOException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
return;
} catch (final ParseException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("MSCView.8")));
return;
}
String message = logrecord.getMessage();
DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
detailsview.setData(detailData, false);
detailsview.setFocus();
}
Aggregations