add initial version of search list
This commit is contained in:
		@@ -164,10 +164,10 @@ public class WaveformView implements IWaveformView  {
 | 
				
			|||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) !=0 , false);
 | 
											setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) !=0 , false);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
					lastClickedEntry = entry.getValue();
 | 
										lastClickedEntry = entry.getValue();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	class WaveformMouseListener implements PaintListener, Listener {
 | 
						class WaveformMouseListener implements PaintListener, Listener {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,9 @@ Require-Bundle: javax.inject;bundle-version="1.0.0",
 | 
				
			|||||||
 org.eclipse.e4.core.di.extensions,
 | 
					 org.eclipse.e4.core.di.extensions,
 | 
				
			||||||
 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
 | 
					 org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
 | 
				
			||||||
 org.eclipse.core.resources;bundle-version="3.13.0",
 | 
					 org.eclipse.core.resources;bundle-version="3.13.0",
 | 
				
			||||||
 javax.annotation;bundle-version="1.2.0"
 | 
					 javax.annotation;bundle-version="1.2.0",
 | 
				
			||||||
 | 
					 org.eclipse.core.databinding,
 | 
				
			||||||
 | 
					 org.eclipse.jface.databinding
 | 
				
			||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 | 
					Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 | 
				
			||||||
Import-Package: com.minres.scviewer.database,
 | 
					Import-Package: com.minres.scviewer.database,
 | 
				
			||||||
 javax.inject;version="1.0.0"
 | 
					 javax.inject;version="1.0.0"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,17 +10,11 @@
 | 
				
			|||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
package com.minres.scviewer.e4.application;
 | 
					package com.minres.scviewer.e4.application;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.io.File;
 | 
					 | 
				
			||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.PostConstruct;
 | 
					import javax.annotation.PostConstruct;
 | 
				
			||||||
import javax.inject.Inject;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.eclipse.core.runtime.Platform;
 | 
					import org.eclipse.core.runtime.Platform;
 | 
				
			||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener;
 | 
					 | 
				
			||||||
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
 | 
					 | 
				
			||||||
import org.eclipse.e4.core.contexts.IEclipseContext;
 | 
					import org.eclipse.e4.core.contexts.IEclipseContext;
 | 
				
			||||||
import org.eclipse.e4.core.services.events.IEventBroker;
 | 
					import org.eclipse.e4.core.services.events.IEventBroker;
 | 
				
			||||||
import org.eclipse.e4.ui.model.application.MApplication;
 | 
					import org.eclipse.e4.ui.model.application.MApplication;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,11 +15,9 @@ import org.eclipse.e4.core.di.annotations.Execute;
 | 
				
			|||||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 | 
					import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 | 
				
			||||||
import org.eclipse.jface.viewers.ISelection;
 | 
					import org.eclipse.jface.viewers.ISelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.StructuredSelection;
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
import org.eclipse.jface.window.Window;
 | 
					 | 
				
			||||||
import org.eclipse.swt.widgets.Shell;
 | 
					import org.eclipse.swt.widgets.Shell;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.minres.scviewer.database.ui.TrackEntry;
 | 
					import com.minres.scviewer.database.ui.TrackEntry;
 | 
				
			||||||
import com.minres.scviewer.e4.application.parts.SearchTxDialog;
 | 
					 | 
				
			||||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
					import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
				
			||||||
public class SearchHandler {
 | 
					public class SearchHandler {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -44,13 +42,14 @@ public class SearchHandler {
 | 
				
			|||||||
		Object obj = activePart.getObject();
 | 
							Object obj = activePart.getObject();
 | 
				
			||||||
		if(obj instanceof WaveformViewer){
 | 
							if(obj instanceof WaveformViewer){
 | 
				
			||||||
			WaveformViewer wfv = (WaveformViewer)obj;
 | 
								WaveformViewer wfv = (WaveformViewer)obj;
 | 
				
			||||||
			ISelection sel = wfv.getSelection();
 | 
								wfv.showSearch();
 | 
				
			||||||
			if(sel instanceof StructuredSelection) {
 | 
					//			ISelection sel = wfv.getSelection();
 | 
				
			||||||
				TrackEntry e = findTrackEntry(((StructuredSelection)sel).toArray());
 | 
					//			if(sel instanceof StructuredSelection) {
 | 
				
			||||||
				SearchTxDialog dlg = new SearchTxDialog(shell, e.getStream());
 | 
					//				TrackEntry e = findTrackEntry(((StructuredSelection)sel).toArray());
 | 
				
			||||||
				if (dlg.open() != Window.OK) return;
 | 
					//				SearchTxDialog dlg = new SearchTxDialog(shell, e.getStream());
 | 
				
			||||||
				wfv.search(dlg.getPropName(), dlg.getPropType(), dlg.getPropValue());
 | 
					//				if (dlg.open() != Window.OK) return;
 | 
				
			||||||
			}
 | 
					//				wfv.search(dlg.getPropName(), dlg.getPropType(), dlg.getPropValue());
 | 
				
			||||||
 | 
					//			}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,5 @@
 | 
				
			|||||||
package com.minres.scviewer.e4.application.parts;
 | 
					package com.minres.scviewer.e4.application.parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.HashMap;
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
import java.util.Map.Entry;
 | 
					import java.util.Map.Entry;
 | 
				
			||||||
@@ -17,11 +16,9 @@ import org.eclipse.jface.viewers.LabelProvider;
 | 
				
			|||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
 | 
					import org.eclipse.jface.viewers.SelectionChangedEvent;
 | 
				
			||||||
import org.eclipse.jface.viewers.StructuredSelection;
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
import org.eclipse.swt.SWT;
 | 
					import org.eclipse.swt.SWT;
 | 
				
			||||||
import org.eclipse.swt.graphics.Point;
 | 
					 | 
				
			||||||
import org.eclipse.swt.layout.GridData;
 | 
					import org.eclipse.swt.layout.GridData;
 | 
				
			||||||
import org.eclipse.swt.layout.GridLayout;
 | 
					import org.eclipse.swt.layout.GridLayout;
 | 
				
			||||||
import org.eclipse.swt.widgets.Button;
 | 
					import org.eclipse.swt.widgets.Button;
 | 
				
			||||||
import org.eclipse.swt.widgets.Combo;
 | 
					 | 
				
			||||||
import org.eclipse.swt.widgets.Composite;
 | 
					import org.eclipse.swt.widgets.Composite;
 | 
				
			||||||
import org.eclipse.swt.widgets.Control;
 | 
					import org.eclipse.swt.widgets.Control;
 | 
				
			||||||
import org.eclipse.swt.widgets.Label;
 | 
					import org.eclipse.swt.widgets.Label;
 | 
				
			||||||
@@ -166,7 +163,6 @@ public class SearchTxDialog extends TitleAreaDialog {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	protected void okPressed() {
 | 
						protected void okPressed() {
 | 
				
			||||||
		//propName=propNameCombo.getItem(propNameCombo.getSelectionIndex());
 | 
					 | 
				
			||||||
		propValue=propValueText.getText();
 | 
							propValue=propValueText.getText();
 | 
				
			||||||
		super.okPressed();
 | 
							super.okPressed();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,15 +10,10 @@
 | 
				
			|||||||
 *******************************************************************************/
 | 
					 *******************************************************************************/
 | 
				
			||||||
package com.minres.scviewer.e4.application.parts;
 | 
					package com.minres.scviewer.e4.application.parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.AbstractMap;
 | 
					 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
import java.util.Objects;
 | 
					import java.util.Objects;
 | 
				
			||||||
import java.util.TreeMap;
 | 
					 | 
				
			||||||
import java.util.Vector;
 | 
					 | 
				
			||||||
import java.util.regex.PatternSyntaxException;
 | 
					 | 
				
			||||||
import java.util.stream.Collectors;
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.annotation.PostConstruct;
 | 
					import javax.annotation.PostConstruct;
 | 
				
			||||||
@@ -34,23 +29,16 @@ import org.eclipse.e4.ui.services.IServiceConstants;
 | 
				
			|||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
					import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
				
			||||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 | 
					import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 | 
				
			||||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
 | 
					import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
 | 
				
			||||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.DoubleClickEvent;
 | 
					import org.eclipse.jface.viewers.DoubleClickEvent;
 | 
				
			||||||
import org.eclipse.jface.viewers.IDoubleClickListener;
 | 
					import org.eclipse.jface.viewers.IDoubleClickListener;
 | 
				
			||||||
import org.eclipse.jface.viewers.ISelection;
 | 
					import org.eclipse.jface.viewers.ISelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
					import org.eclipse.jface.viewers.IStructuredSelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.ITreeContentProvider;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.ITreeViewerListener;
 | 
					import org.eclipse.jface.viewers.ITreeViewerListener;
 | 
				
			||||||
import org.eclipse.jface.viewers.LabelProvider;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.StructuredSelection;
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.StyledString;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.TreeExpansionEvent;
 | 
					import org.eclipse.jface.viewers.TreeExpansionEvent;
 | 
				
			||||||
import org.eclipse.jface.viewers.TreePath;
 | 
					import org.eclipse.jface.viewers.TreePath;
 | 
				
			||||||
import org.eclipse.jface.viewers.TreeViewer;
 | 
					import org.eclipse.jface.viewers.TreeViewer;
 | 
				
			||||||
import org.eclipse.jface.viewers.TreeViewerColumn;
 | 
					import org.eclipse.jface.viewers.TreeViewerColumn;
 | 
				
			||||||
import org.eclipse.jface.viewers.Viewer;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.ViewerComparator;
 | 
					 | 
				
			||||||
import org.eclipse.jface.viewers.ViewerFilter;
 | 
					 | 
				
			||||||
import org.eclipse.swt.SWT;
 | 
					import org.eclipse.swt.SWT;
 | 
				
			||||||
import org.eclipse.swt.events.ControlAdapter;
 | 
					import org.eclipse.swt.events.ControlAdapter;
 | 
				
			||||||
import org.eclipse.swt.events.ControlEvent;
 | 
					import org.eclipse.swt.events.ControlEvent;
 | 
				
			||||||
@@ -68,11 +56,14 @@ import org.eclipse.swt.widgets.Text;
 | 
				
			|||||||
import org.eclipse.swt.widgets.Tree;
 | 
					import org.eclipse.swt.widgets.Tree;
 | 
				
			||||||
import org.eclipse.swt.widgets.TreeItem;
 | 
					import org.eclipse.swt.widgets.TreeItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.minres.scviewer.database.DataType;
 | 
					 | 
				
			||||||
import com.minres.scviewer.database.ITx;
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
import com.minres.scviewer.database.ITxAttribute;
 | 
					 | 
				
			||||||
import com.minres.scviewer.database.ITxRelation;
 | 
					 | 
				
			||||||
import com.minres.scviewer.e4.application.Messages;
 | 
					import com.minres.scviewer.e4.application.Messages;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNode;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNodeType;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.TxAttributeFilter;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.TxAttributeViewerSorter;
 | 
				
			||||||
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
 | 
					import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -145,7 +136,18 @@ public class TransactionDetails {
 | 
				
			|||||||
		viewSorter = new TxAttributeViewerSorter();
 | 
							viewSorter = new TxAttributeViewerSorter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		treeViewer = new TreeViewer(top);
 | 
							treeViewer = new TreeViewer(top);
 | 
				
			||||||
		treeViewer.setContentProvider(new TransactionTreeContentProvider());
 | 
							treeViewer.setContentProvider(new AbstractTransactionTreeContentProvider(waveformViewerPart) {
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public Object[] getElements(Object element) {
 | 
				
			||||||
 | 
									return new Object[]{
 | 
				
			||||||
 | 
											new TransactionTreeNode((ITx)element, TransactionTreeNodeType.PROPS),  
 | 
				
			||||||
 | 
											new TransactionTreeNode((ITx)element, TransactionTreeNodeType.ATTRS),  
 | 
				
			||||||
 | 
											new TransactionTreeNode((ITx)element, TransactionTreeNodeType.IN_REL),
 | 
				
			||||||
 | 
											new TransactionTreeNode((ITx)element, TransactionTreeNodeType.OUT_REL)
 | 
				
			||||||
 | 
									};
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
		treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
 | 
							treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
 | 
				
			||||||
		treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
 | 
							treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
 | 
				
			||||||
		treeViewer.addFilter(attributeFilter);
 | 
							treeViewer.addFilter(attributeFilter);
 | 
				
			||||||
@@ -171,7 +173,7 @@ public class TransactionDetails {
 | 
				
			|||||||
		col1 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
							col1 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
		col1.getColumn().setText(Messages.TransactionDetails_1);
 | 
							col1.getColumn().setText(Messages.TransactionDetails_1);
 | 
				
			||||||
		col1.getColumn().setResizable(true);
 | 
							col1.getColumn().setResizable(true);
 | 
				
			||||||
		col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.NAME)));
 | 
							col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.NAME)));
 | 
				
			||||||
		col1.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
							col1.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
				
			||||||
			public void widgetSelected(SelectionEvent event) {
 | 
								public void widgetSelected(SelectionEvent event) {
 | 
				
			||||||
				((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_FIRST);
 | 
									((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_FIRST);
 | 
				
			||||||
@@ -182,7 +184,7 @@ public class TransactionDetails {
 | 
				
			|||||||
		col2 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
							col2 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
		col2.getColumn().setText(Messages.TransactionDetails_2);
 | 
							col2.getColumn().setText(Messages.TransactionDetails_2);
 | 
				
			||||||
		col2.getColumn().setResizable(true);
 | 
							col2.getColumn().setResizable(true);
 | 
				
			||||||
		col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.TYPE)));
 | 
							col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.TYPE)));
 | 
				
			||||||
		col2.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
							col2.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
				
			||||||
			public void widgetSelected(SelectionEvent event) {
 | 
								public void widgetSelected(SelectionEvent event) {
 | 
				
			||||||
				((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
 | 
									((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
 | 
				
			||||||
@@ -193,7 +195,7 @@ public class TransactionDetails {
 | 
				
			|||||||
		col3 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
							col3 = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
		col3.getColumn().setText(Messages.TransactionDetails_3);
 | 
							col3.getColumn().setText(Messages.TransactionDetails_3);
 | 
				
			||||||
		col3.getColumn().setResizable(true);
 | 
							col3.getColumn().setResizable(true);
 | 
				
			||||||
		col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.VALUE)));
 | 
							col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.VALUE)));
 | 
				
			||||||
		col3.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
							col3.getColumn().addSelectionListener(new SelectionAdapter() {
 | 
				
			||||||
			public void widgetSelected(SelectionEvent event) {
 | 
								public void widgetSelected(SelectionEvent event) {
 | 
				
			||||||
				((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
 | 
									((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
 | 
				
			||||||
@@ -333,15 +335,15 @@ public class TransactionDetails {
 | 
				
			|||||||
		if(paths==null)
 | 
							if(paths==null)
 | 
				
			||||||
			treeViewer.setAutoExpandLevel(2);
 | 
								treeViewer.setAutoExpandLevel(2);
 | 
				
			||||||
		else {
 | 
							else {
 | 
				
			||||||
			TransactionTreeContentProvider cp = (TransactionTreeContentProvider) treeViewer.getContentProvider();
 | 
								AbstractTransactionTreeContentProvider cp = (AbstractTransactionTreeContentProvider) treeViewer.getContentProvider();
 | 
				
			||||||
			Object[] elems = cp.getElements(treeViewer.getInput());
 | 
								Object[] elems = cp.getElements(treeViewer.getInput());
 | 
				
			||||||
			for(TreePath path: paths) {
 | 
								for(TreePath path: paths) {
 | 
				
			||||||
				TreeNode firstSeg = (TreeNode)path.getFirstSegment();
 | 
									TransactionTreeNode firstSeg = (TransactionTreeNode)path.getFirstSegment();
 | 
				
			||||||
				for(Object elem : elems) {
 | 
									for(Object elem : elems) {
 | 
				
			||||||
					if(((TreeNode)elem).type == firstSeg.type) {
 | 
										if(((TransactionTreeNode)elem).type == firstSeg.type) {
 | 
				
			||||||
						treeViewer.setExpandedState(elem, true);
 | 
											treeViewer.setExpandedState(elem, true);
 | 
				
			||||||
						if(firstSeg.type==TransactionDetails.Type.ATTRS && path.getSegmentCount()>1)
 | 
											if(firstSeg.type==TransactionTreeNodeType.ATTRS && path.getSegmentCount()>1)
 | 
				
			||||||
							expandSubNodes(path, 1, (TreeNode)elem);
 | 
												expandSubNodes(path, 1, (TransactionTreeNode)elem);
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -349,14 +351,14 @@ public class TransactionDetails {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private void expandSubNodes(TreePath path, int level, TreeNode elem) {
 | 
						private void expandSubNodes(TreePath path, int level, TransactionTreeNode elem) {
 | 
				
			||||||
		if(level==path.getSegmentCount()) return;
 | 
							if(level==path.getSegmentCount()) return;
 | 
				
			||||||
		TransactionTreeContentProvider cp = (TransactionTreeContentProvider) treeViewer.getContentProvider();
 | 
							AbstractTransactionTreeContentProvider cp = (AbstractTransactionTreeContentProvider) treeViewer.getContentProvider();
 | 
				
			||||||
		Object[] childs = cp.getChildren(elem);
 | 
							Object[] childs = cp.getChildren(elem);
 | 
				
			||||||
		TreeNode nextSeg = (TreeNode)path.getSegment(level);
 | 
							TransactionTreeNode nextSeg = (TransactionTreeNode)path.getSegment(level);
 | 
				
			||||||
		for(Object child:childs) {
 | 
							for(Object child:childs) {
 | 
				
			||||||
			if(child instanceof TreeNode) {
 | 
								if(child instanceof TransactionTreeNode) {
 | 
				
			||||||
				TreeNode node = (TreeNode) child;
 | 
									TransactionTreeNode node = (TransactionTreeNode) child;
 | 
				
			||||||
				if(nextSeg.toString().equals(node.toString())) {
 | 
									if(nextSeg.toString().equals(node.toString())) {
 | 
				
			||||||
					treeViewer.setExpandedState(node, true);
 | 
										treeViewer.setExpandedState(node, true);
 | 
				
			||||||
					expandSubNodes(path, level+1, node);
 | 
										expandSubNodes(path, level+1, node);
 | 
				
			||||||
@@ -398,7 +400,7 @@ public class TransactionDetails {
 | 
				
			|||||||
	public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
 | 
						public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
 | 
				
			||||||
		// only react if selection is actually from the WaveformViewer and nothing else
 | 
							// only react if selection is actually from the WaveformViewer and nothing else
 | 
				
			||||||
		MPart part = partService.getActivePart();
 | 
							MPart part = partService.getActivePart();
 | 
				
			||||||
		if( part == null || ! (part.getObject() instanceof WaveformViewer ) )
 | 
							if( part == null || ! (part.getObject() instanceof WaveformViewer )  || part.getObject() != waveformViewerPart)
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
 | 
							if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
 | 
				
			||||||
			if( selection instanceof IStructuredSelection && !selection.isEmpty()) {
 | 
								if( selection instanceof IStructuredSelection && !selection.isEmpty()) {
 | 
				
			||||||
@@ -406,406 +408,5 @@ public class TransactionDetails {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * Time to string.
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param time the time
 | 
					 | 
				
			||||||
	 * @return the string
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	String timeToString(Long time){
 | 
					 | 
				
			||||||
		return waveformViewerPart.getScaledTime(time);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * Tx to string.
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * @param tx the tx
 | 
					 | 
				
			||||||
	 * @return the string
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	String txToString(ITx tx){
 | 
					 | 
				
			||||||
		StringBuilder sb = new StringBuilder();
 | 
					 | 
				
			||||||
		sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())); //$NON-NLS-1$ //$NON-NLS-2$
 | 
					 | 
				
			||||||
		sb.append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
					 | 
				
			||||||
		return sb.toString();
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Class TxAttributeViewerSorter.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	class TxAttributeViewerSorter extends ViewerComparator {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The Constant ASCENDING. */
 | 
					 | 
				
			||||||
		private static final int ASCENDING = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The Constant DESCENDING. */
 | 
					 | 
				
			||||||
		private static final int DESCENDING = 1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The column. */
 | 
					 | 
				
			||||||
		private int column;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The direction. */
 | 
					 | 
				
			||||||
		private int direction;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * Does the sort. If it's a different column from the previous sort, do an
 | 
					 | 
				
			||||||
		 * ascending sort. If it's the same column as the last sort, toggle the sort
 | 
					 | 
				
			||||||
		 * direction.
 | 
					 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * @param column the column
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public void doSort(int column) {
 | 
					 | 
				
			||||||
			if (column == this.column) {
 | 
					 | 
				
			||||||
				// Same column as last sort; toggle the direction
 | 
					 | 
				
			||||||
				direction = 1 - direction;
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				// New column; do an ascending sort
 | 
					 | 
				
			||||||
				this.column = column;
 | 
					 | 
				
			||||||
				direction = ASCENDING;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * Compares the object for sorting.
 | 
					 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * @param viewer the viewer
 | 
					 | 
				
			||||||
		 * @param e1 the e1
 | 
					 | 
				
			||||||
		 * @param e2 the e2
 | 
					 | 
				
			||||||
		 * @return the int
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public int compare(Viewer viewer, Object e1, Object e2) {
 | 
					 | 
				
			||||||
			int rc = 0;
 | 
					 | 
				
			||||||
			if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
 | 
					 | 
				
			||||||
				ITxAttribute p1 = (ITxAttribute) e1;
 | 
					 | 
				
			||||||
				ITxAttribute p2 = (ITxAttribute) e2;
 | 
					 | 
				
			||||||
				// Determine which column and do the appropriate sort
 | 
					 | 
				
			||||||
				switch (column) {
 | 
					 | 
				
			||||||
				case COLUMN_FIRST:
 | 
					 | 
				
			||||||
					rc = getComparator().compare(p1.getName(), p2.getName());
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				case COLUMN_SECOND:
 | 
					 | 
				
			||||||
					rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				case COLUMN_THIRD:
 | 
					 | 
				
			||||||
					rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString());
 | 
					 | 
				
			||||||
					break;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				// If descending order, flip the direction
 | 
					 | 
				
			||||||
				if (direction == DESCENDING) rc = -rc;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return rc;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Class TxAttributeFilter.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	class TxAttributeFilter extends ViewerFilter {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The search string. */
 | 
					 | 
				
			||||||
		private String searchString;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * Sets the search text.
 | 
					 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * @param s the new search text
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public void setSearchText(String s) {
 | 
					 | 
				
			||||||
			this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public boolean select(Viewer viewer, Object parentElement, Object element) {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (searchString == null || searchString.length() == 0) {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(element instanceof TreeNode) {
 | 
					 | 
				
			||||||
				return true;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if(element instanceof ITxAttribute){
 | 
					 | 
				
			||||||
				try {
 | 
					 | 
				
			||||||
					return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase()));
 | 
					 | 
				
			||||||
				} catch (PatternSyntaxException e) {
 | 
					 | 
				
			||||||
					return true;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} 
 | 
					 | 
				
			||||||
			if(element instanceof Object[]) {
 | 
					 | 
				
			||||||
				try {
 | 
					 | 
				
			||||||
					return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());	
 | 
					 | 
				
			||||||
				} catch (PatternSyntaxException e) {
 | 
					 | 
				
			||||||
					return true;
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Enum Type.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	enum Type {
 | 
					 | 
				
			||||||
		PROPS,  /** The props. */
 | 
					 | 
				
			||||||
		ATTRS,  /** The attrs. */
 | 
					 | 
				
			||||||
		IN_REL, /** The in rel. */ 
 | 
					 | 
				
			||||||
		OUT_REL,/** The out rel. */
 | 
					 | 
				
			||||||
		HIER
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Class TreeNode.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	class TreeNode implements Comparable<TreeNode>{
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The type. */
 | 
					 | 
				
			||||||
		public Type type;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The element. */
 | 
					 | 
				
			||||||
		public ITx element;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		private String hier_path;
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * Instantiates a new tree node.
 | 
					 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * @param element the element
 | 
					 | 
				
			||||||
		 * @param type the type
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public TreeNode(ITx element, Type type){
 | 
					 | 
				
			||||||
			this.element=element;
 | 
					 | 
				
			||||||
			this.type=type;
 | 
					 | 
				
			||||||
			this.hier_path="";
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		public TreeNode(ITx element, String path){
 | 
					 | 
				
			||||||
			this.element=element;
 | 
					 | 
				
			||||||
			this.type=Type.HIER;
 | 
					 | 
				
			||||||
			this.hier_path=path;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see java.lang.Object#toString()
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public String toString(){
 | 
					 | 
				
			||||||
			switch(type){
 | 
					 | 
				
			||||||
			case PROPS:      return Messages.TransactionDetails_10;
 | 
					 | 
				
			||||||
			case ATTRS:	     return Messages.TransactionDetails_11;
 | 
					 | 
				
			||||||
			case IN_REL:     return Messages.TransactionDetails_12;
 | 
					 | 
				
			||||||
			case OUT_REL:    return Messages.TransactionDetails_13;
 | 
					 | 
				
			||||||
			case HIER:{
 | 
					 | 
				
			||||||
				String[] tokens = hier_path.split("\\.");
 | 
					 | 
				
			||||||
				return tokens[tokens.length-1];
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return ""; //$NON-NLS-1$
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		public Object[] getAttributeListForHier() {
 | 
					 | 
				
			||||||
			if(childs==null) {
 | 
					 | 
				
			||||||
				Map<String, Object> res = element.getAttributes().stream()
 | 
					 | 
				
			||||||
				.filter(txAttr -> txAttr.getName().startsWith(hier_path))
 | 
					 | 
				
			||||||
				.map(txAttr -> {
 | 
					 | 
				
			||||||
					String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', "");
 | 
					 | 
				
			||||||
					String[] tokens = target.split("\\.");
 | 
					 | 
				
			||||||
					if(tokens.length==1)
 | 
					 | 
				
			||||||
						return new AbstractMap.SimpleEntry<>(tokens[0], txAttr);
 | 
					 | 
				
			||||||
					else 
 | 
					 | 
				
			||||||
						return new AbstractMap.SimpleEntry<>(tokens[0], new TreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0]));
 | 
					 | 
				
			||||||
				})
 | 
					 | 
				
			||||||
				.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first));
 | 
					 | 
				
			||||||
				childs = new TreeMap<String, Object>(res).values().toArray();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return childs;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		private Object[] childs=null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public boolean equals(Object o) {
 | 
					 | 
				
			||||||
			if(o instanceof TreeNode) {
 | 
					 | 
				
			||||||
				TreeNode t = (TreeNode) o;
 | 
					 | 
				
			||||||
				return type==t.type && hier_path.equals(t.hier_path); 
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return false;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public int compareTo(TreeNode o) {
 | 
					 | 
				
			||||||
			int res1 = type.compareTo(o.type);
 | 
					 | 
				
			||||||
			if(res1==0) {
 | 
					 | 
				
			||||||
				return hier_path.compareTo(o.hier_path);
 | 
					 | 
				
			||||||
			} else
 | 
					 | 
				
			||||||
				return res1;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Class TransactionTreeContentProvider.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	class TransactionTreeContentProvider implements ITreeContentProvider {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public void dispose() {	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public Object[] getElements(Object element) {
 | 
					 | 
				
			||||||
			return new Object[]{
 | 
					 | 
				
			||||||
					new TreeNode((ITx)element, Type.PROPS),  
 | 
					 | 
				
			||||||
					new TreeNode((ITx)element, Type.ATTRS),  
 | 
					 | 
				
			||||||
					new TreeNode((ITx)element, Type.IN_REL),
 | 
					 | 
				
			||||||
					new TreeNode((ITx)element, Type.OUT_REL)
 | 
					 | 
				
			||||||
			};
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public Object[] getChildren(Object element) {
 | 
					 | 
				
			||||||
			if(element instanceof TreeNode){
 | 
					 | 
				
			||||||
				TreeNode propertyHolder=(TreeNode) element;
 | 
					 | 
				
			||||||
				if(propertyHolder.type == Type.PROPS){
 | 
					 | 
				
			||||||
					return new Object[][]{
 | 
					 | 
				
			||||||
						{Messages.TransactionDetails_1, Messages.TransactionDetails_16, propertyHolder.element.getStream().getFullName()},
 | 
					 | 
				
			||||||
						{Messages.TransactionDetails_2, Messages.TransactionDetails_16, propertyHolder.element.getGenerator().getName()},
 | 
					 | 
				
			||||||
						{Messages.TransactionDetails_19, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getBeginTime())},
 | 
					 | 
				
			||||||
						{Messages.TransactionDetails_21, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getEndTime())}
 | 
					 | 
				
			||||||
					};
 | 
					 | 
				
			||||||
				}else if(propertyHolder.type == Type.ATTRS || propertyHolder.type == Type.HIER)
 | 
					 | 
				
			||||||
					return propertyHolder.getAttributeListForHier();
 | 
					 | 
				
			||||||
				else if(propertyHolder.type == Type.IN_REL){
 | 
					 | 
				
			||||||
					Vector<Object[] > res = new Vector<>();
 | 
					 | 
				
			||||||
					for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){
 | 
					 | 
				
			||||||
						res.add(new Object[]{
 | 
					 | 
				
			||||||
								rel.getRelationType(), 
 | 
					 | 
				
			||||||
								rel.getSource().getGenerator().getName(), 
 | 
					 | 
				
			||||||
								rel.getSource()});
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					return res.toArray();
 | 
					 | 
				
			||||||
				} else if(propertyHolder.type == Type.OUT_REL){
 | 
					 | 
				
			||||||
					Vector<Object[] > res = new Vector<>();
 | 
					 | 
				
			||||||
					for(ITxRelation rel:propertyHolder.element.getOutgoingRelations()){
 | 
					 | 
				
			||||||
						res.add(new Object[]{
 | 
					 | 
				
			||||||
								rel.getRelationType(), 
 | 
					 | 
				
			||||||
								rel.getTarget().getGenerator().getName(), 
 | 
					 | 
				
			||||||
								rel.getTarget()});
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					return res.toArray();
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public Object getParent(Object element) {
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public boolean hasChildren(Object element) {
 | 
					 | 
				
			||||||
			return getChildren(element)!=null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * The Class AttributeLabelProvider.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The field. */
 | 
					 | 
				
			||||||
		final int field;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The Constant NAME. */
 | 
					 | 
				
			||||||
		public static final int NAME=0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The Constant TYPE. */
 | 
					 | 
				
			||||||
		public static final int TYPE=1;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/** The Constant VALUE. */
 | 
					 | 
				
			||||||
		public static final int VALUE=2;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/**
 | 
					 | 
				
			||||||
		 * Instantiates a new attribute label provider.
 | 
					 | 
				
			||||||
		 *
 | 
					 | 
				
			||||||
		 * @param field the field
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		public  AttributeLabelProvider(int field) {
 | 
					 | 
				
			||||||
			this.field=field;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		/* (non-Javadoc)
 | 
					 | 
				
			||||||
		 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
 | 
					 | 
				
			||||||
		 */
 | 
					 | 
				
			||||||
		@Override
 | 
					 | 
				
			||||||
		public StyledString getStyledText(Object element) {
 | 
					 | 
				
			||||||
			switch(field){
 | 
					 | 
				
			||||||
			case NAME:
 | 
					 | 
				
			||||||
				if (element instanceof ITxAttribute) {
 | 
					 | 
				
			||||||
					ITxAttribute attribute = (ITxAttribute) element;
 | 
					 | 
				
			||||||
					String[] tokens = attribute.getName().split("\\.");
 | 
					 | 
				
			||||||
					return new StyledString(tokens[tokens.length-1]);
 | 
					 | 
				
			||||||
				}else if (element instanceof ITxRelation) {
 | 
					 | 
				
			||||||
					return new StyledString(Messages.TransactionDetails_4);
 | 
					 | 
				
			||||||
				}else if(element instanceof Object[]){
 | 
					 | 
				
			||||||
					Object[] elements = (Object[]) element;
 | 
					 | 
				
			||||||
					return new StyledString(elements[field].toString());
 | 
					 | 
				
			||||||
				} else 
 | 
					 | 
				
			||||||
					return new StyledString(element.toString());
 | 
					 | 
				
			||||||
			case TYPE:
 | 
					 | 
				
			||||||
				if (element instanceof ITxAttribute) {
 | 
					 | 
				
			||||||
					ITxAttribute attribute = (ITxAttribute) element;
 | 
					 | 
				
			||||||
					return new StyledString(attribute.getDataType().toString());
 | 
					 | 
				
			||||||
				}else if(element instanceof Object[]){
 | 
					 | 
				
			||||||
					Object[] elements = (Object[]) element;
 | 
					 | 
				
			||||||
					return new StyledString(elements[field].toString());
 | 
					 | 
				
			||||||
				}else 
 | 
					 | 
				
			||||||
					return new StyledString("");					 //$NON-NLS-1$
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				if (element instanceof ITxAttribute) {
 | 
					 | 
				
			||||||
					ITxAttribute attribute = (ITxAttribute) element;
 | 
					 | 
				
			||||||
					String value = attribute.getValue().toString();
 | 
					 | 
				
			||||||
					if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
 | 
					 | 
				
			||||||
						try {
 | 
					 | 
				
			||||||
							value += " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
 | 
					 | 
				
			||||||
						} catch(NumberFormatException e) { }
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
					return new StyledString(value);
 | 
					 | 
				
			||||||
				}else if(element instanceof Object[]){
 | 
					 | 
				
			||||||
					Object[] elements = (Object[]) element;
 | 
					 | 
				
			||||||
					Object o = elements[field];
 | 
					 | 
				
			||||||
					if(o instanceof ITx) {
 | 
					 | 
				
			||||||
						ITx tx = (ITx)o;
 | 
					 | 
				
			||||||
						return new StyledString(txToString(tx)+" ("+tx.getStream().getFullName()+")");
 | 
					 | 
				
			||||||
					} else
 | 
					 | 
				
			||||||
						return new StyledString(o.toString());
 | 
					 | 
				
			||||||
				} else if(element instanceof ITx){
 | 
					 | 
				
			||||||
					return new StyledString(txToString((ITx) element));
 | 
					 | 
				
			||||||
				}else 
 | 
					 | 
				
			||||||
					return new StyledString("");					 //$NON-NLS-1$
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,286 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.concurrent.ConcurrentHashMap;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.core.databinding.observable.list.ObservableList;
 | 
				
			||||||
 | 
					import org.eclipse.core.databinding.observable.list.WritableList;
 | 
				
			||||||
 | 
					import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ComboViewer;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.DoubleClickEvent;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.IDoubleClickListener;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ITreeSelection;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.LabelProvider;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.TreeViewer;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.TreeViewerColumn;
 | 
				
			||||||
 | 
					import org.eclipse.swt.SWT;
 | 
				
			||||||
 | 
					import org.eclipse.swt.events.ModifyEvent;
 | 
				
			||||||
 | 
					import org.eclipse.swt.events.ModifyListener;
 | 
				
			||||||
 | 
					import org.eclipse.swt.events.SelectionEvent;
 | 
				
			||||||
 | 
					import org.eclipse.swt.events.SelectionListener;
 | 
				
			||||||
 | 
					import org.eclipse.swt.layout.GridData;
 | 
				
			||||||
 | 
					import org.eclipse.swt.layout.GridLayout;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.Combo;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.Composite;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.Text;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.Tree;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.TreeColumn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.DataType;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxAttribute;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxEvent;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxEvent.Type;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxStream;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ui.TrackEntry;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.txTableTree.TxFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TransactionList extends Composite {
 | 
				
			||||||
 | 
						public class AttributeNameBean {
 | 
				
			||||||
 | 
							public String getName() {
 | 
				
			||||||
 | 
								return name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							public void setName(String name) {
 | 
				
			||||||
 | 
								this.name = name;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							public DataType getType() {
 | 
				
			||||||
 | 
								return type;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							public void setType(DataType type) {
 | 
				
			||||||
 | 
								this.type = type;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							public AttributeNameBean(String name, DataType type) {
 | 
				
			||||||
 | 
								super();
 | 
				
			||||||
 | 
								this.name = name;
 | 
				
			||||||
 | 
								this.type = type;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							String name;
 | 
				
			||||||
 | 
							DataType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ComboViewer searchPropComboViewer = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ComboViewer viewPropComboViewer = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private Text searchPropValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private TreeViewer treeViewer = null; 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private TreeColumn valueColumn = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private AttributeLabelProvider nameLabelProvider = null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ITxStream<? extends ITxEvent> stream;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ObservableList<AttributeNameBean> attrNames = new WritableList<AttributeNameBean>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<ITx> eventList = new ArrayList<ITx>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<ITx> emptyList = new ArrayList<ITx>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TxFilter txFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Create the composite.
 | 
				
			||||||
 | 
						 * @param parent
 | 
				
			||||||
 | 
						 * @param style
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public TransactionList(Composite parent, int style, WaveformViewer waveformViewer) {
 | 
				
			||||||
 | 
							super(parent, style);
 | 
				
			||||||
 | 
							setLayout(new GridLayout(3, false));
 | 
				
			||||||
 | 
							txFilter = new TxFilter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							searchPropComboViewer = new ComboViewer(this, SWT.NONE);
 | 
				
			||||||
 | 
							searchPropComboViewer.setLabelProvider(new LabelProvider() {
 | 
				
			||||||
 | 
								public String getText(Object element) {
 | 
				
			||||||
 | 
									AttributeNameBean entry = (AttributeNameBean) element;
 | 
				
			||||||
 | 
									return entry.getName()+" ["+entry.getType().toString()+"]";
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							searchPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
 | 
				
			||||||
 | 
							searchPropComboViewer.setInput(attrNames);
 | 
				
			||||||
 | 
							Combo searchPropCombo = searchPropComboViewer.getCombo();
 | 
				
			||||||
 | 
							searchPropCombo.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
 | 
				
			||||||
 | 
							searchPropCombo.addSelectionListener(new SelectionListener() {
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void widgetSelected(SelectionEvent e) {
 | 
				
			||||||
 | 
									int idx = searchPropCombo.getSelectionIndex();
 | 
				
			||||||
 | 
									AttributeNameBean sel = attrNames.get(idx);
 | 
				
			||||||
 | 
									txFilter.setSearchProp(sel.getName(), sel.getType());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void widgetDefaultSelected(SelectionEvent e) { 
 | 
				
			||||||
 | 
									int idx = searchPropCombo.getSelectionIndex();
 | 
				
			||||||
 | 
									AttributeNameBean sel = attrNames.get(idx);
 | 
				
			||||||
 | 
									txFilter.setSearchProp(sel.getName(), sel.getType());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							searchPropValue = new Text(this, SWT.BORDER);
 | 
				
			||||||
 | 
							searchPropValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
 | 
				
			||||||
 | 
							searchPropValue.addModifyListener(new ModifyListener() {
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void modifyText(ModifyEvent e) {
 | 
				
			||||||
 | 
									txFilter.setSearchValue(((Text) e.widget).getText());
 | 
				
			||||||
 | 
									treeViewer.refresh();
 | 
				
			||||||
 | 
									//treeViewer.expandAll(false);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							viewPropComboViewer = new ComboViewer(this, SWT.NONE);
 | 
				
			||||||
 | 
							viewPropComboViewer.setLabelProvider(new LabelProvider() {
 | 
				
			||||||
 | 
								public String getText(Object element) {
 | 
				
			||||||
 | 
									AttributeNameBean entry = (AttributeNameBean) element;
 | 
				
			||||||
 | 
									return entry.getName()+" ["+entry.getType().toString()+"]";
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							viewPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
 | 
				
			||||||
 | 
							viewPropComboViewer.setInput(attrNames);
 | 
				
			||||||
 | 
							Combo viewPropCombo = viewPropComboViewer.getCombo();
 | 
				
			||||||
 | 
							viewPropCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
 | 
				
			||||||
 | 
							viewPropCombo.addSelectionListener(new SelectionListener() {
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void widgetSelected(SelectionEvent e) {
 | 
				
			||||||
 | 
									int idx = viewPropCombo.getSelectionIndex();
 | 
				
			||||||
 | 
									AttributeNameBean sel = attrNames.get(idx);
 | 
				
			||||||
 | 
									nameLabelProvider.setShowProp(sel.getName());
 | 
				
			||||||
 | 
									treeViewer.refresh(true);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void widgetDefaultSelected(SelectionEvent e) { }
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							treeViewer = new TreeViewer(this, SWT.BORDER);
 | 
				
			||||||
 | 
							treeViewer.setContentProvider(new AbstractTransactionTreeContentProvider(waveformViewer) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								@SuppressWarnings("rawtypes")
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public Object[] getElements(Object inputElement) {
 | 
				
			||||||
 | 
									if (inputElement instanceof Object[]) {
 | 
				
			||||||
 | 
										return (Object[]) inputElement;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									if (inputElement instanceof Collection) {
 | 
				
			||||||
 | 
										return ((Collection) inputElement).toArray();
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return new Object[0];
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							treeViewer.addFilter(txFilter);
 | 
				
			||||||
 | 
							treeViewer.addDoubleClickListener(new IDoubleClickListener() {
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								public void doubleClick(DoubleClickEvent event) {
 | 
				
			||||||
 | 
									ITreeSelection treeSelection = treeViewer.getStructuredSelection();
 | 
				
			||||||
 | 
									Object selected = treeSelection.getFirstElement();
 | 
				
			||||||
 | 
									if(selected instanceof ITx){
 | 
				
			||||||
 | 
										waveformViewer.setSelection(new StructuredSelection(selected));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							Tree tree = treeViewer.getTree();
 | 
				
			||||||
 | 
							tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							TreeViewerColumn nameColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
 | 
							TreeColumn nameColumn = nameColumnViewer.getColumn();
 | 
				
			||||||
 | 
							nameColumn.setWidth(200);
 | 
				
			||||||
 | 
							nameColumn.setText("Tx ID");
 | 
				
			||||||
 | 
							nameColumn.setResizable(true);
 | 
				
			||||||
 | 
							nameColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.NAME)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							TreeViewerColumn timeColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
 | 
							TreeColumn timeColumn = timeColumnViewer.getColumn();
 | 
				
			||||||
 | 
							timeColumn.setAlignment(SWT.RIGHT);
 | 
				
			||||||
 | 
							timeColumn.setWidth(150);
 | 
				
			||||||
 | 
							timeColumn.setText("Start time");
 | 
				
			||||||
 | 
							timeColumn.setResizable(true);
 | 
				
			||||||
 | 
							timeColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.TX_TIME)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							TreeViewerColumn typeColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
 | 
							TreeColumn typeColumn = typeColumnViewer.getColumn();
 | 
				
			||||||
 | 
							typeColumn.setAlignment(SWT.RIGHT);
 | 
				
			||||||
 | 
							typeColumn.setWidth(150);
 | 
				
			||||||
 | 
							typeColumn.setText("Type");
 | 
				
			||||||
 | 
							typeColumn.setResizable(true);
 | 
				
			||||||
 | 
							typeColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.TYPE)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							TreeViewerColumn valueColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
 | 
				
			||||||
 | 
							valueColumn = valueColumnViewer.getColumn();
 | 
				
			||||||
 | 
							valueColumn.setWidth(150);
 | 
				
			||||||
 | 
							valueColumn.setText("Value");
 | 
				
			||||||
 | 
							valueColumn.setResizable(true);
 | 
				
			||||||
 | 
							nameLabelProvider= new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.VALUE);
 | 
				
			||||||
 | 
							valueColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(nameLabelProvider));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Turn on the header and the lines
 | 
				
			||||||
 | 
							tree.setHeaderVisible(true);
 | 
				
			||||||
 | 
							tree.setLinesVisible(true);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setInput(TrackEntry trackEntry) {
 | 
				
			||||||
 | 
							if(trackEntry==null || !trackEntry.isStream()) {
 | 
				
			||||||
 | 
								attrNames.clear();
 | 
				
			||||||
 | 
								treeViewer.setInput(emptyList);
 | 
				
			||||||
 | 
							} else { 
 | 
				
			||||||
 | 
								stream=trackEntry.getStream();
 | 
				
			||||||
 | 
								treeViewer.setInput(emptyList);
 | 
				
			||||||
 | 
								new Thread() {
 | 
				
			||||||
 | 
									private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									private List<AttributeNameBean> getEntries() {
 | 
				
			||||||
 | 
										return propNames.entrySet().stream()
 | 
				
			||||||
 | 
												.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))
 | 
				
			||||||
 | 
												.map(e -> new AttributeNameBean(e.getKey(), e.getValue()))
 | 
				
			||||||
 | 
												.collect(Collectors.toList());
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									public void run() {
 | 
				
			||||||
 | 
										stream.getEvents().values().parallelStream().forEach(evtLst -> {
 | 
				
			||||||
 | 
											evtLst.forEach(evt -> {
 | 
				
			||||||
 | 
												if(evt.getType()==Type.BEGIN) {
 | 
				
			||||||
 | 
													eventList.add(evt.getTransaction());
 | 
				
			||||||
 | 
													for(ITxAttribute attr: evt.getTransaction().getAttributes()) {
 | 
				
			||||||
 | 
														propNames.put(attr.getName(), attr.getDataType());
 | 
				
			||||||
 | 
													}
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											});
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
 | 
										eventList = eventList.parallelStream().sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime())).collect(Collectors.toList());
 | 
				
			||||||
 | 
										getDisplay().asyncExec(new Runnable() {
 | 
				
			||||||
 | 
											@Override
 | 
				
			||||||
 | 
											public void run() {
 | 
				
			||||||
 | 
												treeViewer.setInput(eventList);
 | 
				
			||||||
 | 
												attrNames.clear();
 | 
				
			||||||
 | 
												attrNames.addAll(getEntries());
 | 
				
			||||||
 | 
												searchPropComboViewer.getCombo().select(0);
 | 
				
			||||||
 | 
												txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
 | 
				
			||||||
 | 
												if (searchPropComboViewer!=null) {
 | 
				
			||||||
 | 
													searchPropComboViewer.setInput(attrNames);
 | 
				
			||||||
 | 
													searchPropComboViewer.setSelection(new StructuredSelection(searchPropComboViewer.getElementAt(0)));
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										});
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}.run();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void setSearchProps(String propName, DataType type, String propValue) {
 | 
				
			||||||
 | 
							for(int i=0; i<attrNames.size(); ++i) {
 | 
				
			||||||
 | 
								AttributeNameBean e = attrNames.get(i);
 | 
				
			||||||
 | 
								if(propName.equals(e.getName()) && type.equals(e.getType())) {
 | 
				
			||||||
 | 
									searchPropComboViewer.getCombo().select(i);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							searchPropValue.setText(propValue);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,84 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javax.annotation.PostConstruct;
 | 
				
			||||||
 | 
					import javax.inject.Inject;
 | 
				
			||||||
 | 
					import javax.inject.Named;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.e4.core.di.annotations.Optional;
 | 
				
			||||||
 | 
					import org.eclipse.e4.core.services.events.IEventBroker;
 | 
				
			||||||
 | 
					import org.eclipse.e4.ui.di.Focus;
 | 
				
			||||||
 | 
					import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 | 
				
			||||||
 | 
					import org.eclipse.e4.ui.services.IServiceConstants;
 | 
				
			||||||
 | 
					import org.eclipse.e4.ui.workbench.modeling.EPartService;
 | 
				
			||||||
 | 
					import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.IStructuredSelection;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
 | 
					import org.eclipse.swt.SWT;
 | 
				
			||||||
 | 
					import org.eclipse.swt.widgets.Composite;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ui.TrackEntry;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TransactionListView {
 | 
				
			||||||
 | 
						private WaveformViewer waveformViewer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private TransactionList transactionList;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
						/** The event broker. */
 | 
				
			||||||
 | 
						@Inject IEventBroker eventBroker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The selection service. */
 | 
				
			||||||
 | 
						@Inject	ESelectionService selectionService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Create the composite.
 | 
				
			||||||
 | 
						 * @param parent
 | 
				
			||||||
 | 
						 * @param style
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Creates the composite.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param parent the parent
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@PostConstruct
 | 
				
			||||||
 | 
						public void createComposite(final Composite parent, @Optional WaveformViewer waveformViewer) {
 | 
				
			||||||
 | 
							this.waveformViewer=waveformViewer;
 | 
				
			||||||
 | 
							transactionList = new TransactionList(parent, SWT.BORDER, waveformViewer);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Focus
 | 
				
			||||||
 | 
						public void setFocus() {
 | 
				
			||||||
 | 
							if(transactionList!=null)
 | 
				
			||||||
 | 
								transactionList.setFocus();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Sets the selection.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param selection the new selection
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Inject
 | 
				
			||||||
 | 
						public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
 | 
				
			||||||
 | 
							// only react if selection is actually from the WaveformViewer and nothing else
 | 
				
			||||||
 | 
							MPart part = partService.getActivePart();
 | 
				
			||||||
 | 
							if( part == null || ! (part.getObject() instanceof WaveformViewer )  || part.getObject() != waveformViewer)
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							if(selection==null || selection.isEmpty())
 | 
				
			||||||
 | 
								transactionList.setInput(null);	
 | 
				
			||||||
 | 
							else if(selection instanceof IStructuredSelection) {
 | 
				
			||||||
 | 
								TrackEntry e = findTrackEntry(((StructuredSelection)selection).toArray());
 | 
				
			||||||
 | 
								if(e!=null)
 | 
				
			||||||
 | 
									transactionList.setInput(e);		
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private TrackEntry findTrackEntry(Object[] elems) {
 | 
				
			||||||
 | 
							for(Object o: elems)
 | 
				
			||||||
 | 
								if(o instanceof TrackEntry)
 | 
				
			||||||
 | 
									return (TrackEntry)o;
 | 
				
			||||||
 | 
							return null;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public TransactionList getControl() {
 | 
				
			||||||
 | 
							return transactionList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -61,7 +61,6 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
 | 
				
			|||||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
					import org.eclipse.jface.viewers.IStructuredSelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
 | 
					import org.eclipse.jface.viewers.SelectionChangedEvent;
 | 
				
			||||||
import org.eclipse.jface.viewers.StructuredSelection;
 | 
					import org.eclipse.jface.viewers.StructuredSelection;
 | 
				
			||||||
import org.eclipse.jface.viewers.TableViewer;
 | 
					 | 
				
			||||||
import org.eclipse.swt.SWT;
 | 
					import org.eclipse.swt.SWT;
 | 
				
			||||||
import org.eclipse.swt.custom.CTabFolder;
 | 
					import org.eclipse.swt.custom.CTabFolder;
 | 
				
			||||||
import org.eclipse.swt.custom.CTabItem;
 | 
					import org.eclipse.swt.custom.CTabItem;
 | 
				
			||||||
@@ -177,9 +176,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	TransactionDetails detailsView = null;
 | 
						TransactionDetails detailsView = null;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						TransactionListView transactionList = null;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	/** The waveform pane. */
 | 
						/** The waveform pane. */
 | 
				
			||||||
	private IWaveformView waveformPane;
 | 
						private IWaveformView waveformPane;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private CTabFolder tabFolder;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private CTabItem tbtmSearchResults;
 | 
				
			||||||
	/** get UISynchronize injected as field */
 | 
						/** get UISynchronize injected as field */
 | 
				
			||||||
	@Inject UISynchronize sync;
 | 
						@Inject UISynchronize sync;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -293,7 +297,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
		waveformPane = factory.createPanel(rightTop);
 | 
							waveformPane = factory.createPanel(rightTop);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		CTabFolder tabFolder = new CTabFolder(sashFormRight, SWT.BORDER);
 | 
							tabFolder = new CTabFolder(sashFormRight, SWT.BORDER);
 | 
				
			||||||
		tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
 | 
							tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		CTabItem tbtmDetails = new CTabItem(tabFolder, SWT.NONE);
 | 
							CTabItem tbtmDetails = new CTabItem(tabFolder, SWT.NONE);
 | 
				
			||||||
@@ -303,12 +307,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
 | 
				
			|||||||
		detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx);
 | 
							detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx);
 | 
				
			||||||
		tbtmDetails.setControl(detailsView.getControl());
 | 
							tbtmDetails.setControl(detailsView.getControl());
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		CTabItem tbtmSearchResults = new CTabItem(tabFolder, SWT.NONE);
 | 
							tbtmSearchResults = new CTabItem(tabFolder, SWT.NONE);
 | 
				
			||||||
		tbtmSearchResults.setText("Search Results");
 | 
							tbtmSearchResults.setText("Search Results");
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		TableViewer tableViewer = new TableViewer(tabFolder, SWT.BORDER | SWT.FULL_SELECTION);
 | 
							transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx);
 | 
				
			||||||
		Table table = tableViewer.getTable();
 | 
							tbtmSearchResults.setControl(transactionList.getControl());
 | 
				
			||||||
		tbtmSearchResults.setControl(table);
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		sashFormRight.setWeights(new int[] {75, 25});
 | 
							sashFormRight.setWeights(new int[] {75, 25});
 | 
				
			||||||
		tabFolder.setSelection(0);
 | 
							tabFolder.setSelection(0);
 | 
				
			||||||
@@ -1312,8 +1315,15 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
 | 
				
			|||||||
    	}
 | 
					    	}
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void search(String propName, DataType type, String propValue) {
 | 
					    public void showSearch() {
 | 
				
			||||||
		// TODO Auto-generated method stub
 | 
					    	tabFolder.setSelection(tbtmSearchResults);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
						public void search(String propName, DataType type, String propValue) {
 | 
				
			||||||
 | 
					//		StructuredSelection sel = (StructuredSelection) getSelection();
 | 
				
			||||||
 | 
					//		TrackEntry e = findTrackEntry((sel).toArray());
 | 
				
			||||||
 | 
					//		if(e==null) return;
 | 
				
			||||||
 | 
							tabFolder.setSelection(tbtmSearchResults);
 | 
				
			||||||
 | 
							transactionList.getControl().setSearchProps(propName, type, propValue);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Vector;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ITreeContentProvider;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.Viewer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxRelation;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.Messages;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class TransactionTreeContentProvider.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public abstract class AbstractTransactionTreeContentProvider implements ITreeContentProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private final WaveformViewer waveformViewerPart;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * @param transactionDetails
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public AbstractTransactionTreeContentProvider(WaveformViewer waveformViewerPart) {
 | 
				
			||||||
 | 
							this.waveformViewerPart = waveformViewerPart;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void dispose() {	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Object[] getChildren(Object element) {
 | 
				
			||||||
 | 
							if(element instanceof ITx) {
 | 
				
			||||||
 | 
								return new Object[]{
 | 
				
			||||||
 | 
										new TransactionTreeNode((ITx)element, TransactionTreeNodeType.ATTRS)  
 | 
				
			||||||
 | 
								};
 | 
				
			||||||
 | 
							} else if(element instanceof TransactionTreeNode){
 | 
				
			||||||
 | 
								TransactionTreeNode propertyHolder=(TransactionTreeNode) element;
 | 
				
			||||||
 | 
								if(propertyHolder.type == TransactionTreeNodeType.PROPS){
 | 
				
			||||||
 | 
									return new Object[][]{
 | 
				
			||||||
 | 
										{Messages.TransactionDetails_1, Messages.TransactionDetails_16, propertyHolder.element.getStream().getFullName()},
 | 
				
			||||||
 | 
										{Messages.TransactionDetails_2, Messages.TransactionDetails_16, propertyHolder.element.getGenerator().getName()},
 | 
				
			||||||
 | 
										{Messages.TransactionDetails_19, Messages.TransactionDetails_20, waveformViewerPart.getScaledTime(propertyHolder.element.getBeginTime())},
 | 
				
			||||||
 | 
										{Messages.TransactionDetails_21, Messages.TransactionDetails_20, waveformViewerPart.getScaledTime(propertyHolder.element.getEndTime())}
 | 
				
			||||||
 | 
									};
 | 
				
			||||||
 | 
								}else if(propertyHolder.type == TransactionTreeNodeType.ATTRS || propertyHolder.type == TransactionTreeNodeType.HIER)
 | 
				
			||||||
 | 
									return propertyHolder.getAttributeListForHier();
 | 
				
			||||||
 | 
								else if(propertyHolder.type == TransactionTreeNodeType.IN_REL){
 | 
				
			||||||
 | 
									Vector<Object[] > res = new Vector<>();
 | 
				
			||||||
 | 
									for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){
 | 
				
			||||||
 | 
										res.add(new Object[]{
 | 
				
			||||||
 | 
												rel.getRelationType(), 
 | 
				
			||||||
 | 
												rel.getSource().getGenerator().getName(), 
 | 
				
			||||||
 | 
												rel.getSource()});
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return res.toArray();
 | 
				
			||||||
 | 
								} else if(propertyHolder.type == TransactionTreeNodeType.OUT_REL){
 | 
				
			||||||
 | 
									Vector<Object[] > res = new Vector<>();
 | 
				
			||||||
 | 
									for(ITxRelation rel:propertyHolder.element.getOutgoingRelations()){
 | 
				
			||||||
 | 
										res.add(new Object[]{
 | 
				
			||||||
 | 
												rel.getRelationType(), 
 | 
				
			||||||
 | 
												rel.getTarget().getGenerator().getName(), 
 | 
				
			||||||
 | 
												rel.getTarget()});
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return res.toArray();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return null;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Object getParent(Object element) {
 | 
				
			||||||
 | 
							return null;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public boolean hasChildren(Object element) {
 | 
				
			||||||
 | 
							return getChildren(element)!=null;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,160 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.LabelProvider;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.StyledString;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.DataType;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxAttribute;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxRelation;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.Messages;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class AttributeLabelProvider.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * 
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						private final WaveformViewer waveformViewerPart;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The field. */
 | 
				
			||||||
 | 
						final int field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant NAME. */
 | 
				
			||||||
 | 
						public static final int NAME=0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant TYPE. */
 | 
				
			||||||
 | 
						public static final int TYPE=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant VALUE. */
 | 
				
			||||||
 | 
						public static final int VALUE=2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant VALUE. */
 | 
				
			||||||
 | 
						public static final int TX_TIME=3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String showProp;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public String getShowProp() {
 | 
				
			||||||
 | 
							return showProp;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setShowProp(String showProp) {
 | 
				
			||||||
 | 
							this.showProp = showProp;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Instantiates a new attribute label provider.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param field the field
 | 
				
			||||||
 | 
						 * @param transactionDetails TODO
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public  AttributeLabelProvider(WaveformViewer waveformViewerPart, int field) {
 | 
				
			||||||
 | 
							this.waveformViewerPart = waveformViewerPart;
 | 
				
			||||||
 | 
							this.field=field;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public StyledString getStyledText(Object element) {
 | 
				
			||||||
 | 
							if(element instanceof ITx) {
 | 
				
			||||||
 | 
								ITx iTx = (ITx) element;
 | 
				
			||||||
 | 
								switch(field){
 | 
				
			||||||
 | 
								case NAME:
 | 
				
			||||||
 | 
									return new StyledString(iTx.getId().toString());
 | 
				
			||||||
 | 
								case TX_TIME:
 | 
				
			||||||
 | 
									return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
 | 
				
			||||||
 | 
								case VALUE:
 | 
				
			||||||
 | 
									if(showProp!=null){
 | 
				
			||||||
 | 
										List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> showProp.equals(a.getName())).collect(Collectors.toList());
 | 
				
			||||||
 | 
										if(res.size()==1)
 | 
				
			||||||
 | 
											return getAttrValueAsStyledString(res.get(0));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									return new StyledString("");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								switch(field){
 | 
				
			||||||
 | 
								case NAME:
 | 
				
			||||||
 | 
									if (element instanceof ITxAttribute) {
 | 
				
			||||||
 | 
										ITxAttribute attribute = (ITxAttribute) element;
 | 
				
			||||||
 | 
										String[] tokens = attribute.getName().split("\\.");
 | 
				
			||||||
 | 
										return new StyledString(tokens[tokens.length-1]);
 | 
				
			||||||
 | 
									}else if (element instanceof ITxRelation) {
 | 
				
			||||||
 | 
										return new StyledString(Messages.TransactionDetails_4);
 | 
				
			||||||
 | 
									}else if(element instanceof Object[]){
 | 
				
			||||||
 | 
										Object[] elements = (Object[]) element;
 | 
				
			||||||
 | 
										return new StyledString(elements[field].toString());
 | 
				
			||||||
 | 
									} else 
 | 
				
			||||||
 | 
										return new StyledString(element.toString());
 | 
				
			||||||
 | 
								case TYPE:
 | 
				
			||||||
 | 
									if (element instanceof ITxAttribute) {
 | 
				
			||||||
 | 
										ITxAttribute attribute = (ITxAttribute) element;
 | 
				
			||||||
 | 
										return new StyledString(attribute.getDataType().toString());
 | 
				
			||||||
 | 
									}else if(element instanceof Object[]){
 | 
				
			||||||
 | 
										Object[] elements = (Object[]) element;
 | 
				
			||||||
 | 
										return new StyledString(elements[field].toString());
 | 
				
			||||||
 | 
									}else 
 | 
				
			||||||
 | 
										return new StyledString("");					 //$NON-NLS-1$
 | 
				
			||||||
 | 
								case TX_TIME:
 | 
				
			||||||
 | 
									return new StyledString("");					 //$NON-NLS-1$
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									if (element instanceof ITxAttribute) {
 | 
				
			||||||
 | 
										ITxAttribute attribute = (ITxAttribute) element;
 | 
				
			||||||
 | 
										return getAttrValueAsStyledString(attribute);
 | 
				
			||||||
 | 
									}else if(element instanceof Object[]){
 | 
				
			||||||
 | 
										Object[] elements = (Object[]) element;
 | 
				
			||||||
 | 
										Object o = elements[field];
 | 
				
			||||||
 | 
										if(o instanceof ITx) {
 | 
				
			||||||
 | 
											ITx tx = (ITx)o;
 | 
				
			||||||
 | 
											return new StyledString(this.txToString(tx)+" ("+tx.getStream().getFullName()+")");
 | 
				
			||||||
 | 
										} else
 | 
				
			||||||
 | 
											return new StyledString(o.toString());
 | 
				
			||||||
 | 
									} else if(element instanceof ITx){
 | 
				
			||||||
 | 
										return new StyledString(this.txToString((ITx) element));
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return new StyledString("");					 //$NON-NLS-1$
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public StyledString getAttrValueAsStyledString(ITxAttribute attribute) {
 | 
				
			||||||
 | 
							String value = attribute.getValue().toString();
 | 
				
			||||||
 | 
							if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
 | 
				
			||||||
 | 
								try {
 | 
				
			||||||
 | 
									value += " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
 | 
				
			||||||
 | 
								} catch(NumberFormatException e) { }
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return new StyledString(value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Tx to string.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param tx the tx
 | 
				
			||||||
 | 
						 * @return the string
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						String txToString(ITx tx){
 | 
				
			||||||
 | 
							StringBuilder sb = new StringBuilder();
 | 
				
			||||||
 | 
							sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())); //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
 | 
							sb.append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
 | 
							return sb.toString();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Time to string.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param time the time
 | 
				
			||||||
 | 
						 * @return the string
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						String timeToString(Long time){
 | 
				
			||||||
 | 
							return waveformViewerPart.getScaledTime(time);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,95 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.AbstractMap;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					import java.util.TreeMap;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
 | 
					import com.minres.scviewer.e4.application.Messages;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class TreeNode.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TransactionTreeNode implements Comparable<TransactionTreeNode>{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The type. */
 | 
				
			||||||
 | 
						public TransactionTreeNodeType type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The element. */
 | 
				
			||||||
 | 
						public ITx element;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String hier_path;
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Instantiates a new tree node.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param element the element
 | 
				
			||||||
 | 
						 * @param type the type
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public TransactionTreeNode(ITx element, TransactionTreeNodeType type){
 | 
				
			||||||
 | 
							this.element=element;
 | 
				
			||||||
 | 
							this.type=type;
 | 
				
			||||||
 | 
							this.hier_path="";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public TransactionTreeNode(ITx element, String path){
 | 
				
			||||||
 | 
							this.element=element;
 | 
				
			||||||
 | 
							this.type=TransactionTreeNodeType.HIER;
 | 
				
			||||||
 | 
							this.hier_path=path;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see java.lang.Object#toString()
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public String toString(){
 | 
				
			||||||
 | 
							switch(type){
 | 
				
			||||||
 | 
							case PROPS:      return Messages.TransactionDetails_10;
 | 
				
			||||||
 | 
							case ATTRS:	     return Messages.TransactionDetails_11;
 | 
				
			||||||
 | 
							case IN_REL:     return Messages.TransactionDetails_12;
 | 
				
			||||||
 | 
							case OUT_REL:    return Messages.TransactionDetails_13;
 | 
				
			||||||
 | 
							case HIER:{
 | 
				
			||||||
 | 
								String[] tokens = hier_path.split("\\.");
 | 
				
			||||||
 | 
								return tokens[tokens.length-1];
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return ""; //$NON-NLS-1$
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public Object[] getAttributeListForHier() {
 | 
				
			||||||
 | 
							if(childs==null) {
 | 
				
			||||||
 | 
								Map<String, Object> res = element.getAttributes().stream()
 | 
				
			||||||
 | 
								.filter(txAttr -> txAttr.getName().startsWith(hier_path))
 | 
				
			||||||
 | 
								.map(txAttr -> {
 | 
				
			||||||
 | 
									String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', "");
 | 
				
			||||||
 | 
									String[] tokens = target.split("\\.");
 | 
				
			||||||
 | 
									if(tokens.length==1)
 | 
				
			||||||
 | 
										return new AbstractMap.SimpleEntry<>(tokens[0], txAttr);
 | 
				
			||||||
 | 
									else 
 | 
				
			||||||
 | 
										return new AbstractMap.SimpleEntry<>(tokens[0], new TransactionTreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0]));
 | 
				
			||||||
 | 
								})
 | 
				
			||||||
 | 
								.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first));
 | 
				
			||||||
 | 
								childs = new TreeMap<String, Object>(res).values().toArray();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return childs;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private Object[] childs=null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public boolean equals(Object o) {
 | 
				
			||||||
 | 
							if(o instanceof TransactionTreeNode) {
 | 
				
			||||||
 | 
								TransactionTreeNode t = (TransactionTreeNode) o;
 | 
				
			||||||
 | 
								return type==t.type && hier_path.equals(t.hier_path); 
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public int compareTo(TransactionTreeNode o) {
 | 
				
			||||||
 | 
							int res1 = type.compareTo(o.type);
 | 
				
			||||||
 | 
							if(res1==0) {
 | 
				
			||||||
 | 
								return hier_path.compareTo(o.hier_path);
 | 
				
			||||||
 | 
							} else
 | 
				
			||||||
 | 
								return res1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,12 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Enum Type.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public enum TransactionTreeNodeType {
 | 
				
			||||||
 | 
						PROPS,  /** The props. */
 | 
				
			||||||
 | 
						ATTRS,  /** The attrs. */
 | 
				
			||||||
 | 
						IN_REL, /** The in rel. */ 
 | 
				
			||||||
 | 
						OUT_REL,/** The out rel. */
 | 
				
			||||||
 | 
						HIER
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
@@ -0,0 +1,55 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.regex.PatternSyntaxException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.Viewer;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ViewerFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxAttribute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class TxAttributeFilter.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TxAttributeFilter extends ViewerFilter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The search string. */
 | 
				
			||||||
 | 
						private String searchString;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Sets the search text.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param s the new search text
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setSearchText(String s) {
 | 
				
			||||||
 | 
							this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public boolean select(Viewer viewer, Object parentElement, Object element) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (searchString == null || searchString.length() == 0) {
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if(element instanceof TransactionTreeNode) {
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if(element instanceof ITxAttribute){
 | 
				
			||||||
 | 
								try {
 | 
				
			||||||
 | 
									return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase()));
 | 
				
			||||||
 | 
								} catch (PatternSyntaxException e) {
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} 
 | 
				
			||||||
 | 
							if(element instanceof Object[]) {
 | 
				
			||||||
 | 
								try {
 | 
				
			||||||
 | 
									return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());	
 | 
				
			||||||
 | 
								} catch (PatternSyntaxException e) {
 | 
				
			||||||
 | 
									return true;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.Viewer;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ViewerComparator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxAttribute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class TxAttributeViewerSorter.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TxAttributeViewerSorter extends ViewerComparator {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant ASCENDING. */
 | 
				
			||||||
 | 
						private static final int ASCENDING = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The Constant DESCENDING. */
 | 
				
			||||||
 | 
						private static final int DESCENDING = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The column. */
 | 
				
			||||||
 | 
						private int column;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The direction. */
 | 
				
			||||||
 | 
						private int direction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Does the sort. If it's a different column from the previous sort, do an
 | 
				
			||||||
 | 
						 * ascending sort. If it's the same column as the last sort, toggle the sort
 | 
				
			||||||
 | 
						 * direction.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param column the column
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void doSort(int column) {
 | 
				
			||||||
 | 
							if (column == this.column) {
 | 
				
			||||||
 | 
								// Same column as last sort; toggle the direction
 | 
				
			||||||
 | 
								direction = 1 - direction;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								// New column; do an ascending sort
 | 
				
			||||||
 | 
								this.column = column;
 | 
				
			||||||
 | 
								direction = ASCENDING;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Compares the object for sorting.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param viewer the viewer
 | 
				
			||||||
 | 
						 * @param e1 the e1
 | 
				
			||||||
 | 
						 * @param e2 the e2
 | 
				
			||||||
 | 
						 * @return the int
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public int compare(Viewer viewer, Object e1, Object e2) {
 | 
				
			||||||
 | 
							int rc = 0;
 | 
				
			||||||
 | 
							if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
 | 
				
			||||||
 | 
								ITxAttribute p1 = (ITxAttribute) e1;
 | 
				
			||||||
 | 
								ITxAttribute p2 = (ITxAttribute) e2;
 | 
				
			||||||
 | 
								// Determine which column and do the appropriate sort
 | 
				
			||||||
 | 
								switch (column) {
 | 
				
			||||||
 | 
								case 0:
 | 
				
			||||||
 | 
									rc = getComparator().compare(p1.getName(), p2.getName());
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case 1:
 | 
				
			||||||
 | 
									rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case 2:
 | 
				
			||||||
 | 
									rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString());
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								// If descending order, flip the direction
 | 
				
			||||||
 | 
								if (direction == DESCENDING) rc = -rc;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return rc;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,92 @@
 | 
				
			|||||||
 | 
					package com.minres.scviewer.e4.application.parts.txTableTree;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigInteger;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.regex.PatternSyntaxException;
 | 
				
			||||||
 | 
					import java.util.stream.Collectors;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.Viewer;
 | 
				
			||||||
 | 
					import org.eclipse.jface.viewers.ViewerFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.DataType;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITx;
 | 
				
			||||||
 | 
					import com.minres.scviewer.database.ITxAttribute;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * The Class TxAttributeFilter.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					public class TxFilter extends ViewerFilter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/** The search string. */
 | 
				
			||||||
 | 
						private String searchProp;
 | 
				
			||||||
 | 
						/** The search type. */
 | 
				
			||||||
 | 
						private DataType searchType;
 | 
				
			||||||
 | 
						/** The search string. */
 | 
				
			||||||
 | 
						private String searchValue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Sets the search text.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param s the new search text
 | 
				
			||||||
 | 
						 * @param dataType 
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setSearchProp(String s, DataType type) {
 | 
				
			||||||
 | 
							this.searchProp = s;
 | 
				
			||||||
 | 
							this.searchType = type;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Sets the search text.
 | 
				
			||||||
 | 
						 *
 | 
				
			||||||
 | 
						 * @param s the new search text
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void setSearchValue(String s) {
 | 
				
			||||||
 | 
							this.searchValue = s; //$NON-NLS-1$ //$NON-NLS-2$
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* (non-Javadoc)
 | 
				
			||||||
 | 
						 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public boolean select(Viewer viewer, Object parentElement, Object element) {
 | 
				
			||||||
 | 
							if (searchValue == null || searchValue.length() == 0)
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							if(element instanceof ITx) {
 | 
				
			||||||
 | 
								ITx iTx = (ITx) element;
 | 
				
			||||||
 | 
								List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> searchProp.equals(a.getName())).collect(Collectors.toList());
 | 
				
			||||||
 | 
								if(res.size()==1) {
 | 
				
			||||||
 | 
									try {
 | 
				
			||||||
 | 
									ITxAttribute attr =res.get(0);
 | 
				
			||||||
 | 
									switch(searchType) {
 | 
				
			||||||
 | 
									case BOOLEAN: // bool
 | 
				
			||||||
 | 
									case ENUMERATION:
 | 
				
			||||||
 | 
										return searchValue.equalsIgnoreCase((String) attr.getValue());
 | 
				
			||||||
 | 
									case INTEGER:
 | 
				
			||||||
 | 
									case UNSIGNED:
 | 
				
			||||||
 | 
										BigInteger lval = new BigInteger(attr.getValue().toString());
 | 
				
			||||||
 | 
										BigInteger sval = parseBigInteger(searchValue);
 | 
				
			||||||
 | 
										return lval.equals(sval);
 | 
				
			||||||
 | 
									case STRING:
 | 
				
			||||||
 | 
										try {
 | 
				
			||||||
 | 
											return (((ITxAttribute) element).getName().toLowerCase().matches(searchValue.toLowerCase()));
 | 
				
			||||||
 | 
										} catch (PatternSyntaxException e) {
 | 
				
			||||||
 | 
											return true;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									default:
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									} catch(RuntimeException ex) {
 | 
				
			||||||
 | 
										return false;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private BigInteger parseBigInteger(String value) {
 | 
				
			||||||
 | 
							if(value.startsWith("0x") || value.startsWith("0X"))
 | 
				
			||||||
 | 
								return new BigInteger(value.substring(2), 16);
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
								return new BigInteger(value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user