fix #29 cannot delete VCD signals

comparison of objects were done by idendity not .equals()
This commit is contained in:
Eyck Jentzsch 2020-03-13 16:01:16 +01:00
parent 9f4f71046d
commit 732bd82034
4 changed files with 15 additions and 17 deletions

View File

@ -193,7 +193,7 @@ public class TxStream extends HierNode implements ITxStream<ITxEvent> {
@Override
public Boolean equals(IWaveform other) {
return(other instanceof TxStream && this.getId()==other.getId());
return(other instanceof TxStream && this.getId().equals(other.getId()));
}
}

View File

@ -117,7 +117,7 @@ public class VCDSignal<T> extends HierNode implements ISignal<T> {
@Override
public Boolean equals(IWaveform other) {
return(other instanceof VCDSignal<?> && this.getId()==other.getId());
return( other instanceof VCDSignal<?> && this.getId().equals(other.getId()));
}
@Override

View File

@ -140,7 +140,7 @@ public class WaveformDb extends HierNode implements IWaveformDb {
break;
}
}
if(name == hier[hier.length-1]){ //leaf
if(name.equals(hier[hier.length-1])){ //leaf
if(n1!=null) {
if(n1 instanceof HierNode){
node.getChildNodes().remove(n1);

View File

@ -669,12 +669,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
* @param persistedState the persisted state
*/
protected void saveWaveformViewerState(Map<String, String> persistedState) {
Integer index;
boolean isStream = false;
persistedState.put(SHOWN_WAVEFORM + "S", Integer.toString(waveformPane.getStreamList().size())); //$NON-NLS-1$
index = 0;
Integer index = 0;
for (TrackEntry trackEntry : waveformPane.getStreamList()) {
if(trackEntry.isStream()) { isStream=true; }
persistedState.put(SHOWN_WAVEFORM + index, trackEntry.waveform.getFullName());
persistedState.put(SHOWN_WAVEFORM + index + VALUE_DISPLAY, trackEntry.valueDisplay.toString());
persistedState.put(SHOWN_WAVEFORM + index + WAVE_DISPLAY, trackEntry.waveDisplay.toString());
@ -693,23 +690,24 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
// get selected transaction of a stream
ISelection selection = waveformPane.getSelection();
if (!selection.isEmpty() && isStream) {
if (!selection.isEmpty()) {
List<Object> t = getISelection(selection);
ITx tx = (ITx) t.get(0);
TrackEntry te = (TrackEntry) t.get(1);
// get transaction id
persistedState.put(SELECTED_TX_ID, Long.toString(tx.getId()));
//get TrackEntry name
String name = te.getStream().getFullName();
persistedState.put(SELECTED_TRACKENTRY_NAME, name);
if(t.get(0) instanceof ITx) {
ITx tx = (ITx) t.get(0);
TrackEntry te = (TrackEntry) t.get(1);
// get transaction id
persistedState.put(SELECTED_TX_ID, Long.toString(tx.getId()));
//get TrackEntry name
String name = te.getStream().getFullName();
persistedState.put(SELECTED_TRACKENTRY_NAME, name);
}
}
}
protected List<Object> getISelection(ISelection selection){
List<Object> result = new LinkedList<Object> ();
if ( selection instanceof IStructuredSelection )
{
if ( selection instanceof IStructuredSelection ) {
Iterator<?> i = ((IStructuredSelection)selection).iterator();
while (i.hasNext()){
Object o = i.next ();