add a select-all key stroke to design browsers stream table

This commit is contained in:
Eyck Jentzsch 2020-03-13 22:06:55 +01:00
parent 674aa7d3ce
commit 8e66e5fe0b
4 changed files with 50 additions and 59 deletions

View File

@ -4,7 +4,7 @@
<children xsi:type="advanced:PerspectiveStack" xmi:id="_95QGxnNmEeWBq8z1Dv39LA"> <children xsi:type="advanced:PerspectiveStack" xmi:id="_95QGxnNmEeWBq8z1Dv39LA">
<children xsi:type="advanced:Perspective" xmi:id="_95QGx3NmEeWBq8z1Dv39LA"> <children xsi:type="advanced:Perspective" xmi:id="_95QGx3NmEeWBq8z1Dv39LA">
<children xsi:type="basic:PartSashContainer" xmi:id="_95QGyHNmEeWBq8z1Dv39LA" horizontal="true"> <children xsi:type="basic:PartSashContainer" xmi:id="_95QGyHNmEeWBq8z1Dv39LA" horizontal="true">
<children xsi:type="basic:Part" xmi:id="_95QGynNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.parts.DesignBrowser" containerData="2000" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.DesignBrowser" label="Design Browser"> <children xsi:type="basic:Part" xmi:id="_95QGynNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.parts.DesignBrowser" containerData="2000" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.DesignBrowser" label="Design Browser" bindingContexts="_iQ3kQGVmEeqSQM-A6dw9ig">
<handlers xmi:id="_JIWOYIq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handler.addWaveformCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.AddWaveformHandler" command="_2PehEHr9EeWVM_sKoXvptg"/> <handlers xmi:id="_JIWOYIq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handler.addWaveformCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.AddWaveformHandler" command="_2PehEHr9EeWVM_sKoXvptg"/>
<menus xsi:type="menu:PopupMenu" xmi:id="_HvUl8Iq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.parts.DesignBrowser.popupmenu"> <menus xsi:type="menu:PopupMenu" xmi:id="_HvUl8Iq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.parts.DesignBrowser.popupmenu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_HvUl8Yq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handledmenuitem.append" label="Append after" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/append_wave.png" command="_2PehEHr9EeWVM_sKoXvptg"> <children xsi:type="menu:HandledMenuItem" xmi:id="_HvUl8Yq-EeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handledmenuitem.append" label="Append after" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/append_wave.png" command="_2PehEHr9EeWVM_sKoXvptg">
@ -187,9 +187,15 @@
<tags>type:user</tags> <tags>type:user</tags>
</bindings> </bindings>
</bindingTables> </bindingTables>
<bindingTables xmi:id="_mnMrUGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingtable.0" bindingContext="_iQ3kQGVmEeqSQM-A6dw9ig">
<bindings xmi:id="_n9yDwGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.keybinding.0" keySequence="M1+A" command="_bV-TMHXHEeWwZ-9vrAR2UQ">
<tags>type:user</tags>
</bindings>
</bindingTables>
<rootContext xmi:id="_95PfuXNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows"> <rootContext xmi:id="_95PfuXNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialogAndWindow" name="In Dialog and Windows">
<children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows"> <children xmi:id="_95PfunNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.window" name="In Windows">
<children xmi:id="_q4VSsGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.waveform" name="In Waveform Part"/> <children xmi:id="_q4VSsGVNEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.waveform" name="In Waveform Part"/>
<children xmi:id="_iQ3kQGVmEeqSQM-A6dw9ig" elementId="com.minres.scviewer.e4.application.bindingcontext.indesignbrowser" name="In DesignBrowser"/>
</children> </children>
<children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/> <children xmi:id="_95Pfu3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.contexts.dialog" name="In Dialogs"/>
</rootContext> </rootContext>

View File

@ -11,13 +11,33 @@
package com.minres.scviewer.e4.application.handlers; package com.minres.scviewer.e4.application.handlers;
import javax.inject.Inject;
import org.eclipse.e4.core.di.annotations.Execute; import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import com.minres.scviewer.e4.application.parts.DesignBrowser;
public class SelectAllHandler { public class SelectAllHandler {
@Inject @Optional DesignBrowser designBrowser;
@Execute @Execute
public void execute() { public void execute(EPartService partService) {
if(designBrowser==null) designBrowser = getListPart(partService);
if(designBrowser!=null){
designBrowser.selectAllWaveforms();
}
} }
protected DesignBrowser getListPart(EPartService partService){
MPart part = partService.getActivePart();
if(part.getObject() instanceof DesignBrowser)
return (DesignBrowser) part.getObject();
else
return null;
}
} }

View File

@ -13,9 +13,9 @@ package com.minres.scviewer.e4.application.parts;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException; import java.util.regex.PatternSyntaxException;
@ -133,7 +133,7 @@ public class DesignBrowser {
private TableViewer txTableViewer; private TableViewer txTableViewer;
/** The append all item. */ /** The append all item. */
ToolItem appendItem, insertItem, insertAllItem, appendAllItem; ToolItem appendItem, insertItem;
/** The other selection count. */ /** The other selection count. */
int thisSelectionCount=0, otherSelectionCount=0; int thisSelectionCount=0, otherSelectionCount=0;
@ -287,7 +287,6 @@ public class DesignBrowser {
updateButtons(); updateButtons();
} }
}); });
menuService.registerContextMenu(txTableViewer.getControl(), POPUP_ID); menuService.registerContextMenu(txTableViewer.getControl(), POPUP_ID);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT); ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT);
@ -322,48 +321,6 @@ public class DesignBrowser {
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx); ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
} }
}); });
new ToolItem(toolBar, SWT.SEPARATOR);
appendAllItem = new ToolItem(toolBar, SWT.NONE);
appendAllItem.setToolTipText(Messages.DesignBrowser_12);
appendAllItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/append_all_waves.png")); //$NON-NLS-1$ //$NON-NLS-2$
appendAllItem.setEnabled(false);
new ToolItem(toolBar, SWT.SEPARATOR);
appendAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] all = getFilteredChildren(txTableViewer);
if(all.length>0){
Object oldSel=selectionService.getSelection();
selectionService.setSelection(new StructuredSelection(all));
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
selectionService.setSelection(oldSel);
}
}
});
insertAllItem = new ToolItem(toolBar, SWT.NONE);
insertAllItem.setToolTipText(Messages.DesignBrowser_16);
insertAllItem.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/insert_all_waves.png")); //$NON-NLS-1$ //$NON-NLS-2$
insertAllItem.setEnabled(false);
insertAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Object[] all = getFilteredChildren(txTableViewer);
if(all.length>0){
Object oldSel=selectionService.getSelection();
selectionService.setSelection(new StructuredSelection(all));
AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "before", false); //$NON-NLS-1$
if(result!=null && (Boolean)result)
ContextInjectionFactory.invoke(myHandler, Execute.class, eclipseCtx);
selectionService.setSelection(oldSel);
}
}
});
} }
/** /**
@ -391,6 +348,16 @@ public class DesignBrowser {
txTableViewer.setSelection(null); txTableViewer.setSelection(null);
} }
public void selectAllWaveforms() {
int itemCount = txTableViewer.getTable().getItemCount();
ArrayList<Object> list = new ArrayList<>();
for(int i=0; i<itemCount; i++) {
list.add(txTableViewer.getElementAt(i));
}
StructuredSelection sel = new StructuredSelection(list);
txTableViewer.setSelection(sel);
}
/** /**
* Gets the status event. * Gets the status event.
* *
@ -458,17 +425,12 @@ public class DesignBrowser {
* Update buttons. * Update buttons.
*/ */
private void updateButtons() { private void updateButtons() {
if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed() && if(txTableViewer!=null && !insertItem.isDisposed() && !appendItem.isDisposed()){
!appendAllItem.isDisposed() && !insertAllItem.isDisposed()){
AddWaveformHandler myHandler = new AddWaveformHandler(); AddWaveformHandler myHandler = new AddWaveformHandler();
Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$ Object result = runCommand(myHandler, CanExecute.class, "after", false); //$NON-NLS-1$
appendItem.setEnabled(result instanceof Boolean && (Boolean)result); appendItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "after", true); //$NON-NLS-1$
appendAllItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "before", false); //$NON-NLS-1$ result = runCommand(myHandler, CanExecute.class, "before", false); //$NON-NLS-1$
insertItem.setEnabled(result instanceof Boolean && (Boolean)result); insertItem.setEnabled(result instanceof Boolean && (Boolean)result);
result = runCommand(myHandler, CanExecute.class, "before", true); //$NON-NLS-1$
insertAllItem.setEnabled(result instanceof Boolean && (Boolean)result);
} }
} }

View File

@ -913,10 +913,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
Object first = selection.getFirstElement(); Object first = selection.getFirstElement();
IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first; IWaveform stream = (first instanceof ITx) ? ((ITx) first).getStream() : (IWaveform) first;
TrackEntry trackEntry = waveformPane.getEntryForStream(stream); TrackEntry trackEntry = waveformPane.getEntryForStream(stream);
int index = waveformPane.getStreamList().indexOf(trackEntry); if (insert) {
if (!insert) int index = waveformPane.getStreamList().indexOf(trackEntry);
index++; waveformPane.getStreamList().addAll(index, streams);
waveformPane.getStreamList().addAll(index, streams); } else {
waveformPane.getStreamList().addAll(streams);
}
} }
setFocus(); setFocus();
} }