Compare commits

...

23 Commits
2.8 ... 2.9.3

Author SHA1 Message Date
0c7631e912 Merge branch 'release/2.9.3' 2020-11-24 16:20:18 +01:00
ded10e1c22 fix some bugs
* NPE when stream contains no transactions and hence no attributes
* changed sash hierarchy in waveform pane
2020-11-24 16:20:08 +01:00
184f1b2d2c Merge branch 'release/2.9.2' 2020-11-11 18:00:58 +01:00
90249dadb9 replace TreeViewer with TableViewer in TransactionList 2020-11-11 17:55:10 +01:00
d47db29b93 Merge branch 'release/2.9.1' 2020-11-11 07:25:05 +01:00
e8148af10f update version numbers 2020-11-11 07:24:54 +01:00
b298a4ca6c fix TX search list implementation 2020-11-10 21:02:34 +01:00
f474e38687 add type for TransactionTreeNode 2020-11-04 08:50:04 +01:00
2e806f7b86 Merge branch 'release/2.9.0' into develop 2020-11-01 18:29:44 +01:00
b7a8d99e2d Merge branch 'release/2.9.0' 2020-11-01 18:29:43 +01:00
2a09fc7e6f update version numbers 2020-11-01 18:29:29 +01:00
e36abb8d55 Merge branch 'feature/tx_search' into develop 2020-11-01 18:18:21 +01:00
5746b9f758 add initial version of search list 2020-11-01 17:42:16 +01:00
6be1f018b1 add search dialog and pane 2020-10-29 07:48:35 +01:00
38a046aaef Merge branch 'release/2.8.1' into develop 2020-10-28 14:19:51 +01:00
fdbd6f8402 Merge branch 'release/2.8.1' 2020-10-28 14:19:50 +01:00
1dad204494 update release numbers 2020-10-28 14:19:25 +01:00
54661c51ce Merge branch 'release/2.8.1' 2020-10-28 14:16:13 +01:00
b34fe0d0ba add reload menu and toolbar item 2020-10-28 13:33:07 +01:00
868eceddc5 fix CLI handling 2020-10-28 13:33:06 +01:00
b642c396c7 add reload menu and toolbar item 2020-10-28 13:32:17 +01:00
f3d8e34ed0 fix CLI handling 2020-10-27 18:11:03 +01:00
401c760e01 Merge branch 'release/2.8' into develop 2020-10-19 07:09:27 +02:00
30 changed files with 1613 additions and 655 deletions

View File

@ -20,6 +20,17 @@
<repository location="http://dist.springsource.org/snapshot/GRECLIPSE/e4.15/"/>
<unit id="org.codehaus.groovy25.feature.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/nattable/releases/1.6.0/repository/"/>
<unit id="org.eclipse.nebula.widgets.nattable.core.feature.feature.group" version="1.6.0.201909181823"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.e4.feature.feature.group" version="1.2.0.201909181823"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.glazedlists.feature.feature.group" version="1.6.0.201909181823"/>
<unit id="org.eclipse.nebula.widgets.nattable.extension.poi.feature.feature.group" version="1.5.1.201909181823"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<repository location="http://download.eclipse.org/nebula/releases/latest"/>
<unit id="org.eclipse.nebula.widgets.xviewer.feature.feature.group" version="1.1.0.202011020719"/>
</location>
</locations>
<targetJRE path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<launcherArgs>

View File

@ -140,7 +140,8 @@ public class WaveformView implements IWaveformView {
public void mouseDown(MouseEvent e) {
if (e.button == 1) {
Entry<Integer, TrackEntry> entry = trackVerticalOffset.floorEntry(e.y);
entry.getValue().selected=true;
if(entry!=null)
entry.getValue().selected=true;
} else if (e.button == 3) {
Menu topMenu= top.getMenu();
if(topMenu!=null) topMenu.setVisible(true);
@ -163,8 +164,8 @@ public class WaveformView implements IWaveformView {
} else {
setSelection(new StructuredSelection(entry.getValue()), (e.stateMask & SWT.CTRL) !=0 , false);
}
lastClickedEntry = entry.getValue();
}
lastClickedEntry = entry.getValue();
}
}
};
@ -191,7 +192,7 @@ public class WaveformView implements IWaveformView {
down=false;
if(start==null) return;
if((e.stateMask&SWT.MODIFIER_MASK&~SWT.SHIFT)!=0) return; //don't react on modifier except shift
if(!start.equals(end)){
if(e.button == 1 && Math.abs(e.x-start.x)>3){
asyncUpdate(e.widget);
long startTime = waveformCanvas.getTimeForOffset(start.x);
long endTime = waveformCanvas.getTimeForOffset(end.x);
@ -287,9 +288,9 @@ public class WaveformView implements IWaveformView {
case SWT.MouseDown:
start=new Point(e.x, e.y);
end=new Point(e.x, e.y);
down=true;
if((e.stateMask&SWT.MODIFIER_MASK)!=0) return; //don't react on modifier
if (e.button == 1) {
down=true;
initialSelected = waveformCanvas.getElementsAt(start);
} else if (e.button == 3) {
Menu topMenu= top.getMenu();
@ -335,15 +336,19 @@ public class WaveformView implements IWaveformView {
SashForm topSash = new SashForm(top, SWT.SMOOTH);
topSash.setBackground(topSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
Composite composite = new Composite(topSash, SWT.NONE);
composite.setLayout(new FillLayout(SWT.HORIZONTAL));
Composite namePane = new Composite(topSash, SWT.NONE);
Composite rightPane = new Composite(topSash, SWT.NONE);
rightPane.setLayout(new FillLayout(SWT.HORIZONTAL));
waveformCanvas = new WaveformCanvas(topSash, SWT.NONE);
SashForm rightSash = new SashForm(rightPane, SWT.SMOOTH);
rightSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
SashForm leftSash = new SashForm(composite, SWT.SMOOTH);
leftSash.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
Composite valuePane = new Composite(rightSash, SWT.NONE);
waveformCanvas = new WaveformCanvas(rightSash, SWT.NONE);
Composite namePane = createTextPane(leftSash, "Name");
// create the name pane
createTextPane(namePane, "Name");
namePaneHeader= namePane.getChildren()[0];
namePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
@ -379,7 +384,8 @@ public class WaveformView implements IWaveformView {
nameList.addMouseListener(nameValueMouseListener);
nameListScrolled.setContent(nameList);
Composite valuePane = createTextPane(leftSash, "Value");
createTextPane(valuePane, "Value");
valuePane.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
valueListScrolled = new ScrolledComposite(valuePane, SWT.H_SCROLL | SWT.V_SCROLL);
valueListScrolled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
@ -444,8 +450,8 @@ public class WaveformView implements IWaveformView {
valueListScrolled.setOrigin(valueListScrolled.getOrigin().x, y);
}
});
topSash.setWeights(new int[] { 30, 70 });
leftSash.setWeights(new int[] { 75, 25 });
topSash.setWeights(new int[] { 25, 75 });
rightSash.setWeights(new int[] { 10, 90 });
createStreamDragSource(nameList);
createStreamDragSource(valueList);
@ -458,8 +464,7 @@ public class WaveformView implements IWaveformView {
toolTipHandler.activateHoverHelp(waveformCanvas);
}
private Composite createTextPane(SashForm leftSash, String text) {
Composite namePane = new Composite(leftSash, SWT.NONE);
private void createTextPane(Composite namePane, String text) {
GridLayout gl_namePane = new GridLayout(1, false);
gl_namePane.verticalSpacing = 0;
gl_namePane.marginWidth = 0;
@ -479,7 +484,6 @@ public class WaveformView implements IWaveformView {
GridData gd_nameSep = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_nameSep.heightHint = 2;
nameSep.setLayoutData(gd_nameSep);
return namePane;
}
@Override
@ -680,15 +684,13 @@ public class WaveformView implements IWaveformView {
*/
@Override
public ISelection getSelection() {
ArrayList<Object> sel = new ArrayList<>();
if (currentTxSelection != null) {
ArrayList<Object> sel = new ArrayList<>();
sel.add(currentTxSelection);
sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList()));
return new StructuredSelection(sel.toArray());
} else if (currentWaveformSelection.size()>0) {
return new StructuredSelection(currentWaveformSelection.toArray());
} else
return new StructuredSelection();
}
// sel.addAll(currentWaveformSelection.stream().map(e -> e.waveform).collect(Collectors.toList()));
sel.addAll(currentWaveformSelection);
return new StructuredSelection(sel.toArray());
}
/* (non-Javadoc)

View File

@ -1,13 +1,13 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.swt;
import java.io.FileInputStream;

View File

@ -1,2 +1,3 @@
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false

View File

@ -11,7 +11,8 @@
<children xsi:type="basic:Part" xmi:id="__VNlAIytEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.dialog.aboutscviewer" toBeRendered="false" visible="false" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.parts.AboutDialog" label="About SCViewer" bindingContexts="_95Pfu3NmEeWBq8z1Dv39LA"/>
<mainMenu xmi:id="_95PfyXNmEeWBq8z1Dv39LA" elementId="menu:org.eclipse.ui.main.menu">
<children xsi:type="menu:Menu" xmi:id="_95QGwHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.file" label="File">
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_igsK0BkREeudD5MqrWoETQ" elementId="" label="Open Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" mnemonics="M1+O" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_VJG3YHgvEeWwZ-9vrAR2UQ" elementId="" label="Re-load Database" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" mnemonics="M1+R" command="_srACsBkREeudD5MqrWoETQ"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_e7MOYJedEeW09eyIbHsdvg" elementId="" label="Load active tab settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
<parameters xmi:id="_4vtYgJehEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.30" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
</children>
@ -53,12 +54,14 @@
<children xsi:type="menu:HandledMenuItem" xmi:id="_JTXBgYl_EeWxJ_wPkM6yGQ" elementId="" label="Preferences" command="_AxH6sIl_EeWxJ_wPkM6yGQ"/>
</children>
<children xsi:type="menu:Menu" xmi:id="_95QGxHNmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.menu.help" label="Help">
<children xsi:type="menu:HandledMenuItem" xmi:id="_UQRi0B07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handledmenuitem.checkforupdate" visible="false" label="Check for Update" enabled="false" command="_-9ED4B06EeuiP60JNw0iiA"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_95QGxXNmEeWBq8z1Dv39LA" label="About" command="_95PfxnNmEeWBq8z1Dv39LA"/>
</children>
</mainMenu>
<trimBars xmi:id="_95QGy3NmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.main.toolbar">
<children xsi:type="menu:ToolBar" xmi:id="_95QGzHNmEeWBq8z1Dv39LA" elementId="toolbar:org.eclipse.ui.main.toolbar">
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGzXNmEeWBq8z1Dv39LA" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" tooltip="Open new database" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_ZSajwBkZEeudD5MqrWoETQ" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_database.png" tooltip="Open new database" command="_95PfwHNmEeWBq8z1Dv39LA"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_95QGzXNmEeWBq8z1Dv39LA" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/database_refresh.png" tooltip="Re-load database" command="_srACsBkREeudD5MqrWoETQ"/>
<children xsi:type="menu:HandledToolItem" xmi:id="_o9UBUJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handledtoolitem.loadsettings" label="Load settings" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/folder_page.png" command="_7-AIMJebEeW09eyIbHsdvg">
<parameters xmi:id="_tQZAEJeiEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.parameter.32" name="com.minres.scviewer.e4.application.commandparameter.loadStore" value="load"/>
</children>
@ -133,6 +136,9 @@
<handlers xmi:id="_V4EscIuGEeWid7xO48ZBXw" elementId="com.minres.scviewer.e4.application.handler.setreleationtype" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SetRelationTypeHandler" command="_E9lUgIt2EeWid7xO48ZBXw"/>
<handlers xmi:id="__99WoJebEeW09eyIbHsdvg" elementId="com.minres.scviewer.e4.application.handler.loadStoreSettings" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.LoadStoreSettingsHandler" command="_7-AIMJebEeW09eyIbHsdvg"/>
<handlers xmi:id="_x4pSEGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.handler.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.EnableHover" command="_uyeyYGtTEeqmlpoaaMHoiw"/>
<handlers xmi:id="_h3jU8BkWEeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.handler.reloadCommand" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.ReloadHandler" command="_srACsBkREeudD5MqrWoETQ"/>
<handlers xmi:id="_gn_boBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.txSearch" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler" command="_XDxTYBlEEeuiP60JNw0iiA"/>
<handlers xmi:id="_CCEtAB07EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handler.update" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.UpdateHandler" command="_-9ED4B06EeuiP60JNw0iiA"/>
<bindingTables xmi:id="_95PfvnNmEeWBq8z1Dv39LA" bindingContext="_95PfuXNmEeWBq8z1Dv39LA">
<bindings xmi:id="_95Pfv3NmEeWBq8z1Dv39LA" elementId="com.minres.scviewer.e4.application.keybinding.quit" keySequence="M1+Q" command="_95PfvHNmEeWBq8z1Dv39LA">
<tags>type:user</tags>
@ -197,6 +203,10 @@
<children xsi:type="menu:HandledMenuItem" xmi:id="_Vj4jUHXIEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.remove" label="Remove" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/cross.png" tooltip="Remove stream/waveform from list" command="_WUZ2wHXHEeWwZ-9vrAR2UQ">
<visibleWhen xsi:type="ui:CoreExpression" xmi:id="_f6MH0HsCEeWVM_sKoXvptg" coreExpressionId="com.minres.scviewer.e4.application.oneWaveSeleted"/>
</children>
<children xsi:type="menu:MenuSeparator" xmi:id="_KSB5EBmuEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.menuseparator.0"/>
<children xsi:type="menu:HandledMenuItem" xmi:id="_HOLGgBmuEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handledmenuitem.search" label="Search Tx..." iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/find.png" command="_XDxTYBlEEeuiP60JNw0iiA">
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_HOLGgRmuEeuiP60JNw0iiA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler"/>
</children>
</menus>
<menus xsi:type="menu:PopupMenu" xmi:id="_CxJvAHXGEeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.popupmenu.wavecontext" label="Wave Menu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_7HrlwHXREeWwZ-9vrAR2UQ" elementId="com.minres.scviewer.e4.application.handledmenuitem.moveup" label="Move up" iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/up_blue.png" command="_N_sOkHXHEeWwZ-9vrAR2UQ">
@ -223,6 +233,9 @@
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_psvR0M1gEei6rfTGo88R-w" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.WaveformPopupMenuContribution"/>
<children xsi:type="menu:DynamicMenuContribution" xmi:id="_IQZZQM3hEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.dynamicmenucontribution.0" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.elements.WaveformPopupMenuContribution"/>
</children>
<children xsi:type="menu:HandledMenuItem" xmi:id="_NnJA4BlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.handledmenuitem.search" label="Search Tx..." iconURI="platform:/plugin/com.minres.scviewer.e4.application/icons/find.png" command="_XDxTYBlEEeuiP60JNw0iiA">
<visibleWhen xsi:type="ui:ImperativeExpression" xmi:id="_Se1voBlEEeuiP60JNw0iiA" contributionURI="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.handlers.SearchHandler"/>
</children>
</menus>
</descriptors>
<commands xmi:id="_95PfvHNmEeWBq8z1Dv39LA" elementId="org.eclipse.ui.file.exit" commandName="Quit Command"/>
@ -264,6 +277,9 @@
<parameters xmi:id="_4C_asc3ZEei6rfTGo88R-w" elementId="com.minres.scviewer.e4.application.commandparameter.changevaluedisplay" name="Type" optional="false"/>
</commands>
<commands xmi:id="_uyeyYGtTEeqmlpoaaMHoiw" elementId="com.minres.scviewer.e4.application.command.enablehover" commandName="Enable hover" description="Enable hover window in waveform"/>
<commands xmi:id="_srACsBkREeudD5MqrWoETQ" elementId="com.minres.scviewer.e4.application.reload" commandName="Reload Command"/>
<commands xmi:id="_XDxTYBlEEeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.txSearch" commandName="Search Command"/>
<commands xmi:id="_-9ED4B06EeuiP60JNw0iiA" elementId="com.minres.scviewer.e4.application.command.update" commandName="Update"/>
<addons xmi:id="_95PfsnNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.core.commands.service" contributionURI="bundleclass://org.eclipse.e4.core.commands/org.eclipse.e4.core.commands.CommandServiceAddon"/>
<addons xmi:id="_95Pfs3NmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.contexts.service" contributionURI="bundleclass://org.eclipse.e4.ui.services/org.eclipse.e4.ui.services.ContextServiceAddon"/>
<addons xmi:id="_95PftHNmEeWBq8z1Dv39LA" elementId="org.eclipse.e4.ui.bindings.service" contributionURI="bundleclass://org.eclipse.e4.ui.bindings/org.eclipse.e4.ui.bindings.BindingServiceAddon"/>

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
Bundle-Version: 2.8.0.qualifier
Bundle-Version: 2.9.3.qualifier
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.11.1",
@ -29,7 +29,13 @@ Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.e4.core.di.extensions,
org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0",
org.eclipse.core.resources;bundle-version="3.13.0",
javax.annotation;bundle-version="1.2.0"
javax.annotation;bundle-version="1.2.0",
org.eclipse.core.databinding,
org.eclipse.jface.databinding,
org.eclipse.equinox.p2.core;bundle-version="2.6.300",
org.eclipse.equinox.p2.engine;bundle-version="2.6.600",
org.eclipse.equinox.p2.operations;bundle-version="2.5.700",
org.eclipse.equinox.p2.metadata.repository;bundle-version="1.3.400"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.minres.scviewer.database,
javax.inject;version="1.0.0"

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

View File

@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>com.minres.scviewer.e4.application</artifactId>
<version>2.8.0-SNAPSHOT</version>
<version>2.9.3-SNAPSHOT</version>
<parent>
<groupId>com.minres.scviewer</groupId>
<artifactId>com.minres.scviewer.parent</artifactId>

View File

@ -10,14 +10,11 @@
*******************************************************************************/
package com.minres.scviewer.e4.application;
import java.io.File;
import java.io.IOException;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.model.application.MApplication;
@ -64,9 +61,11 @@ public class E4LifeCycle {
* @param eventBroker the event broker
*/
@PostContextCreate
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker) {
void postContextCreate(IApplicationContext appContext, final IEventBroker eventBroker,
final IEclipseContext workbenchContext) {
final String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
Options opt = new Options(args, 0, 1);
final Options opt = new Options(args, 0, Integer.MAX_VALUE);
opt.getSet()
.addOption("clearPersistedState", Multiplicity.ZERO_OR_ONE)
.addOption("c", Separator.BLANK, Multiplicity.ZERO_OR_ONE);
@ -77,22 +76,14 @@ public class E4LifeCycle {
final String confFile =opt.getSet().isSet("c")?opt.getSet().getOption("c").getResultValue(0):"";
// react on the first view being created, at that time the UI is available
eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
@Override
public void handleEvent(Event event) {
MPart part = (MPart) event.getProperty("ChangedElement"); //$NON-NLS-1$
if(part!=null){
IEclipseContext ctx = part.getContext();
OpenViewHandler openViewHandler= new OpenViewHandler();
if(confFile.length()>0) openViewHandler.setConfigFile(confFile);
ContextInjectionFactory.inject(openViewHandler, ctx);
eventBroker.unsubscribe(this);
for(String name:opt.getSet().getData()){
openViewHandler.openViewForFile(name);
}
}
}
});
// eventBroker.subscribe(UIEvents.UILifeCycle.ACTIVATE, new EventHandler() {
// @Override
// public void handleEvent(Event event) {
// MPart part = (MPart) event.getProperty("ChangedElement"); //$NON-NLS-1$
// if(part!=null){
// }
// }
// });
eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
@Override
public void handleEvent(Event event) {
@ -101,9 +92,20 @@ public class E4LifeCycle {
boolean isLocked = instanceLocation.isLocked();
if(isLocked)
instanceLocation.release();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) { }
if(opt.getSet().getData().size()>0) {
MApplication app= workbenchContext.get(MApplication.class);
EModelService modelService = workbenchContext.get(EModelService.class);
EPartService partService= workbenchContext.get(EPartService.class);
MPart part = partService .createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
part.setLabel(opt.getSet().getData().get(0));
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
partStack.getChildren().add(part);
partService.showPart(part, PartState.CREATE);
partService.showPart(part, PartState.ACTIVATE);
IEclipseContext ctx = part.getContext();
ctx.modify("input", opt.getSet().getData());
ctx.modify("config", confFile); //$NON-NLS-1$
}
}
});
@ -135,70 +137,4 @@ public class E4LifeCycle {
@ProcessRemovals
void processRemovals(IEclipseContext workbenchContext) {
}
/**
* Join.
*
* @param tokens the tokens
* @return the string
*/
String join(String[] tokens){
StringBuilder sb = new StringBuilder();
boolean first=true;
for(String token:tokens){
if(!first) sb.append(","); //$NON-NLS-1$
sb.append(token);
first=false;
}
return sb.toString();
}
/**
* The Class OpenViewHandler.
*/
private class OpenViewHandler {
/** The app. */
@Inject MApplication app;
/** The model service. */
@Inject EModelService modelService;
/** The part service. */
@Inject EPartService partService;
String confFile="";
/**
* Open view for file.
*
* @param name the name
*/
public void openViewForFile(String name){
File file = new File(getFirstFileName(name));
if(!file.exists())
return;
MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$
part.setLabel(file.getName());
MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$
partStack.getChildren().add(part);
partService.showPart(part, PartState.ACTIVATE);
IEclipseContext ctx=part.getContext();
ctx.modify("input", name); //$NON-NLS-1$
//ctx.declareModifiable("input"); //$NON-NLS-1$
ctx.modify("config", confFile); //$NON-NLS-1$
//ctx.declareModifiable("config"); //$NON-NLS-1$
}
private String getFirstFileName(String name) {
if(name.contains(",")) {
String[] tokens = name.split(",");
return tokens[0];
} else
return name;
}
public void setConfigFile(String confFile) {
this.confFile=confFile;
}
}
}

View File

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.CanExecute;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.swt.widgets.Shell;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class ReloadHandler {
@CanExecute
public boolean canExecute(EPartService partService) {
MPart part = partService.getActivePart();
if(part==null) return false;
return (part.getObject() instanceof WaveformViewer);
}
@Execute
public void execute(Shell shell, MApplication app, EModelService modelService,
EPartService partService){
MPart part = partService.getActivePart();
Object obj = part.getObject();
if(part!=null && (obj instanceof WaveformViewer)) {
((WaveformViewer)obj).reloadDatabase();
}
}
}

View File

@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.e4.core.di.annotations.Evaluate;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.widgets.Shell;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
public class SearchHandler {
@Evaluate
public boolean evaluate(MPart activePart) {
Object obj = activePart.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
ISelection sel = wfv.getSelection();
if(sel instanceof StructuredSelection) {
Object[] elem = ((StructuredSelection)sel).toArray();
if(elem.length ==0) return false;
TrackEntry e = findTrackEntry(elem);
return e!=null && e.isStream();
}
}
return false;
}
@Execute
public void execute(Shell shell, MPart activePart){
Object obj = activePart.getObject();
if(obj instanceof WaveformViewer){
WaveformViewer wfv = (WaveformViewer)obj;
wfv.showSearch();
// ISelection sel = wfv.getSelection();
// if(sel instanceof StructuredSelection) {
// TrackEntry e = findTrackEntry(((StructuredSelection)sel).toArray());
// SearchTxDialog dlg = new SearchTxDialog(shell, e.getStream());
// if (dlg.open() != Window.OK) return;
// wfv.search(dlg.getPropName(), dlg.getPropType(), dlg.getPropValue());
// }
}
}
private TrackEntry findTrackEntry(Object[] elems) {
for(Object o: elems)
if(o instanceof TrackEntry)
return (TrackEntry)o;
return null;
}
}

View File

@ -0,0 +1,24 @@
package com.minres.scviewer.e4.application.handlers;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.di.UISynchronize;
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.operations.ProvisioningSession;
import org.eclipse.equinox.p2.operations.UpdateOperation;
import org.eclipse.jface.dialogs.MessageDialog;
public class UpdateHandler {
@Execute
public void execute(IProvisioningAgent agent, UISynchronize synchronize, IWorkbench workbench) {
ProvisioningSession session = new ProvisioningSession(agent);
UpdateOperation operation = new UpdateOperation(session);
IStatus status = operation.resolveModal(null);
if(status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
MessageDialog.openInformation(null, "Information", "Nothing to update");
}
}
}

View File

@ -0,0 +1,181 @@
package com.minres.scviewer.e4.application.parts;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.ResourceManager;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxStream;
public class SearchTxDialog extends TitleAreaDialog {
private ComboViewer propNameComboViewer = null;
private Text propValueText = null;
private String propName="";
private DataType propType=null;
private String propValue="";
private ITxStream<? extends ITxEvent> stream;
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
/**
* Create the dialog.
* @param parentShell
* @param iTxStream
*/
public SearchTxDialog(Shell parentShell, ITxStream<? extends ITxEvent> iTxStream) {
super(parentShell);
setShellStyle(SWT.BORDER | SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL);
stream=iTxStream;
new Thread() {
public void run() {
stream.getEvents().values().parallelStream().forEach(evtLst -> {
evtLst.forEach(evt -> {
evt.getTransaction().getAttributes().stream().forEach(attr -> {
propNames.put(attr.getName(), attr.getDataType());
});
});
});
parentShell.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (propNameComboViewer!=null) {
propNameComboViewer.setInput(getEntries());
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
}
}
});
}
}.run();
}
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
setMessage("Specify property name and value to search for");
setTitleImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/Minres_logo.png"));
setTitle("Search Tx in stream");
final Composite area = (Composite) super.createDialogArea(parent);
final GridLayout gridLayout = (GridLayout) area.getLayout();
gridLayout.marginTop = 10;
gridLayout.marginBottom = 10;
final Composite container = new Composite(area, SWT.NONE);
final GridLayout gl_container = new GridLayout(2, false);
gl_container.horizontalSpacing = 2;
container.setLayout(gl_container);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
final Label header = new Label(container, SWT.CENTER | SWT.WRAP);
GridData gd_header = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
gd_header.verticalIndent = 10;
header.setLayoutData(gd_header);
header.setText("Stream: "+stream.getName());
final Label propNameLabel = new Label(container, SWT.NONE);
propNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
propNameLabel.setText("Property Name:");
propNameComboViewer = new ComboViewer(container, SWT.NONE);
propNameComboViewer.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
propNameComboViewer.setContentProvider(ArrayContentProvider.getInstance());
propNameComboViewer.setLabelProvider(new LabelProvider() {
@SuppressWarnings("unchecked")
@Override
public String getText(Object element) {
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)element;
return e.getKey()+" ("+e.getValue().name()+")";
}
});
propNameComboViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@SuppressWarnings("unchecked")
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = event.getStructuredSelection();
Map.Entry<String, DataType> e = (Map.Entry<String, DataType>)sel.getFirstElement();
propName=e.getKey();
propType=e.getValue();
}
});
propNameComboViewer.setInput(getEntries());
propNameComboViewer.setSelection(new StructuredSelection(propNameComboViewer.getElementAt(0)));
final Label propValueLabel = new Label(container, SWT.NONE);
propValueLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
propValueLabel.setText("Property Value:");
propValueText = new Text(container, SWT.BORDER);
propValueText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
return area;
}
private List<Entry<String,DataType>> getEntries() {
return propNames.entrySet().stream().sorted((e1,e2)->e1.getKey().compareTo(e2.getKey())).collect(Collectors.toList());
}
/**
* Create contents of the button bar.
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
final Button okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
okButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/tick.png"));
final Button cancelButton = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
cancelButton.setImage(ResourceManager.getPluginImage("com.minres.scviewer.e4.application", "icons/cross.png"));
}
protected void constrainShellSize() {
super.constrainShellSize();
getShell().setMinimumSize(getShell().computeSize(-1, -1));
}
@Override
protected void okPressed() {
propValue=propValueText.getText();
super.okPressed();
}
public String getPropName() {
return propName;
}
public DataType getPropType() {
return propType;
}
public String getPropValue() {
return propValue;
}
}

View File

@ -10,15 +10,10 @@
*******************************************************************************/
package com.minres.scviewer.e4.application.parts;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.Vector;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
@ -34,23 +29,16 @@ import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeViewerListener;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TreeExpansionEvent;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.TreeViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
@ -63,15 +51,19 @@ import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNode;
import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNodeType;
import com.minres.scviewer.e4.application.parts.txTableTree.TxAttributeFilter;
import com.minres.scviewer.e4.application.parts.txTableTree.TxAttributeViewerSorter;
import com.minres.scviewer.e4.application.provider.TxPropertiesLabelProvider;
/**
@ -113,7 +105,8 @@ public class TransactionDetails {
/** The waveform viewer part. */
private WaveformViewer waveformViewerPart;
private Composite top;
/**
* Creates the composite.
*
@ -123,9 +116,10 @@ public class TransactionDetails {
public void createComposite(final Composite parent, @Optional WaveformViewer waveformViewerPart) {
this.waveformViewerPart=waveformViewerPart;
parent.setLayout(new GridLayout(1, false));
top = new Composite(parent, SWT.NONE);
top.setLayout(new GridLayout(1, false));
nameFilter = new Text(parent, SWT.BORDER);
nameFilter = new Text(top, SWT.BORDER);
nameFilter.setMessage(Messages.TransactionDetails_0);
nameFilter.addModifyListener(new ModifyListener() {
@Override
@ -141,8 +135,18 @@ public class TransactionDetails {
attributeFilter = new TxAttributeFilter();
viewSorter = new TxAttributeViewerSorter();
treeViewer = new TreeViewer(parent);
treeViewer.setContentProvider(new TransactionTreeContentProvider());
treeViewer = new TreeViewer(top);
treeViewer.setContentProvider(new AbstractTransactionTreeContentProvider(waveformViewerPart) {
@Override
public Object[] getElements(Object element) {
return new Object[]{
new TransactionTreeNode((ITx)element, TransactionTreeNodeType.PROPS),
new TransactionTreeNode((ITx)element, TransactionTreeNodeType.ATTRS),
new TransactionTreeNode((ITx)element, TransactionTreeNodeType.IN_REL),
new TransactionTreeNode((ITx)element, TransactionTreeNodeType.OUT_REL)
};
}
});
treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
treeViewer.addFilter(attributeFilter);
@ -168,7 +172,7 @@ public class TransactionDetails {
col1 = new TreeViewerColumn(treeViewer, SWT.NONE);
col1.getColumn().setText(Messages.TransactionDetails_1);
col1.getColumn().setResizable(true);
col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.NAME)));
col1.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.NAME)));
col1.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_FIRST);
@ -179,7 +183,7 @@ public class TransactionDetails {
col2 = new TreeViewerColumn(treeViewer, SWT.NONE);
col2.getColumn().setText(Messages.TransactionDetails_2);
col2.getColumn().setResizable(true);
col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.TYPE)));
col2.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.TYPE)));
col2.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
@ -190,7 +194,7 @@ public class TransactionDetails {
col3 = new TreeViewerColumn(treeViewer, SWT.NONE);
col3.getColumn().setText(Messages.TransactionDetails_3);
col3.getColumn().setResizable(true);
col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(AttributeLabelProvider.VALUE)));
col3.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewerPart, AttributeLabelProvider.VALUE)));
col3.getColumn().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
((TxAttributeViewerSorter) treeViewer.getComparator()).doSort(COLUMN_SECOND);
@ -225,10 +229,10 @@ public class TransactionDetails {
}
});
parent.addControlListener(new ControlAdapter() {
top.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
Tree table = treeViewer.getTree();
Rectangle area = parent.getClientArea();
Rectangle area = top.getClientArea();
Point preferredSize = table.computeSize(SWT.DEFAULT, SWT.DEFAULT);
int width = area.width - 2*table.getBorderWidth();
if (preferredSize.y > area.height + table.getHeaderHeight()) {
@ -259,6 +263,9 @@ public class TransactionDetails {
});
}
public Control getControl() {
return top;
}
/**
* Sets the focus.
*/
@ -327,15 +334,15 @@ public class TransactionDetails {
if(paths==null)
treeViewer.setAutoExpandLevel(2);
else {
TransactionTreeContentProvider cp = (TransactionTreeContentProvider) treeViewer.getContentProvider();
AbstractTransactionTreeContentProvider cp = (AbstractTransactionTreeContentProvider) treeViewer.getContentProvider();
Object[] elems = cp.getElements(treeViewer.getInput());
for(TreePath path: paths) {
TreeNode firstSeg = (TreeNode)path.getFirstSegment();
TransactionTreeNode firstSeg = (TransactionTreeNode)path.getFirstSegment();
for(Object elem : elems) {
if(((TreeNode)elem).type == firstSeg.type) {
if(((TransactionTreeNode)elem).type == firstSeg.type) {
treeViewer.setExpandedState(elem, true);
if(firstSeg.type==TransactionDetails.Type.ATTRS && path.getSegmentCount()>1)
expandSubNodes(path, 1, (TreeNode)elem);
if(firstSeg.type==TransactionTreeNodeType.ATTRS && path.getSegmentCount()>1)
expandSubNodes(path, 1, (TransactionTreeNode)elem);
break;
}
}
@ -343,14 +350,14 @@ public class TransactionDetails {
}
}
private void expandSubNodes(TreePath path, int level, TreeNode elem) {
private void expandSubNodes(TreePath path, int level, TransactionTreeNode elem) {
if(level==path.getSegmentCount()) return;
TransactionTreeContentProvider cp = (TransactionTreeContentProvider) treeViewer.getContentProvider();
AbstractTransactionTreeContentProvider cp = (AbstractTransactionTreeContentProvider) treeViewer.getContentProvider();
Object[] childs = cp.getChildren(elem);
TreeNode nextSeg = (TreeNode)path.getSegment(level);
TransactionTreeNode nextSeg = (TransactionTreeNode)path.getSegment(level);
for(Object child:childs) {
if(child instanceof TreeNode) {
TreeNode node = (TreeNode) child;
if(child instanceof TransactionTreeNode) {
TransactionTreeNode node = (TransactionTreeNode) child;
if(nextSeg.toString().equals(node.toString())) {
treeViewer.setExpandedState(node, true);
expandSubNodes(path, level+1, node);
@ -392,7 +399,7 @@ public class TransactionDetails {
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
// only react if selection is actually from the WaveformViewer and nothing else
MPart part = partService.getActivePart();
if( part == null || ! (part.getObject() instanceof WaveformViewer ) )
if( part == null || ! (part.getObject() instanceof WaveformViewer ) || part.getObject() != waveformViewerPart)
return;
if(treeViewer!=null && selection!=null && !treeViewer.getTree().isDisposed()){
if( selection instanceof IStructuredSelection && !selection.isEmpty()) {
@ -400,406 +407,5 @@ public class TransactionDetails {
}
}
}
/**
* Time to string.
*
* @param time the time
* @return the string
*/
String timeToString(Long time){
return waveformViewerPart.getScaledTime(time);
}
/**
* Tx to string.
*
* @param tx the tx
* @return the string
*/
String txToString(ITx tx){
StringBuilder sb = new StringBuilder();
sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())); //$NON-NLS-1$ //$NON-NLS-2$
sb.append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return sb.toString();
}
/**
* The Class TxAttributeViewerSorter.
*/
class TxAttributeViewerSorter extends ViewerComparator {
/** The Constant ASCENDING. */
private static final int ASCENDING = 0;
/** The Constant DESCENDING. */
private static final int DESCENDING = 1;
/** The column. */
private int column;
/** The direction. */
private int direction;
/**
* Does the sort. If it's a different column from the previous sort, do an
* ascending sort. If it's the same column as the last sort, toggle the sort
* direction.
*
* @param column the column
*/
public void doSort(int column) {
if (column == this.column) {
// Same column as last sort; toggle the direction
direction = 1 - direction;
} else {
// New column; do an ascending sort
this.column = column;
direction = ASCENDING;
}
}
/**
* Compares the object for sorting.
*
* @param viewer the viewer
* @param e1 the e1
* @param e2 the e2
* @return the int
*/
public int compare(Viewer viewer, Object e1, Object e2) {
int rc = 0;
if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
ITxAttribute p1 = (ITxAttribute) e1;
ITxAttribute p2 = (ITxAttribute) e2;
// Determine which column and do the appropriate sort
switch (column) {
case COLUMN_FIRST:
rc = getComparator().compare(p1.getName(), p2.getName());
break;
case COLUMN_SECOND:
rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
break;
case COLUMN_THIRD:
rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString());
break;
}
// If descending order, flip the direction
if (direction == DESCENDING) rc = -rc;
}
return rc;
}
}
/**
* The Class TxAttributeFilter.
*/
class TxAttributeFilter extends ViewerFilter {
/** The search string. */
private String searchString;
/**
* Sets the search text.
*
* @param s the new search text
*/
public void setSearchText(String s) {
this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
if(element instanceof TreeNode) {
return true;
}
if(element instanceof ITxAttribute){
try {
return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase()));
} catch (PatternSyntaxException e) {
return true;
}
}
if(element instanceof Object[]) {
try {
return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());
} catch (PatternSyntaxException e) {
return true;
}
}
return false;
}
}
/**
* The Enum Type.
*/
enum Type {
PROPS, /** The props. */
ATTRS, /** The attrs. */
IN_REL, /** The in rel. */
OUT_REL,/** The out rel. */
HIER
}
/**
* The Class TreeNode.
*/
class TreeNode implements Comparable<TreeNode>{
/** The type. */
public Type type;
/** The element. */
public ITx element;
private String hier_path;
/**
* Instantiates a new tree node.
*
* @param element the element
* @param type the type
*/
public TreeNode(ITx element, Type type){
this.element=element;
this.type=type;
this.hier_path="";
}
public TreeNode(ITx element, String path){
this.element=element;
this.type=Type.HIER;
this.hier_path=path;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString(){
switch(type){
case PROPS: return Messages.TransactionDetails_10;
case ATTRS: return Messages.TransactionDetails_11;
case IN_REL: return Messages.TransactionDetails_12;
case OUT_REL: return Messages.TransactionDetails_13;
case HIER:{
String[] tokens = hier_path.split("\\.");
return tokens[tokens.length-1];
}
}
return ""; //$NON-NLS-1$
}
public Object[] getAttributeListForHier() {
if(childs==null) {
Map<String, Object> res = element.getAttributes().stream()
.filter(txAttr -> txAttr.getName().startsWith(hier_path))
.map(txAttr -> {
String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', "");
String[] tokens = target.split("\\.");
if(tokens.length==1)
return new AbstractMap.SimpleEntry<>(tokens[0], txAttr);
else
return new AbstractMap.SimpleEntry<>(tokens[0], new TreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0]));
})
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first));
childs = new TreeMap<String, Object>(res).values().toArray();
}
return childs;
}
private Object[] childs=null;
@Override
public boolean equals(Object o) {
if(o instanceof TreeNode) {
TreeNode t = (TreeNode) o;
return type==t.type && hier_path.equals(t.hier_path);
}
return false;
}
@Override
public int compareTo(TreeNode o) {
int res1 = type.compareTo(o.type);
if(res1==0) {
return hier_path.compareTo(o.hier_path);
} else
return res1;
}
}
/**
* The Class TransactionTreeContentProvider.
*/
class TransactionTreeContentProvider implements ITreeContentProvider {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
public void dispose() { }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object element) {
return new Object[]{
new TreeNode((ITx)element, Type.PROPS),
new TreeNode((ITx)element, Type.ATTRS),
new TreeNode((ITx)element, Type.IN_REL),
new TreeNode((ITx)element, Type.OUT_REL)
};
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object element) {
if(element instanceof TreeNode){
TreeNode propertyHolder=(TreeNode) element;
if(propertyHolder.type == Type.PROPS){
return new Object[][]{
{Messages.TransactionDetails_1, Messages.TransactionDetails_16, propertyHolder.element.getStream().getFullName()},
{Messages.TransactionDetails_2, Messages.TransactionDetails_16, propertyHolder.element.getGenerator().getName()},
{Messages.TransactionDetails_19, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getBeginTime())},
{Messages.TransactionDetails_21, Messages.TransactionDetails_20, timeToString(propertyHolder.element.getEndTime())}
};
}else if(propertyHolder.type == Type.ATTRS || propertyHolder.type == Type.HIER)
return propertyHolder.getAttributeListForHier();
else if(propertyHolder.type == Type.IN_REL){
Vector<Object[] > res = new Vector<>();
for(ITxRelation rel:propertyHolder.element.getIncomingRelations()){
res.add(new Object[]{
rel.getRelationType(),
rel.getSource().getGenerator().getName(),
rel.getSource()});
}
return res.toArray();
} else if(propertyHolder.type == Type.OUT_REL){
Vector<Object[] > res = new Vector<>();
for(ITxRelation rel:propertyHolder.element.getOutgoingRelations()){
res.add(new Object[]{
rel.getRelationType(),
rel.getTarget().getGenerator().getName(),
rel.getTarget()});
}
return res.toArray();
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
@Override
public Object getParent(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
public boolean hasChildren(Object element) {
return getChildren(element)!=null;
}
}
/**
* The Class AttributeLabelProvider.
*/
class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
/** The field. */
final int field;
/** The Constant NAME. */
public static final int NAME=0;
/** The Constant TYPE. */
public static final int TYPE=1;
/** The Constant VALUE. */
public static final int VALUE=2;
/**
* Instantiates a new attribute label provider.
*
* @param field the field
*/
public AttributeLabelProvider(int field) {
this.field=field;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
*/
@Override
public StyledString getStyledText(Object element) {
switch(field){
case NAME:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
String[] tokens = attribute.getName().split("\\.");
return new StyledString(tokens[tokens.length-1]);
}else if (element instanceof ITxRelation) {
return new StyledString(Messages.TransactionDetails_4);
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
} else
return new StyledString(element.toString());
case TYPE:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getDataType().toString());
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
}else
return new StyledString(""); //$NON-NLS-1$
default:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
String value = attribute.getValue().toString();
if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
try {
value += " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
} catch(NumberFormatException e) { }
}
return new StyledString(value);
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
Object o = elements[field];
if(o instanceof ITx) {
ITx tx = (ITx)o;
return new StyledString(txToString(tx)+" ("+tx.getStream().getFullName()+")");
} else
return new StyledString(o.toString());
} else if(element instanceof ITx){
return new StyledString(txToString((ITx) element));
}else
return new StyledString(""); //$NON-NLS-1$
}
}
}
}

View File

@ -0,0 +1,301 @@
package com.minres.scviewer.e4.application.parts;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import org.eclipse.core.databinding.observable.list.ObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
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.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxEvent;
import com.minres.scviewer.database.ITxEvent.Type;
import com.minres.scviewer.database.ITxStream;
import com.minres.scviewer.database.ui.TrackEntry;
import com.minres.scviewer.e4.application.parts.txTableTree.AbstractTransactionTreeContentProvider;
import com.minres.scviewer.e4.application.parts.txTableTree.AttributeLabelProvider;
import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNode;
import com.minres.scviewer.e4.application.parts.txTableTree.TransactionTreeNodeType;
import com.minres.scviewer.e4.application.parts.txTableTree.TxFilter;
public class TransactionList extends Composite {
public class AttributeNameBean {
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public DataType getType() {
return type;
}
public void setType(DataType type) {
this.type = type;
}
public AttributeNameBean(String name, DataType type) {
super();
this.name = name;
this.type = type;
}
String name;
DataType type;
}
private ComboViewer searchPropComboViewer = null;
private ComboViewer viewPropComboViewer = null;
private Text searchPropValue;
private TableViewer tableViewer = null;
private TableColumn valueColumn = null;
private AttributeLabelProvider valueLabelProvider = null;
private ITxStream<? extends ITxEvent> stream;
private ObservableList<AttributeNameBean> attrNames = new WritableList<AttributeNameBean>();
private List<ITx> eventList = new ArrayList<ITx>();
private List<ITx> emptyList = new ArrayList<ITx>();
TxFilter txFilter;
/**
* Create the composite.
* @param parent
* @param style
*/
public TransactionList(Composite parent, int style, WaveformViewer waveformViewer) {
super(parent, style);
setLayout(new GridLayout(5, false));
txFilter = new TxFilter();
Label lbl1 = new Label(this, SWT.NONE);
lbl1.setAlignment(SWT.RIGHT);
lbl1.setText("Property to match:");
lbl1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
searchPropComboViewer = new ComboViewer(this, SWT.NONE);
searchPropComboViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
AttributeNameBean entry = (AttributeNameBean) element;
return entry.getName()+" ["+entry.getType().toString()+"]";
}
});
searchPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
searchPropComboViewer.setInput(attrNames);
Combo searchPropCombo = searchPropComboViewer.getCombo();
searchPropCombo.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false, 1, 1));
searchPropCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
int idx = searchPropCombo.getSelectionIndex();
AttributeNameBean sel = attrNames.get(idx);
txFilter.setSearchProp(sel.getName(), sel.getType());
tableViewer.refresh();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
int idx = searchPropCombo.getSelectionIndex();
AttributeNameBean sel = attrNames.get(idx);
txFilter.setSearchProp(sel.getName(), sel.getType());
tableViewer.refresh();
}
});
searchPropValue = new Text(this, SWT.BORDER);
GridData gd_searchPropValue = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
gd_searchPropValue.minimumWidth = 50;
searchPropValue.setLayoutData(gd_searchPropValue);
searchPropValue.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
txFilter.setSearchValue(((Text) e.widget).getText());
tableViewer.refresh();
}
});
Label lbl2 = new Label(this, SWT.NONE);
lbl2.setAlignment(SWT.RIGHT);
lbl2.setText("Property to show:");
lbl2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
viewPropComboViewer = new ComboViewer(this, SWT.NONE);
viewPropComboViewer.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
AttributeNameBean entry = (AttributeNameBean) element;
return entry.getName()+" ["+entry.getType().toString()+"]";
}
});
viewPropComboViewer.setContentProvider(new ObservableListContentProvider<AttributeNameBean>());
viewPropComboViewer.setInput(attrNames);
Combo viewPropCombo = viewPropComboViewer.getCombo();
viewPropCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
viewPropCombo.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
int idx = viewPropCombo.getSelectionIndex();
valueLabelProvider.setShowProp(attrNames.get(idx).getName());
tableViewer.refresh(true);
}
@Override
public void widgetDefaultSelected(SelectionEvent e) { }
});
tableViewer = new TableViewer(this);
tableViewer.setContentProvider(new AbstractTransactionTreeContentProvider(waveformViewer) {
@SuppressWarnings("unchecked")
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof ArrayList<?>) {
return ((ArrayList<ITx>) inputElement).stream().map(tx-> new TransactionTreeNode(tx, TransactionTreeNodeType.TX)).collect(Collectors.toList()).toArray();
}
return new Object[0];
}
});
tableViewer.addFilter(txFilter);
tableViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
ISelection treeSelection = tableViewer.getSelection();
if(treeSelection instanceof IStructuredSelection) {
Object selected = ((IStructuredSelection)treeSelection).getFirstElement();
if(selected instanceof ITx){
waveformViewer.setSelection(new StructuredSelection(selected));
} else if(selected instanceof TransactionTreeNode && ((TransactionTreeNode)selected).type == TransactionTreeNodeType.TX) {
waveformViewer.setSelection(new StructuredSelection(((TransactionTreeNode)selected).element));
}
}
}
});
Table table = tableViewer.getTable();
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
TableViewerColumn nameColumnViewer = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn nameColumn = nameColumnViewer.getColumn();
nameColumn.setWidth(200);
nameColumn.setText("Tx ID");
nameColumn.setResizable(true);
nameColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.NAME)));
TableViewerColumn timeColumnViewer = new TableViewerColumn(tableViewer, SWT.NONE);
TableColumn timeColumn = timeColumnViewer.getColumn();
timeColumn.setAlignment(SWT.RIGHT);
timeColumn.setWidth(150);
timeColumn.setText("Start time");
timeColumn.setResizable(true);
timeColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.TX_TIME)));
TableViewerColumn valueColumnViewer = new TableViewerColumn(tableViewer, SWT.NONE);
valueColumn = valueColumnViewer.getColumn();
valueColumn.setWidth(150);
valueColumn.setText("Property Value");
valueColumn.setResizable(true);
valueLabelProvider= new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.VALUE);
valueColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(valueLabelProvider));
// Turn on the header and the lines
table.setHeaderVisible(true);
table.setLinesVisible(true);
new Label(this, SWT.NONE);
new Label(this, SWT.NONE);
new Label(this, SWT.NONE);
new Label(this, SWT.NONE);
new Label(this, SWT.NONE);
}
public void setInput(TrackEntry trackEntry) {
if(trackEntry==null || !trackEntry.isStream()) {
attrNames.clear();
tableViewer.setInput(emptyList);
} else {
stream=trackEntry.getStream();
tableViewer.setInput(emptyList);
new Thread() {
private ConcurrentHashMap<String, DataType> propNames=new ConcurrentHashMap<String, DataType>();
private List<AttributeNameBean> getEntries() {
return propNames.entrySet().stream()
.sorted((e1,e2)->e1.getKey().compareTo(e2.getKey()))
.map(e -> new AttributeNameBean(e.getKey(), e.getValue()))
.collect(Collectors.toList());
}
public void run() {
eventList = stream.getEvents().values().parallelStream()
.flatMap(List::stream)
.filter(evt -> evt.getType()==Type.BEGIN)
.map(evt-> {
ITx tx = evt.getTransaction();
for(ITxAttribute attr: tx.getAttributes()) {
propNames.put(attr.getName(), attr.getDataType());
}
return tx;
})
.sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime()))
.collect(Collectors.toList());
getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
tableViewer.setInput(eventList);
attrNames.clear();
attrNames.addAll(getEntries());
if(attrNames.size()>0)
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
if (searchPropComboViewer!=null) {
searchPropComboViewer.setInput(attrNames);
searchPropComboViewer.setSelection(new StructuredSelection(searchPropComboViewer.getElementAt(0)));
}
tableViewer.refresh(true);
}
});
}
}.run();
}
}
public void setSearchProps(String propName, DataType type, String propValue) {
for(int i=0; i<attrNames.size(); ++i) {
AttributeNameBean e = attrNames.get(i);
if(propName.equals(e.getName()) && type.equals(e.getType())) {
searchPropComboViewer.getCombo().select(i);
break;
}
}
searchPropValue.setText(propValue);
}
}

View File

@ -0,0 +1,84 @@
package com.minres.scviewer.e4.application.parts;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.ui.di.Focus;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.services.IServiceConstants;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import com.minres.scviewer.database.ui.TrackEntry;
public class TransactionListView {
private WaveformViewer waveformViewer;
private TransactionList transactionList;
/** The event broker. */
@Inject IEventBroker eventBroker;
/** The selection service. */
@Inject ESelectionService selectionService;
/**
* Create the composite.
* @param parent
* @param style
*/
/**
* Creates the composite.
*
* @param parent the parent
*/
@PostConstruct
public void createComposite(final Composite parent, @Optional WaveformViewer waveformViewer) {
this.waveformViewer=waveformViewer;
transactionList = new TransactionList(parent, SWT.BORDER, waveformViewer);
}
@Focus
public void setFocus() {
if(transactionList!=null)
transactionList.setFocus();
}
/**
* Sets the selection.
*
* @param selection the new selection
*/
@Inject
public void setSelection(@Named(IServiceConstants.ACTIVE_SELECTION) @Optional IStructuredSelection selection, EPartService partService){
// only react if selection is actually from the WaveformViewer and nothing else
MPart part = partService.getActivePart();
if( part == null || ! (part.getObject() instanceof WaveformViewer ) || part.getObject() != waveformViewer)
return;
if(selection==null || selection.isEmpty())
transactionList.setInput(null);
else if(selection instanceof IStructuredSelection) {
TrackEntry e = findTrackEntry(((StructuredSelection)selection).toArray());
if(e!=null)
transactionList.setInput(e);
}
}
private TrackEntry findTrackEntry(Object[] elems) {
for(Object o: elems)
if(o instanceof TrackEntry)
return (TrackEntry)o;
return null;
}
public TransactionList getControl() {
return transactionList;
}
}

View File

@ -62,6 +62,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@ -174,9 +176,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
TransactionDetails detailsView = null;
TransactionListView transactionList = null;
/** The waveform pane. */
private IWaveformView waveformPane;
private CTabFolder tabFolder;
private CTabItem tbtmSearchResults;
/** get UISynchronize injected as field */
@Inject UISynchronize sync;
@ -287,14 +294,27 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
sashFormTop.setWeights(new int[] {25, 75});
Composite rightTop = new Composite(sashFormRight, SWT.NONE);
Composite rightBottom = new Composite(sashFormRight, SWT.NONE);
sashFormRight.setWeights(new int[] {80, 20});
waveformPane = factory.createPanel(rightTop);
ctx.set(Composite.class, rightBottom);
detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx);
tabFolder = new CTabFolder(sashFormRight, SWT.BORDER);
tabFolder.setSelectionBackground(Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));
CTabItem tbtmDetails = new CTabItem(tabFolder, SWT.NONE);
tbtmDetails.setText("Transaction Details");
ctx.set(Composite.class, tabFolder);
detailsView = ContextInjectionFactory.make(TransactionDetails.class, ctx);
tbtmDetails.setControl(detailsView.getControl());
tbtmSearchResults = new CTabItem(tabFolder, SWT.NONE);
tbtmSearchResults.setText("Search Results");
transactionList = ContextInjectionFactory.make(TransactionListView.class, ctx);
tbtmSearchResults.setControl(transactionList.getControl());
sashFormRight.setWeights(new int[] {75, 25});
tabFolder.setSelection(0);
waveformPane.setMaxTime(0);
setupColors();
@ -577,6 +597,10 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
* @param state the state
*/
protected void loadDatabase(final Map<String, String> state) {
loadDatabase(state, 1000L);
}
protected void loadDatabase(final Map<String, String> state, long delay) {
fileMonitor.removeFileChangeListener(this);
Job job = new Job(Messages.WaveformViewer_15) {
@Override
@ -619,8 +643,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
return result;
}
};
job.setName("Load Database");
job.setSystem(true);
job.schedule(1000L); // let the UI initialize so that we have a progress monitor
job.schedule(delay); // let the UI initialize so that we have a progress monitor
}
/* (non-Javadoc)
@ -634,18 +659,23 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
public void run() {
if (MessageDialog.openQuestion(display.getActiveShell(), Messages.WaveformViewer_17,
Messages.WaveformViewer_18)) {
Map<String, String> state = new HashMap<>();
saveWaveformViewerState(state);
waveformPane.getStreamList().clear();
database.clear();
if (filesToLoad.size() > 0)
loadDatabase(state);
reloadDatabase();
}
}
});
fileMonitor.removeFileChangeListener(this);
}
public void reloadDatabase() {
Map<String, String> state = new HashMap<>();
saveWaveformViewerState(state);
waveformPane.getStreamList().clear();
database.clear();
if (filesToLoad.size() > 0)
loadDatabase(state, 0L);
}
/**
* Sets the part input.
*
@ -1284,4 +1314,16 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
eventBroker.post(WaveStatusBarControl.MARKER_DIFF, null);
}
}
public void showSearch() {
tabFolder.setSelection(tbtmSearchResults);
}
public void search(String propName, DataType type, String propValue) {
// StructuredSelection sel = (StructuredSelection) getSelection();
// TrackEntry e = findTrackEntry((sel).toArray());
// if(e==null) return;
tabFolder.setSelection(tbtmSearchResults);
transactionList.getControl().setSearchProps(propName, type, propValue);
}
}

View File

@ -0,0 +1,103 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import java.util.Vector;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class TransactionTreeContentProvider.
*/
public abstract class AbstractTransactionTreeContentProvider implements ITreeContentProvider {
/**
*
*/
private final WaveformViewer waveformViewerPart;
/**
* @param transactionDetails
*/
public AbstractTransactionTreeContentProvider(WaveformViewer waveformViewerPart) {
this.waveformViewerPart = waveformViewerPart;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
public void dispose() { }
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object element) {
if(element instanceof ITx) {
return new Object[]{new TransactionTreeNode((ITx)element, TransactionTreeNodeType.ATTRS)};
} else if(element instanceof TransactionTreeNode){
TransactionTreeNode node=(TransactionTreeNode) element;
switch(node.type) {
case PROPS:
return new Object[][]{
{Messages.TransactionDetails_1, Messages.TransactionDetails_16, node.element.getStream().getFullName()},
{Messages.TransactionDetails_2, Messages.TransactionDetails_16, node.element.getGenerator().getName()},
{Messages.TransactionDetails_19, Messages.TransactionDetails_20, waveformViewerPart.getScaledTime(node.element.getBeginTime())},
{Messages.TransactionDetails_21, Messages.TransactionDetails_20, waveformViewerPart.getScaledTime(node.element.getEndTime())}
};
case TX:
case ATTRS:
case HIER:
return node.getAttributeListForHier();
case IN_REL:
Vector<Object[] > res_in = new Vector<>();
for(ITxRelation rel:node.element.getIncomingRelations()){
res_in.add(new Object[]{
rel.getRelationType(),
rel.getSource().getGenerator().getName(),
rel.getSource()});
}
return res_in.toArray();
case OUT_REL:
Vector<Object[] > res_out = new Vector<>();
for(ITxRelation rel:node.element.getOutgoingRelations()){
res_out.add(new Object[]{
rel.getRelationType(),
rel.getTarget().getGenerator().getName(),
rel.getTarget()});
}
return res_out.toArray();
}
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
@Override
public Object getParent(Object element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
public boolean hasChildren(Object element) {
return getChildren(element)!=null;
}
}

View File

@ -0,0 +1,186 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
import com.minres.scviewer.database.ITxRelation;
import com.minres.scviewer.e4.application.Messages;
import com.minres.scviewer.e4.application.parts.WaveformViewer;
/**
* The Class AttributeLabelProvider.
*/
public class AttributeLabelProvider extends LabelProvider implements IStyledLabelProvider {
/**
*
*/
private final WaveformViewer waveformViewerPart;
/** The field. */
final int field;
/** The Constant NAME. */
public static final int NAME=0;
/** The Constant TYPE. */
public static final int TYPE=1;
/** The Constant VALUE. */
public static final int VALUE=2;
/** The Constant VALUE. */
public static final int TX_TIME=3;
String showProp;
public String getShowProp() {
return showProp;
}
public void setShowProp(String showProp) {
this.showProp = showProp;
}
/**
* Instantiates a new attribute label provider.
*
* @param field the field
* @param transactionDetails TODO
*/
public AttributeLabelProvider(WaveformViewer waveformViewerPart, int field) {
this.waveformViewerPart = waveformViewerPart;
this.field=field;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
*/
@Override
public StyledString getStyledText(Object element) {
if(element instanceof ITx) {
ITx iTx = (ITx) element;
switch(field){
case NAME:
return new StyledString(iTx.getId().toString());
case TX_TIME:
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
case TYPE:
if(showProp!=null){
List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> showProp.equals(a.getName())).collect(Collectors.toList());
if(res.size()==1)
return new StyledString(res.get(0).getDataType().toString());
}
return new StyledString("");
case VALUE:
if(showProp!=null){
List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> showProp.equals(a.getName())).collect(Collectors.toList());
if(res.size()==1)
return getAttrValueAsStyledString(res.get(0));
}
return new StyledString("");
}
} else {
switch(field){
case NAME:
if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
String[] tokens = attribute.getName().split("\\.");
return new StyledString(tokens[tokens.length-1]);
}else if (element instanceof ITxRelation) {
return new StyledString(Messages.TransactionDetails_4);
}else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
} else
return new StyledString(element.toString());
case TYPE:
if(element instanceof TransactionTreeNode) {
if(showProp!=null){
ITx iTx = ((TransactionTreeNode) element).element;
List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> showProp.equals(a.getName())).collect(Collectors.toList());
if(res.size()==1)
return new StyledString(res.get(0).getDataType().toString());
}
return new StyledString("");
} else if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return new StyledString(attribute.getDataType().toString());
} else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
return new StyledString(elements[field].toString());
} else
return new StyledString(""); //$NON-NLS-1$
case TX_TIME:
if(element instanceof TransactionTreeNode) {
ITx iTx = ((TransactionTreeNode) element).element;
return new StyledString(waveformViewerPart.getScaledTime(iTx.getBeginTime()));
}
case VALUE:
if(element instanceof TransactionTreeNode) {
if(showProp!=null){
ITx iTx = ((TransactionTreeNode) element).element;
List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> showProp.equals(a.getName())).collect(Collectors.toList());
if(res.size()==1)
return getAttrValueAsStyledString(res.get(0));
}
return new StyledString("");
} else if (element instanceof ITxAttribute) {
ITxAttribute attribute = (ITxAttribute) element;
return getAttrValueAsStyledString(attribute);
} else if(element instanceof Object[]){
Object[] elements = (Object[]) element;
Object o = elements[field];
if(o instanceof ITx) {
ITx tx = (ITx)o;
return new StyledString(this.txToString(tx)+" ("+tx.getStream().getFullName()+")");
} else
return new StyledString(o.toString());
} else if(element instanceof ITx){
return new StyledString(this.txToString((ITx) element));
}
}
}
return new StyledString(""); //$NON-NLS-1$
}
public StyledString getAttrValueAsStyledString(ITxAttribute attribute) {
String value = attribute.getValue().toString();
if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
try {
value += " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
} catch(NumberFormatException e) { }
}
return new StyledString(value);
}
/**
* Tx to string.
*
* @param tx the tx
* @return the string
*/
String txToString(ITx tx){
StringBuilder sb = new StringBuilder();
sb.append("tx#").append(tx.getId()).append("[").append(timeToString(tx.getBeginTime())); //$NON-NLS-1$ //$NON-NLS-2$
sb.append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
return sb.toString();
}
/**
* Time to string.
*
* @param time the time
* @return the string
*/
String timeToString(Long time){
return waveformViewerPart.getScaledTime(time);
}
}

View File

@ -0,0 +1,96 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import java.util.AbstractMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.e4.application.Messages;
/**
* The Class TreeNode.
*/
public class TransactionTreeNode implements Comparable<TransactionTreeNode>{
/** The type. */
public TransactionTreeNodeType type;
/** The element. */
public ITx element;
private String hier_path;
/**
* Instantiates a new tree node.
*
* @param element the element
* @param type the type
*/
public TransactionTreeNode(ITx element, TransactionTreeNodeType type){
this.element=element;
this.type=type;
this.hier_path="";
}
public TransactionTreeNode(ITx element, String path){
this.element=element;
this.type=TransactionTreeNodeType.HIER;
this.hier_path=path;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString(){
switch(type){
case TX: return "tx#"+element.getId();
case PROPS: return Messages.TransactionDetails_10;
case ATTRS: return Messages.TransactionDetails_11;
case IN_REL: return Messages.TransactionDetails_12;
case OUT_REL: return Messages.TransactionDetails_13;
case HIER:{
String[] tokens = hier_path.split("\\.");
return tokens[tokens.length-1];
}
}
return ""; //$NON-NLS-1$
}
public Object[] getAttributeListForHier() {
if(childs==null) {
Map<String, Object> res = element.getAttributes().stream()
.filter(txAttr -> txAttr.getName().startsWith(hier_path))
.map(txAttr -> {
String target = hier_path.length()==0?txAttr.getName():txAttr.getName().replace(hier_path+'.', "");
String[] tokens = target.split("\\.");
if(tokens.length==1)
return new AbstractMap.SimpleEntry<>(tokens[0], txAttr);
else
return new AbstractMap.SimpleEntry<>(tokens[0], new TransactionTreeNode(element, hier_path.length()>0?hier_path+"."+tokens[0]:tokens[0]));
})
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue(), (first, second) -> first));
childs = new TreeMap<String, Object>(res).values().toArray();
}
return childs;
}
private Object[] childs=null;
@Override
public boolean equals(Object o) {
if(o instanceof TransactionTreeNode) {
TransactionTreeNode t = (TransactionTreeNode) o;
return type==t.type && hier_path.equals(t.hier_path);
}
return false;
}
@Override
public int compareTo(TransactionTreeNode o) {
int res1 = type.compareTo(o.type);
if(res1==0) {
return hier_path.compareTo(o.hier_path);
} else
return res1;
}
}

View File

@ -0,0 +1,13 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
/**
* The Enum Type.
*/
public enum TransactionTreeNodeType {
TX, /** The transaction. */
PROPS, /** The props. */
ATTRS, /** The attrs. */
IN_REL, /** The in rel. */
OUT_REL,/** The out rel. */
HIER
}

View File

@ -0,0 +1,55 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import java.util.regex.PatternSyntaxException;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import com.minres.scviewer.database.ITxAttribute;
/**
* The Class TxAttributeFilter.
*/
public class TxAttributeFilter extends ViewerFilter {
/** The search string. */
private String searchString;
/**
* Sets the search text.
*
* @param s the new search text
*/
public void setSearchText(String s) {
this.searchString = ".*" + s + ".*"; //$NON-NLS-1$ //$NON-NLS-2$
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
if(element instanceof TransactionTreeNode) {
return true;
}
if(element instanceof ITxAttribute){
try {
return (((ITxAttribute) element).getName().toLowerCase().matches(searchString.toLowerCase()));
} catch (PatternSyntaxException e) {
return true;
}
}
if(element instanceof Object[]) {
try {
return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());
} catch (PatternSyntaxException e) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,73 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import com.minres.scviewer.database.ITxAttribute;
/**
* The Class TxAttributeViewerSorter.
*/
public class TxAttributeViewerSorter extends ViewerComparator {
/** The Constant ASCENDING. */
private static final int ASCENDING = 0;
/** The Constant DESCENDING. */
private static final int DESCENDING = 1;
/** The column. */
private int column;
/** The direction. */
private int direction;
/**
* Does the sort. If it's a different column from the previous sort, do an
* ascending sort. If it's the same column as the last sort, toggle the sort
* direction.
*
* @param column the column
*/
public void doSort(int column) {
if (column == this.column) {
// Same column as last sort; toggle the direction
direction = 1 - direction;
} else {
// New column; do an ascending sort
this.column = column;
direction = ASCENDING;
}
}
/**
* Compares the object for sorting.
*
* @param viewer the viewer
* @param e1 the e1
* @param e2 the e2
* @return the int
*/
public int compare(Viewer viewer, Object e1, Object e2) {
int rc = 0;
if(e1 instanceof ITxAttribute && e2 instanceof ITxAttribute){
ITxAttribute p1 = (ITxAttribute) e1;
ITxAttribute p2 = (ITxAttribute) e2;
// Determine which column and do the appropriate sort
switch (column) {
case 0:
rc = getComparator().compare(p1.getName(), p2.getName());
break;
case 1:
rc = getComparator().compare(p1.getDataType().name(), p2.getDataType().name());
break;
case 2:
rc = getComparator().compare(p1.getValue().toString(), p2.getValue().toString());
break;
}
// If descending order, flip the direction
if (direction == DESCENDING) rc = -rc;
}
return rc;
}
}

View File

@ -0,0 +1,94 @@
package com.minres.scviewer.e4.application.parts.txTableTree;
import java.math.BigInteger;
import java.util.List;
import java.util.regex.PatternSyntaxException;
import java.util.stream.Collectors;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import com.minres.scviewer.database.DataType;
import com.minres.scviewer.database.ITx;
import com.minres.scviewer.database.ITxAttribute;
/**
* The Class TxAttributeFilter.
*/
public class TxFilter extends ViewerFilter {
/** The search string. */
private String searchProp;
/** The search type. */
private DataType searchType;
/** The search string. */
private String searchValue;
/**
* Sets the search text.
*
* @param s the new search text
* @param dataType
*/
public void setSearchProp(String s, DataType type) {
this.searchProp = s;
this.searchType = type;
}
/**
* Sets the search text.
*
* @param s the new search text
*/
public void setSearchValue(String s) {
this.searchValue = s;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchValue == null || searchValue.length() == 0)
return true;
ITx iTx = null;
if(element instanceof ITx)
iTx = (ITx) element;
else if(element instanceof TransactionTreeNode && ((TransactionTreeNode)element).type == TransactionTreeNodeType.TX)
iTx = ((TransactionTreeNode)element).element;
if(iTx==null) return true;
List<ITxAttribute> res = iTx.getAttributes().stream().filter(a -> searchProp.equals(a.getName())).collect(Collectors.toList());
if(res.size()==1) {
try {
ITxAttribute attr =res.get(0);
switch(searchType) {
case BOOLEAN: // bool
case ENUMERATION:
return searchValue.equalsIgnoreCase((String) attr.getValue());
case INTEGER:
case UNSIGNED:
BigInteger lval = new BigInteger(attr.getValue().toString());
BigInteger sval = parseBigInteger(searchValue);
return lval.equals(sval);
case STRING:
try {
return (((ITxAttribute) element).getName().toLowerCase().matches(searchValue.toLowerCase()));
} catch (PatternSyntaxException e) {
return true;
}
default:
break;
}
} catch(RuntimeException ex) {
return false;
}
}
return false;
}
private BigInteger parseBigInteger(String value) {
if(value.startsWith("0x") || value.startsWith("0X"))
return new BigInteger(value.substring(2), 16);
else
return new BigInteger(value);
}
}

View File

@ -1,13 +1,14 @@
/*******************************************************************************
* Copyright (c) 2015 MINRES Technologies GmbH and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* MINRES Technologies GmbH - initial API and implementation
*******************************************************************************/
/*******************************************************************************
* Copyright (c) 2011 Google, Inc. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Google, Inc. - initial API and implementation
* Wim Jongman - 1.8 and higher compliance
*******************************************************************************/
package org.eclipse.wb.swt;
import java.io.File;
@ -24,51 +25,61 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.CompositeImageDescriptor;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.ImageDataProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.osgi.framework.Bundle;
import org.osgi.framework.Bundle;
import com.minres.scviewer.e4.application.Messages;
/**
* Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images,
* etc.
* Utility class for managing OS resources associated with SWT/JFace controls
* such as colors, fonts, images, etc.
*
* !!! IMPORTANT !!! Application code must explicitly invoke the <code>dispose()</code> method to release the
* operating system resources managed by cached objects when those objects and OS resources are no longer
* needed (e.g. on application shutdown)
* This class is created automatically when you fiddle around with images and
* colors in WB. You might want to prevent your application from using this
* class and provide your own more effective means of resource caching.
*
* Even though this class can be used to manage these resources, if they are
* here for the duration of the application and not used then you still have an
* effective resource leak.
*
* Application code must explicitly invoke the <code>dispose()</code> method to
* release the operating system resources managed by cached objects when those
* objects and OS resources are no longer needed.
*
* This class may be freely distributed as part of any application or plugin.
* <p>
*
* @author scheglov_ke
* @author Dan Rubel
* @author Wim Jongman
*/
public class ResourceManager extends SWTResourceManager {
////////////////////////////////////////////////////////////////////////////
//
// Image
//
////////////////////////////////////////////////////////////////////////////
private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
/**
* Returns an {@link ImageDescriptor} stored in the file at the specified path relative to the specified
* class.
* The map where we store our images.
*/
private static Map<ImageDescriptor, Image> m_descriptorImageMap = new HashMap<ImageDescriptor, Image>();
/**
* Returns an {@link ImageDescriptor} stored in the file at the specified path
* relative to the specified class.
*
* @param clazz
* the {@link Class} relative to which to find the image descriptor.
* @param path
* the path to the image file.
* @param clazz the {@link Class} relative to which to find the image
* descriptor.
* @param path the path to the image file.
* @return the {@link ImageDescriptor} stored in the file at the specified path.
*/
public static ImageDescriptor getImageDescriptor(Class<?> clazz, String path) {
return ImageDescriptor.createFromFile(clazz, path);
}
/**
* Returns an {@link ImageDescriptor} stored in the file at the specified path.
*
* @param path
* the path to the image file.
* @param path the path to the image file.
* @return the {@link ImageDescriptor} stored in the file at the specified path.
*/
public static ImageDescriptor getImageDescriptor(String path) {
@ -78,11 +89,11 @@ public class ResourceManager extends SWTResourceManager {
return null;
}
}
/**
* Returns an {@link Image} based on the specified {@link ImageDescriptor}.
*
* @param descriptor
* the {@link ImageDescriptor} for the {@link Image}.
* @param descriptor the {@link ImageDescriptor} for the {@link Image}.
* @return the {@link Image} based on the specified {@link ImageDescriptor}.
*/
public static Image getImage(ImageDescriptor descriptor) {
@ -96,23 +107,24 @@ public class ResourceManager extends SWTResourceManager {
}
return image;
}
/**
* Maps images to decorated images.
*/
@SuppressWarnings("unchecked")
private static Map<Image, Map<Image, Image>>[] m_decoratedImageMap = new Map[LAST_CORNER_KEY];
/**
* Returns an {@link Image} composed of a base image decorated by another image.
*
* @param baseImage
* the base {@link Image} that should be decorated.
* @param decorator
* the {@link Image} to decorate the base image.
* @param baseImage the base {@link Image} that should be decorated.
* @param decorator the {@link Image} to decorate the base image.
* @return {@link Image} The resulting decorated image.
*/
public static Image decorateImage(Image baseImage, Image decorator) {
return decorateImage(baseImage, decorator, BOTTOM_RIGHT);
}
/**
* Returns an {@link Image} composed of a base image decorated by another image.
*
@ -149,13 +161,13 @@ public class ResourceManager extends SWTResourceManager {
protected void drawCompositeImage(int width, int height) {
drawImage(createCachedImageDataProvider(baseImage), 0, 0);
if (corner == TOP_LEFT) {
drawImage(createCachedImageDataProvider(decorator), 0, 0);
drawImage(getUnzoomedImageDataProvider(decorator.getImageData()) , 0, 0);
} else if (corner == TOP_RIGHT) {
drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, 0);
drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, 0);
} else if (corner == BOTTOM_LEFT) {
drawImage(createCachedImageDataProvider(decorator), 0, bib.height - dib.height);
drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), 0, bib.height - dib.height);
} else if (corner == BOTTOM_RIGHT) {
drawImage(createCachedImageDataProvider(decorator), bib.width - dib.width, bib.height - dib.height);
drawImage(getUnzoomedImageDataProvider(decorator.getImageData()), bib.width - dib.width, bib.height - dib.height);
}
}
@Override
@ -169,6 +181,12 @@ public class ResourceManager extends SWTResourceManager {
}
return result;
}
private static ImageDataProvider getUnzoomedImageDataProvider(ImageData imageData) {
return zoom -> zoom == 100 ? imageData : null;
}
/**
* Dispose all of the cached images.
*/
@ -202,6 +220,7 @@ public class ResourceManager extends SWTResourceManager {
m_URLImageMap.clear();
}
}
////////////////////////////////////////////////////////////////////////////
//
// Plugin images support
@ -211,23 +230,25 @@ public class ResourceManager extends SWTResourceManager {
* Maps URL to images.
*/
private static Map<String, Image> m_URLImageMap = new HashMap<String, Image>();
/**
* Provider for plugin resources, used by WindowBuilder at design time.
*/
public interface PluginResourceProvider {
URL getEntry(String symbolicName, String path);
}
/**
* Instance of {@link PluginResourceProvider}, used by WindowBuilder at design time.
* Instance of {@link PluginResourceProvider}, used by WindowBuilder at design
* time.
*/
private static PluginResourceProvider m_designTimePluginResourceProvider = null;
/**
* Returns an {@link Image} based on a plugin and file path.
*
* @param plugin
* the plugin {@link Object} containing the image
* @param name
* the path to the image within the plugin
* @param plugin the plugin {@link Object} containing the image
* @param name the path to the image within the plugin
* @return the {@link Image} stored in the file at the specified path
*
* @deprecated Use {@link #getPluginImage(String, String)} instead.
@ -244,13 +265,12 @@ public class ResourceManager extends SWTResourceManager {
}
return null;
}
/**
* Returns an {@link Image} based on a {@link Bundle} and resource entry path.
*
* @param symbolicName
* the symbolic name of the {@link Bundle}.
* @param path
* the path of the resource entry.
* @param symbolicName the symbolic name of the {@link Bundle}.
* @param path the path of the resource entry.
* @return the {@link Image} stored in the file at the specified path.
*/
public static Image getPluginImage(String symbolicName, String path) {
@ -264,6 +284,7 @@ public class ResourceManager extends SWTResourceManager {
}
return null;
}
/**
* Returns an {@link Image} based on given {@link URL}.
*/
@ -290,13 +311,12 @@ public class ResourceManager extends SWTResourceManager {
}
return null;
}
/**
* Returns an {@link ImageDescriptor} based on a plugin and file path.
*
* @param plugin
* the plugin {@link Object} containing the image.
* @param name
* the path to th eimage within the plugin.
* @param plugin the plugin {@link Object} containing the image.
* @param name the path to th eimage within the plugin.
* @return the {@link ImageDescriptor} stored in the file at the specified path.
*
* @deprecated Use {@link #getPluginImageDescriptor(String, String)} instead.
@ -315,14 +335,15 @@ public class ResourceManager extends SWTResourceManager {
}
return null;
}
/**
* Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
* Returns an {@link ImageDescriptor} based on a {@link Bundle} and resource
* entry path.
*
* @param symbolicName
* the symbolic name of the {@link Bundle}.
* @param path
* the path of the resource entry.
* @return the {@link ImageDescriptor} based on a {@link Bundle} and resource entry path.
* @param symbolicName the symbolic name of the {@link Bundle}.
* @param path the path of the resource entry.
* @return the {@link ImageDescriptor} based on a {@link Bundle} and resource
* entry path.
*/
public static ImageDescriptor getPluginImageDescriptor(String symbolicName, String path) {
try {
@ -335,6 +356,7 @@ public class ResourceManager extends SWTResourceManager {
}
return null;
}
/**
* Returns an {@link URL} based on a {@link Bundle} and resource entry path.
*/
@ -353,13 +375,12 @@ public class ResourceManager extends SWTResourceManager {
// no such resource
return null;
}
/**
* Returns an {@link URL} based on a plugin and file path.
*
* @param plugin
* the plugin {@link Object} containing the file path.
* @param name
* the file path.
* @param plugin the plugin {@link Object} containing the file path.
* @param name the file path.
* @return the {@link URL} representing the file at the specified path.
* @throws Exception
*/
@ -373,13 +394,13 @@ public class ResourceManager extends SWTResourceManager {
Object bundle = getBundleMethod.invoke(plugin, new Object[0]);
//
Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
Object path = pathConstructor.newInstance(new Object[]{name});
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
Object path = pathConstructor.newInstance(new Object[] { name });
//
Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$
Method findMethod = PlatformClass.getMethod("find", new Class[]{BundleClass, IPathClass}); //$NON-NLS-1$
return (URL) findMethod.invoke(null, new Object[]{bundle, path});
Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$
return (URL) findMethod.invoke(null, new Object[] { bundle, path });
}
} catch (Throwable e) {
// Ignore any exceptions
@ -390,24 +411,26 @@ public class ResourceManager extends SWTResourceManager {
if (PluginClass.isAssignableFrom(plugin.getClass())) {
//
Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[]{String.class});
Object path = pathConstructor.newInstance(new Object[]{name});
Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
Object path = pathConstructor.newInstance(new Object[] { name });
//
Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
Method findMethod = PluginClass.getMethod("find", new Class[]{IPathClass}); //$NON-NLS-1$
return (URL) findMethod.invoke(plugin, new Object[]{path});
Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$
return (URL) findMethod.invoke(plugin, new Object[] { path });
}
}
return null;
}
////////////////////////////////////////////////////////////////////////////
//
// General
//
////////////////////////////////////////////////////////////////////////////
/**
* Dispose of cached objects and their underlying OS resources. This should only be called when the cached
* objects are no longer needed (e.g. on application shutdown).
* Dispose of cached objects and their underlying OS resources. This should only
* be called when the cached objects are no longer needed (e.g. on application
* shutdown).
*/
public static void dispose() {
disposeColors();

View File

@ -10,7 +10,7 @@
<relativePath>../..</relativePath>
</parent>
<artifactId>com.minres.scviewer.e4.product</artifactId>
<version>2.8.0-SNAPSHOT</version>
<version>2.9.3-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<groupId>com.minres.scviewer</groupId>
<build>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="SCViewer" uid="product" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.8.0.qualifier" useFeatures="true" includeLaunchers="true">
<product name="SCViewer" uid="product" id="com.minres.scviewer.e4.application.product" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.9.3.qualifier" useFeatures="true" includeLaunchers="true">
<configIni use="default">
</configIni>
@ -49,6 +49,7 @@
<features>
<feature id="com.minres.scviewer.e4.feature" installMode="root"/>
<feature id="com.minres.scviewer.e4.platform.feature" installMode="root"/>
<feature id="org.eclipse.equinox.p2.core.feature" installMode="root"/>
</features>
<configurations>

View File

@ -10,7 +10,7 @@
<relativePath>../..</relativePath>
</parent>
<artifactId>com.minres.scviewer.e4.product_slim</artifactId>
<version>2.8.0-SNAPSHOT</version>
<version>2.9.3-SNAPSHOT</version>
<packaging>eclipse-repository</packaging>
<groupId>com.minres.scviewer</groupId>
<build>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>
<product name="SCViewer" uid="product_slim" id="com.minres.scviewer.e4.application.product_slim" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.8.0.qualifier" useFeatures="false" includeLaunchers="true">
<product name="SCViewer" uid="product_slim" id="com.minres.scviewer.e4.application.product_slim" application="org.eclipse.e4.ui.workbench.swt.E4Application" version="2.9.3.qualifier" useFeatures="false" includeLaunchers="true">
<configIni use="default">
</configIni>