configure the hover visibility from UI
This commit is contained in:
@ -22,6 +22,7 @@ public class Messages extends NLS {
|
||||
public static String RelationTypeToolControl_1;
|
||||
public static String ResourceManager_0;
|
||||
public static String SCViewerPreferencesPage_0;
|
||||
public static String SCViewerPreferencesPage_1;
|
||||
public static String StatusBarControl_1;
|
||||
public static String StatusBarControl_2;
|
||||
public static String StatusBarControl_3;
|
||||
|
@ -0,0 +1,49 @@
|
||||
|
||||
package com.minres.scviewer.e4.application.handlers;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.e4.core.contexts.Active;
|
||||
import org.eclipse.e4.core.di.annotations.Execute;
|
||||
import org.eclipse.e4.core.di.extensions.Preference;
|
||||
import org.eclipse.e4.ui.model.application.MApplication;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
||||
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
|
||||
import org.eclipse.e4.ui.model.application.ui.menu.MHandledItem;
|
||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||
|
||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||
|
||||
@SuppressWarnings("restriction")
|
||||
public class EnableHover {
|
||||
static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$
|
||||
|
||||
@Inject
|
||||
@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE)
|
||||
IEclipsePreferences prefs;
|
||||
|
||||
@Inject
|
||||
MApplication application;
|
||||
|
||||
@PostConstruct
|
||||
public void initialize(EModelService modelService) {
|
||||
List<String> tags = new LinkedList<>();
|
||||
tags.add(TAG_NAME);
|
||||
List<MHandledItem> 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());
|
||||
}
|
||||
|
||||
}
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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<Object> 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);
|
||||
|
@ -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$
|
||||
}
|
||||
|
@ -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$
|
||||
|
||||
|
@ -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()));
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user