add initial implementation of TX hover

This commit is contained in:
2020-03-21 06:28:28 +01:00
parent ffbffd88f1
commit 210d925987
14 changed files with 492 additions and 54 deletions

View File

@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true
Bundle-Version: 2.3.0.qualifier
Bundle-Version: 2.4.0.qualifier
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: javax.inject;bundle-version="1.0.0",
org.eclipse.core.runtime;bundle-version="3.11.1",

View File

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

View File

@ -97,7 +97,7 @@ public class TransactionDetails {
/** The attribute filter. */
TxAttributeFilter attributeFilter;
/** The view sorter. */
TxAttributeViewerSorter viewSorter;
@ -124,12 +124,12 @@ public class TransactionDetails {
treeViewer.expandAll(true);
}
});
nameFilter.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
attributeFilter = new TxAttributeFilter();
viewSorter = new TxAttributeViewerSorter();
treeViewer = new TreeViewer(parent);
treeViewer.setContentProvider(new TransactionTreeContentProvider());
treeViewer.setLabelProvider(new TxPropertiesLabelProvider());
@ -148,7 +148,7 @@ public class TransactionDetails {
public void treeExpanded(TreeExpansionEvent event) {
treeViewer.getSelection();
}
});
// Set up the table
@ -188,14 +188,14 @@ public class TransactionDetails {
}
});
// Pack the columns
// for (int i = 0, n = table.getColumnCount(); i < n; i++) {
// table.getColumn(i).pack();
// }
// for (int i = 0, n = table.getColumnCount(); i < n; i++) {
// table.getColumn(i).pack();
// }
// Turn on the header and the lines
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
treeViewer.addDoubleClickListener(new IDoubleClickListener(){
@Override
@ -213,7 +213,7 @@ public class TransactionDetails {
}
}
}
});
parent.addControlListener(new ControlAdapter() {
public void controlResized(ControlEvent e) {
@ -279,7 +279,7 @@ public class TransactionDetails {
} else {
treeViewer.setInput(null);
}
}
private void setExpandedState(TreeItem[] treeItems, ArrayList<Boolean> states) {
@ -294,7 +294,7 @@ public class TransactionDetails {
ret.add(treeItem.getItemCount()>0?treeItem.getExpanded():true);
return ret;
}
private int getTopItemHier(ArrayList<String> names){
int indexInParent=-1;
TreeItem obj = treeViewer.getTree().getTopItem();
@ -314,7 +314,7 @@ public class TransactionDetails {
}
return indexInParent;
}
private void setTopItemFromHier(ArrayList<String> names, int indexInParent) {
if(indexInParent<0 || names.size()==0 ) return;
TreeItem selItem=null;
@ -375,16 +375,16 @@ public class TransactionDetails {
*/
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$
append(" - ").append(timeToString(tx.getEndTime())).append("]"); //$NON-NLS-1$ //$NON-NLS-2$
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;
@ -469,7 +469,7 @@ public class TransactionDetails {
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (searchString == null || searchString.length() == 0) {
return true;
}
@ -482,7 +482,7 @@ public class TransactionDetails {
if(element instanceof Object[]) {
return (((Object[])element)[0]).toString().toLowerCase().matches(searchString.toLowerCase());
}
return false;
}
}
@ -491,19 +491,19 @@ public class TransactionDetails {
* The Enum Type.
*/
enum Type {/** The props. */
PROPS, /** The attrs. */
ATTRS, /** The in rel. */
IN_REL, /** The out rel. */
OUT_REL}
PROPS, /** The attrs. */
ATTRS, /** The in rel. */
IN_REL, /** The out rel. */
OUT_REL}
/**
* The Class TreeNode.
*/
class TreeNode{
/** The type. */
public Type type;
/** The element. */
public ITx element;
@ -624,16 +624,16 @@ PROPS, /** The attrs. */
* 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;
@ -678,13 +678,18 @@ PROPS, /** The attrs. */
String value = attribute.getValue().toString();
if((DataType.UNSIGNED == attribute.getDataType() || DataType.INTEGER==attribute.getDataType()) && !"0".equals(value)) {
try {
value = attribute.getValue().toString() + " [0x"+Long.toHexString(Long.parseLong(attribute.getValue().toString()))+"]";
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;
return new StyledString(elements[field].toString());
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

View File

@ -65,14 +65,18 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Widget;
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.ITxRelation;
import com.minres.scviewer.database.IWaveform;
@ -80,6 +84,7 @@ import com.minres.scviewer.database.IWaveformDb;
import com.minres.scviewer.database.IWaveformDbFactory;
import com.minres.scviewer.database.RelationType;
import com.minres.scviewer.database.swt.Constants;
import com.minres.scviewer.database.swt.ToolTipTableContentProvider;
import com.minres.scviewer.database.swt.WaveformViewerFactory;
import com.minres.scviewer.database.ui.GotoDirection;
import com.minres.scviewer.database.ui.ICursor;
@ -366,6 +371,50 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
prefs.addPreferenceChangeListener(this);
waveformPane.addDisposeListener(this);
waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipTableContentProvider() {
private List<Object> res;
@Override
public ToolTipTableContentProvider initialize(Widget widget, Point pt) {
res = waveformPane.getElementsAt(pt);
return this;
}
@Override
public String getTableTitle() {
if(res.size()>0) {
Object o = res.get(0);
if(o instanceof ITx) {
ITx tx = (ITx)o;
return tx.toString();
}
}
return "";
}
@Override
public List<String[]> getTableContent() {
final ArrayList<String[]> ret = new ArrayList<>();
if(res.size()>0){
Object o = res.get(0);
if(o instanceof ITx) {
ITx tx = (ITx)o;
ret.add(new String[]{"type", tx.getGenerator().getName()});
for (ITxAttribute iTxAttribute : tx.getAttributes()) {
String value = iTxAttribute.getValue().toString();
if((DataType.UNSIGNED == iTxAttribute.getDataType() || DataType.INTEGER==iTxAttribute.getDataType()) && !"0".equals(value)) {
try {
value += " [0x"+Long.toHexString(Long.parseLong(iTxAttribute.getValue().toString()))+"]";
} catch(NumberFormatException e) { }
}
ret.add(new String[]{iTxAttribute.getName(), value});
}
}
}
return ret;
}
});
}
/* (non-Javadoc)