use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class ActionUtils method closeView.
private static void closeView(IFile file, IWorkbenchPage activePage, IViewReference reference) {
IViewPart view = reference.getView(false);
// a restored view with faulty content
if (view == null) {
activePage.hideView(reference);
return;
}
if (!(view instanceof ILogViewerView)) {
return;
}
final ILogViewerView logViewerView = (ILogViewerView) view;
final LogFileMetaData metadata = logViewerView.getLogFileMetaData();
if (metadata == null) {
activePage.hideView(reference);
return;
}
if (file.getLocationURI().equals(metadata.getFilePath())) {
if (logViewerView instanceof DetailsView) {
((DetailsView) logViewerView).setData(null, false);
}
activePage.hideView(reference);
}
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class ActionUtils method closeView.
private static void closeView(IProject project, IWorkbenchPage activePage, IViewReference reference, IViewPart view) {
// a restored view with faulty content
if (view == null) {
activePage.hideView(reference);
return;
}
if (!(view instanceof ILogViewerView)) {
return;
}
final ILogViewerView logViewerView = (ILogViewerView) view;
final LogFileMetaData metaData = logViewerView.getLogFileMetaData();
if (metaData == null) {
activePage.hideView(reference);
return;
}
if (project.getName().equals(metaData.getProjectName())) {
activePage.hideView(reference);
}
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class LogFileCacheHandler method logFileMetaDataReader.
/**
* @param propertyFile property file to read from
* @return Log file meta data
* @throws IOException if log file meta data can not be found
* @throws ClassNotFoundException if log file meta data can not be found
*/
public static LogFileMetaData logFileMetaDataReader(final File propertyFile) throws IOException, ClassNotFoundException {
FileInputStream stream = null;
LogFileMetaData logFileMetaData = null;
ObjectInputStream objectFile = null;
try {
stream = new FileInputStream(propertyFile);
objectFile = new ObjectInputStream(stream);
logFileMetaData = (LogFileMetaData) objectFile.readObject();
} catch (final InvalidClassException e) {
FileUtils.deleteQuietly(propertyFile);
} finally {
IOUtils.closeQuietly(stream, objectFile);
}
return logFileMetaData;
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class LogFileCacheHandler method isPropertyFileInvalid.
private static boolean isPropertyFileInvalid(IFile logFile, File propertyFile) {
try {
LogFileMetaData logFileMetaData = logFileMetaDataReader(propertyFile);
String projectName = logFile.getProject().getName();
String projectRelativePath = File.separator + projectName + File.separator + logFile.getProjectRelativePath().toOSString();
URI logFilePath = logFile.getLocationURI();
if (!logFileMetaData.getProjectRelativePath().contentEquals(projectRelativePath) || !logFileMetaData.getFilePath().equals(logFilePath)) {
return true;
}
} catch (final IOException e) {
return true;
} catch (final ClassNotFoundException e) {
return true;
}
return false;
}
use of org.eclipse.titan.log.viewer.models.LogFileMetaData in project titan.EclipsePlug-ins by eclipse.
the class OpenValueViewAction method run.
@Override
public void run() {
if (selectedLine == null || this.mscView == null || selectedLine < 2 || selectedLine >= this.mscView.getModel().getNumberOfEvents() + 2) {
return;
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage == null) {
return;
}
LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
IProject project = getProjectByName(logFileMetaData);
IFile logFile = getLogFileFromProject(logFileMetaData, project);
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewAction.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("OpenValueViewAction.4") + e.getMessage()));
return;
}
}
// pass log file meta data
detailsview.setLogFileMetaData(this.mscView.getLogFileMetaData());
ExecutionModel model = this.mscView.getModel();
IEventObject ieventObject = model.getEvent(selectedLine - 2);
if (!(ieventObject instanceof EventObject)) {
return;
}
EventObject eventObject = (EventObject) ieventObject;
String testCase = model.getTestCase().getTestCaseName();
if ((testCase == null) || eventObject.getRecordNumber() == 0) {
return;
}
// get value
LogRecord logrecord;
try {
logrecord = ValueReader.getInstance().readLogRecordFromLogFileCached(this.mscView.getLogFileMetaData().getFilePath(), eventObject);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.3")));
return;
}
String message = logrecord.getMessage();
DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
detailsview.setData(detailData, false);
}
Aggregations