diff --git a/com.minres.scviewer.e4.application/Application.e4xmi b/com.minres.scviewer.e4.application/Application.e4xmi index 1bc8147..42c316c 100644 --- a/com.minres.scviewer.e4.application/Application.e4xmi +++ b/com.minres.scviewer.e4.application/Application.e4xmi @@ -4,7 +4,7 @@ - + @@ -187,9 +187,15 @@ type:user + + + type:user + + + diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SelectAllHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SelectAllHandler.java index 14d89a1..a641546 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SelectAllHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/SelectAllHandler.java @@ -11,13 +11,33 @@ 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.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 { + @Inject @Optional DesignBrowser designBrowser; + @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; + } + } \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java index 370849b..e49a360 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/DesignBrowser.java @@ -13,9 +13,9 @@ package com.minres.scviewer.e4.application.parts; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.lang.annotation.Annotation; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -133,7 +133,7 @@ public class DesignBrowser { private TableViewer txTableViewer; /** The append all item. */ - ToolItem appendItem, insertItem, insertAllItem, appendAllItem; + ToolItem appendItem, insertItem; /** The other selection count. */ int thisSelectionCount=0, otherSelectionCount=0; @@ -287,7 +287,6 @@ public class DesignBrowser { updateButtons(); } }); - menuService.registerContextMenu(txTableViewer.getControl(), POPUP_ID); ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.RIGHT); @@ -322,48 +321,6 @@ public class DesignBrowser { 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); } + public void selectAllWaveforms() { + int itemCount = txTableViewer.getTable().getItemCount(); + ArrayList list = new ArrayList<>(); + for(int i=0; i