fix Sonarlint warnings
This commit is contained in:
parent
af388b2462
commit
90f45c698f
|
@ -16,6 +16,9 @@ import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -99,25 +102,25 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
if(file.length() < 75000000*(gzipped?1:10) || "memory".equals(System.getProperty("ScvBackingDB", "file")))
|
if(file.length() < 75000000*(gzipped?1:10) || "memory".equals(System.getProperty("ScvBackingDB", "file")))
|
||||||
mapDb = DBMaker
|
mapDb = DBMaker
|
||||||
.memoryDirectDB()
|
.memoryDirectDB()
|
||||||
.allocateStartSize(512*1024*1024)
|
.allocateStartSize(512l*1024l*1024l)
|
||||||
.allocateIncrement(128*1024*1024)
|
.allocateIncrement(128l*1024l*1024l)
|
||||||
.cleanerHackEnable()
|
.cleanerHackEnable()
|
||||||
.make();
|
.make();
|
||||||
else {
|
else {
|
||||||
File mapDbFile;
|
File mapDbFile;
|
||||||
try {
|
try {
|
||||||
mapDbFile = File.createTempFile("."+file.getName(), ".mapdb", null /*file.parentFile*/);
|
mapDbFile = File.createTempFile("."+file.getName(), ".mapdb", null /*file.parentFile*/);
|
||||||
|
Files.delete(Paths.get(mapDbFile.getPath()));
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mapDbFile.delete(); // we just need a file name
|
|
||||||
mapDb = DBMaker
|
mapDb = DBMaker
|
||||||
.fileDB(mapDbFile)
|
.fileDB(mapDbFile)
|
||||||
.fileMmapEnable() // Always enable mmap
|
.fileMmapEnable() // Always enable mmap
|
||||||
.fileMmapEnableIfSupported()
|
.fileMmapEnableIfSupported()
|
||||||
.fileMmapPreclearDisable()
|
.fileMmapPreclearDisable()
|
||||||
.allocateStartSize(512*1024*1024)
|
.allocateStartSize(512l*1024l*1024l)
|
||||||
.allocateIncrement(128*1024*1024)
|
.allocateIncrement(128l*1024l*1024l)
|
||||||
.cleanerHackEnable()
|
.cleanerHackEnable()
|
||||||
.make();
|
.make();
|
||||||
mapDbFile.deleteOnExit();
|
mapDbFile.deleteOnExit();
|
||||||
|
@ -134,6 +137,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
for(TxStream stream:txStreams.values()) {
|
for(TxStream stream:txStreams.values()) {
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
stream.calculateConcurrency();
|
stream.calculateConcurrency();
|
||||||
|
@ -145,7 +149,8 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
attrValues.clear();
|
attrValues.clear();
|
||||||
relationTypes.clear();
|
relationTypes.clear();
|
||||||
|
@ -214,7 +219,7 @@ public class TextDbLoader implements IWaveformDbLoader{
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseInput(InputStream inputStream) throws IOException{
|
void parseInput(InputStream inputStream) throws IOException{
|
||||||
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
|
||||||
String curLine = reader.readLine();
|
String curLine = reader.readLine();
|
||||||
String nextLine = null;
|
String nextLine = null;
|
||||||
while((nextLine=reader.readLine())!=null && curLine!=null) {
|
while((nextLine=reader.readLine())!=null && curLine!=null) {
|
||||||
|
|
|
@ -31,6 +31,8 @@ class TxStream extends HierNode implements IWaveform {
|
||||||
|
|
||||||
private TextDbLoader loader;
|
private TextDbLoader loader;
|
||||||
|
|
||||||
|
final String kind;
|
||||||
|
|
||||||
private int maxConcurrency = 0;
|
private int maxConcurrency = 0;
|
||||||
|
|
||||||
private int concurrency = 0;
|
private int concurrency = 0;
|
||||||
|
@ -53,6 +55,7 @@ class TxStream extends HierNode implements IWaveform {
|
||||||
super(name);
|
super(name);
|
||||||
this.id=id;
|
this.id=id;
|
||||||
this.loader=loader;
|
this.loader=loader;
|
||||||
|
this.kind=kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ITxGenerator> getGenerators(){
|
List<ITxGenerator> getGenerators(){
|
||||||
|
@ -78,7 +81,7 @@ class TxStream extends HierNode implements IWaveform {
|
||||||
@Override
|
@Override
|
||||||
public NavigableMap<Long, IEvent[]> getEvents() {
|
public NavigableMap<Long, IEvent[]> getEvents() {
|
||||||
if(!concurrencyCalculated) calculateConcurrency();
|
if(!concurrencyCalculated) calculateConcurrency();
|
||||||
return (NavigableMap<Long, IEvent[]>)events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -89,15 +92,16 @@ class TxStream extends HierNode implements IWaveform {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSame(IWaveform other) {
|
public boolean isSame(IWaveform other) {
|
||||||
return(other instanceof TxStream && this.getId()==other.getId());
|
return(other instanceof TxStream && this.getId().equals(other.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEvent[] getEventsBeforeTime(Long time) {
|
public IEvent[] getEventsBeforeTime(Long time) {
|
||||||
if(!concurrencyCalculated) calculateConcurrency();
|
if(!concurrencyCalculated)
|
||||||
|
calculateConcurrency();
|
||||||
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
Entry<Long, IEvent[]> e = events.floorEntry(time);
|
||||||
if(e==null)
|
if(e==null)
|
||||||
return null;
|
return new IEvent[] {};
|
||||||
else
|
else
|
||||||
return events.floorEntry(time).getValue();
|
return events.floorEntry(time).getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,16 +13,12 @@ import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
|
||||||
import org.eclipse.jface.viewers.ComboViewer;
|
import org.eclipse.jface.viewers.ComboViewer;
|
||||||
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
|
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
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.jface.viewers.TableViewer;
|
||||||
import org.eclipse.jface.viewers.TableViewerColumn;
|
import org.eclipse.jface.viewers.TableViewerColumn;
|
||||||
import org.eclipse.swt.SWT;
|
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.SelectionEvent;
|
||||||
import org.eclipse.swt.events.SelectionListener;
|
import org.eclipse.swt.events.SelectionListener;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
|
@ -83,16 +79,16 @@ public class TransactionList extends Composite {
|
||||||
private TableViewer tableViewer = null;
|
private TableViewer tableViewer = null;
|
||||||
|
|
||||||
private TableColumn valueColumn = null;
|
private TableColumn valueColumn = null;
|
||||||
|
|
||||||
private AttributeLabelProvider valueLabelProvider = null;
|
private AttributeLabelProvider valueLabelProvider = null;
|
||||||
|
|
||||||
private IWaveform stream;
|
private IWaveform stream;
|
||||||
|
|
||||||
private ObservableList<AttributeNameBean> attrNames = new WritableList<AttributeNameBean>();
|
private ObservableList<AttributeNameBean> attrNames = new WritableList<>();
|
||||||
|
|
||||||
private List<ITx> eventList = new ArrayList<ITx>();
|
private List<ITx> eventList = new ArrayList<>();
|
||||||
|
|
||||||
private List<ITx> emptyList = new ArrayList<ITx>();
|
private List<ITx> emptyList = new ArrayList<>();
|
||||||
|
|
||||||
TxFilter txFilter;
|
TxFilter txFilter;
|
||||||
|
|
||||||
|
@ -115,6 +111,7 @@ public class TransactionList extends Composite {
|
||||||
|
|
||||||
searchPropComboViewer = new ComboViewer(this, SWT.NONE);
|
searchPropComboViewer = new ComboViewer(this, SWT.NONE);
|
||||||
searchPropComboViewer.setLabelProvider(new LabelProvider() {
|
searchPropComboViewer.setLabelProvider(new LabelProvider() {
|
||||||
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
AttributeNameBean entry = (AttributeNameBean) element;
|
AttributeNameBean entry = (AttributeNameBean) element;
|
||||||
return entry.getName()+" ["+entry.getType().toString()+"]";
|
return entry.getName()+" ["+entry.getType().toString()+"]";
|
||||||
|
@ -123,20 +120,19 @@ public class TransactionList extends Composite {
|
||||||
searchPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
searchPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
||||||
searchPropComboViewer.setInput(attrNames);
|
searchPropComboViewer.setInput(attrNames);
|
||||||
Combo searchPropCombo = searchPropComboViewer.getCombo();
|
Combo searchPropCombo = searchPropComboViewer.getCombo();
|
||||||
GridData gd_searchProp = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1);
|
GridData gdSearchProp = new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1);
|
||||||
gd_searchProp.widthHint=100;
|
gdSearchProp.widthHint=100;
|
||||||
searchPropCombo.setLayoutData(gd_searchProp);
|
searchPropCombo.setLayoutData(gdSearchProp);
|
||||||
searchPropCombo.addSelectionListener(new SelectionListener() {
|
searchPropCombo.addSelectionListener(new SelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
int idx = searchPropCombo.getSelectionIndex();
|
extracted(searchPropCombo);
|
||||||
if(idx<0) return;
|
|
||||||
AttributeNameBean sel = attrNames.get(idx);
|
|
||||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
|
||||||
tableViewer.refresh();
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
extracted(searchPropCombo);
|
||||||
|
}
|
||||||
|
private void extracted(Combo searchPropCombo) {
|
||||||
int idx = searchPropCombo.getSelectionIndex();
|
int idx = searchPropCombo.getSelectionIndex();
|
||||||
if(idx<0) return;
|
if(idx<0) return;
|
||||||
AttributeNameBean sel = attrNames.get(idx);
|
AttributeNameBean sel = attrNames.get(idx);
|
||||||
|
@ -146,15 +142,12 @@ public class TransactionList extends Composite {
|
||||||
});
|
});
|
||||||
|
|
||||||
searchPropValue = new Text(this, SWT.BORDER);
|
searchPropValue = new Text(this, SWT.BORDER);
|
||||||
GridData gd_searchPropValue = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
|
GridData gdSearchPropValue = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
|
||||||
gd_searchPropValue.minimumWidth = 50;
|
gdSearchPropValue.minimumWidth = 50;
|
||||||
searchPropValue.setLayoutData(gd_searchPropValue);
|
searchPropValue.setLayoutData(gdSearchPropValue);
|
||||||
searchPropValue.addModifyListener(new ModifyListener() {
|
searchPropValue.addModifyListener(e -> {
|
||||||
@Override
|
txFilter.setSearchValue(((Text) e.widget).getText());
|
||||||
public void modifyText(ModifyEvent e) {
|
tableViewer.refresh();
|
||||||
txFilter.setSearchValue(((Text) e.widget).getText());
|
|
||||||
tableViewer.refresh();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Label lbl2 = new Label(this, SWT.NONE);
|
Label lbl2 = new Label(this, SWT.NONE);
|
||||||
|
@ -164,6 +157,7 @@ public class TransactionList extends Composite {
|
||||||
|
|
||||||
viewPropComboViewer = new ComboViewer(this, SWT.NONE);
|
viewPropComboViewer = new ComboViewer(this, SWT.NONE);
|
||||||
viewPropComboViewer.setLabelProvider(new LabelProvider() {
|
viewPropComboViewer.setLabelProvider(new LabelProvider() {
|
||||||
|
@Override
|
||||||
public String getText(Object element) {
|
public String getText(Object element) {
|
||||||
AttributeNameBean entry = (AttributeNameBean) element;
|
AttributeNameBean entry = (AttributeNameBean) element;
|
||||||
return entry.getName()+" ["+entry.getType().toString()+"]";
|
return entry.getName()+" ["+entry.getType().toString()+"]";
|
||||||
|
@ -172,9 +166,9 @@ public class TransactionList extends Composite {
|
||||||
viewPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
viewPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
|
||||||
viewPropComboViewer.setInput(attrNames);
|
viewPropComboViewer.setInput(attrNames);
|
||||||
Combo viewPropCombo = viewPropComboViewer.getCombo();
|
Combo viewPropCombo = viewPropComboViewer.getCombo();
|
||||||
GridData gd_viewProp = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
GridData gdviewProp = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
|
||||||
gd_viewProp.widthHint=100;
|
gdviewProp.widthHint=100;
|
||||||
viewPropCombo.setLayoutData(gd_viewProp);
|
viewPropCombo.setLayoutData(gdviewProp);
|
||||||
viewPropCombo.addSelectionListener(new SelectionListener() {
|
viewPropCombo.addSelectionListener(new SelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
@ -184,7 +178,7 @@ public class TransactionList extends Composite {
|
||||||
tableViewer.refresh(true);
|
tableViewer.refresh(true);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void widgetDefaultSelected(SelectionEvent e) { }
|
public void widgetDefaultSelected(SelectionEvent e) { /* do nothing */ }
|
||||||
});
|
});
|
||||||
|
|
||||||
tableViewer = new TableViewer(this);
|
tableViewer = new TableViewer(this);
|
||||||
|
@ -200,21 +194,18 @@ public class TransactionList extends Composite {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tableViewer.addFilter(txFilter);
|
tableViewer.addFilter(txFilter);
|
||||||
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
tableViewer.addSelectionChangedListener(event -> {
|
||||||
@Override
|
ISelection treeSelection = event.getSelection();
|
||||||
public void selectionChanged(SelectionChangedEvent event) {
|
if(treeSelection instanceof IStructuredSelection) {
|
||||||
ISelection treeSelection = event.getSelection();
|
Object selected = ((IStructuredSelection)treeSelection).getFirstElement();
|
||||||
if(treeSelection instanceof IStructuredSelection) {
|
if(selected instanceof ITx){
|
||||||
Object selected = ((IStructuredSelection)treeSelection).getFirstElement();
|
waveformViewer.setSelection(new StructuredSelection(selected));
|
||||||
if(selected instanceof ITx){
|
} else if(selected instanceof TransactionTreeNode && ((TransactionTreeNode)selected).type == TransactionTreeNodeType.TX) {
|
||||||
waveformViewer.setSelection(new StructuredSelection(selected));
|
waveformViewer.setSelection(new StructuredSelection(((TransactionTreeNode)selected).element));
|
||||||
} else if(selected instanceof TransactionTreeNode && ((TransactionTreeNode)selected).type == TransactionTreeNodeType.TX) {
|
|
||||||
waveformViewer.setSelection(new StructuredSelection(((TransactionTreeNode)selected).element));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Table table = tableViewer.getTable();
|
Table table = tableViewer.getTable();
|
||||||
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
|
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
|
||||||
|
|
||||||
|
@ -254,7 +245,7 @@ public class TransactionList extends Composite {
|
||||||
stream=trackEntry.waveform;
|
stream=trackEntry.waveform;
|
||||||
tableViewer.setInput(emptyList);
|
tableViewer.setInput(emptyList);
|
||||||
new Thread() {
|
new Thread() {
|
||||||
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
|
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private List<AttributeNameBean> getEntries() {
|
private List<AttributeNameBean> getEntries() {
|
||||||
return propNames.entrySet().stream()
|
return propNames.entrySet().stream()
|
||||||
|
@ -263,6 +254,7 @@ public class TransactionList extends Composite {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Collection<IEvent[]> values = stream.getEvents().values();
|
Collection<IEvent[]> values = stream.getEvents().values();
|
||||||
eventList = values.parallelStream().map(Arrays::asList)
|
eventList = values.parallelStream().map(Arrays::asList)
|
||||||
|
@ -283,7 +275,7 @@ public class TransactionList extends Composite {
|
||||||
tableViewer.setInput(eventList);
|
tableViewer.setInput(eventList);
|
||||||
attrNames.clear();
|
attrNames.clear();
|
||||||
attrNames.addAll(getEntries());
|
attrNames.addAll(getEntries());
|
||||||
if(attrNames.size()>0)
|
if(!attrNames.isEmpty())
|
||||||
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
|
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
|
||||||
if (searchPropComboViewer!=null) {
|
if (searchPropComboViewer!=null) {
|
||||||
searchPropComboViewer.setInput(attrNames);
|
searchPropComboViewer.setInput(attrNames);
|
||||||
|
@ -297,7 +289,7 @@ public class TransactionList extends Composite {
|
||||||
}.start();
|
}.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchProps(String propName, DataType type, String propValue) {
|
public void setSearchProps(String propName, DataType type, String propValue) {
|
||||||
for(int i=0; i<attrNames.size(); ++i) {
|
for(int i=0; i<attrNames.size(); ++i) {
|
||||||
AttributeNameBean e = attrNames.get(i);
|
AttributeNameBean e = attrNames.get(i);
|
||||||
|
|
Loading…
Reference in New Issue