use of org.eclipse.titan.log.viewer.views.msc.ui.view.MSCWidget 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();
}
Aggregations