add multi-selection in waveform viewer
This commit is contained in:
		@@ -1,8 +1,6 @@
 | 
			
		||||
 
 | 
			
		||||
package com.minres.scviewer.e4.application.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Named;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.e4.core.di.annotations.CanExecute;
 | 
			
		||||
@@ -34,18 +32,14 @@ public class ChangeValueDisplay {
 | 
			
		||||
			WaveformViewer wfv = (WaveformViewer)obj;
 | 
			
		||||
			ISelection sel = wfv.getSelection();
 | 
			
		||||
			if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
 | 
			
		||||
				Iterator<?> it = ((IStructuredSelection)sel).iterator();
 | 
			
		||||
				it.next();
 | 
			
		||||
				if(it.hasNext()) {
 | 
			
		||||
						Object second = it.next();
 | 
			
		||||
						if(second instanceof TrackEntry) {
 | 
			
		||||
							TrackEntry.ValueDisplay val = TrackEntry.ValueDisplay.valueOf(param);
 | 
			
		||||
							((TrackEntry)second).valueDisplay=val;
 | 
			
		||||
							wfv.update();
 | 
			
		||||
						}
 | 
			
		||||
				for(Object elem:(IStructuredSelection)sel) {
 | 
			
		||||
					if(elem instanceof TrackEntry) {
 | 
			
		||||
						TrackEntry.ValueDisplay val= TrackEntry.ValueDisplay.valueOf(param);
 | 
			
		||||
						((TrackEntry)elem).valueDisplay=val;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				wfv.update();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
		
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
 
 | 
			
		||||
package com.minres.scviewer.e4.application.handlers;
 | 
			
		||||
 | 
			
		||||
import java.util.Iterator;
 | 
			
		||||
 | 
			
		||||
import javax.inject.Named;
 | 
			
		||||
 | 
			
		||||
import org.eclipse.e4.core.di.annotations.CanExecute;
 | 
			
		||||
@@ -34,16 +32,13 @@ public class ChangeWaveformDisplay {
 | 
			
		||||
			WaveformViewer wfv = (WaveformViewer)obj;
 | 
			
		||||
			ISelection sel = wfv.getSelection();
 | 
			
		||||
			if(!sel.isEmpty() && sel instanceof IStructuredSelection) {
 | 
			
		||||
				Iterator<?> it = ((IStructuredSelection)sel).iterator();
 | 
			
		||||
				it.next();
 | 
			
		||||
				if(it.hasNext()) {
 | 
			
		||||
						Object second = it.next();
 | 
			
		||||
						if(second instanceof TrackEntry) {
 | 
			
		||||
							TrackEntry.WaveDisplay val= TrackEntry.WaveDisplay.valueOf(param);
 | 
			
		||||
							((TrackEntry)second).waveDisplay=val;
 | 
			
		||||
							wfv.update();
 | 
			
		||||
						}
 | 
			
		||||
				for(Object elem:(IStructuredSelection)sel) {
 | 
			
		||||
					if(elem instanceof TrackEntry) {
 | 
			
		||||
						TrackEntry.WaveDisplay val= TrackEntry.WaveDisplay.valueOf(param);
 | 
			
		||||
						((TrackEntry)elem).waveDisplay=val;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				wfv.update();
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,23 +17,30 @@ import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 | 
			
		||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
 | 
			
		||||
import org.eclipse.jface.viewers.IStructuredSelection;
 | 
			
		||||
 | 
			
		||||
import com.minres.scviewer.database.IWaveform;
 | 
			
		||||
import com.minres.scviewer.database.ui.TrackEntry;
 | 
			
		||||
import com.minres.scviewer.e4.application.parts.WaveformViewer;
 | 
			
		||||
 | 
			
		||||
public class DeleteWaveformHandler {
 | 
			
		||||
	
 | 
			
		||||
	@SuppressWarnings("unchecked")
 | 
			
		||||
	@CanExecute
 | 
			
		||||
	public Boolean canExecute(ESelectionService selectionService){
 | 
			
		||||
		Object o = selectionService.getSelection();
 | 
			
		||||
		return o instanceof IStructuredSelection && ((IStructuredSelection)o).getFirstElement() instanceof IWaveform;
 | 
			
		||||
		if(o instanceof IStructuredSelection) {
 | 
			
		||||
			IStructuredSelection sel = (IStructuredSelection) o;
 | 
			
		||||
			if(sel.size()>0)
 | 
			
		||||
				return sel.toList().stream().allMatch(e-> e instanceof TrackEntry);
 | 
			
		||||
			else
 | 
			
		||||
				return false;
 | 
			
		||||
		} else
 | 
			
		||||
			return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Execute
 | 
			
		||||
	public void execute(ESelectionService selectionService, MPart activePart) {
 | 
			
		||||
		Object o = activePart.getObject();
 | 
			
		||||
		Object sel = selectionService.getSelection();
 | 
			
		||||
		if(o instanceof WaveformViewer && ((IStructuredSelection)sel).getFirstElement() instanceof IWaveform){
 | 
			
		||||
			((WaveformViewer)o).removeStreamFromList((IWaveform) ((IStructuredSelection)sel).getFirstElement());
 | 
			
		||||
		if(o instanceof WaveformViewer){
 | 
			
		||||
			((WaveformViewer)o).removeSelectedStreamsFromList();
 | 
			
		||||
		}	
 | 
			
		||||
	}	
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user