fix preference handling
This commit is contained in:
parent
24720340be
commit
7ad70411f3
|
@ -84,12 +84,5 @@
|
||||||
category="com.minres.scviewer.e4.application.preferences.scviewer">
|
category="com.minres.scviewer.e4.application.preferences.scviewer">
|
||||||
</page>
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
|
||||||
point="com.opcoach.e4.preferences.e4PreferenceStoreProvider">
|
|
||||||
<preferenceStoreProvider
|
|
||||||
class="bundleclass://com.minres.scviewer.e4.application/com.minres.scviewer.e4.application.preferences.PreferencesStoreProvider"
|
|
||||||
pluginId="com.minres.scviewer.e4.application">
|
|
||||||
</preferenceStoreProvider>
|
|
||||||
</extension>
|
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -4,45 +4,43 @@ package com.minres.scviewer.e4.application.handlers;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
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.annotations.Execute;
|
||||||
|
import org.eclipse.e4.core.di.annotations.Optional;
|
||||||
|
import org.eclipse.e4.core.di.extensions.Preference;
|
||||||
import org.eclipse.e4.ui.model.application.MApplication;
|
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.model.application.ui.menu.MHandledItem;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
import org.eclipse.e4.ui.workbench.modeling.EModelService;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
|
||||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
|
||||||
|
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
public class EnableHover {
|
public class EnableHover {
|
||||||
static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$
|
static final String TAG_NAME = "EnableHover"; //$NON-NLS-1$
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MApplication application;
|
MApplication application;
|
||||||
|
|
||||||
@PostConstruct
|
@Inject
|
||||||
public void initialize(EModelService modelService) {
|
@Optional
|
||||||
|
public void reactOnShowHoverChange(EModelService modelService, @Preference(value = PreferenceConstants.SHOW_HOVER) Boolean hover) {
|
||||||
List<String> tags = new LinkedList<>();
|
List<String> tags = new LinkedList<>();
|
||||||
tags.add(TAG_NAME);
|
tags.add(TAG_NAME);
|
||||||
List<MHandledItem> elements = modelService.findElements(application, null, MHandledItem.class, tags );
|
List<MHandledItem> elements = modelService.findElements(application, null, MHandledItem.class, tags );
|
||||||
// cover initialization stuff, sync it with code
|
|
||||||
IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
|
||||||
boolean state = store.getBoolean(PreferenceConstants.SHOW_HOVER);
|
|
||||||
for( MHandledItem hi : elements ){
|
for( MHandledItem hi : elements ){
|
||||||
hi.setSelected(state);
|
hi.setSelected(hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Execute
|
@Execute
|
||||||
public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) {
|
public void execute(MHandledItem handledItem, @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs ) {
|
||||||
IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
try {
|
||||||
store.setValue(PreferenceConstants.SHOW_HOVER, handledItem.isSelected());
|
prefs.putBoolean(PreferenceConstants.SHOW_HOVER, handledItem.isSelected());
|
||||||
|
prefs.flush();
|
||||||
|
} catch (BackingStoreException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,17 +31,18 @@ import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import org.eclipse.core.internal.preferences.InstancePreferences;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.OperationCanceledException;
|
import org.eclipse.core.runtime.OperationCanceledException;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.eclipse.core.runtime.jobs.JobGroup;
|
import org.eclipse.core.runtime.jobs.JobGroup;
|
||||||
import org.eclipse.core.runtime.preferences.ConfigurationScope;
|
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
|
||||||
import org.eclipse.e4.core.di.annotations.Optional;
|
import org.eclipse.e4.core.di.annotations.Optional;
|
||||||
|
import org.eclipse.e4.core.di.extensions.Preference;
|
||||||
import org.eclipse.e4.core.services.events.IEventBroker;
|
import org.eclipse.e4.core.services.events.IEventBroker;
|
||||||
import org.eclipse.e4.ui.di.Focus;
|
import org.eclipse.e4.ui.di.Focus;
|
||||||
import org.eclipse.e4.ui.di.PersistState;
|
import org.eclipse.e4.ui.di.PersistState;
|
||||||
|
@ -52,9 +53,7 @@ import org.eclipse.e4.ui.services.EMenuService;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
import org.eclipse.e4.ui.workbench.modeling.EPartService;
|
||||||
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
import org.eclipse.e4.ui.workbench.modeling.ESelectionService;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
|
||||||
import org.eclipse.jface.resource.StringConverter;
|
import org.eclipse.jface.resource.StringConverter;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
@ -80,7 +79,7 @@ import org.eclipse.swt.widgets.Table;
|
||||||
import org.eclipse.swt.widgets.TableColumn;
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
import org.eclipse.swt.widgets.TableItem;
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
import org.eclipse.swt.widgets.Widget;
|
import org.eclipse.swt.widgets.Widget;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
import com.minres.scviewer.database.DataType;
|
import com.minres.scviewer.database.DataType;
|
||||||
import com.minres.scviewer.database.ITx;
|
import com.minres.scviewer.database.ITx;
|
||||||
|
@ -108,7 +107,6 @@ import com.minres.scviewer.e4.application.internal.util.FileMonitor;
|
||||||
import com.minres.scviewer.e4.application.internal.util.IFileChangeListener;
|
import com.minres.scviewer.e4.application.internal.util.IFileChangeListener;
|
||||||
import com.minres.scviewer.e4.application.internal.util.IModificationChecker;
|
import com.minres.scviewer.e4.application.internal.util.IModificationChecker;
|
||||||
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
import com.minres.scviewer.e4.application.preferences.PreferenceConstants;
|
||||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class WaveformViewerPart.
|
* The Class WaveformViewerPart.
|
||||||
|
@ -190,7 +188,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
@Inject
|
@Inject
|
||||||
EPartService ePartService;
|
EPartService ePartService;
|
||||||
|
|
||||||
IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
IEclipsePreferences store = null;
|
||||||
|
|
||||||
@Inject @Optional DesignBrowser designBrowser;
|
@Inject @Optional DesignBrowser designBrowser;
|
||||||
|
|
||||||
|
@ -207,7 +205,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
private Composite myParent;
|
private Composite myParent;
|
||||||
|
|
||||||
/** The files to load. */
|
/** The files to load. */
|
||||||
ArrayList<File> filesToLoad;
|
ArrayList<File> filesToLoad = new ArrayList<>();
|
||||||
|
|
||||||
/** The persisted state. */
|
/** The persisted state. */
|
||||||
Map<String, String> persistedState;
|
Map<String, String> persistedState;
|
||||||
|
@ -227,6 +225,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
/** The file checker. */
|
/** The file checker. */
|
||||||
IModificationChecker fileChecker;
|
IModificationChecker fileChecker;
|
||||||
|
|
||||||
|
private Boolean showHover;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the composite.
|
* Creates the composite.
|
||||||
*
|
*
|
||||||
|
@ -235,11 +235,13 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
* @param dbFactory the db factory
|
* @param dbFactory the db factory
|
||||||
*/
|
*/
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory) {
|
public void createComposite(MPart part, Composite parent, IWaveformDbFactory dbFactory, @Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs, @Preference(value = PreferenceConstants.SHOW_HOVER) Boolean hover) {
|
||||||
disposeListenerNumber += 1;
|
disposeListenerNumber += 1;
|
||||||
|
|
||||||
myPart = part;
|
myPart = part;
|
||||||
myParent = parent;
|
myParent = parent;
|
||||||
|
store=prefs;
|
||||||
|
showHover=hover;
|
||||||
database = dbFactory.getDatabase();
|
database = dbFactory.getDatabase();
|
||||||
database.addPropertyChangeListener(new PropertyChangeListener() {
|
database.addPropertyChangeListener(new PropertyChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -256,7 +258,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
});
|
});
|
||||||
waveformPane = factory.createPanel(parent);
|
waveformPane = factory.createPanel(parent);
|
||||||
waveformPane.setMaxTime(0);
|
waveformPane.setMaxTime(0);
|
||||||
|
setupColors();
|
||||||
//set selection to empty selection when opening a new waveformPane
|
//set selection to empty selection when opening a new waveformPane
|
||||||
selectionService.setSelection(new StructuredSelection());
|
selectionService.setSelection(new StructuredSelection());
|
||||||
|
|
||||||
|
@ -344,8 +346,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
});
|
});
|
||||||
|
|
||||||
zoomLevel = waveformPane.getZoomLevels();
|
zoomLevel = waveformPane.getZoomLevels();
|
||||||
setupColors();
|
checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
||||||
checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD);
|
|
||||||
filesToLoad = new ArrayList<File>();
|
filesToLoad = new ArrayList<File>();
|
||||||
persistedState = part.getPersistedState();
|
persistedState = part.getPersistedState();
|
||||||
Integer files = persistedState.containsKey(DATABASE_FILE + "S") //$NON-NLS-1$
|
Integer files = persistedState.containsKey(DATABASE_FILE + "S") //$NON-NLS-1$
|
||||||
|
@ -374,23 +375,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
store.addPropertyChangeListener(new IPropertyChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void propertyChange(org.eclipse.jface.util.PropertyChangeEvent event) {
|
|
||||||
if (PreferenceConstants.DATABASE_RELOAD.equals(event.getProperty())) {
|
|
||||||
checkForUpdates = (Boolean)event.getNewValue();
|
|
||||||
fileChecker = null;
|
|
||||||
if (checkForUpdates)
|
|
||||||
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad,
|
|
||||||
FILE_CHECK_INTERVAL);
|
|
||||||
else
|
|
||||||
fileMonitor.removeFileChangeListener(WaveformViewer.this);
|
|
||||||
} else if (!PreferenceConstants.SHOW_HOVER.equals(event.getProperty())){
|
|
||||||
setupColors();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
waveformPane.addDisposeListener(this);
|
waveformPane.addDisposeListener(this);
|
||||||
|
|
||||||
waveformPane.getWaveformControl().setData(Constants.HELP_PROVIDER_TAG, new ToolTipHelpTextProvider() {
|
waveformPane.getWaveformControl().setData(Constants.HELP_PROVIDER_TAG, new ToolTipHelpTextProvider() {
|
||||||
|
@ -402,7 +386,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipContentProvider() {
|
waveformPane.getWaveformControl().setData(Constants.CONTENT_PROVIDER_TAG, new ToolTipContentProvider() {
|
||||||
@Override
|
@Override
|
||||||
public boolean createContent(Composite parent, Point pt) {
|
public boolean createContent(Composite parent, Point pt) {
|
||||||
if(!store.getBoolean(PreferenceConstants.SHOW_HOVER)) return false;
|
if(!showHover) return false;
|
||||||
List<Object> res = waveformPane.getElementsAt(pt);
|
List<Object> res = waveformPane.getElementsAt(pt);
|
||||||
if(res.size()>0)
|
if(res.size()>0)
|
||||||
if(res.get(0) instanceof ITx) {
|
if(res.get(0) instanceof ITx) {
|
||||||
|
@ -472,8 +456,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL);
|
final Font font = new Font(Display.getCurrent(), "Terminal", 10, SWT.NORMAL);
|
||||||
|
|
||||||
final Label label = new Label(parent, SWT.NONE);
|
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.setText(te.waveform.getFullName());
|
||||||
label.setFont(font);
|
label.setFont(font);
|
||||||
GridData labelGridData = new GridData();
|
GridData labelGridData = new GridData();
|
||||||
|
@ -487,35 +469,49 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Optional
|
||||||
|
public void reactOnPrefsChange(@Preference(nodePath = PreferenceConstants.PREFERENCES_SCOPE) IEclipsePreferences prefs) {
|
||||||
|
prefs.addPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Optional
|
||||||
|
public void reactOnShowHoverChange(@Preference(value = PreferenceConstants.SHOW_HOVER) Boolean hover) {
|
||||||
|
showHover=hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Optional
|
||||||
|
public void reactOnReloadDatabaseChange(@Preference(value = PreferenceConstants.DATABASE_RELOAD) Boolean checkForUpdates) {
|
||||||
|
if (checkForUpdates) {
|
||||||
|
fileChecker = fileMonitor.addFileChangeListener(WaveformViewer.this, filesToLoad, FILE_CHECK_INTERVAL);
|
||||||
|
} else {
|
||||||
|
fileMonitor.removeFileChangeListener(WaveformViewer.this);
|
||||||
|
fileChecker = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
|
* @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void preferenceChange(PreferenceChangeEvent event) {
|
public void preferenceChange(PreferenceChangeEvent event) {
|
||||||
InstancePreferences pref = (InstancePreferences)event.getSource();
|
if (!PreferenceConstants.DATABASE_RELOAD.equals(event.getKey()) && !PreferenceConstants.SHOW_HOVER.equals(event.getKey())){
|
||||||
if (PreferenceConstants.DATABASE_RELOAD.equals(event.getKey())) {
|
|
||||||
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 if (!PreferenceConstants.SHOW_HOVER.equals(event.getKey())){
|
|
||||||
setupColors();
|
setupColors();
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
pref.flush();
|
|
||||||
} catch (BackingStoreException e) { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup colors.
|
* Setup colors.
|
||||||
*/
|
*/
|
||||||
protected void setupColors() {
|
protected void setupColors() {
|
||||||
|
Preferences defaultPrefs= store.parent().parent().node("/"+DefaultScope.SCOPE+"/"+PreferenceConstants.PREFERENCES_SCOPE);
|
||||||
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
HashMap<WaveformColors, RGB> colorPref = new HashMap<>();
|
||||||
for (WaveformColors c : WaveformColors.values()) {
|
for (WaveformColors c : WaveformColors.values()) {
|
||||||
String prefValue = store.getString(c.name() + "_COLOR"); //$NON-NLS-1$
|
String key = c.name() + "_COLOR";
|
||||||
|
String prefValue = store.get(key, defaultPrefs.get(key, "")); //$NON-NLS-1$
|
||||||
RGB rgb = StringConverter.asRGB(prefValue);
|
RGB rgb = StringConverter.asRGB(prefValue);
|
||||||
colorPref.put(c, rgb);
|
colorPref.put(c, rgb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,14 +12,14 @@ package com.minres.scviewer.e4.application.preferences;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
import org.eclipse.core.runtime.preferences.DefaultScope;
|
import org.eclipse.core.runtime.preferences.DefaultScope;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.jface.resource.StringConverter;
|
import org.eclipse.jface.resource.StringConverter;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.graphics.Color;
|
import org.eclipse.swt.graphics.Color;
|
||||||
import org.eclipse.wb.swt.SWTResourceManager;
|
import org.eclipse.wb.swt.SWTResourceManager;
|
||||||
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
import com.minres.scviewer.database.ui.WaveformColors;
|
import com.minres.scviewer.database.ui.WaveformColors;
|
||||||
import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class DefaultValuesInitializer.
|
* The Class DefaultValuesInitializer.
|
||||||
|
@ -27,7 +27,7 @@ import com.opcoach.e4.preferences.ScopedPreferenceStore;
|
||||||
public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
||||||
|
|
||||||
/** The default colors. */
|
/** The default colors. */
|
||||||
public final Color[] colors = new Color[WaveformColors.values().length];
|
public static final Color[] colors = new Color[WaveformColors.values().length];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new default values initializer.
|
* Instantiates a new default values initializer.
|
||||||
|
@ -64,21 +64,12 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
// IEclipsePreferences node = DefaultScope.INSTANCE.getNode(PreferenceConstants.PREFERENCES_SCOPE);
|
IEclipsePreferences store = DefaultScope.INSTANCE.getNode(FrameworkUtil.getBundle(getClass()).getSymbolicName());
|
||||||
// if (node != null)
|
|
||||||
// {
|
store.putBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
||||||
// node.putBoolean(PreferenceConstants.DATABASE_RELOAD, true);
|
store.putBoolean(PreferenceConstants.SHOW_HOVER, 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(DefaultScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE);
|
|
||||||
|
|
||||||
store.setDefault(PreferenceConstants.DATABASE_RELOAD, true);
|
|
||||||
store.setDefault(PreferenceConstants.SHOW_HOVER, true);
|
|
||||||
for (WaveformColors c : WaveformColors.values()) {
|
for (WaveformColors c : WaveformColors.values()) {
|
||||||
store.setDefault(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$
|
store.put(c.name()+"_COLOR", StringConverter.asString(colors[c.ordinal()].getRGB())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue