From 5933bcd5120e40d15b75400b27a438f8cf70a9fd Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Sat, 21 Mar 2020 11:30:30 +0100 Subject: [PATCH] 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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Fm7=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())); }