Search in sources :

Example 1 with EventSelection

use of org.eclipse.titan.log.viewer.views.msc.model.EventSelection in project titan.EclipsePlug-ins by eclipse.

the class TextTableView method addListeners.

private void addListeners() {
    this.table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (logFileMetaData == null) {
                return;
            }
            final IFile logFile = logFileMetaData.getLogfile();
            if (logFile == null) {
                return;
            }
            if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
                LogFileCacheHandler.handleLogFileChange(logFile);
                return;
            }
            setContentDescription(TextTableView.this.logFileMetaData.getProjectRelativePath() + " [" + (TextTableView.this.table.getSelectionIndex() + 1) + "/" + TextTableView.this.filteredLogReader.size() + "]");
            if (e.getSource() instanceof Table) {
                updateSelection((Table) e.getSource());
            }
        }
    });
    this.table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(final MouseEvent e) {
            if (logFileMetaData == null) {
                return;
            }
            final IFile logFile = logFileMetaData.getLogfile();
            if (logFile == null) {
                return;
            }
            if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
                LogFileCacheHandler.handleLogFileChange(logFile);
                return;
            }
            if (!(e.getSource() instanceof Table)) {
                return;
            }
            Table table = (Table) e.getSource();
            int index = table.getSelectionIndex();
            if (index < 0 || index >= table.getItemCount()) {
                return;
            }
            TableItem tableItem = table.getItem(index);
            Object data = tableItem.getData();
            if (data instanceof LogRecord) {
                LogRecord logrecord = (LogRecord) data;
                EventObject eventObject = createEventObject(logrecord);
                // $NON-NLS-1$
                TextTableView.this.eventSelection = new EventSelection(eventObject, "");
                TextTableView.this.openValueViewMenuAction.run();
                silentOpenSourceViewMenuAction.selectionChanged(eventSelection);
                silentOpenSourceViewMenuAction.run();
            } else {
                TextTableView.this.eventSelection = new EventSelection(null, null);
            }
            fireSelectionChangeEvent();
        }
    });
    this.table.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(final KeyEvent e) {
            int moves = e.keyCode;
            if (moves != SWT.CR) {
                return;
            }
            if (e.getSource() instanceof Table) {
                Table table = (Table) e.getSource();
                TableItem tableItem = table.getItem(table.getSelectionIndex());
                Object data = tableItem.getData();
                if (data instanceof LogRecord) {
                    LogRecord logrecord = (LogRecord) data;
                    EventObject eventObject = createEventObject(logrecord);
                    // $NON-NLS-1$
                    TextTableView.this.eventSelection = new EventSelection(eventObject, "");
                } else {
                    TextTableView.this.eventSelection = new EventSelection(null, null);
                }
            }
            fireSelectionChangeEvent();
            TextTableView.this.openValueViewMenuAction.run();
            silentOpenSourceViewMenuAction.selectionChanged(eventSelection);
            silentOpenSourceViewMenuAction.run();
        }
    });
}
Also used : IFile(org.eclipse.core.resources.IFile) Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) KeyAdapter(org.eclipse.swt.events.KeyAdapter) MouseAdapter(org.eclipse.swt.events.MouseAdapter) EventSelection(org.eclipse.titan.log.viewer.views.msc.model.EventSelection) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) KeyEvent(org.eclipse.swt.events.KeyEvent) LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject)

Example 2 with EventSelection

use of org.eclipse.titan.log.viewer.views.msc.model.EventSelection in project titan.EclipsePlug-ins by eclipse.

the class TextTableView method updateSelection.

/**
 * Update the selection in the provided table
 *
 *  @param table to work on
 */
private void updateSelection(Table table1) {
    TableItem tableItem = table1.getItem(table1.getSelectionIndex());
    Object data = tableItem.getData();
    if (data instanceof LogRecord) {
        LogRecord logrecord = (LogRecord) data;
        TextTableView.this.selectedEventObject = createEventObject(logrecord);
        TextTableView.this.eventSelection = new EventSelection(TextTableView.this.selectedEventObject, "");
    } else {
        TextTableView.this.eventSelection = new EventSelection(null, null);
    }
    fireSelectionChangeEvent();
    silentOpenSourceViewMenuAction.delayedRun(eventSelection);
    silentOpenValueViewMenuAction.delayedRun(eventSelection);
}
Also used : LogRecord(org.eclipse.titan.log.viewer.parsers.data.LogRecord) TableItem(org.eclipse.swt.widgets.TableItem) EventObject(org.eclipse.titan.log.viewer.views.msc.model.EventObject) EventSelection(org.eclipse.titan.log.viewer.views.msc.model.EventSelection)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)2 LogRecord (org.eclipse.titan.log.viewer.parsers.data.LogRecord)2 EventObject (org.eclipse.titan.log.viewer.views.msc.model.EventObject)2 EventSelection (org.eclipse.titan.log.viewer.views.msc.model.EventSelection)2 IFile (org.eclipse.core.resources.IFile)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Table (org.eclipse.swt.widgets.Table)1