Merge branch 'release/2.9.0'
This commit is contained in:
commit
b7a8d99e2d
@ -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();
|
||||
@ -680,15 +681,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)
|
||||
|
@ -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;
|
||||
|
@ -136,6 +136,7 @@
|
||||
<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"/>
|
||||
<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>
|
||||
@ -200,6 +201,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">
|
||||
@ -226,6 +231,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"/>
|
||||
@ -268,6 +276,7 @@
|
||||
</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"/>
|
||||
<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"/>
|
||||
|
@ -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.1.qualifier
|
||||
Bundle-Version: 2.9.0.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,9 @@ 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
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Import-Package: com.minres.scviewer.database,
|
||||
javax.inject;version="1.0.0"
|
||||
|
BIN
plugins/com.minres.scviewer.e4.application/icons/find.png
Executable file
BIN
plugins/com.minres.scviewer.e4.application/icons/find.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 659 B |
@ -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.1-SNAPSHOT</version>
|
||||
<version>2.9.0-SNAPSHOT</version>
|
||||
<parent>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<artifactId>com.minres.scviewer.parent</artifactId>
|
||||
|
@ -10,17 +10,11 @@
|
||||
*******************************************************************************/
|
||||
package com.minres.scviewer.e4.application;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener;
|
||||
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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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,19 @@ 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 +173,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 +184,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 +195,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 +230,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 +264,9 @@ public class TransactionDetails {
|
||||
});
|
||||
}
|
||||
|
||||
public Control getControl() {
|
||||
return top;
|
||||
}
|
||||
/**
|
||||
* Sets the focus.
|
||||
*/
|
||||
@ -327,15 +335,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 +351,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 +400,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 +408,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$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,286 @@
|
||||
package com.minres.scviewer.e4.application.parts;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
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.ITreeSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.TreeViewerColumn;
|
||||
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.Text;
|
||||
import org.eclipse.swt.widgets.Tree;
|
||||
import org.eclipse.swt.widgets.TreeColumn;
|
||||
|
||||
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.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 TreeViewer treeViewer = null;
|
||||
|
||||
private TreeColumn valueColumn = null;
|
||||
|
||||
private AttributeLabelProvider nameLabelProvider = 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(3, false));
|
||||
txFilter = new TxFilter();
|
||||
|
||||
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());
|
||||
}
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) {
|
||||
int idx = searchPropCombo.getSelectionIndex();
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
txFilter.setSearchProp(sel.getName(), sel.getType());
|
||||
}
|
||||
});
|
||||
|
||||
searchPropValue = new Text(this, SWT.BORDER);
|
||||
searchPropValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
|
||||
searchPropValue.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
txFilter.setSearchValue(((Text) e.widget).getText());
|
||||
treeViewer.refresh();
|
||||
//treeViewer.expandAll(false);
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
AttributeNameBean sel = attrNames.get(idx);
|
||||
nameLabelProvider.setShowProp(sel.getName());
|
||||
treeViewer.refresh(true);
|
||||
}
|
||||
@Override
|
||||
public void widgetDefaultSelected(SelectionEvent e) { }
|
||||
});
|
||||
|
||||
treeViewer = new TreeViewer(this, SWT.BORDER);
|
||||
treeViewer.setContentProvider(new AbstractTransactionTreeContentProvider(waveformViewer) {
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
if (inputElement instanceof Object[]) {
|
||||
return (Object[]) inputElement;
|
||||
}
|
||||
if (inputElement instanceof Collection) {
|
||||
return ((Collection) inputElement).toArray();
|
||||
}
|
||||
return new Object[0];
|
||||
}
|
||||
});
|
||||
treeViewer.addFilter(txFilter);
|
||||
treeViewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||
@Override
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
ITreeSelection treeSelection = treeViewer.getStructuredSelection();
|
||||
Object selected = treeSelection.getFirstElement();
|
||||
if(selected instanceof ITx){
|
||||
waveformViewer.setSelection(new StructuredSelection(selected));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Tree tree = treeViewer.getTree();
|
||||
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
|
||||
|
||||
TreeViewerColumn nameColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
TreeColumn nameColumn = nameColumnViewer.getColumn();
|
||||
nameColumn.setWidth(200);
|
||||
nameColumn.setText("Tx ID");
|
||||
nameColumn.setResizable(true);
|
||||
nameColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.NAME)));
|
||||
|
||||
TreeViewerColumn timeColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
TreeColumn 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)));
|
||||
|
||||
TreeViewerColumn typeColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
TreeColumn typeColumn = typeColumnViewer.getColumn();
|
||||
typeColumn.setAlignment(SWT.RIGHT);
|
||||
typeColumn.setWidth(150);
|
||||
typeColumn.setText("Type");
|
||||
typeColumn.setResizable(true);
|
||||
typeColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.TYPE)));
|
||||
|
||||
TreeViewerColumn valueColumnViewer = new TreeViewerColumn(treeViewer, SWT.NONE);
|
||||
valueColumn = valueColumnViewer.getColumn();
|
||||
valueColumn.setWidth(150);
|
||||
valueColumn.setText("Value");
|
||||
valueColumn.setResizable(true);
|
||||
nameLabelProvider= new AttributeLabelProvider(waveformViewer, AttributeLabelProvider.VALUE);
|
||||
valueColumnViewer.setLabelProvider(new DelegatingStyledCellLabelProvider(nameLabelProvider));
|
||||
|
||||
// Turn on the header and the lines
|
||||
tree.setHeaderVisible(true);
|
||||
tree.setLinesVisible(true);
|
||||
}
|
||||
|
||||
public void setInput(TrackEntry trackEntry) {
|
||||
if(trackEntry==null || !trackEntry.isStream()) {
|
||||
attrNames.clear();
|
||||
treeViewer.setInput(emptyList);
|
||||
} else {
|
||||
stream=trackEntry.getStream();
|
||||
treeViewer.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() {
|
||||
stream.getEvents().values().parallelStream().forEach(evtLst -> {
|
||||
evtLst.forEach(evt -> {
|
||||
if(evt.getType()==Type.BEGIN) {
|
||||
eventList.add(evt.getTransaction());
|
||||
for(ITxAttribute attr: evt.getTransaction().getAttributes()) {
|
||||
propNames.put(attr.getName(), attr.getDataType());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
eventList = eventList.parallelStream().sorted((t1, t2)-> t1.getBeginTime().compareTo(t2.getBeginTime())).collect(Collectors.toList());
|
||||
getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
treeViewer.setInput(eventList);
|
||||
attrNames.clear();
|
||||
attrNames.addAll(getEntries());
|
||||
searchPropComboViewer.getCombo().select(0);
|
||||
txFilter.setSearchProp(attrNames.get(0).getName(), attrNames.get(0).getType());
|
||||
if (searchPropComboViewer!=null) {
|
||||
searchPropComboViewer.setInput(attrNames);
|
||||
searchPropComboViewer.setSelection(new StructuredSelection(searchPropComboViewer.getElementAt(0)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}.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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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();
|
||||
@ -1294,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);
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
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 propertyHolder=(TransactionTreeNode) element;
|
||||
if(propertyHolder.type == TransactionTreeNodeType.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, waveformViewerPart.getScaledTime(propertyHolder.element.getBeginTime())},
|
||||
{Messages.TransactionDetails_21, Messages.TransactionDetails_20, waveformViewerPart.getScaledTime(propertyHolder.element.getEndTime())}
|
||||
};
|
||||
}else if(propertyHolder.type == TransactionTreeNodeType.ATTRS || propertyHolder.type == TransactionTreeNodeType.HIER)
|
||||
return propertyHolder.getAttributeListForHier();
|
||||
else if(propertyHolder.type == TransactionTreeNodeType.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 == TransactionTreeNodeType.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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
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 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 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:
|
||||
return new StyledString(""); //$NON-NLS-1$
|
||||
default:
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
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 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.minres.scviewer.e4.application.parts.txTableTree;
|
||||
|
||||
/**
|
||||
* The Enum Type.
|
||||
*/
|
||||
public enum TransactionTreeNodeType {
|
||||
PROPS, /** The props. */
|
||||
ATTRS, /** The attrs. */
|
||||
IN_REL, /** The in rel. */
|
||||
OUT_REL,/** The out rel. */
|
||||
HIER
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
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-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 (searchValue == null || searchValue.length() == 0)
|
||||
return true;
|
||||
if(element instanceof ITx) {
|
||||
ITx iTx = (ITx) element;
|
||||
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 true;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
|
@ -10,7 +10,7 @@
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>com.minres.scviewer.e4.product</artifactId>
|
||||
<version>2.8.1-SNAPSHOT</version>
|
||||
<version>2.9.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-repository</packaging>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<build>
|
||||
|
@ -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.1.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.0.qualifier" useFeatures="true" includeLaunchers="true">
|
||||
|
||||
<configIni use="default">
|
||||
</configIni>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>com.minres.scviewer.e4.product_slim</artifactId>
|
||||
<version>2.8.1-SNAPSHOT</version>
|
||||
<version>2.9.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-repository</packaging>
|
||||
<groupId>com.minres.scviewer</groupId>
|
||||
<build>
|
||||
|
@ -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.1.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.0.qualifier" useFeatures="false" includeLaunchers="true">
|
||||
|
||||
<configIni use="default">
|
||||
</configIni>
|
||||
|
Loading…
Reference in New Issue
Block a user