use of org.eclipse.titan.log.viewer.views.details.DetailData 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);
}
use of org.eclipse.titan.log.viewer.views.details.DetailData 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();
}
use of org.eclipse.titan.log.viewer.views.details.DetailData in project titan.EclipsePlug-ins by eclipse.
the class DetailsView 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 (memento == null) {
return;
}
// $NON-NLS-1$
memento = memento.getChild("selection");
if (memento != null) {
DetailData detailObject = new DetailData();
try {
// $NON-NLS-1$
IMemento mementoEventObject = memento.getChild("eventObject");
// $NON-NLS-1$
detailObject.setName(mementoEventObject.getString("name"));
// $NON-NLS-1$
detailObject.setPort(mementoEventObject.getString("port"));
// $NON-NLS-1$
detailObject.setLine(mementoEventObject.getString("line"));
// $NON-NLS-1$
detailObject.setTestCase(mementoEventObject.getString("testCaseName"));
// $NON-NLS-1$
detailObject.setEventType(mementoEventObject.getString("eventType"));
// $NON-NLS-1$
detailObject.setSourceInfo(mementoEventObject.getString("sourceInfo"));
// $NON-NLS-1$
long fileSize = Long.parseLong(mementoEventObject.getString("fileSize"));
// $NON-NLS-1$
long fileModification = Long.parseLong(mementoEventObject.getString("fileModification"));
// retrieve logfilemetaData
// $NON-NLS-1$
String propertyFilePath = mementoEventObject.getString("propertyFile");
if (propertyFilePath != null) {
File propertyFile = new File(propertyFilePath);
if (!propertyFile.exists()) {
return;
}
logFileMetaData = LogFileCacheHandler.logFileMetaDataReader(propertyFile);
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(logFileMetaData.getProjectName());
if (project != null && project.exists() && project.isOpen()) {
Path path = new Path(logFileMetaData.getProjectRelativePath());
IFile logFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
if (logFile != null && logFile.getProject().getName().equals(project.getName()) && logFile.exists()) {
File file = logFile.getLocation().toFile();
if (file.lastModified() == fileModification && file.length() == fileSize) {
// $NON-NLS-1$
Integer silentEvent = mementoEventObject.getInteger("isSilentEvent");
this.textView = getTextView();
if (silentEvent == 1) {
this.useFormatting = true;
this.textView.setUseFormatting(false);
} else {
this.useFormatting = false;
this.textView.setUseFormatting(true);
}
setData(detailObject, this.useFormatting);
}
}
}
} catch (final IOException e) {
ErrorReporter.logExceptionStackTrace(e);
} catch (final ClassNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
memento = null;
}
Aggregations