improve preferences handling and textual representation

This commit is contained in:
Eyck Jentzsch 2020-06-21 17:06:18 +02:00
parent b170fb3c2a
commit 55a14edc9d
4 changed files with 67 additions and 4 deletions

View File

@ -41,6 +41,7 @@ public class Messages extends NLS {
public static String TransactionDetails_21;
public static String TransactionDetails_3;
public static String TransactionDetails_4;
public static String WaveformPreferencesPage_description;
public static String WaveformPreferencesPage_1;
public static String WaveformViewer_13;
public static String WaveformViewer_14;
@ -61,6 +62,30 @@ public class Messages extends NLS {
public static String WaveStatusBarControl_6;
public static String WaveStatusBarControl_7;
public static String WaveStatusBarControl_8;
public static String line;
public static String line_highlite;
public static String track_bg_even;
public static String track_bg_odd;
public static String track_bg_highlite;
public static String tx_bg;
public static String tx_bg_highlite;
public static String tx_border;
public static String signal0;
public static String signal1;
public static String signalz;
public static String signalx;
public static String signalu;
public static String signal_text;
public static String signal_real;
public static String signal_nan;
public static String cursor;
public static String cursor_drag;
public static String cursor_text;
public static String marker;
public static String marker_text;
public static String rel_arrow;
public static String rel_arrow_highlite;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);

View File

@ -35,6 +35,7 @@ TransactionDetails_20=Time
TransactionDetails_21=End time
TransactionDetails_3=Value
TransactionDetails_4=Relation
WaveformPreferencesPage_description=Default Waveform Window Settings
WaveformPreferencesPage_1=Color for
WaveformViewer_13=Database Load Status
WaveformViewer_14=Database Load Cancelled
@ -55,3 +56,27 @@ WaveStatusBarControl_5=C:
WaveStatusBarControl_6=M:
WaveStatusBarControl_7=C-M:
WaveStatusBarControl_8=Z:
line=Track line
line_highlite=higlighted Track line
track_bg_even=even Track Background
track_bg_odd=odd Track Background
track_bg_highlite=highlighted Track Background
tx_bg=Transaction Background
tx_bg_highlite=highlighted Transaction Background
tx_border=Transaction Border
signal0=Signal Value '0'
signal1=Signal Value '1'
signalz=Signal Value 'Z'
signalx=Signal Value 'X'
signalu=Signal Value 'U'
signal_text=Signal text
signal_real=Signal real Value
signal_nan=Signal NaN Value
cursor=Cursor
cursor_drag=dragged Cursor
cursor_text=Cursor Text
marker=Marker
marker_text=Marker TExt
rel_arrow=Relation arrow
rel_arrow_highlite=highlighted Relation arrorw

View File

@ -478,13 +478,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
@Inject
@Optional
public void reactOnShowHoverChange(@Preference(value = PreferenceConstants.SHOW_HOVER) Boolean hover) {
public void reactOnShowHoverChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.SHOW_HOVER) Boolean hover) {
showHover=hover;
}
@Inject
@Optional
public void reactOnReloadDatabaseChange(@Preference(value = PreferenceConstants.DATABASE_RELOAD) Boolean checkForUpdates) {
public void reactOnReloadDatabaseChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE, value = PreferenceConstants.DATABASE_RELOAD) Boolean checkForUpdates) {
if (checkForUpdates) {
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL);
} else {

View File

@ -10,6 +10,9 @@
*******************************************************************************/
package com.minres.scviewer.e4.application.preferences;
import java.lang.reflect.Field;
import java.util.HashMap;
import org.eclipse.jface.preference.ColorFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
@ -26,6 +29,7 @@ public class WaveformPreferencesPage extends FieldEditorPreferencePage {
*/
public WaveformPreferencesPage() {
super(GRID);
setDescription(Messages.WaveformPreferencesPage_description);
}
/* (non-Javadoc)
@ -33,9 +37,18 @@ public class WaveformPreferencesPage extends FieldEditorPreferencePage {
*/
@Override
protected void createFieldEditors() {
Field[] declaredFields = Messages.class.getDeclaredFields();
HashMap<String, String> staticFields = new HashMap<String, String>();
for (Field field : declaredFields) {
if (java.lang.reflect.Modifier.isStatic(field.getModifiers())) {
try {
staticFields.put(field.getName(), (String)field.get(null));
} catch (IllegalArgumentException | IllegalAccessException e) {}
}
}
for (WaveformColors c : WaveformColors.values()) {
addField(new ColorFieldEditor(c.name() + "_COLOR", Messages.WaveformPreferencesPage_1 + c.name().toLowerCase(), //$NON-NLS-1$
addField(new ColorFieldEditor(c.name() + "_COLOR",
Messages.WaveformPreferencesPage_1 + staticFields.get(c.name().toLowerCase()), //$NON-NLS-1$
getFieldEditorParent()));
}
}