From ffbffd88f1ac5f6f86bb7768bf87412b3236fe21 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Tue, 17 Mar 2020 13:42:18 +0100 Subject: [PATCH 01/10] fix typos --- .../src/com/minres/scviewer/e4/application/E4LifeCycle.java | 6 ++++-- .../scviewer/e4/application/handlers/OpenHandler.java | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java index 2feb068..e0d15fc 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/E4LifeCycle.java @@ -86,7 +86,7 @@ public class E4LifeCycle { ContextInjectionFactory.inject(openViewHandler, ctx); eventBroker.unsubscribe(this); for(String name:opt.getSet().getData()){ - if(new File(name).exists()) openViewHandler.openViewForFile(name); + openViewHandler.openViewForFile(name); } } } @@ -159,6 +159,8 @@ public class E4LifeCycle { */ public void openViewForFile(String name){ File file = new File(getFirstFileName(name)); + if(!file.exists()) + return; MPart part = partService.createPart("com.minres.scviewer.e4.application.partdescriptor.waveformviewer"); //$NON-NLS-1$ part.setLabel(file.getName()); MPartStack partStack = (MPartStack)modelService.find("org.eclipse.editorss", app); //$NON-NLS-1$ @@ -172,7 +174,7 @@ public class E4LifeCycle { } private String getFirstFileName(String name) { - if(name.contains(":")) { + if(name.contains(",")) { String[] tokens = name.split(","); return tokens[0]; } else diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java index 42288c2..48dbb7b 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/OpenHandler.java @@ -32,7 +32,9 @@ public class OpenHandler { public void execute(Shell shell, MApplication app, EModelService modelService, EPartService partService){ FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); dialog.setFilterExtensions (new String []{Messages.OpenHandler_0}); - dialog.open(); + String ret = dialog.open(); + if(ret==null) + return; String path = dialog.getFilterPath(); ArrayList files = new ArrayList(); for(String fileName: dialog.getFileNames()){ From 210d92598718b9f13ed65ffb9840f8cbb2bb48ca Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 06:28:28 +0100 Subject: [PATCH 02/10] add initial implementation of TX hover --- .../META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.database.ui.swt/pom.xml | 2 +- .../scviewer/database/swt/Constants.java | 8 +- .../database/swt/ToolTipHelpTextProvider.java | 12 + .../swt/ToolTipTableContentProvider.java | 21 ++ .../swt/internal/RelSelectionDialog.java | 73 ++++++ .../database/swt/internal/ToolTipHandler.java | 244 ++++++++++++++++++ .../database/swt/internal/WaveformCanvas.java | 2 +- .../database/swt/internal/WaveformViewer.java | 61 +++-- .../scviewer/database/ui/IWaveformViewer.java | 3 + .../META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.e4.application/pom.xml | 2 +- .../application/parts/TransactionDetails.java | 65 ++--- .../e4/application/parts/WaveformViewer.java | 49 ++++ 14 files changed, 492 insertions(+), 54 deletions(-) create mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipHelpTextProvider.java create mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java create mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RelSelectionDialog.java create mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java diff --git a/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF b/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF index 1e8ad75..a11ba7f 100644 --- a/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.database.ui.swt/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: SWT widget Bundle-SymbolicName: com.minres.scviewer.database.ui.swt -Bundle-Version: 2.1.0.qualifier +Bundle-Version: 2.2.0.qualifier Bundle-Vendor: MINRES Technologies GmbH Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.swt;bundle-version="3.103.1", diff --git a/com.minres.scviewer.database.ui.swt/pom.xml b/com.minres.scviewer.database.ui.swt/pom.xml index 95ddd22..34b8a4f 100644 --- a/com.minres.scviewer.database.ui.swt/pom.xml +++ b/com.minres.scviewer.database.ui.swt/pom.xml @@ -8,5 +8,5 @@ 2.0.0-SNAPSHOT ../com.minres.scviewer.parent - 2.1.0-SNAPSHOT + 2.2.0-SNAPSHOT \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java index 679fc92..f2142fc 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java @@ -2,8 +2,12 @@ package com.minres.scviewer.database.swt; public class Constants { - public final static String[] unitString={"fs", "ps", "ns", "us", "ms"};//, "s"}; + public static final String[] unitString={"fs", "ps", "ns", "us", "ms"};//, "s"}; - public final static int[] unitMultiplier={1, 3, 10, 30, 100, 300}; + public static final int[] unitMultiplier={1, 3, 10, 30, 100, 300}; + + public static final String CONTENT_PROVIDER_TAG = "TOOLTIP_CONTENT_PROVIDER"; + public static final String TEXT_PROVIDER_TAG = "TOOLTIP_TEXT_PROVIDER"; + public static final String HELP_PROVIDER_TAG = "TOOLTIP_HELP_PROVIDER"; } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipHelpTextProvider.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipHelpTextProvider.java new file mode 100644 index 0000000..8892b80 --- /dev/null +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipHelpTextProvider.java @@ -0,0 +1,12 @@ +package com.minres.scviewer.database.swt; + +import org.eclipse.swt.widgets.Widget; + +public interface ToolTipHelpTextProvider { + /** + * Get help text + * @param widget the widget that is under help + * @return a help text string + */ + public String getHelpText(Widget widget); +} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java new file mode 100644 index 0000000..8a9daee --- /dev/null +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java @@ -0,0 +1,21 @@ +package com.minres.scviewer.database.swt; + +import java.util.List; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Widget; + +public interface ToolTipTableContentProvider { + + public ToolTipTableContentProvider initialize(Widget widget, Point pt); + + public String getTableTitle(); + /** + * Get tool tip table content + * @param widget the widget that is under help + * @oaram pt the point where the mouse cursor is located + * @return a list of string arrays of size 2 (content & value) + */ + public List getTableContent(); + +} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RelSelectionDialog.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RelSelectionDialog.java new file mode 100644 index 0000000..fc53660 --- /dev/null +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/RelSelectionDialog.java @@ -0,0 +1,73 @@ +package com.minres.scviewer.database.swt.internal; + +import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter; + +import java.util.ArrayList; +import java.util.stream.Collectors; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.RowLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Dialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; + +import com.minres.scviewer.database.ITx; +import com.minres.scviewer.database.ITxRelation; + +class RelSelectionDialog extends Dialog { + private java.util.List entries; + + private java.util.List entryTx; + + private ITxRelation selected = null; + + public RelSelectionDialog(Shell shell, ArrayList candidates, boolean target) { + super(shell); + entries = candidates; + entryTx = entries.stream().map(r->target?r.getTarget():r.getSource()).collect(Collectors.toCollection(ArrayList::new)); + } + +public ITxRelation open() { + Shell parent = getParent(); + Shell dialog = new Shell(parent, SWT.SHEET | SWT.APPLICATION_MODAL); + dialog.setMinimumSize(10, 10); + + RowLayout rowLayout = new RowLayout(SWT.VERTICAL); + //rowLayout.fill = true; // Overriding default values. + rowLayout.marginWidth=3; + rowLayout.marginHeight=0; + rowLayout.marginLeft = 3; + rowLayout.marginTop = 0; + rowLayout.marginRight = 3; + rowLayout.marginBottom = 0; + dialog.setLayout(rowLayout); + final Label lbl = new Label(dialog,SWT.NONE); + lbl.setText("Select one:"); + final List list = new List (dialog, SWT.NONE); + for (ITx iTx : entryTx) { + list.add ("#tx" + iTx.getId()+" ("+iTx.getStream().getFullName()+")"); + } + list.addListener (SWT.Selection, e -> { + int selection = list.getSelectionIndex(); + if(selection>=0) { + selected=entries.get(selection); + dialog.close(); + } + }); + final Button bt = new Button(dialog, SWT.PUSH | SWT.RIGHT); + bt.setText("Dismiss"); + bt.setAlignment(SWT.CENTER); + bt.addSelectionListener(widgetSelectedAdapter(e -> dialog.close())); + dialog.pack(); + dialog.open(); + Display display = parent.getDisplay(); + while (!dialog.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + return selected; + } +} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java new file mode 100644 index 0000000..f95173b --- /dev/null +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -0,0 +1,244 @@ +package com.minres.scviewer.database.swt.internal; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.MouseTrackAdapter; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.Widget; + +import com.minres.scviewer.database.swt.Constants; +import com.minres.scviewer.database.swt.ToolTipHelpTextProvider; +import com.minres.scviewer.database.swt.ToolTipTableContentProvider; + +class ToolTipHandler { + + private Shell parentShell; + private Shell tipShell; + private Label tipLabelText; + private Table tipTable; + private Widget tipWidget; // widget this tooltip is hovering over + private Point tipPosition; // the position being hovered over + + private final TableColumn[] columns; + + private static final int hoverYOffset = 1; + + private static final String[] COLUMN_NAMES = { "Name", "Value"}; + + + private static final int MAX_CHARS = 48; + // The names of the first 32 characters + private Color[] colors = new Color[MAX_CHARS]; + + /** + * Creates a new tooltip handler + * + * @param parent the parent Shell + */ + public ToolTipHandler(Shell parent) { + final Display display = parent.getDisplay(); + this.parentShell = parent; + + tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); + GridLayout gridLayout = new GridLayout(); + gridLayout.numColumns = 1; + gridLayout.marginWidth = 2; + gridLayout.marginHeight = 2; + tipShell.setLayout(gridLayout); + + tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + + tipLabelText = new Label(tipShell, SWT.NONE); + tipLabelText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + tipLabelText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + tipLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |GridData.VERTICAL_ALIGN_CENTER)); + + final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); + tipTable = new Table(tipShell, SWT.NONE); + tipTable.setHeaderVisible(true); + tipTable.setLinesVisible(true); + tipTable.setFont(font); + + columns = createColumns(tipTable); + + tipTable.setRedraw(false); + for (int i = 0; i < MAX_CHARS; i++) { + // Create a background color for this row + colors[i] = new Color(tipTable.getDisplay(), 255 - i, 127 + i, i); + + // Create the row in the table by creating + // a TableItem and setting text for each + // column + int c = 0; + TableItem item = new TableItem(tipTable, SWT.NONE); + item.setText(c++, String.valueOf((char) i)); + item.setText(c++, String.valueOf(i)); + item.setBackground(colors[i]); + } + // Now that we've set the text into the columns, + // we call pack() on each one to size it to the + // contents. + for (int i = 0, n = columns.length; i < n; i++) + columns[i].pack(); + // Set redraw back to true so that the table + // will paint appropriately + tipTable.setRedraw(true); + + } + + private TableColumn[] createColumns(Table table) { + TableColumn[] columns = new TableColumn[COLUMN_NAMES.length]; + for (int i = 0, n = columns.length; i < n; i++) { + columns[i] = new TableColumn(table, SWT.LEFT); + columns[i].setText(COLUMN_NAMES[i]); + } + return columns; + } + + /** + * Enables customized hover help for a specified control + * + * @control the control on which to enable hoverhelp + */ + public void activateHoverHelp(final Control control) { + /* + * Get out of the way if we attempt to activate the control underneath the tooltip + */ + control.addMouseListener(MouseListener.mouseDownAdapter(e -> { + if (tipShell.isVisible()) + tipShell.setVisible(false); + })); + /* + * get out of the way if we move the mouse + */ + control.addMouseMoveListener(new MouseMoveListener() { + @Override + public void mouseMove(MouseEvent e) { + if (tipShell.isVisible()) + tipShell.setVisible(false); + } + + }); + /* + * Trap hover events to pop-up tooltip + */ + control.addMouseTrackListener(new MouseTrackAdapter () { + @Override + public void mouseExit(MouseEvent e) { + if (tipShell.isVisible()) tipShell.setVisible(false); + tipWidget = null; + } + @Override + public void mouseHover (MouseEvent event) { + Point pt = new Point (event.x, event.y); + Widget widget = event.widget; + if (widget instanceof ToolBar) { + ToolBar w = (ToolBar) widget; + widget = w.getItem (pt); + } + if (widget instanceof Table) { + Table w = (Table) widget; + widget = w.getItem (pt); + } + if (widget instanceof Tree) { + Tree w = (Tree) widget; + widget = w.getItem (pt); + } + if (widget == null) { + tipShell.setVisible(false); + tipWidget = null; + return; + } + if (widget == tipWidget && tipShell.isVisible()) return; + tipWidget = widget; + tipPosition = control.toDisplay(pt); + boolean showDialog = false; + Object o = widget.getData(Constants.CONTENT_PROVIDER_TAG); + if(o != null) { + ToolTipTableContentProvider provider = ((ToolTipTableContentProvider)o).initialize(widget, pt); + tipLabelText.setText(provider.getTableTitle()); + tipTable.setRedraw(false); + tipTable.removeAll(); + for (String[] strings : provider.getTableContent()) { + if(strings.length>0) { + showDialog=true; + TableItem item = new TableItem(tipTable, SWT.NONE); + item.setText(0, strings[0]); + if(strings.length>1) + item.setText(1, strings[1]); + } + } + for (int i = 0, n = columns.length; i < n; i++) + columns[i].pack(); + tipTable.setRedraw(true); + tipTable.setVisible(true); + } else { + tipTable.setVisible(false); + } + String text = (String) widget.getData(Constants.TEXT_PROVIDER_TAG); + if(text != null) { + tipLabelText.setText(text != null ? text : "Hover test should go here"); + showDialog=true; + } + if(showDialog) { + tipShell.pack(); + setHoverLocation(tipShell, tipPosition); + tipShell.setVisible(true); + } + } + }); + + /* + * Trap F1 Help to pop up a custom help box + */ + control.addHelpListener(event -> { + if (tipWidget == null) return; + ToolTipHelpTextProvider handler = (ToolTipHelpTextProvider)tipWidget.getData(Constants.HELP_PROVIDER_TAG); + if (handler == null) return; + String text = handler.getHelpText(tipWidget); + if (text == null) return; + + if (tipShell.isVisible()) { + tipShell.setVisible(false); + Shell helpShell = new Shell(parentShell, SWT.SHELL_TRIM); + helpShell.setLayout(new FillLayout()); + Label label = new Label(helpShell, SWT.NONE); + label.setText(text); + helpShell.pack(); + setHoverLocation(helpShell, tipPosition); + helpShell.open(); + } + }); + } + + /** + * Sets the location for a hovering shell + * @param shell the object that is to hover + * @param position the position of a widget to hover over + * @return the top-left location for a hovering box + */ + private void setHoverLocation(Shell shell, Point position) { + Rectangle displayBounds = shell.getDisplay().getBounds(); + Rectangle shellBounds = shell.getBounds(); + shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0); + shellBounds.y = Math.max(Math.min(position.y + hoverYOffset, displayBounds.height - shellBounds.height), 0); + shell.setBounds(shellBounds); + } +} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java index 06687bc..dd29137 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformCanvas.java @@ -426,7 +426,7 @@ public class WaveformCanvas extends Canvas{ } } - public List getClicked(Point point) { + public List getElementsAt(Point point) { LinkedList result=new LinkedList<>(); for (IPainter p : Lists.reverse(painterList)) { if (p instanceof TrackAreaPainter) { diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java index 7f0654f..7cc3267 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/WaveformViewer.java @@ -15,6 +15,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.text.DecimalFormat; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -24,6 +25,7 @@ import java.util.Map.Entry; import java.util.NavigableMap; import java.util.NoSuchElementException; import java.util.TreeMap; +import java.util.stream.Collectors; import org.eclipse.core.runtime.ListenerList; import org.eclipse.jface.util.LocalSelectionTransfer; @@ -97,7 +99,7 @@ public class WaveformViewer implements IWaveformViewer { private PropertyChangeSupport pcs; - static final DecimalFormat df = new DecimalFormat("#.00####"); + static final DecimalFormat df = new DecimalFormat("#0.00####"); private ITx currentTxSelection; @@ -115,6 +117,8 @@ public class WaveformViewer implements IWaveformViewer { final WaveformCanvas waveformCanvas; + final ToolTipHandler toolTipHandler; + private boolean revealSelected=false; private Composite top; @@ -159,7 +163,7 @@ public class WaveformViewer implements IWaveformViewer { down=true; if((e.stateMask&SWT.MODIFIER_MASK)!=0) return; //don't react on modifier if (e.button == 1) { - initialSelected = waveformCanvas.getClicked(start); + initialSelected = waveformCanvas.getElementsAt(start); } else if (e.button == 3) { Menu topMenu= top.getMenu(); if(topMenu!=null) topMenu.setVisible(true); @@ -248,7 +252,7 @@ public class WaveformViewer implements IWaveformViewer { protected long snapOffsetToEvent(Point p) { long time= waveformCanvas.getTimeForOffset(p.x); long scaling=5*waveformCanvas.getScaleFactor(); - for(Object o:waveformCanvas.getClicked(p)){ + for(Object o:waveformCanvas.getElementsAt(p)){ Entry floorEntry=null, ceilEntry=null; if(o instanceof TrackEntry){ TrackEntry entry = (TrackEntry) o; @@ -417,6 +421,9 @@ public class WaveformViewer implements IWaveformViewer { createStreamDropTarget(valueList); createWaveformDragSource(waveformCanvas); createWaveformDropTarget(waveformCanvas); + + toolTipHandler = new ToolTipHandler(parent.getShell()); + toolTipHandler.activateHoverHelp(waveformCanvas); } private Composite createTextPane(SashForm leftSash, String text) { @@ -809,25 +816,41 @@ public class WaveformViewer implements IWaveformViewer { } else { if (direction == GotoDirection.NEXT) { Collection outRel=currentTxSelection.getOutgoingRelations(); - for(ITxRelation rel:outRel){ - if(relationType.equals(rel.getRelationType())){ - setSelection(new StructuredSelection(rel.getTarget()), true); - return; - } - } + ITxRelation tx = selectTxToNavigateTo(outRel, relationType, true); + if(tx!=null) setSelection(new StructuredSelection(tx.getTarget()), true); } else if (direction == GotoDirection.PREV) { Collection inRel=currentTxSelection.getIncomingRelations(); - for(ITxRelation rel:inRel){ - if(relationType.equals(rel.getRelationType())){ - setSelection(new StructuredSelection(rel.getSource()), true); - return; - } - } + ITxRelation tx = selectTxToNavigateTo(inRel, relationType, false); + if(tx!=null) setSelection(new StructuredSelection(tx.getSource()), true); } } } } + private ITxRelation selectTxToNavigateTo(Collection rel, RelationType relationType, boolean target) { + ArrayList candidates = rel.stream().filter(r -> relationType.equals(r.getRelationType())).collect(Collectors.toCollection(ArrayList::new)); + //new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open(); + switch (candidates.size()) { + case 0: return null; + case 1: return candidates.get(0); + default: + ArrayList visibleCandidates = candidates.stream().filter(r -> streamsVisible(r)).collect(Collectors.toCollection(ArrayList::new)); + if(visibleCandidates.size()==0) { + return new RelSelectionDialog(waveformCanvas.getShell(), candidates, target).open(); + } else if(visibleCandidates.size()==1) { + return visibleCandidates.size()==1?visibleCandidates.get(0):null; + } else { + return new RelSelectionDialog(waveformCanvas.getShell(), visibleCandidates, target).open(); + } + } + } + + private boolean streamsVisible(ITxRelation relation) { + final ITxStream src = relation.getSource().getStream(); + final ITxStream tgt = relation.getTarget().getStream(); + return streams.stream().anyMatch(x -> x.waveform == src) && streams.stream().anyMatch(x -> x.waveform == tgt); + } + /* (non-Javadoc) * @see com.minres.scviewer.database.swt.IWaveformPanel#moveCursor(com.minres.scviewer.database.swt.GotoDirection) */ @@ -1130,6 +1153,10 @@ public class WaveformViewer implements IWaveformViewer { return null; } + public List getElementsAt(Point pt){ + return waveformCanvas.getElementsAt(pt); + } + private void createWaveformDragSource(final Canvas canvas) { Transfer[] types = new Transfer[] { LocalSelectionTransfer.getTransfer() }; DragSource dragSource = new DragSource(canvas, DND.DROP_MOVE); @@ -1137,7 +1164,7 @@ public class WaveformViewer implements IWaveformViewer { dragSource.addDragListener(new DragSourceAdapter() { public void dragStart(DragSourceEvent event) { event.doit = false; - List clicked = waveformCanvas.getClicked(new Point(event.x, event.y)); + List clicked = waveformCanvas.getElementsAt(new Point(event.x, event.y)); for(Object o:clicked){ if(o instanceof CursorPainter){ LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(o)); @@ -1150,7 +1177,7 @@ public class WaveformViewer implements IWaveformViewer { public void dragSetData(DragSourceEvent event) { if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { - event.data=waveformCanvas.getClicked(new Point(event.x, event.y)); + event.data=waveformCanvas.getElementsAt(new Point(event.x, event.y)); } } }); diff --git a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java index 6575cfc..77ced9b 100644 --- a/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java +++ b/com.minres.scviewer.database.ui/src/com/minres/scviewer/database/ui/IWaveformViewer.java @@ -18,6 +18,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Control; @@ -62,6 +63,8 @@ public interface IWaveformViewer extends PropertyChangeListener, ISelectionProvi public TrackEntry getEntryForStream(IWaveform source); + public List getElementsAt(Point pt); + public void moveSelectedTrack(int i); public void setHighliteRelation(RelationType relationType); diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 3fee919..2018fcc 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -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", diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index a0c8e84..2fb3288 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -1,7 +1,7 @@ 4.0.0 com.minres.scviewer.e4.application - 2.3.0-SNAPSHOT + 2.4.0-SNAPSHOT com.minres.scviewer com.minres.scviewer.parent diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java index bb39838..a562c1e 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/TransactionDetails.java @@ -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 states) { @@ -294,7 +294,7 @@ public class TransactionDetails { ret.add(treeItem.getItemCount()>0?treeItem.getExpanded():true); return ret; } - + private int getTopItemHier(ArrayList names){ int indexInParent=-1; TreeItem obj = treeViewer.getTree().getTopItem(); @@ -314,7 +314,7 @@ public class TransactionDetails { } return indexInParent; } - + private void setTopItemFromHier(ArrayList 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 diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 5495e59..ef059fa 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -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 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 getTableContent() { + final ArrayList 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) From cea11743ebd827b3cdfea81012f22f4f7d76f10d Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 07:31:14 +0100 Subject: [PATCH 03/10] clean up of ToolTip handler --- .../database/swt/internal/ToolTipHandler.java | 156 +++++++----------- 1 file changed, 64 insertions(+), 92 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index f95173b..27381fe 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -3,9 +3,9 @@ package com.minres.scviewer.database.swt.internal; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseEvent; import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseMoveListener; import org.eclipse.swt.events.MouseTrackAdapter; -import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; @@ -29,87 +29,63 @@ import com.minres.scviewer.database.swt.ToolTipTableContentProvider; class ToolTipHandler { + private final Display display; private Shell parentShell; - private Shell tipShell; - private Label tipLabelText; - private Table tipTable; + private Shell shell; + private Label label; + private Table table; + private TableColumn nameCol; + private TableColumn valueCol; + private Widget tipWidget; // widget this tooltip is hovering over private Point tipPosition; // the position being hovered over - private final TableColumn[] columns; - private static final int hoverYOffset = 1; - private static final String[] COLUMN_NAMES = { "Name", "Value"}; - - - private static final int MAX_CHARS = 48; - // The names of the first 32 characters - private Color[] colors = new Color[MAX_CHARS]; - /** * Creates a new tooltip handler * * @param parent the parent Shell */ public ToolTipHandler(Shell parent) { - final Display display = parent.getDisplay(); + display = parent.getDisplay(); this.parentShell = parent; - tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL); + shell = new Shell(parent, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1; gridLayout.marginWidth = 2; gridLayout.marginHeight = 2; - tipShell.setLayout(gridLayout); + shell.setLayout(gridLayout); - tipShell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - tipLabelText = new Label(tipShell, SWT.NONE); - tipLabelText.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - tipLabelText.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - tipLabelText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |GridData.VERTICAL_ALIGN_CENTER)); + label = new Label(shell, SWT.NONE); + label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |GridData.VERTICAL_ALIGN_CENTER)); final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); - tipTable = new Table(tipShell, SWT.NONE); - tipTable.setHeaderVisible(true); - tipTable.setLinesVisible(true); - tipTable.setFont(font); + table = new Table(shell, SWT.NONE); + table.setHeaderVisible(false); + table.setLinesVisible(true); + table.setFont(font); + table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + nameCol = new TableColumn(table, SWT.LEFT); + nameCol.setText("Name"); + valueCol = new TableColumn(table, SWT.LEFT); + nameCol.setText("Value"); - columns = createColumns(tipTable); - - tipTable.setRedraw(false); - for (int i = 0; i < MAX_CHARS; i++) { - // Create a background color for this row - colors[i] = new Color(tipTable.getDisplay(), 255 - i, 127 + i, i); - - // Create the row in the table by creating - // a TableItem and setting text for each - // column - int c = 0; - TableItem item = new TableItem(tipTable, SWT.NONE); - item.setText(c++, String.valueOf((char) i)); - item.setText(c++, String.valueOf(i)); - item.setBackground(colors[i]); - } - // Now that we've set the text into the columns, - // we call pack() on each one to size it to the - // contents. - for (int i = 0, n = columns.length; i < n; i++) - columns[i].pack(); - // Set redraw back to true so that the table - // will paint appropriately - tipTable.setRedraw(true); - - } - - private TableColumn[] createColumns(Table table) { - TableColumn[] columns = new TableColumn[COLUMN_NAMES.length]; - for (int i = 0, n = columns.length; i < n; i++) { - columns[i] = new TableColumn(table, SWT.LEFT); - columns[i].setText(COLUMN_NAMES[i]); - } - return columns; + shell.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + Rectangle area = shell.getClientArea(); + valueCol.setWidth(area.width - nameCol.getWidth()); + } + }); } /** @@ -122,27 +98,16 @@ class ToolTipHandler { * Get out of the way if we attempt to activate the control underneath the tooltip */ control.addMouseListener(MouseListener.mouseDownAdapter(e -> { - if (tipShell.isVisible()) - tipShell.setVisible(false); + if (shell.isVisible()) + shell.setVisible(false); })); - /* - * get out of the way if we move the mouse - */ - control.addMouseMoveListener(new MouseMoveListener() { - @Override - public void mouseMove(MouseEvent e) { - if (tipShell.isVisible()) - tipShell.setVisible(false); - } - - }); /* * Trap hover events to pop-up tooltip */ control.addMouseTrackListener(new MouseTrackAdapter () { @Override public void mouseExit(MouseEvent e) { - if (tipShell.isVisible()) tipShell.setVisible(false); + if (shell.isVisible()) shell.setVisible(false); tipWidget = null; } @Override @@ -162,45 +127,47 @@ class ToolTipHandler { widget = w.getItem (pt); } if (widget == null) { - tipShell.setVisible(false); + shell.setVisible(false); tipWidget = null; return; } - if (widget == tipWidget && tipShell.isVisible()) return; + Point newPos = control.toDisplay(pt); + if(shell.isFocusControl()) return; + if (widget == tipWidget && tipPosition.equals(newPos) && shell.isVisible()) return; tipWidget = widget; - tipPosition = control.toDisplay(pt); + tipPosition = newPos; boolean showDialog = false; Object o = widget.getData(Constants.CONTENT_PROVIDER_TAG); if(o != null) { ToolTipTableContentProvider provider = ((ToolTipTableContentProvider)o).initialize(widget, pt); - tipLabelText.setText(provider.getTableTitle()); - tipTable.setRedraw(false); - tipTable.removeAll(); + label.setText(provider.getTableTitle()); + table.setRedraw(false); + table.removeAll(); for (String[] strings : provider.getTableContent()) { if(strings.length>0) { showDialog=true; - TableItem item = new TableItem(tipTable, SWT.NONE); + TableItem item = new TableItem(table, SWT.NONE); item.setText(0, strings[0]); if(strings.length>1) item.setText(1, strings[1]); } } - for (int i = 0, n = columns.length; i < n; i++) - columns[i].pack(); - tipTable.setRedraw(true); - tipTable.setVisible(true); + nameCol.pack(); + valueCol.pack(); + table.setRedraw(true); + table.setVisible(true); } else { - tipTable.setVisible(false); + table.setVisible(false); } String text = (String) widget.getData(Constants.TEXT_PROVIDER_TAG); if(text != null) { - tipLabelText.setText(text != null ? text : "Hover test should go here"); + label.setText(text != null ? text : "Hover test should go here"); showDialog=true; } if(showDialog) { - tipShell.pack(); - setHoverLocation(tipShell, tipPosition); - tipShell.setVisible(true); + shell.pack(); + setHoverLocation(shell, tipPosition); + shell.setVisible(true); } } }); @@ -215,8 +182,8 @@ class ToolTipHandler { String text = handler.getHelpText(tipWidget); if (text == null) return; - if (tipShell.isVisible()) { - tipShell.setVisible(false); + if (shell.isVisible()) { + shell.setVisible(false); Shell helpShell = new Shell(parentShell, SWT.SHELL_TRIM); helpShell.setLayout(new FillLayout()); Label label = new Label(helpShell, SWT.NONE); @@ -226,6 +193,11 @@ class ToolTipHandler { helpShell.open(); } }); +// control.addKeyListener(KeyListener.keyPressedAdapter( e-> { +// if (e.keyCode == SWT.F2 && shell.isVisible()) { +// shell.setFocus(); +// } +// })); } /** From 14ac6654b94d143ff67dad82e5b2ae6b754231e4 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 08:42:35 +0100 Subject: [PATCH 04/10] refactor ToolTipHandler to allow more control over content --- .../scviewer/database/swt/Constants.java | 1 - .../database/swt/ToolTipContentProvider.java | 10 ++ .../swt/ToolTipTableContentProvider.java | 21 --- .../database/swt/internal/ToolTipHandler.java | 163 +++++------------- .../e4/application/parts/WaveformViewer.java | 97 +++++++---- 5 files changed, 124 insertions(+), 168 deletions(-) create mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipContentProvider.java delete mode 100644 com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java index f2142fc..4abb67c 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/Constants.java @@ -7,7 +7,6 @@ public class Constants { public static final int[] unitMultiplier={1, 3, 10, 30, 100, 300}; public static final String CONTENT_PROVIDER_TAG = "TOOLTIP_CONTENT_PROVIDER"; - public static final String TEXT_PROVIDER_TAG = "TOOLTIP_TEXT_PROVIDER"; public static final String HELP_PROVIDER_TAG = "TOOLTIP_HELP_PROVIDER"; } diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipContentProvider.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipContentProvider.java new file mode 100644 index 0000000..6d46a31 --- /dev/null +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipContentProvider.java @@ -0,0 +1,10 @@ +package com.minres.scviewer.database.swt; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; + +public interface ToolTipContentProvider { + + public boolean createContent(Composite parent, Point pt); + +} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java deleted file mode 100644 index 8a9daee..0000000 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/ToolTipTableContentProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.minres.scviewer.database.swt; - -import java.util.List; - -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Widget; - -public interface ToolTipTableContentProvider { - - public ToolTipTableContentProvider initialize(Widget widget, Point pt); - - public String getTableTitle(); - /** - * Get tool tip table content - * @param widget the widget that is under help - * @oaram pt the point where the mouse cursor is located - * @return a list of string arrays of size 2 (content & value) - */ - public List getTableContent(); - -} \ No newline at end of file diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index 27381fe..23dd0d3 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -12,9 +12,12 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -24,11 +27,11 @@ import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Widget; import com.minres.scviewer.database.swt.Constants; +import com.minres.scviewer.database.swt.ToolTipContentProvider; import com.minres.scviewer.database.swt.ToolTipHelpTextProvider; -import com.minres.scviewer.database.swt.ToolTipTableContentProvider; class ToolTipHandler { - + private final Display display; private Shell parentShell; private Shell shell; @@ -36,12 +39,12 @@ class ToolTipHandler { private Table table; private TableColumn nameCol; private TableColumn valueCol; - + private Widget tipWidget; // widget this tooltip is hovering over private Point tipPosition; // the position being hovered over private static final int hoverYOffset = 1; - + /** * Creates a new tooltip handler * @@ -49,43 +52,7 @@ class ToolTipHandler { */ public ToolTipHandler(Shell parent) { display = parent.getDisplay(); - this.parentShell = parent; - - shell = new Shell(parent, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - gridLayout.marginWidth = 2; - gridLayout.marginHeight = 2; - shell.setLayout(gridLayout); - - shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - - label = new Label(shell, SWT.NONE); - label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL |GridData.VERTICAL_ALIGN_CENTER)); - - final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); - table = new Table(shell, SWT.NONE); - table.setHeaderVisible(false); - table.setLinesVisible(true); - table.setFont(font); - table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); - table.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - nameCol = new TableColumn(table, SWT.LEFT); - nameCol.setText("Name"); - valueCol = new TableColumn(table, SWT.LEFT); - nameCol.setText("Value"); - - shell.addPaintListener(new PaintListener() { - @Override - public void paintControl(PaintEvent e) { - Rectangle area = shell.getClientArea(); - valueCol.setWidth(area.width - nameCol.getWidth()); - } - }); + parentShell = parent; } /** @@ -94,83 +61,45 @@ class ToolTipHandler { * @control the control on which to enable hoverhelp */ public void activateHoverHelp(final Control control) { - /* - * Get out of the way if we attempt to activate the control underneath the tooltip - */ - control.addMouseListener(MouseListener.mouseDownAdapter(e -> { - if (shell.isVisible()) - shell.setVisible(false); - })); - /* - * Trap hover events to pop-up tooltip - */ - control.addMouseTrackListener(new MouseTrackAdapter () { + Listener listener = new Listener () { + Shell tip = null; @Override - public void mouseExit(MouseEvent e) { - if (shell.isVisible()) shell.setVisible(false); - tipWidget = null; - } - @Override - public void mouseHover (MouseEvent event) { - Point pt = new Point (event.x, event.y); - Widget widget = event.widget; - if (widget instanceof ToolBar) { - ToolBar w = (ToolBar) widget; - widget = w.getItem (pt); + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Dispose: + case SWT.KeyDown: + case SWT.MouseMove: { + if (tip == null) break; + tip.dispose (); + tip = null; + label = null; + break; } - if (widget instanceof Table) { - Table w = (Table) widget; - widget = w.getItem (pt); - } - if (widget instanceof Tree) { - Tree w = (Tree) widget; - widget = w.getItem (pt); - } - if (widget == null) { - shell.setVisible(false); - tipWidget = null; - return; - } - Point newPos = control.toDisplay(pt); - if(shell.isFocusControl()) return; - if (widget == tipWidget && tipPosition.equals(newPos) && shell.isVisible()) return; - tipWidget = widget; - tipPosition = newPos; - boolean showDialog = false; - Object o = widget.getData(Constants.CONTENT_PROVIDER_TAG); - if(o != null) { - ToolTipTableContentProvider provider = ((ToolTipTableContentProvider)o).initialize(widget, pt); - label.setText(provider.getTableTitle()); - table.setRedraw(false); - table.removeAll(); - for (String[] strings : provider.getTableContent()) { - if(strings.length>0) { - showDialog=true; - TableItem item = new TableItem(table, SWT.NONE); - item.setText(0, strings[0]); - if(strings.length>1) - item.setText(1, strings[1]); - } + case SWT.MouseHover: { + Object o = control.getData(Constants.CONTENT_PROVIDER_TAG); + if(o != null && o instanceof ToolTipContentProvider) { + ToolTipContentProvider provider = ((ToolTipContentProvider)o); + Point pt = new Point (event.x, event.y); + tipPosition = control.toDisplay(pt); + if (tip != null && !tip.isDisposed ()) tip.dispose (); + tip = new Shell (parentShell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); + tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND)); + RowLayout layout=new RowLayout(SWT.VERTICAL); + layout.fill=true; + tip.setLayout(layout); + boolean visible = provider.createContent(tip, pt); + tip.pack(); + setHoverLocation(tip, tipPosition); + tip.setVisible (visible); } - nameCol.pack(); - valueCol.pack(); - table.setRedraw(true); - table.setVisible(true); - } else { - table.setVisible(false); } - String text = (String) widget.getData(Constants.TEXT_PROVIDER_TAG); - if(text != null) { - label.setText(text != null ? text : "Hover test should go here"); - showDialog=true; - } - if(showDialog) { - shell.pack(); - setHoverLocation(shell, tipPosition); - shell.setVisible(true); } } - }); + }; + control.addListener (SWT.Dispose, listener); + control.addListener (SWT.KeyDown, listener); + control.addListener (SWT.MouseMove, listener); + control.addListener (SWT.MouseHover, listener); /* * Trap F1 Help to pop up a custom help box @@ -193,11 +122,11 @@ class ToolTipHandler { helpShell.open(); } }); -// control.addKeyListener(KeyListener.keyPressedAdapter( e-> { -// if (e.keyCode == SWT.F2 && shell.isVisible()) { -// shell.setFocus(); -// } -// })); + // control.addKeyListener(KeyListener.keyPressedAdapter( e-> { + // if (e.keyCode == SWT.F2 && shell.isVisible()) { + // shell.setFocus(); + // } + // })); } /** diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index ef059fa..f1abb83 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -65,13 +65,21 @@ 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.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; import com.minres.scviewer.database.DataType; @@ -84,7 +92,8 @@ 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.ToolTipContentProvider; +import com.minres.scviewer.database.swt.ToolTipHelpTextProvider; import com.minres.scviewer.database.swt.WaveformViewerFactory; import com.minres.scviewer.database.ui.GotoDirection; import com.minres.scviewer.database.ui.ICursor; @@ -372,35 +381,41 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.addDisposeListener(this); - waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipTableContentProvider() { - private List res; - + waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipHelpTextProvider() { @Override - public ToolTipTableContentProvider initialize(Widget widget, Point pt) { - res = waveformPane.getElementsAt(pt); - return this; + public String getHelpText(Widget widget) { + return "Waveform pane: press F2 to set the focus to the tooltip"; } - + }); + waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipContentProvider() { @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 ""; - } + public boolean createContent(Composite parent, Point pt) { + List res = waveformPane.getElementsAt(pt); + if(res.size()>0) + if(res.get(0) instanceof ITx) { + ITx tx = (ITx)res.get(0); + final Display display = parent.getDisplay(); + final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); + + final Label label = new Label(parent, SWT.NONE); + label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + label.setText(tx.toString()); + label.setFont(font); + + final Table table = new Table(parent, SWT.NONE); + table.setHeaderVisible(true); + table.setLinesVisible(true); + table.setFont(font); + table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + table.setRedraw(false); + + final TableColumn nameCol = new TableColumn(table, SWT.LEFT); + nameCol.setText("Attribute"); + final TableColumn valueCol = new TableColumn(table, SWT.LEFT); + valueCol.setText("Value"); - @Override - public List getTableContent() { - final ArrayList 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)) { @@ -408,11 +423,35 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis value += " [0x"+Long.toHexString(Long.parseLong(iTxAttribute.getValue().toString()))+"]"; } catch(NumberFormatException e) { } } - ret.add(new String[]{iTxAttribute.getName(), value}); + TableItem item = new TableItem(table, SWT.NONE); + item.setText(0, iTxAttribute.getName()); + item.setText(1, value); } + nameCol.pack(); + valueCol.pack(); + table.setRedraw(true); + + parent.addPaintListener(new PaintListener() { + @Override + public void paintControl(PaintEvent e) { + Rectangle area = parent.getClientArea(); + valueCol.setWidth(area.width - nameCol.getWidth()); + } + }); + return true; + } else if(res.get(0) instanceof TrackEntry) { + TrackEntry te = (TrackEntry)res.get(0); + final Display display = parent.getDisplay(); + final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); + + final Label label = new Label(parent, SWT.NONE); + label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + label.setText(te.waveform.getFullName()); + label.setFont(font); + return true; } - } - return ret; + return false; } }); } From 5933bcd5120e40d15b75400b27a438f8cf70a9fd Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 11:30:30 +0100 Subject: [PATCH 05/10] configure the hover visibility from UI --- .../database/swt/internal/ToolTipHandler.java | 39 ++++++------ .../Application.e4xmi | 13 +++- .../META-INF/MANIFEST.MF | 56 +++++++++--------- .../icons/lightbulb.png | Bin 0 -> 782 bytes .../icons/magifier_zoom_out.png | Bin 0 -> 657 bytes .../icons/magnifier.png | Bin 0 -> 615 bytes .../icons/magnifier_zoom_in.png | Bin 0 -> 680 bytes .../scviewer/e4/application/Messages.java | 1 + .../e4/application/handlers/EnableHover.java | 49 +++++++++++++++ .../e4/application/messages.properties | 1 + .../e4/application/parts/AboutDialog.java | 7 +-- .../e4/application/parts/WaveformViewer.java | 8 ++- .../preferences/DefaultValuesInitializer.java | 1 + .../preferences/PreferenceConstants.java | 3 + .../preferences/SCViewerPreferencesPage.java | 2 + 15 files changed, 120 insertions(+), 60 deletions(-) create mode 100644 com.minres.scviewer.e4.application/icons/lightbulb.png create mode 100755 com.minres.scviewer.e4.application/icons/magifier_zoom_out.png create mode 100755 com.minres.scviewer.e4.application/icons/magnifier.png create mode 100755 com.minres.scviewer.e4.application/icons/magnifier_zoom_in.png create mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index 23dd0d3..087e0f6 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -1,17 +1,9 @@ package com.minres.scviewer.database.swt.internal; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.MouseEvent; -import org.eclipse.swt.events.MouseListener; -import org.eclipse.swt.events.MouseTrackAdapter; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -21,9 +13,6 @@ import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.Widget; import com.minres.scviewer.database.swt.Constants; @@ -35,10 +24,6 @@ class ToolTipHandler { private final Display display; private Shell parentShell; private Shell shell; - private Label label; - private Table table; - private TableColumn nameCol; - private TableColumn valueCol; private Widget tipWidget; // widget this tooltip is hovering over private Point tipPosition; // the position being hovered over @@ -66,13 +51,20 @@ class ToolTipHandler { @Override public void handleEvent (Event event) { switch (event.type) { + case SWT.KeyDown:{ + if (tip != null && tip.isVisible() && event.keyCode == SWT.F2) { + tip.setFocus(); + break; + } + } case SWT.Dispose: - case SWT.KeyDown: - case SWT.MouseMove: { - if (tip == null) break; - tip.dispose (); - tip = null; - label = null; + case SWT.MouseMove: + case SWT.MouseDown: { + if (tip != null){ + tip.dispose (); + tip = null; + tipWidget=null; + } break; } case SWT.MouseHover: { @@ -91,6 +83,8 @@ class ToolTipHandler { tip.pack(); setHoverLocation(tip, tipPosition); tip.setVisible (visible); + if(visible) + tipWidget=event.widget; } } } @@ -98,8 +92,9 @@ class ToolTipHandler { }; control.addListener (SWT.Dispose, listener); control.addListener (SWT.KeyDown, listener); - control.addListener (SWT.MouseMove, listener); + //control.addListener (SWT.MouseMove, listener); control.addListener (SWT.MouseHover, listener); + control.addListener (SWT.MouseDown, listener); /* * Trap F1 Help to pop up a custom help box diff --git a/com.minres.scviewer.e4.application/Application.e4xmi b/com.minres.scviewer.e4.application/Application.e4xmi index 42c316c..66eb04a 100644 --- a/com.minres.scviewer.e4.application/Application.e4xmi +++ b/com.minres.scviewer.e4.application/Application.e4xmi @@ -123,17 +123,22 @@ - + - + - + + + + EnableHover + + @@ -156,6 +161,7 @@ + type:user @@ -286,6 +292,7 @@ + diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index 2018fcc..a5566e3 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -5,34 +5,34 @@ Bundle-SymbolicName: com.minres.scviewer.e4.application;singleton:=true 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", - org.eclipse.swt;bundle-version="3.104.1", - org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100", - org.eclipse.jface;bundle-version="3.11.0", - org.eclipse.e4.ui.services;bundle-version="1.2.0", - org.eclipse.e4.ui.workbench;bundle-version="1.3.0", - org.eclipse.e4.core.di;bundle-version="1.5.0", - org.eclipse.e4.ui.di;bundle-version="1.1.0", - org.eclipse.e4.core.contexts;bundle-version="1.4.0", - com.minres.scviewer.database.ui.swt;bundle-version="1.0.0", - com.minres.scviewer.database.ui, - com.minres.scviewer.database;bundle-version="1.0.0", - org.eclipse.equinox.ds;bundle-version="1.4.300", - org.eclipse.equinox.util;bundle-version="1.0.500", - org.eclipse.osgi.services;bundle-version="3.5.0", - org.eclipse.e4.core.services;bundle-version="2.0.0", - org.eclipse.osgi.services;bundle-version="3.5.0", - org.eclipse.core.jobs, - org.eclipse.osgi, - com.google.guava, - org.eclipse.equinox.preferences, - org.eclipse.core.expressions, - org.eclipse.e4.core.commands;bundle-version="0.11.0", - org.eclipse.e4.ui.workbench.addons.swt, - com.opcoach.e4.preferences, - org.eclipse.e4.core.di.extensions, - org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0" + org.eclipse.core.runtime;bundle-version="3.11.1", + org.eclipse.swt;bundle-version="3.104.1", + org.eclipse.e4.ui.model.workbench;bundle-version="1.1.100", + org.eclipse.jface;bundle-version="3.11.0", + org.eclipse.e4.ui.services;bundle-version="1.2.0", + org.eclipse.e4.ui.workbench;bundle-version="1.3.0", + org.eclipse.e4.core.di;bundle-version="1.5.0", + org.eclipse.e4.ui.di;bundle-version="1.1.0", + org.eclipse.e4.core.contexts;bundle-version="1.4.0", + com.minres.scviewer.database.ui.swt;bundle-version="1.0.0", + com.minres.scviewer.database.ui, + com.minres.scviewer.database;bundle-version="1.0.0", + org.eclipse.equinox.ds;bundle-version="1.4.300", + org.eclipse.equinox.util;bundle-version="1.0.500", + org.eclipse.osgi.services;bundle-version="3.5.0", + org.eclipse.e4.core.services;bundle-version="2.0.0", + org.eclipse.osgi.services;bundle-version="3.5.0", + org.eclipse.core.jobs, + org.eclipse.osgi, + com.google.guava, + org.eclipse.equinox.preferences, + org.eclipse.core.expressions, + org.eclipse.e4.core.commands;bundle-version="0.11.0", + org.eclipse.e4.ui.workbench.addons.swt, + com.opcoach.e4.preferences, + org.eclipse.e4.core.di.extensions, + org.eclipse.e4.ui.css.swt.theme;bundle-version="0.10.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.minres.scviewer.database, - javax.inject;version="1.0.0" + javax.inject;version="1.0.0" Automatic-Module-Name: com.minres.scviewer.e4.application diff --git a/com.minres.scviewer.e4.application/icons/lightbulb.png b/com.minres.scviewer.e4.application/icons/lightbulb.png new file mode 100644 index 0000000000000000000000000000000000000000..d22fde8ba46eabd4335e4fa88077e80f96b92d62 GIT binary patch literal 782 zcmV+p1M&QcP)0XYhLR!1P*SpVQi>)dUV<_*6qInHGcnEb zQfX6|c{lO4l#RKaZC-XZ&u-_k%Q@eEE?Qa!_Tt0u@H@}<^E~``A^=3}gr(l4vU*i7 zyV6Lx=4yE7RGGkx6gV71cjvY=iqb#p!ylZn>j-Cf+b>x95wMRT==lzjH$f681f9ze zR{P)>$i_z3RfAovII&B>n%*Ds>XegyS_9EX5sW0f1d*FX&^tjGBX?Rzej4t{=ddW_ z9h>UH!(o9}TURNVdq{y5qM#$E1yaxnNWKtKkRh^p1YA9U=z#4*HY{(h_k{(nnF>pQ znJ2Y6(rFb^z)nJ2pnqIQ&_2v{yl+xxUhm5uO{Q#!J8DY)klFd8VI0S0!CoiyA}k0DS`b78y(oGU6a>AkUK9~n*^7|=kr7cwRFWv6%Z}9bXJxHq zv!bQ7t!|lawm;5>vpILy?iOC&HfG!Hc8BBJ-HKqfMb?WCJa0aq=l6SfssL2|4?ho1 zYF_hZS|)5^i5(2(3eSVtLjTwt+viCU4@P*+9|NQ!zmCYHkC8wnWH2cSOj5$smpmL3 zY1}4f$SympsTgoXWWvkj!KP${W<>az96Yfc0&EV^Sqav$1oSUxqGI6Xq{vddRFu7n z`2LdsHzi;=Dtr$y0$QI$*opyl-1%;k%_tFkSWDaJm;MHp-}I<6Z; z`=uSavTxAsh-+>P#z@O32VYD;@Uw_<1$Q)qo>w&5O)gAWuE2V33*Ucwqps{ny7nxp zX|aTf%a1~AQ*W?v_D-PC*yD@0=#7-ucnX}S5B~d&FdbXR-#fBe_gkP615I1CPtR;N z4-*FwcN*ZjSr5aZ75rZZR34vLukCGEW45>LLezQ{#QvpNP(bBYeXX{uZkgF|xEA`o r)y)eIsC4dIvZ!Ov;+nFL_^*5eZM*&99gNuvOO$0ks zMIj=HnnBRUR?tKXG11rxCU4&7dG4NbuvR2_mEvc)n?Cow;~Wve|KR^>9@p5l)|QB+ z$jmun3q#x>;ss-PW_mnr2MHVzLAl1RW&0?VkixF*4t!St0YVb2wnKdU(kmOHiL;aW zK8Xte%(k>MVGG$E4no6dcNnb>BhVHHGD&1pv4YZ68kE2V03t5#PCEFm7=ad$6)+3B zTCmn*?A?=u(o~ET7~-7g0)ZB=6|lumi4}B}MLgy~Ysy6)Q5%Al7|05&1z3Jpu>cF8 z3?VXs*3<}%h3`5Wld)N2zJnk%Agw<~3k)sPTLFd=F5;d8-bj-09SkQuynfflNcZLN z!^_37fdZvzrq=9~mp*($%mcDRKC&qvaaZuX+C=AT6O*~tHl>0mcP<_q>-z%$xO(@! zYluq5a8VQI$S@4?r*v;gPo!QQ%pX3A#>xx4t=w-L6COWx?aj&`f+!YePsFtj=hOQR zP3=E2j@9L7s8;T^&s?u(Hdpu?CubjMrGn{t_37>9$|AD)QE08weJlKn8|OyjL~7oP zC8mPT`jzuH*Dh^I0048RGafUIT)4H~*m8m>egI0iH=(LB%b@@O002ovPDHLkV1lw0 B3FJNMp+(Bt!=q9U!ZZOlw$c zuAy5i+nTd|<_>NivLu&tYWf+obh7aHN%Hi45`pBR)x`tA#^U98gM4FFC6h~&)aWQw>e5Y84Gj%C?Fa5wL3#v12nvm3<6OafjJt}U((Qj zn8!nMmXr-qoCO7XcZRS8(x9RlIA>F^1(GoPldw}sc)rpQ>IL9yYf!7MN);5mno3dL zFr9-f3^@5I0h2d@QBNW#I`RB4IwvonO1T#W1?;?jrZNjp_!1ar;E|a)8g&BH^;Scq zt%uAgf}pb+yKn5ouFDnCJb}hGpY=s(m>77B`PIn4hUqw48S;@<+#YViwZYT4_>vEC z?=frJc<3Fn+HA3jXTwUklhgJ-dYkmNL^YBTW!uzZM O0000 tags = new LinkedList<>(); + tags.add(TAG_NAME); + List elements = modelService.findElements(application, null, MHandledItem.class, tags ); + // cover initialization stuff, sync it with code + for( MHandledItem hi : elements ){ + hi.setSelected(prefs.getBoolean(PreferenceConstants.SHOW_HOVER, true)); + } + } + + @Execute + public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) { + prefs.putBoolean(PreferenceConstants.SHOW_HOVER, handledItem.isSelected()); + } + +} \ No newline at end of file diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties index 124b0c4..264be16 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/messages.properties @@ -16,6 +16,7 @@ RelationTypeToolControl_0=------------ RelationTypeToolControl_1=Select ResourceManager_0=Wrong decorate corner SCViewerPreferencesPage_0=Check for changed database +SCViewerPreferencesPage_1=Show hover window in waveform StatusBarControl_1=Currently running: StatusBarControl_2=\nLast task: StatusBarControl_3=Currently running: diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java index 7ed8815..d137e59 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/AboutDialog.java @@ -50,9 +50,6 @@ import com.minres.scviewer.e4.application.Messages; */ public class AboutDialog extends Dialog { - /** The product title. */ - private String productTitle=Messages.AboutDialog_0; - /** The copyright text. */ private String copyrightText=Messages.AboutDialog_1; @@ -106,8 +103,8 @@ public class AboutDialog extends Dialog { styledText.setLayoutData(gd_styledText); Version version = Platform.getProduct().getDefiningBundle().getVersion(); String versionString = String.format("%d.%d.%d", version.getMajor(), version.getMinor(), version.getMicro()); - String pt = NLS.bind(Messages.AboutDialog_0, versionString); - styledText.setText(pt+copyrightText); + String productTitle = NLS.bind(Messages.AboutDialog_0, versionString); + styledText.setText(productTitle+copyrightText); styledText.setBackground(white); styledText.setWordWrap(true); styledText.setLeftMargin(5); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index f1abb83..3993103 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -65,13 +65,13 @@ 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.events.FocusListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -381,7 +381,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.addDisposeListener(this); - waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipHelpTextProvider() { + waveformPane.getWaveformControl().setData(Constants.HELP_PROVIDER_TAG, new ToolTipHelpTextProvider() { @Override public String getHelpText(Widget widget) { return "Waveform pane: press F2 to set the focus to the tooltip"; @@ -390,6 +390,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipContentProvider() { @Override public boolean createContent(Composite parent, Point pt) { + if(!prefs.getBoolean(PreferenceConstants.SHOW_HOVER, true)) return false; List res = waveformPane.getElementsAt(pt); if(res.size()>0) if(res.get(0) instanceof ITx) { @@ -438,6 +439,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis valueCol.setWidth(area.width - nameCol.getWidth()); } }); + parent.addFocusListener(FocusListener.focusGainedAdapter(e -> { + table.setFocus(); + })); return true; } else if(res.get(0) instanceof TrackEntry) { TrackEntry te = (TrackEntry)res.get(0); diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index 17afd9b..a2fdd5c 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -67,6 +67,7 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); store.setDefault(PreferenceConstants.DATABASE_RELOAD, true); + store.setDefault(PreferenceConstants.SHOW_HOVER, true); for (WaveformColors c : WaveformColors.values()) { store.setDefault(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java index b9ed912..9a6d057 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferenceConstants.java @@ -21,6 +21,9 @@ public class PreferenceConstants { /** The Constant DATABASE_RELOAD. */ public static final String DATABASE_RELOAD="databaseReload"; //$NON-NLS-1$ + /** The Constant DATABASE_RELOAD. */ + public static final String SHOW_HOVER="showWaveformHover"; //$NON-NLS-1$ + /** The Constant LINE_COLOR. */ public static final String LINE_COLOR="LINE_COLOR"; //$NON-NLS-1$ diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java index ef8f9ab..25005e9 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/SCViewerPreferencesPage.java @@ -36,6 +36,8 @@ public class SCViewerPreferencesPage extends FieldEditorPreferencePage { addField(new BooleanFieldEditor(PreferenceConstants.DATABASE_RELOAD, Messages.SCViewerPreferencesPage_0, getFieldEditorParent())); + addField(new BooleanFieldEditor(PreferenceConstants.SHOW_HOVER, Messages.SCViewerPreferencesPage_1, + getFieldEditorParent())); } From 0cfcc8c1183b8a4c3cbdb8797fa09e3699f57f15 Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 11:31:59 +0100 Subject: [PATCH 06/10] fix identification of SQLite file --- .../com/minres/scviewer/database/sqlite/SQLiteDbLoader.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java b/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java index a6e05ed..d677b73 100644 --- a/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java +++ b/com.minres.scviewer.database.sqlite/src/com/minres/scviewer/database/sqlite/SQLiteDbLoader.java @@ -14,6 +14,7 @@ import java.beans.IntrospectionException; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.sql.SQLException; import java.util.ArrayList; @@ -91,6 +92,8 @@ public class SQLiteDbLoader implements IWaveformDbLoader { if (buffer[i] != x[i]) return false; } catch(FileNotFoundException e) { return false; + } catch(IOException e) { //if an I/O error occurs + return false; } database=new SQLiteDatabase(file.getAbsolutePath()); database.setData("TIMERESOLUTION", 1L); From 9b6908f19382f927b3592e2b1b7f331f7754f13f Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 11:35:29 +0100 Subject: [PATCH 07/10] update product version and removed leveldb --- com.minres.scviewer.e4.product/pom.xml | 2 +- com.minres.scviewer.e4.product/scviewer.product | 3 +-- com.minres.scviewer.parent/pom.xml | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml index effbfb5..b23c351 100644 --- a/com.minres.scviewer.e4.product/pom.xml +++ b/com.minres.scviewer.e4.product/pom.xml @@ -10,7 +10,7 @@ ../com.minres.scviewer.parent com.minres.scviewer.e4.product - 2.3.0-SNAPSHOT + 2.4.0-SNAPSHOT eclipse-repository com.minres.scviewer diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index 6a40894..90c16d6 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -1,7 +1,7 @@ - + @@ -47,7 +47,6 @@ - diff --git a/com.minres.scviewer.parent/pom.xml b/com.minres.scviewer.parent/pom.xml index f7296c1..e8a9fef 100644 --- a/com.minres.scviewer.parent/pom.xml +++ b/com.minres.scviewer.parent/pom.xml @@ -12,7 +12,7 @@ ../com.minres.scviewer.database.sqlite ../com.minres.scviewer.database.text ../com.minres.scviewer.database.vcd - ../com.minres.scviewer.database.leveldb + ../com.minres.scviewer.database.test ../com.minres.scviewer.database.ui ../com.minres.scviewer.database.ui.swt From 767b083a227dc50373b084829234f44d713ffe4c Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 15:17:34 +0100 Subject: [PATCH 08/10] fix preferences storage --- .../database/swt/internal/ToolTipHandler.java | 2 -- .../e4/application/parts/WaveformViewer.java | 20 +++++++++---- .../preferences/DefaultValuesInitializer.java | 28 ++++++++++++------- .../preferences/PreferencesStoreProvider.java | 18 ++++++++++++ .../scviewer.product | 2 +- .../internal/E4PreferenceRegistry.java | 6 +++- 6 files changed, 56 insertions(+), 20 deletions(-) create mode 100644 com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index 087e0f6..d950602 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -11,8 +11,6 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.Widget; import com.minres.scviewer.database.swt.Constants; diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 3993103..c6e871a 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -31,6 +31,7 @@ import javax.annotation.PostConstruct; import javax.inject.Inject; import javax.inject.Named; +import org.eclipse.core.internal.preferences.InstancePreferences; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; @@ -41,9 +42,11 @@ import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.JobChangeAdapter; import org.eclipse.core.runtime.jobs.JobGroup; +import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.di.annotations.Optional; import org.eclipse.e4.core.di.extensions.Preference; import org.eclipse.e4.core.services.events.IEventBroker; @@ -81,6 +84,7 @@ import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; +import org.osgi.service.prefs.BackingStoreException; import com.minres.scviewer.database.DataType; import com.minres.scviewer.database.ITx; @@ -192,9 +196,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis /** The prefs. */ @Inject - @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) - IEclipsePreferences prefs; - + @Preference(value = ConfigurationScope.SCOPE, nodePath = PreferenceConstants.PREFERENCES_SCOPE) + protected IEclipsePreferences prefs; + @Inject @Optional DesignBrowser designBrowser; /** The database. */ @@ -240,7 +244,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @PostConstruct public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) { disposeListenerNumber += 1; - + myPart = part; myParent = parent; database = dbFactory.getDatabase(); @@ -465,17 +469,21 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis */ @Override public void preferenceChange(PreferenceChangeEvent event) { + InstancePreferences pref = (InstancePreferences)event.getSource(); if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) { - checkForUpdates = (Boolean) event.getNewValue(); + checkForUpdates = pref.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); fileChecker = null; if (checkForUpdates) fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL); else fileMonitor.removeFileChangeListener(this); - } else { + } else if (!PreferenceConstants.SHOW_HOVER.equals(event.getKey())){ setupColors(); } + try { + pref.flush(); + } catch (BackingStoreException e) { } } /** diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java index a2fdd5c..0a56c96 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/DefaultValuesInitializer.java @@ -11,15 +11,14 @@ package com.minres.scviewer.e4.application.preferences; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.core.runtime.preferences.DefaultScope; +import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.resource.StringConverter; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.wb.swt.SWTResourceManager; import com.minres.scviewer.database.ui.WaveformColors; -import com.opcoach.e4.preferences.ScopedPreferenceStore; /** * The Class DefaultValuesInitializer. @@ -64,13 +63,22 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { */ @Override public void initializeDefaultPreferences() { - IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); - - store.setDefault(PreferenceConstants.DATABASE_RELOAD, true); - store.setDefault(PreferenceConstants.SHOW_HOVER, true); - for (WaveformColors c : WaveformColors.values()) { - store.setDefault(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ - } + IEclipsePreferences node = DefaultScope.INSTANCE.getNode(PreferenceConstants.PREFERENCES_SCOPE); + if (node != null) + { + node.putBoolean(PreferenceConstants.DATABASE_RELOAD, true); + node.putBoolean(PreferenceConstants.SHOW_HOVER, true); + for (WaveformColors c : WaveformColors.values()) { + node.put(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ + } + } +// IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); +// +// store.setDefault(PreferenceConstants.DATABASE_RELOAD, true); +// store.setDefault(PreferenceConstants.SHOW_HOVER, true); +// for (WaveformColors c : WaveformColors.values()) { +// store.setDefault(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$ +// } } } diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java new file mode 100644 index 0000000..ad4e320 --- /dev/null +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/preferences/PreferencesStoreProvider.java @@ -0,0 +1,18 @@ +package com.minres.scviewer.e4.application.preferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; +import org.eclipse.jface.preference.IPreferenceStore; + +import com.opcoach.e4.preferences.IPreferenceStoreProvider; +import com.opcoach.e4.preferences.ScopedPreferenceStore; + +public class PreferencesStoreProvider implements IPreferenceStoreProvider{ + + public PreferencesStoreProvider(){ + } + + @Override + public IPreferenceStore getPreferenceStore() { + return new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + } + +} \ No newline at end of file diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index 90c16d6..79c1649 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -7,7 +7,7 @@ - -clearPersistedState -data @none + -clearPersistedState -Xmx2G diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java index 5623c9d..de4baf8 100644 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java +++ b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/internal/E4PreferenceRegistry.java @@ -46,6 +46,7 @@ public class E4PreferenceRegistry public static final String PREFS_PAGE_XP = "com.opcoach.e4.preferences.e4PreferencePages"; // $NON-NLS-1$ public static final String PREF_STORE_PROVIDER = "com.opcoach.e4.preferences.e4PreferenceStoreProvider"; // $NON-NLS-1$ + public static final String KEY_PREF_STORE_PROVIDERS = "com.opcoach.e4.preferences.e4PreferenceStoreProviders"; // $NON-NLS-1$ protected static final String ELMT_PAGE = "page"; // $NON-NLS-1$ protected static final String ATTR_ID = "id"; // $NON-NLS-1$ protected static final String ATTR_CATEGORY = "category"; // $NON-NLS-1$ @@ -235,6 +236,7 @@ public class E4PreferenceRegistry IContributionFactory factory = context.get(IContributionFactory.class); psProviders = new HashMap(); + IExtensionRegistry registry = context.get(IExtensionRegistry.class); // Read extensions and fill the map... for (IConfigurationElement elmt : registry.getConfigurationElementsFor(PREF_STORE_PROVIDER)) @@ -261,7 +263,7 @@ public class E4PreferenceRegistry Object data = objectId; if (classname != null) { - data = factory.create(classname, context); + data = factory.create("bundleclass://"+declaringBundle+"/"+classname, context); if (!(data instanceof IPreferenceStoreProvider)) { logger.warn("In extension " + PREF_STORE_PROVIDER + " the class must implements IPreferenceStoreProvider. Check the plugin " + declaringBundle); @@ -272,6 +274,8 @@ public class E4PreferenceRegistry psProviders.put(pluginId, data); } + + context.set(KEY_PREF_STORE_PROVIDERS, psProviders); } } From f1d080983a54bf5f92fcc0413391ea9492977c70 Mon Sep 17 00:00:00 2001 From: eyck Date: Tue, 24 Mar 2020 06:43:10 +0000 Subject: [PATCH 09/10] fix #32 --- .../database/swt/internal/ToolTipHandler.java | 9 ++++-- .../e4/application/parts/WaveformViewer.java | 29 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java index d950602..ea6b0d0 100644 --- a/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java +++ b/com.minres.scviewer.database.ui.swt/src/com/minres/scviewer/database/swt/internal/ToolTipHandler.java @@ -4,6 +4,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; @@ -74,11 +75,15 @@ class ToolTipHandler { if (tip != null && !tip.isDisposed ()) tip.dispose (); tip = new Shell (parentShell, SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND)); - RowLayout layout=new RowLayout(SWT.VERTICAL); - layout.fill=true; + GridLayout layout = new GridLayout(1, true); + layout.verticalSpacing=0; + layout.horizontalSpacing=0; + layout.marginWidth = 0; + layout.marginHeight = 0; tip.setLayout(layout); boolean visible = provider.createContent(tip, pt); tip.pack(); + tip.setSize(tip.computeSize(SWT.DEFAULT, SWT.DEFAULT)); setHoverLocation(tip, tipPosition); tip.setVisible (visible); if(visible) diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index c6e871a..6334d6c 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java @@ -75,6 +75,7 @@ import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -403,18 +404,26 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); final Label label = new Label(parent, SWT.NONE); - label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); +// label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); +// label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label.setText(tx.toString()); label.setFont(font); + GridData labelGridData = new GridData(); + labelGridData.horizontalAlignment = GridData.FILL; + labelGridData.grabExcessHorizontalSpace = true; + label.setLayoutData(labelGridData); final Table table = new Table(parent, SWT.NONE); table.setHeaderVisible(true); table.setLinesVisible(true); table.setFont(font); - table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); +// table.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); +// table.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); table.setRedraw(false); + GridData tableGridData = new GridData(); + tableGridData.horizontalAlignment = GridData.FILL; + tableGridData.grabExcessHorizontalSpace = true; + table.setLayoutData(tableGridData); final TableColumn nameCol = new TableColumn(table, SWT.LEFT); nameCol.setText("Attribute"); @@ -432,8 +441,12 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis item.setText(0, iTxAttribute.getName()); item.setText(1, value); } + TableItem item = new TableItem(table, SWT.NONE); + item.setText(0, ""); + item.setText(1, ""); nameCol.pack(); valueCol.pack(); + table.pack(); table.setRedraw(true); parent.addPaintListener(new PaintListener() { @@ -453,10 +466,14 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL); final Label label = new Label(parent, SWT.NONE); - label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + //label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND)); + //label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND)); label.setText(te.waveform.getFullName()); label.setFont(font); + GridData labelGridData = new GridData(); + labelGridData.horizontalAlignment = GridData.FILL; + labelGridData.grabExcessHorizontalSpace = true; + label.setLayoutData(labelGridData); return true; } return false; From 2b1cb7856f2312dd15493cec2603a00cf02b7ecb Mon Sep 17 00:00:00 2001 From: eyck Date: Tue, 24 Mar 2020 08:05:55 +0000 Subject: [PATCH 10/10] update version this release contains for #31 and #14 --- com.minres.scviewer.e4.application/META-INF/MANIFEST.MF | 2 +- com.minres.scviewer.e4.application/pom.xml | 2 +- com.minres.scviewer.e4.product/pom.xml | 2 +- com.minres.scviewer.e4.product/scviewer.product | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index a5566e3..c848cd2 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -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.4.0.qualifier +Bundle-Version: 2.4.1.qualifier Bundle-Vendor: %Bundle-Vendor Require-Bundle: javax.inject;bundle-version="1.0.0", org.eclipse.core.runtime;bundle-version="3.11.1", diff --git a/com.minres.scviewer.e4.application/pom.xml b/com.minres.scviewer.e4.application/pom.xml index 2fb3288..718f006 100644 --- a/com.minres.scviewer.e4.application/pom.xml +++ b/com.minres.scviewer.e4.application/pom.xml @@ -1,7 +1,7 @@ 4.0.0 com.minres.scviewer.e4.application - 2.4.0-SNAPSHOT + 2.4.1-SNAPSHOT com.minres.scviewer com.minres.scviewer.parent diff --git a/com.minres.scviewer.e4.product/pom.xml b/com.minres.scviewer.e4.product/pom.xml index b23c351..2ecb3ec 100644 --- a/com.minres.scviewer.e4.product/pom.xml +++ b/com.minres.scviewer.e4.product/pom.xml @@ -10,7 +10,7 @@ ../com.minres.scviewer.parent com.minres.scviewer.e4.product - 2.4.0-SNAPSHOT + 2.4.1-SNAPSHOT eclipse-repository com.minres.scviewer diff --git a/com.minres.scviewer.e4.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index 79c1649..163149f 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -1,7 +1,8 @@ - + + @@ -33,6 +34,7 @@ + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8 org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8