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 ea6b0d0..c6b448c 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 @@ -5,7 +5,6 @@ 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; import org.eclipse.swt.widgets.Event; @@ -73,7 +72,7 @@ class ToolTipHandler { 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 = new Shell (parentShell, SWT.NO_FOCUS | SWT.TOOL); tip.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND)); GridLayout layout = new GridLayout(1, true); layout.verticalSpacing=0; diff --git a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF index c848cd2..422b98f 100644 --- a/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF +++ b/com.minres.scviewer.e4.application/META-INF/MANIFEST.MF @@ -31,7 +31,9 @@ Require-Bundle: javax.inject;bundle-version="1.0.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.e4.ui.css.swt.theme;bundle-version="0.10.0", + org.eclipse.core.resources;bundle-version="3.13.0", + com.opcoach.e4.preferences.mainmenu;bundle-version="1.2.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: com.minres.scviewer.database, javax.inject;version="1.0.0" diff --git a/com.minres.scviewer.e4.application/plugin.xml b/com.minres.scviewer.e4.application/plugin.xml index 236f625..f585ee3 100644 --- a/com.minres.scviewer.e4.application/plugin.xml +++ b/com.minres.scviewer.e4.application/plugin.xml @@ -84,5 +84,12 @@ category="com.minres.scviewer.e4.application.preferences.scviewer"> + + + + 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 e0d15fc..7532fb8 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 @@ -11,10 +11,12 @@ package com.minres.scviewer.e4.application; import java.io.File; +import java.io.IOException; import javax.annotation.PostConstruct; import javax.inject.Inject; +import org.eclipse.core.runtime.Platform; import org.eclipse.e4.core.contexts.ContextInjectionFactory; import org.eclipse.e4.core.contexts.IEclipseContext; import org.eclipse.e4.core.services.events.IEventBroker; @@ -30,6 +32,7 @@ import org.eclipse.e4.ui.workbench.modeling.EModelService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.EPartService.PartState; import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.osgi.service.datalocation.Location; import org.osgi.service.event.Event; import org.osgi.service.event.EventHandler; @@ -91,6 +94,20 @@ public class E4LifeCycle { } } }); + eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() { + @Override + public void handleEvent(Event event) { + Location instanceLocation = Platform.getInstanceLocation(); + try { + boolean isLocked = instanceLocation.isLocked(); + if(isLocked) + instanceLocation.release(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); } /** diff --git a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java index 557c61a..2990c28 100644 --- a/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java +++ b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/handlers/EnableHover.java @@ -7,26 +7,22 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.inject.Inject; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.ConfigurationScope; 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 org.eclipse.jface.preference.IPreferenceStore; import com.minres.scviewer.e4.application.preferences.PreferenceConstants; +import com.opcoach.e4.preferences.ScopedPreferenceStore; -@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; @@ -36,14 +32,17 @@ public class EnableHover { tags.add(TAG_NAME); List 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 ){ - hi.setSelected(prefs.getBoolean(PreferenceConstants.SHOW_HOVER, true)); + hi.setSelected(state); } } @Execute public void execute(@Active MPart part, @Active MWindow window, MHandledItem handledItem, EModelService modelService ) { - prefs.putBoolean(PreferenceConstants.SHOW_HOVER, handledItem.isSelected()); + IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); + store.setValue(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/parts/WaveformViewer.java b/com.minres.scviewer.e4.application/src/com/minres/scviewer/e4/application/parts/WaveformViewer.java index 6334d6c..9952cdb 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 @@ -43,12 +43,9 @@ 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; import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.di.PersistState; @@ -59,7 +56,9 @@ import org.eclipse.e4.ui.services.EMenuService; import org.eclipse.e4.ui.workbench.modeling.EPartService; import org.eclipse.e4.ui.workbench.modeling.ESelectionService; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.StringConverter; +import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; @@ -112,8 +111,8 @@ import com.minres.scviewer.e4.application.internal.status.WaveStatusBarControl; 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.IModificationChecker; -import com.minres.scviewer.e4.application.preferences.DefaultValuesInitializer; import com.minres.scviewer.e4.application.preferences.PreferenceConstants; +import com.opcoach.e4.preferences.ScopedPreferenceStore; /** * The Class WaveformViewerPart. @@ -195,10 +194,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis @Inject EPartService ePartService; - /** The prefs. */ - @Inject - @Preference(value = ConfigurationScope.SCOPE, nodePath = PreferenceConstants.PREFERENCES_SCOPE) - protected IEclipsePreferences prefs; + IPreferenceStore store = new ScopedPreferenceStore(ConfigurationScope.INSTANCE, PreferenceConstants.PREFERENCES_SCOPE); @Inject @Optional DesignBrowser designBrowser; @@ -353,7 +349,7 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis zoomLevel = waveformPane.getZoomLevels(); setupColors(); - checkForUpdates = prefs.getBoolean(PreferenceConstants.DATABASE_RELOAD, true); + checkForUpdates = store.getBoolean(PreferenceConstants.DATABASE_RELOAD); filesToLoad = new ArrayList(); persistedState = part.getPersistedState(); Integer files = persistedState.containsKey(DATABASE_FILE + "S") //$NON-NLS-1$ @@ -382,7 +378,22 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis } } }); - prefs.addPreferenceChangeListener(this); + 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); @@ -395,7 +406,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; + if(!store.getBoolean(PreferenceConstants.SHOW_HOVER)) return false; List res = waveformPane.getElementsAt(pt); if(res.size()>0) if(res.get(0) instanceof ITx) { @@ -403,9 +414,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis 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)); + final Label label = new Label(parent, SWT.SHADOW_IN); + label.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + label.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); label.setText(tx.toString()); label.setFont(font); GridData labelGridData = new GridData(); @@ -417,9 +428,8 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis 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); + label.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + label.setBackground(display.getSystemColor(SWT.COLOR_GRAY)); GridData tableGridData = new GridData(); tableGridData.horizontalAlignment = GridData.FILL; tableGridData.grabExcessHorizontalSpace = true; @@ -441,14 +451,15 @@ 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, ""); + if(table.getHeaderVisible()) { + // add dummy row to get make last row visible + TableItem item = new TableItem(table, SWT.NONE); + item.setText(0, ""); + item.setText(1, ""); + } nameCol.pack(); valueCol.pack(); - table.pack(); - table.setRedraw(true); - + table.setSize(table.computeSize(SWT.DEFAULT, SWT.DEFAULT)); parent.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { @@ -462,7 +473,6 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis 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); @@ -507,11 +517,9 @@ public class WaveformViewer implements IFileChangeListener, IPreferenceChangeLis * Setup colors. */ protected void setupColors() { - DefaultValuesInitializer initializer = new DefaultValuesInitializer(); HashMap colorPref = new HashMap<>(); for (WaveformColors c : WaveformColors.values()) { - String prefValue = prefs.get(c.name() + "_COLOR", //$NON-NLS-1$ - StringConverter.asString(initializer.colors[c.ordinal()].getRGB())); + String prefValue = store.getString(c.name() + "_COLOR"); //$NON-NLS-1$ RGB rgb = StringConverter.asRGB(prefValue); colorPref.put(c, rgb); } 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 0a56c96..ca89128 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 @@ -12,13 +12,14 @@ package com.minres.scviewer.e4.application.preferences; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.jface.preference.IPreferenceStore; 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. @@ -63,22 +64,22 @@ public class DefaultValuesInitializer extends AbstractPreferenceInitializer { */ @Override public void initializeDefaultPreferences() { - 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$ -// } +// 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(DefaultScope.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.product/scviewer.product b/com.minres.scviewer.e4.product/scviewer.product index 163149f..46513c7 100644 --- a/com.minres.scviewer.e4.product/scviewer.product +++ b/com.minres.scviewer.e4.product/scviewer.product @@ -11,6 +11,8 @@ -clearPersistedState -Xmx2G +-Dosgi.instance.area=@user.home/.scviewer +-Dosgi.instance.area.default=@user.home/.scviewer -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts @@ -18,6 +20,7 @@ + @@ -142,4 +145,11 @@ + + + + + + + diff --git a/com.minres.scviewer.parent/pom.xml b/com.minres.scviewer.parent/pom.xml index e8a9fef..edd3538 100644 --- a/com.minres.scviewer.parent/pom.xml +++ b/com.minres.scviewer.parent/pom.xml @@ -12,11 +12,9 @@ ../com.minres.scviewer.database.sqlite ../com.minres.scviewer.database.text ../com.minres.scviewer.database.vcd - ../com.minres.scviewer.database.test ../com.minres.scviewer.database.ui ../com.minres.scviewer.database.ui.swt - ../com.opcoach.e4.preferences ../com.minres.scviewer.e4.application ../com.minres.scviewer.ui ../com.minres.scviewer.feature diff --git a/com.minres.scviewer.target/com.minres.scviewer.target.target b/com.minres.scviewer.target/com.minres.scviewer.target.target index 35d5d82..4571d61 100644 --- a/com.minres.scviewer.target/com.minres.scviewer.target.target +++ b/com.minres.scviewer.target/com.minres.scviewer.target.target @@ -17,6 +17,10 @@ + + + + x86_64 diff --git a/com.opcoach.e4.preferences/.classpath b/com.opcoach.e4.preferences/.classpath deleted file mode 100644 index 4f83b23..0000000 --- a/com.opcoach.e4.preferences/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/com.opcoach.e4.preferences/.gitignore b/com.opcoach.e4.preferences/.gitignore deleted file mode 100644 index 0f63015..0000000 --- a/com.opcoach.e4.preferences/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target/ -/bin/ diff --git a/com.opcoach.e4.preferences/.project b/com.opcoach.e4.preferences/.project deleted file mode 100644 index 8a820c7..0000000 --- a/com.opcoach.e4.preferences/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - com.opcoach.e4.preferences - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs b/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a698e59..0000000 --- a/com.opcoach.e4.preferences/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,12 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF b/com.opcoach.e4.preferences/META-INF/MANIFEST.MF deleted file mode 100644 index 5ec77eb..0000000 --- a/com.opcoach.e4.preferences/META-INF/MANIFEST.MF +++ /dev/null @@ -1,19 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Preferences -Bundle-SymbolicName: com.opcoach.e4.preferences;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: OPCOACH -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: javax.inject, - org.eclipse.core.runtime;bundle-version="3.9.0", - org.eclipse.jface;bundle-version="3.9.0", - org.eclipse.e4.core.di;bundle-version="1.3.0", - org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0", - org.eclipse.e4.core.services;bundle-version="1.1.0", - org.eclipse.e4.core.contexts;bundle-version="1.3.0", - org.eclipse.e4.ui.services;bundle-version="1.0.0" -Export-Package: com.opcoach.e4.preferences, - com.opcoach.e4.preferences.handlers -Bundle-ActivationPolicy: lazy -Automatic-Module-Name: com.opcoach.e4.preferences diff --git a/com.opcoach.e4.preferences/build.properties b/com.opcoach.e4.preferences/build.properties deleted file mode 100644 index e9863e2..0000000 --- a/com.opcoach.e4.preferences/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/com.opcoach.e4.preferences/plugin.xml b/com.opcoach.e4.preferences/plugin.xml deleted file mode 100644 index bd6f696..0000000 --- a/com.opcoach.e4.preferences/plugin.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/com.opcoach.e4.preferences/pom.xml b/com.opcoach.e4.preferences/pom.xml deleted file mode 100644 index 4dafa82..0000000 --- a/com.opcoach.e4.preferences/pom.xml +++ /dev/null @@ -1,13 +0,0 @@ - - 4.0.0 - com.opcoach.e4.preferences - - com.minres.scviewer - com.minres.scviewer.parent - 2.0.0-SNAPSHOT - ../com.minres.scviewer.parent - - eclipse-plugin - 1.0.0-SNAPSHOT - com.minres.scviewer - \ No newline at end of file diff --git a/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd b/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd deleted file mode 100644 index bcae797..0000000 --- a/com.opcoach.e4.preferences/schema/e4PreferencePages.exsd +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - - - - [Enter description of this extension point.] - - - - - - - - - - - - - - - - - a fully qualified identifier of the target extension point - - - - - - - an optional identifier of the extension instance - - - - - - - an optional name of the extension instance - - - - - - - - - - - - - - - - - - - - - - - a unique name that will be used to identify this page. - - - - - - - a translatable name that will be used in the UI for this page. - - - - - - - - - - a name of the fully qualified class that implements -<samp>org.eclipse.jface.preference.IPreferencePage</samp>. - -IT IS EASYER to extend FieldEditorPreferencePage - -If this class extends directly org.eclipse.jface.preference.FieldEditorPreferencePage preferenceStore is automatically set on it. - - - - - - - - - - a path indicating the location of the page in the preference tree. The path may either be a parent node ID or a sequence - of IDs separated by '/', representing the full path from the root node. - - - - - - - - - - - - - A reference by a preference page to a keyword. See the keywords extension point. - - - - - - - The id of the keyword being referred to. - - - - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - [Enter extension point usage example here.] - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - diff --git a/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd b/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd deleted file mode 100644 index 93e4127..0000000 --- a/com.opcoach.e4.preferences/schema/e4PreferenceStoreProvider.exsd +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - This extension point is used to associate a preference store to a plugin. -You can choose either to implement the IPreferenceStoreProvider interface or to give the ID of the IPreferenceStore to use (stored in the workbench context of your E4 application). -If this extension point is not used, a default ScopedPreferenceStore will be used for the preference page. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Set here the plugin Id concerned by this extension. -Must be a valid plugin ID (control will be done at runtime) - - - - - - - Set a class to get the IPreferenceStore for the defined pluginID. -This parameter is optional if you use the contextId attribute. - - - - - - - - - - If no class is defined, you can set here the ID of the IPreferenceStore available in the context. -This object must be set in the workbenchContext using an Addon for instance, with the following code (in addon): - -@PostContextCreate -public void initMyAddon(IEclipseContext ctx) -{ - IPreferenceStore ps = new ... . // The code to create your pref store - ctx.set(ID set in this extension, ps); -} - - - - - - - - - - - - [Enter the first release in which this extension point appears.] - - - - - - - - - The definition could be like the following : - -pluginId="yourPluginID" -provider="a class implementing IPreferenceStoreProvider" - - -Or using the key in context (usefull to share the same preference store between plugins) : - -pluginId="yourPluginID" -keyInContext="the key of the IPreferenceStore stored in context" - - - - - - - - - - - - [Enter API information here.] - - - - - - - - - [Enter information about supplied implementation of this extension point.] - - - - - - - - - @OPCoach 2014 - - - - diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java deleted file mode 100644 index b1a3307..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/IPreferenceStoreProvider.java +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * OPCoach - initial API and implementation - *******************************************************************************/ -package com.opcoach.e4.preferences; - -import org.eclipse.jface.preference.IPreferenceStore; - -/** This interface can be implemented to provide a PreferenceStore for a given plugin. - * This associatino must be done in the e4PreferenceStoreProvider extension point. - * @author olivier - * - */ -public interface IPreferenceStoreProvider -{ - /** Must be implemented to return a preference store */ - public IPreferenceStore getPreferenceStore(); - -} diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java deleted file mode 100644 index 3017845..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/ScopedPreferenceStore.java +++ /dev/null @@ -1,861 +0,0 @@ - -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Eclipse - copy of the implementation coming from jface - *******************************************************************************/ - -package com.opcoach.e4.preferences; - -import java.io.IOException; - -import org.eclipse.core.commands.common.EventManager; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.SafeRunner; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent; -import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; -import org.eclipse.jface.preference.IPersistentPreferenceStore; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.jface.util.SafeRunnable; -import org.osgi.service.prefs.BackingStoreException; - -/** - * The ScopedPreferenceStore is an IPreferenceStore that uses the scopes - * provided in org.eclipse.core.runtime.preferences. - *

- * A ScopedPreferenceStore does the lookup of a preference based on it's search - * scopes and sets the value of the preference based on its store scope. - *

- *

- * The default scope is always included in the search scopes when searching for - * preference values. - *

- * - * @see org.eclipse.core.runtime.preferences - * @since 3.1 - */ -public class ScopedPreferenceStore extends EventManager implements - IPreferenceStore, IPersistentPreferenceStore { - - /** - * The storeContext is the context where values will stored with the - * setValue methods. If there are no searchContexts this will be the search - * context. (along with the "default" context) - */ - private IScopeContext storeContext; - - /** - * The searchContext is the array of contexts that will be used by the get - * methods for searching for values. - */ - private IScopeContext[] searchContexts; - - /** - * A boolean to indicate the property changes should not be propagated. - */ - protected boolean silentRunning = false; - - /** - * The listener on the IEclipsePreferences. This is used to forward updates - * to the property change listeners on the preference store. - */ - IEclipsePreferences.IPreferenceChangeListener preferencesListener; - - /** - * The default context is the context where getDefault and setDefault - * methods will search. This context is also used in the search. - */ - private IScopeContext defaultContext = DefaultScope.INSTANCE; - - /** - * The nodeQualifer is the string used to look up the node in the contexts. - */ - String nodeQualifier; - - /** - * The defaultQualifier is the string used to look up the default node. - */ - String defaultQualifier; - - /** - * Boolean value indicating whether or not this store has changes to be - * saved. - */ - private boolean dirty; - - /** - * Create a new instance of the receiver. Store the values in context in the - * node looked up by qualifier. NOTE: Any instance of - * ScopedPreferenceStore should call - * - * @param context - * the scope to store to - * @param qualifier - * the qualifier used to look up the preference node - * @param defaultQualifierPath - * the qualifier used when looking up the defaults - */ - public ScopedPreferenceStore(IScopeContext context, String qualifier, - String defaultQualifierPath) { - this(context, qualifier); - this.defaultQualifier = defaultQualifierPath; - } - - /** - * Create a new instance of the receiver. Store the values in context in the - * node looked up by qualifier. - * - * @param context - * the scope to store to - * @param qualifier - * the qualifer used to look up the preference node - */ - public ScopedPreferenceStore(IScopeContext context, String qualifier) { - storeContext = context; - this.nodeQualifier = qualifier; - this.defaultQualifier = qualifier; - - ((IEclipsePreferences) getStorePreferences().parent()) - .addNodeChangeListener(getNodeChangeListener()); - } - - /** - * Return a node change listener that adds a removes the receiver when nodes - * change. - * - * @return INodeChangeListener - */ - private INodeChangeListener getNodeChangeListener() { - return new IEclipsePreferences.INodeChangeListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#added(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) - */ - public void added(NodeChangeEvent event) { - if (nodeQualifier.equals(event.getChild().name()) - && isListenerAttached()) { - getStorePreferences().addPreferenceChangeListener( - preferencesListener); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.INodeChangeListener#removed(org.eclipse.core.runtime.preferences.IEclipsePreferences.NodeChangeEvent) - */ - public void removed(NodeChangeEvent event) { - // Do nothing as there are no events from removed node - } - }; - } - - /** - * Initialize the preferences listener. - */ - private void initializePreferencesListener() { - if (preferencesListener == null) { - preferencesListener = new IEclipsePreferences.IPreferenceChangeListener() { - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener#preferenceChange(org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent) - */ - public void preferenceChange(PreferenceChangeEvent event) { - - if (silentRunning) { - return; - } - - Object oldValue = event.getOldValue(); - Object newValue = event.getNewValue(); - String key = event.getKey(); - if (newValue == null) { - newValue = getDefault(key, oldValue); - } else if (oldValue == null) { - oldValue = getDefault(key, newValue); - } - firePropertyChangeEvent(event.getKey(), oldValue, newValue); - } - }; - getStorePreferences().addPreferenceChangeListener( - preferencesListener); - } - - } - - /** - * Does its best at determining the default value for the given key. Checks - * the given object's type and then looks in the list of defaults to see if - * a value exists. If not or if there is a problem converting the value, the - * default default value for that type is returned. - * - * @param key - * the key to search - * @param obj - * the object who default we are looking for - * @return Object or null - */ - Object getDefault(String key, Object obj) { - IEclipsePreferences defaults = getDefaultPreferences(); - if (obj instanceof String) { - return defaults.get(key, STRING_DEFAULT_DEFAULT); - } else if (obj instanceof Integer) { - return new Integer(defaults.getInt(key, INT_DEFAULT_DEFAULT)); - } else if (obj instanceof Double) { - return new Double(defaults.getDouble(key, DOUBLE_DEFAULT_DEFAULT)); - } else if (obj instanceof Float) { - return new Float(defaults.getFloat(key, FLOAT_DEFAULT_DEFAULT)); - } else if (obj instanceof Long) { - return new Long(defaults.getLong(key, LONG_DEFAULT_DEFAULT)); - } else if (obj instanceof Boolean) { - return defaults.getBoolean(key, BOOLEAN_DEFAULT_DEFAULT) ? Boolean.TRUE - : Boolean.FALSE; - } else { - return null; - } - } - - /** - * Return the IEclipsePreferences node associated with this store. - * - * @return the preference node for this store - */ - IEclipsePreferences getStorePreferences() { - return storeContext.getNode(nodeQualifier); - } - - /** - * Return the default IEclipsePreferences for this store. - * - * @return this store's default preference node - */ - private IEclipsePreferences getDefaultPreferences() { - return defaultContext.getNode(defaultQualifier); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - initializePreferencesListener();// Create the preferences listener if it - // does not exist - addListenerObject(listener); - } - - /** - * Return the preference path to search preferences on. This is the list of - * preference nodes based on the scope contexts for this store. If there are - * no search contexts set, then return this store's context. - *

- * Whether or not the default context should be included in the resulting - * list is specified by the includeDefault parameter. - *

- * - * @param includeDefault - * true if the default context should be included - * and false otherwise - * @return IEclipsePreferences[] - * @since 3.4 public, was added in 3.1 as private method - */ - public IEclipsePreferences[] getPreferenceNodes(boolean includeDefault) { - // if the user didn't specify a search order, then return the scope that - // this store was created on. (and optionally the default) - if (searchContexts == null) { - if (includeDefault) { - return new IEclipsePreferences[] { getStorePreferences(), - getDefaultPreferences() }; - } - return new IEclipsePreferences[] { getStorePreferences() }; - } - // otherwise the user specified a search order so return the appropriate - // nodes based on it - int length = searchContexts.length; - if (includeDefault) { - length++; - } - IEclipsePreferences[] preferences = new IEclipsePreferences[length]; - for (int i = 0; i < searchContexts.length; i++) { - preferences[i] = searchContexts[i].getNode(nodeQualifier); - } - if (includeDefault) { - preferences[length - 1] = getDefaultPreferences(); - } - return preferences; - } - - /** - * Set the search contexts to scopes. When searching for a value the seach - * will be done in the order of scope contexts and will not search the - * storeContext unless it is in this list. - *

- * If the given list is null, then clear this store's search - * contexts. This means that only this store's scope context and default - * scope will be used during preference value searching. - *

- *

- * The defaultContext will be added to the end of this list automatically - * and MUST NOT be included by the user. - *

- * - * @param scopes - * a list of scope contexts to use when searching, or - * null - */ - public void setSearchContexts(IScopeContext[] scopes) { - this.searchContexts = scopes; - if (scopes == null) { - return; - } - - // Assert that the default was not included (we automatically add it to - // the end) - for (int i = 0; i < scopes.length; i++) { - if (scopes[i].equals(defaultContext)) { - Assert - .isTrue( - false, - "Do not add the default to the search contexts"); - } - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String) - */ - public boolean contains(String name) { - if (name == null) { - return false; - } - return (Platform.getPreferencesService().get(name, null, - getPreferenceNodes(true))) != null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, - * java.lang.Object, java.lang.Object) - */ - public void firePropertyChangeEvent(String name, Object oldValue, - Object newValue) { - // important: create intermediate array to protect against listeners - // being added/removed during the notification - final Object[] list = getListeners(); - if (list.length == 0) { - return; - } - final PropertyChangeEvent event = new PropertyChangeEvent(this, name, - oldValue, newValue); - for (int i = 0; i < list.length; i++) { - final IPropertyChangeListener listener = (IPropertyChangeListener) list[i]; - SafeRunner.run(new SafeRunnable(JFaceResources - .getString("PreferenceStore.changeError")) { //$NON-NLS-1$ - public void run() { - listener.propertyChange(event); - } - }); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) - */ - public boolean getBoolean(String name) { - String value = internalGet(name); - return value == null ? BOOLEAN_DEFAULT_DEFAULT : Boolean.valueOf(value) - .booleanValue(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String) - */ - public boolean getDefaultBoolean(String name) { - return getDefaultPreferences() - .getBoolean(name, BOOLEAN_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String) - */ - public double getDefaultDouble(String name) { - return getDefaultPreferences().getDouble(name, DOUBLE_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String) - */ - public float getDefaultFloat(String name) { - return getDefaultPreferences().getFloat(name, FLOAT_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String) - */ - public int getDefaultInt(String name) { - return getDefaultPreferences().getInt(name, INT_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String) - */ - public long getDefaultLong(String name) { - return getDefaultPreferences().getLong(name, LONG_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String) - */ - public String getDefaultString(String name) { - return getDefaultPreferences().get(name, STRING_DEFAULT_DEFAULT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String) - */ - public double getDouble(String name) { - String value = internalGet(name); - if (value == null) { - return DOUBLE_DEFAULT_DEFAULT; - } - try { - return Double.parseDouble(value); - } catch (NumberFormatException e) { - return DOUBLE_DEFAULT_DEFAULT; - } - } - - /** - * Return the string value for the specified key. Look in the nodes which - * are specified by this object's list of search scopes. If the value does - * not exist then return null. - * - * @param key - * the key to search with - * @return String or null if the value does not exist. - */ - private String internalGet(String key) { - return Platform.getPreferencesService().get(key, null, - getPreferenceNodes(true)); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String) - */ - public float getFloat(String name) { - String value = internalGet(name); - if (value == null) { - return FLOAT_DEFAULT_DEFAULT; - } - try { - return Float.parseFloat(value); - } catch (NumberFormatException e) { - return FLOAT_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String) - */ - public int getInt(String name) { - String value = internalGet(name); - if (value == null) { - return INT_DEFAULT_DEFAULT; - } - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - return INT_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String) - */ - public long getLong(String name) { - String value = internalGet(name); - if (value == null) { - return LONG_DEFAULT_DEFAULT; - } - try { - return Long.parseLong(value); - } catch (NumberFormatException e) { - return LONG_DEFAULT_DEFAULT; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String) - */ - public String getString(String name) { - String value = internalGet(name); - return value == null ? STRING_DEFAULT_DEFAULT : value; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String) - */ - public boolean isDefault(String name) { - if (name == null) { - return false; - } - return (Platform.getPreferencesService().get(name, null, - getPreferenceNodes(false))) == null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving() - */ - public boolean needsSaving() { - return dirty; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, - * java.lang.String) - */ - public void putValue(String name, String value) { - try { - // Do not notify listeners - silentRunning = true; - getStorePreferences().put(name, value); - } finally { - // Be sure that an exception does not stop property updates - silentRunning = false; - dirty = true; - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - removeListenerObject(listener); - if (!isListenerAttached()) { - disposePreferenceStoreListener(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * double) - */ - public void setDefault(String name, double value) { - getDefaultPreferences().putDouble(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * float) - */ - public void setDefault(String name, float value) { - getDefaultPreferences().putFloat(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * int) - */ - public void setDefault(String name, int value) { - getDefaultPreferences().putInt(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * long) - */ - public void setDefault(String name, long value) { - getDefaultPreferences().putLong(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * java.lang.String) - */ - public void setDefault(String name, String defaultObject) { - getDefaultPreferences().put(name, defaultObject); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, - * boolean) - */ - public void setDefault(String name, boolean value) { - getDefaultPreferences().putBoolean(name, value); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String) - */ - public void setToDefault(String name) { - - String oldValue = getString(name); - String defaultValue = getDefaultString(name); - try { - silentRunning = true;// Turn off updates from the store - // removing a non-existing preference is a no-op so call the Core - // API directly - getStorePreferences().remove(name); - if (oldValue != defaultValue){ - dirty = true; - firePropertyChangeEvent(name, oldValue, defaultValue); - } - - } finally { - silentRunning = false;// Restart listening to preferences - } - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * double) - */ - public void setValue(String name, double value) { - double oldValue = getDouble(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultDouble(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putDouble(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Double(oldValue), new Double( - value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * float) - */ - public void setValue(String name, float value) { - float oldValue = getFloat(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultFloat(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putFloat(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Float(oldValue), new Float(value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * int) - */ - public void setValue(String name, int value) { - int oldValue = getInt(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultInt(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putInt(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Integer(oldValue), new Integer( - value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * long) - */ - public void setValue(String name, long value) { - long oldValue = getLong(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultLong(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putLong(name, value); - } - dirty = true; - firePropertyChangeEvent(name, new Long(oldValue), new Long(value)); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * java.lang.String) - */ - public void setValue(String name, String value) { - // Do not turn on silent running here as Strings are propagated - if (getDefaultString(name).equals(value)) { - getStorePreferences().remove(name); - } else { - getStorePreferences().put(name, value); - } - dirty = true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, - * boolean) - */ - public void setValue(String name, boolean value) { - boolean oldValue = getBoolean(name); - if (oldValue == value) { - return; - } - try { - silentRunning = true;// Turn off updates from the store - if (getDefaultBoolean(name) == value) { - getStorePreferences().remove(name); - } else { - getStorePreferences().putBoolean(name, value); - } - dirty = true; - firePropertyChangeEvent(name, oldValue ? Boolean.TRUE - : Boolean.FALSE, value ? Boolean.TRUE : Boolean.FALSE); - } finally { - silentRunning = false;// Restart listening to preferences - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.preference.IPersistentPreferenceStore#save() - */ - public void save() throws IOException { - try { - getStorePreferences().flush(); - dirty = false; - } catch (BackingStoreException e) { - throw new IOException(e.getMessage()); - } - - } - - /** - * Dispose the receiver. - */ - private void disposePreferenceStoreListener() { - - IEclipsePreferences root = (IEclipsePreferences) Platform - .getPreferencesService().getRootNode().node( - Plugin.PLUGIN_PREFERENCE_SCOPE); - try { - if (!(root.nodeExists(nodeQualifier))) { - return; - } - } catch (BackingStoreException e) { - return;// No need to report here as the node won't have the - // listener - } - - IEclipsePreferences preferences = getStorePreferences(); - if (preferences == null) { - return; - } - if (preferencesListener != null) { - preferences.removePreferenceChangeListener(preferencesListener); - preferencesListener = null; - } - } - -} diff --git a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java b/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java deleted file mode 100644 index 166989b..0000000 --- a/com.opcoach.e4.preferences/src/com/opcoach/e4/preferences/handlers/E4PreferencesHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 OPCoach. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Manumitting Technologies : Brian de Alwis for initial API and implementation - * OPCoach : O.Prouvost fix bugs on hierarchy - *******************************************************************************//* - * Handler to open up a configured preferences dialog. - * Written by Brian de Alwis, Manumitting Technologies. - * Placed in the public domain. - * This code comes from : http://www.eclipse.org/forums/index.php/fa/4347/ - * and was referenced in the thread : http://www.eclipse.org/forums/index.php/m/750139/ - */ -package com.opcoach.e4.preferences.handlers; - -import javax.inject.Named; - -import org.eclipse.e4.core.di.annotations.CanExecute; -import org.eclipse.e4.core.di.annotations.Execute; -import org.eclipse.e4.ui.services.IServiceConstants; -import org.eclipse.jface.preference.PreferenceDialog; -import org.eclipse.jface.preference.PreferenceManager; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.widgets.Shell; - -import com.opcoach.e4.preferences.internal.E4PreferenceRegistry; - - -public class E4PreferencesHandler -{ - - - @CanExecute - public boolean canExecute() - { - return true; - } - - @Execute - public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg) - { - PreferenceManager pm = prefReg.getPreferenceManager(); - PreferenceDialog dialog = new PreferenceDialog(shell, pm); - dialog.create(); - dialog.getTreeViewer().setComparator(new ViewerComparator()); - dialog.getTreeViewer().expandAll(); - dialog.open(); - } - - - - -}