adapt UI
This commit is contained in:
@ -1,181 +0,0 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||
import org.eclipse.jface.dialogs.TitleAreaDialog;
|
||||
import org.eclipse.jface.viewers.ArrayContentProvider;
|
||||
import org.eclipse.jface.viewers.ComboViewer;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.wb.swt.ResourceManager;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
import com.minres.scviewer.database.ITxStream;
|
||||
|
||||
public class SearchTxDialog extends TitleAreaDialog {
|
||||
private ComboViewer propNameComboViewer = null;
|
||||
|
||||
private Text propValueText = null;
|
||||
|
||||
private String propName="";
|
||||
private DataType propType=null;
|
||||
private String propValue="";
|
||||
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
|
||||
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
|
||||
|
||||
/**
|
||||
* Create the dialog.
|
||||
* @param parentShell
|
||||
* @param iTxStream
|
||||
*/
|
||||
public SearchTxDialog(Shell parentShell, ITxStream<? extends ITxEvent> iTxStream) {
|
||||
super(parentShell);
|
||||
setShellStyle(SWT.BORDER | SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL);
|
||||
stream=iTxStream;
|
||||
new Thread() {
|
||||
public void run() {
|
||||
stream.getEvents().values().parallelStream().forEach(evtLst -> {
|
||||
evtLst.forEach(evt -> {
|
||||
evt.getTransaction().getAttributes().stream().forEach(attr -> {
|
||||
propNames.put(attr.getName(), attr.getDataType());
|
||||
});
|
||||
});
|
||||
});
|
||||
parentShell.getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (propNameComboViewer!=null) {
|
||||
propNameComboViewer.setInput(getEntries());
|
||||
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the dialog.
|
||||
* @param parent
|
||||
*/
|
||||
@Override
|
||||
protected Control createDialogArea(Composite parent) {
|
||||
setMessage("Specify property name and value to search for");
|
||||
setTitleImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"));
|
||||
setTitle("Search Tx in stream");
|
||||
final Composite area = (Composite) super.createDialogArea(parent);
|
||||
final GridLayout gridLayout = (GridLayout) area.getLayout();
|
||||
gridLayout.marginTop = 10;
|
||||
gridLayout.marginBottom = 10;
|
||||
final Composite container = new Composite(area, SWT.NONE);
|
||||
final GridLayout gl_container = new GridLayout(2, false);
|
||||
gl_container.horizontalSpacing = 2;
|
||||
container.setLayout(gl_container);
|
||||
container.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||
|
||||
final Label header = new Label(container, SWT.CENTER | SWT.WRAP);
|
||||
GridData gd_header = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
|
||||
gd_header.verticalIndent = 10;
|
||||
header.setLayoutData(gd_header);
|
||||
header.setText("Stream: "+stream.getName());
|
||||
|
||||
final Label propNameLabel = new Label(container, SWT.NONE);
|
||||
propNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
propNameLabel.setText("Property Name:");
|
||||
|
||||
propNameComboViewer = new ComboViewer(container, SWT.NONE);
|
||||
propNameComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
propNameComboViewer.setContentProvider(ArrayContentProvider.getInstance());
|
||||
propNameComboViewer.setLabelProvider(new LabelProvider() {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)element;
|
||||
return e.getKey()+" ("+e.getValue().name()+")";
|
||||
}
|
||||
|
||||
});
|
||||
propNameComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void selectionChanged(SelectionChangedEvent event) {
|
||||
IStructuredSelection sel = event.getStructuredSelection();
|
||||
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)sel.getFirstElement();
|
||||
propName=e.getKey();
|
||||
propType=e.getValue();
|
||||
}
|
||||
});
|
||||
propNameComboViewer.setInput(getEntries());
|
||||
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
|
||||
|
||||
final Label propValueLabel = new Label(container, SWT.NONE);
|
||||
propValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
|
||||
propValueLabel.setText("Property Value:");
|
||||
|
||||
propValueText = new Text(container, SWT.BORDER);
|
||||
propValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
private List<Entry<String,DataType>> getEntries() {
|
||||
return propNames.entrySet().stream().sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create contents of the button bar.
|
||||
* @param parent
|
||||
*/
|
||||
@Override
|
||||
protected void createButtonsForButtonBar(Composite parent) {
|
||||
final Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
|
||||
okButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/tick.png"));
|
||||
final Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
|
||||
cancelButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/cross.png"));
|
||||
}
|
||||
|
||||
protected void constrainShellSize() {
|
||||
super.constrainShellSize();
|
||||
getShell().setMinimumSize(getShell().computeSize(-1, -1));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void okPressed() {
|
||||
propValue=propValueText.getText();
|
||||
super.okPressed();
|
||||
}
|
||||
|
||||
public String getPropName() {
|
||||
return propName;
|
||||
}
|
||||
|
||||
public DataType getPropType() {
|
||||
return propType;
|
||||
}
|
||||
|
||||
public String getPropValue() {
|
||||
return propValue;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
@ -10,8 +12,6 @@ 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.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
@ -36,11 +36,13 @@ import org.eclipse.swt.widgets.TableColumn;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.EventKind;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
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.IWaveform;
|
||||
import com.minres.scviewer.database.WaveformType;
|
||||
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;
|
||||
@ -84,7 +86,7 @@ public class TransactionList extends Composite {
|
||||
|
||||
private AttributeLabelProvider valueLabelProvider = null;
|
||||
|
||||
private ITxStream<? extends ITxEvent> stream;
|
||||
private IWaveform stream;
|
||||
|
||||
private ObservableList<AttributeNameBean> attrNames = new WritableList<AttributeNameBean>();
|
||||
|
||||
@ -126,6 +128,7 @@ public class TransactionList extends Composite {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int idx = searchPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
||||
tableViewer.refresh();
|
||||
@ -133,6 +136,7 @@ public class TransactionList extends Composite {
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
int idx = searchPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
||||
tableViewer.refresh();
|
||||
@ -171,6 +175,7 @@ public class TransactionList extends Composite {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
int idx = viewPropCombo.getSelectionIndex();
|
||||
if(idx<0) return;
|
||||
valueLabelProvider.setShowProp(attrNames.get(idx).getName());
|
||||
tableViewer.refresh(true);
|
||||
}
|
||||
@ -238,11 +243,11 @@ public class TransactionList extends Composite {
|
||||
}
|
||||
|
||||
public void setInput(TrackEntry trackEntry) {
|
||||
if(trackEntry==null || !trackEntry.isStream()) {
|
||||
if(trackEntry==null || trackEntry.waveform.getType()!=WaveformType.TRANSACTION) {
|
||||
attrNames.clear();
|
||||
tableViewer.setInput(emptyList);
|
||||
} else {
|
||||
stream=trackEntry.getStream();
|
||||
stream=trackEntry.waveform;
|
||||
tableViewer.setInput(emptyList);
|
||||
new Thread() {
|
||||
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
|
||||
@ -255,11 +260,12 @@ public class TransactionList extends Composite {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
eventList = stream.getEvents().values().parallelStream()
|
||||
Collection<IEvent[]> values = stream.getEvents().values();
|
||||
eventList = values.parallelStream().map(Arrays::asList)
|
||||
.flatMap(List::stream)
|
||||
.filter(evt -> evt.getType()==Type.BEGIN)
|
||||
.filter(evt -> evt.getKind()==EventKind.BEGIN)
|
||||
.map(evt-> {
|
||||
ITx tx = evt.getTransaction();
|
||||
ITx tx = ((ITxEvent)evt).getTransaction();
|
||||
for(ITxAttribute attr: tx.getAttributes()) {
|
||||
propNames.put(attr.getName(), attr.getDataType());
|
||||
}
|
||||
|
@ -62,8 +62,6 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CTabFolder;
|
||||
import org.eclipse.swt.custom.CTabItem;
|
||||
import org.eclipse.swt.custom.SashForm;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
@ -88,6 +86,7 @@ import org.eclipse.swt.widgets.Widget;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
import com.minres.scviewer.database.DataType;
|
||||
import com.minres.scviewer.database.IEvent;
|
||||
import com.minres.scviewer.database.ITx;
|
||||
import com.minres.scviewer.database.ITxAttribute;
|
||||
import com.minres.scviewer.database.ITxEvent;
|
||||
@ -790,7 +789,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
// get transaction id
|
||||
persistedState.put(SELECTED_TX_ID, Long.toString(tx.getId()));
|
||||
//get TrackEntry name
|
||||
String name = te.getStream().getFullName();
|
||||
String name = te.waveform.getFullName();
|
||||
persistedState.put(SELECTED_TRACKENTRY_NAME, name);
|
||||
}
|
||||
}
|
||||
@ -874,11 +873,11 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||
if(te.waveform.getFullName().compareTo(trackentryName)==0) {
|
||||
boolean found = false;
|
||||
// TODO: find transaction by time? To avoid 3x for-loop
|
||||
for( List<ITxEvent> lev : te.getStream().getEvents().values() ) {
|
||||
for( IEvent[] lev : te.waveform.getEvents().values() ) {
|
||||
if(lev == null) continue;
|
||||
for(ITxEvent itxe : lev) {
|
||||
if(itxe == null) continue;
|
||||
ITx itx = itxe.getTransaction();
|
||||
for(IEvent itxe : lev) {
|
||||
if(itxe == null || !(itxe instanceof ITxEvent)) continue;
|
||||
ITx itx = ((ITxEvent)itxe).getTransaction();
|
||||
if(itx.getId() == txId) {
|
||||
found = true;
|
||||
ArrayList<Object> selectionList = new ArrayList<Object>();
|
||||
|
Reference in New Issue
Block a user