use of org.eclipse.titan.log.viewer.views.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.
the class LogSearchResultPage method showMatch.
@Override
protected void showMatch(final Match match, final int currentOffset, final int currentLength, final boolean activate) throws PartInitException {
IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection();
if (!selection.toList().contains(match)) {
treeViewer.setSelection(new StructuredSelection(match));
}
IFile logFile = (IFile) match.getElement();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
TextTableView openedView;
IViewReference viewReference = activePage.findViewReference(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString());
if (viewReference == null) {
openTextTableView(logFile, match.getOffset());
return;
}
TextTableView view = (TextTableView) viewReference.getView(false);
if (view != null && view.isFiltered() && !view.contains(match.getOffset())) {
MessageBox mb = new MessageBox(this.getSite().getShell(), SWT.ICON_QUESTION | SWT.YES | SWT.NO);
mb.setText("Filtered match");
mb.setMessage("The selected record can not be displayed in the opened TextTableView." + " Would you like to open a new view? (The old one will be closed)");
switch(mb.open()) {
case SWT.YES:
activePage.hideView(viewReference);
openTextTableView(logFile, match.getOffset());
break;
case SWT.NO:
break;
default:
return;
}
return;
}
openedView = (TextTableView) activePage.showView(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString(), org.eclipse.ui.IWorkbenchPage.VIEW_VISIBLE);
openedView.setSelectedRecord(match.getOffset());
}
use of org.eclipse.titan.log.viewer.views.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.
the class MSCView method createPartControl.
@Override
public void createPartControl(final Composite c) {
// restores any saved state
final WorkspaceJob job = restoreState();
if (this.problemDuringRestore) {
Label text = new Label(c, SWT.LEFT);
// $NON-NLS-1$
text.setText(Messages.getString("MSCView.0"));
return;
}
Composite parent = new Composite(c, SWT.NONE);
GridLayout parentLayout = new GridLayout();
parentLayout.numColumns = 1;
parentLayout.marginWidth = 0;
parentLayout.marginHeight = 0;
parent.setLayout(parentLayout);
GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
this.mscWidget = new MSCWidget(parent, SWT.NONE);
this.mscWidget.setLayoutData(seqDiagLayoutData);
this.mscWidget.setDragAutoScroll(false);
this.mscWidget.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.keyCode != SWT.CR) {
return;
}
PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(MSCView.this.logFileMetaData.getProjectName());
int defaultBehaviour = preferences.getMscViewDefault();
if (defaultBehaviour == PreferenceConstants.DEFAULT_TEXT) {
MSCView.this.openTextTable.run();
} else {
MSCView.this.openValueView.run();
}
}
});
this.mscWidget.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(final MouseEvent e) {
PreferencesHolder preferences = PreferencesHandler.getInstance().getPreferences(MSCView.this.logFileMetaData.getProjectName());
int defaultBehaviour = preferences.getMscViewDefault();
if (defaultBehaviour == PreferenceConstants.DEFAULT_TEXT) {
MSCView.this.openTextTable.run();
} else {
MSCView.this.openValueView.run();
}
}
});
this.mscWidget.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(final SelectionChangedEvent event) {
if (!(event.getSelection() instanceof IStructuredSelection)) {
return;
}
if (MSCView.this.model == null) {
return;
}
final IFile logFile = MSCView.this.model.getTestCase().getLogFile();
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return;
}
final IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
final IViewReference[] viewReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
if (MSCView.this.logFileMetaData == null) {
return;
}
for (IViewReference viewReference : viewReferences) {
final IViewPart viewPart = viewReference.getView(false);
if (viewPart instanceof TextTableView && ((TextTableView) viewPart).getLogFileMetaData() != null && MSCView.this.logFileMetaData.getFilePath().equals(((TextTableView) viewPart).getLogFileMetaData().getFilePath())) {
final Integer selectedLine = (Integer) structuredSelection.getFirstElement();
final int recordNumber = MSCView.this.model.getEvent(selectedLine - 2).getRecordNumber();
TextTableView textTableView = (TextTableView) viewPart;
if (textTableView.getSelectedRecord() != null && textTableView.getSelectedRecord().getRecordNumber() != recordNumber) {
textTableView.setSelectedRecord(recordNumber);
}
break;
}
}
silentOpenSource.delayedRun(event.getSelection());
silentOpenValueView.delayedRun(event.getSelection());
}
});
createCoolbarContent();
hookContextMenu();
parent.layout(true);
WorkspaceJob job2 = new WorkspaceJob("Displaying loaded log information") {
@Override
public IStatus runInWorkspace(final IProgressMonitor monitor) throws CoreException {
if (job == null) {
return Status.OK_STATUS;
}
try {
job.join();
} catch (InterruptedException e) {
return Status.CANCEL_STATUS;
}
// Check if model was restored
if ((MSCView.this.logFileMetaData != null) && (MSCView.this.model != null)) {
// always open restore at top
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
setModel(MSCView.this.model, MSCView.this.restoredSelection);
}
});
}
return Status.OK_STATUS;
}
};
job2.setSystem(true);
job2.schedule();
}
use of org.eclipse.titan.log.viewer.views.text.table.TextTableView 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.text.table.TextTableView in project titan.EclipsePlug-ins by eclipse.
the class LogSearchResultPage method openTextTableView.
private TextTableView openTextTableView(final IFile logFile, final int recordToSelect) {
try {
TextTableView part = (TextTableView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(Constants.TEXT_TABLE_VIEW_ID, logFile.getFullPath().toOSString(), IWorkbenchPage.VIEW_VISIBLE);
part.setInput(logFile, recordToSelect);
return part;
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.5") + e.getMessage()));
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.6") + e.getMessage()));
} catch (ClassNotFoundException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenTextTableProjectsViewMenuAction.7") + e.getMessage()));
}
return null;
}
Aggregations