summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-10 09:05:49 (EDT)
committerEike Stepper2007-09-10 09:05:49 (EDT)
commit996459fd010109aa5f99e2d1d0cd0abc9453d1fa (patch)
tree85732a7636250297f0efdaddbab76fd88dd76b14
parenta448c447c3de30946233cd0592679165524ab0b1 (diff)
downloadcdo-996459fd010109aa5f99e2d1d0cd0abc9453d1fa.zip
cdo-996459fd010109aa5f99e2d1d0cd0abc9453d1fa.tar.gz
cdo-996459fd010109aa5f99e2d1d0cd0abc9453d1fa.tar.bz2
[202776] Add preferences for various defaults
https://bugs.eclipse.org/bugs/show_bug.cgi?id=202776
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.xml13
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java239
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/PreferenceConstants.java16
-rw-r--r--plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java25
-rw-r--r--plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferencePage.java44
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferenceStore.java268
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java32
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java8
15 files changed, 659 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index 12526e2..19d2f95 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -15,10 +15,12 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.net4j.util.ui;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.emf.cdo;bundle-version="[0.8.0,0.9.0)";visibility:=reexport,
org.eclipse.emf.cdo.edit;bundle-version="[0.8.0,0.9.0)",
- org.eclipse.emf.cdo.server.db;bundle-version="[0.8.0,0.9.0)"
+ org.eclipse.emf.cdo.server.db;bundle-version="[0.8.0,0.9.0)",
+ org.eclipse.ui
Export-Package: org.eclipse.emf.cdo.internal.ui;version="0.8.0",
org.eclipse.emf.cdo.internal.ui.actions;version="0.8.0",
org.eclipse.emf.cdo.internal.ui.dialogs;version="0.8.0",
org.eclipse.emf.cdo.internal.ui.editor;version="0.8.0",
+ org.eclipse.emf.cdo.internal.ui.preferences;version="0.8.0",
org.eclipse.emf.cdo.internal.ui.views;version="0.8.0"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index 753475e..677b0dc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -60,6 +60,15 @@
class = "org.eclipse.emf.cdo.internal.ui.editor.CDOEditor"
contributorClass="org.eclipse.emf.cdo.internal.ui.editor.CDOActionBarContributor" >
</editor>
- </extension>
-
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ class="org.eclipse.emf.cdo.internal.ui.preferences.CDOPreferencePage"
+ id="org.eclipse.emf.cdo.ui.preferences.CDOPreferencePage"
+ name="CDO">
+ </page>
+ </extension>
+
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java
new file mode 100644
index 0000000..b9ecac1
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java
@@ -0,0 +1,239 @@
+package org.eclipse.emf.cdo.internal.ui.preferences;
+
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.ui.prefs.OMPreferencePage;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOPreferencePage extends OMPreferencePage
+{
+ private Text repositoryName;
+
+ private Text userName;
+
+ private Text connectorDescription;
+
+ private TextAndDisable referenceChunkSize;
+
+ private TextAndDisable preloadChunkSize;
+
+ private Button invalidationNotifications;
+
+ private SelectionListener selectionListener = new SelectionListener()
+ {
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ dialogChanged();
+ }
+
+ public void widgetSelected(SelectionEvent e)
+ {
+ dialogChanged();
+ }
+ };
+
+ private ModifyListener modifyListener = new ModifyListener()
+ {
+ public void modifyText(ModifyEvent e)
+ {
+ dialogChanged();
+ }
+ };
+
+ public CDOPreferencePage()
+ {
+ super(org.eclipse.emf.internal.cdo.bundle.OM.PREFS);
+ // setDescription("CDO Preferences");
+ }
+
+ @Override
+ protected Control createContents(Composite parent)
+ {
+ GridLayout grid = new GridLayout(1, false);
+ grid.marginHeight = 0;
+ grid.marginWidth = 0;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(grid);
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Group sessionGroup = new Group(composite, SWT.NONE);
+ sessionGroup.setText("Session Defaults");
+ sessionGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ sessionGroup.setLayout(new GridLayout(2, false));
+
+ new Label(sessionGroup, SWT.NONE).setText("Repository name:");
+ repositoryName = new Text(sessionGroup, SWT.BORDER);
+ repositoryName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ repositoryName.addModifyListener(modifyListener);
+
+ new Label(sessionGroup, SWT.NONE).setText("User name:");
+ userName = new Text(sessionGroup, SWT.BORDER);
+ userName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ userName.addModifyListener(modifyListener);
+
+ new Label(sessionGroup, SWT.NONE).setText("Connector description:");
+ connectorDescription = new Text(sessionGroup, SWT.BORDER);
+ connectorDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ connectorDescription.addModifyListener(modifyListener);
+
+ new Label(sessionGroup, SWT.NONE).setText("Reference chunk size:");
+ referenceChunkSize = new TextAndDisable(sessionGroup, SWT.BORDER, String.valueOf(CDORevision.UNCHUNKED));
+ referenceChunkSize.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ referenceChunkSize.getText().addModifyListener(modifyListener);
+ referenceChunkSize.getButton().addSelectionListener(selectionListener);
+
+ Group viewGroup = new Group(composite, SWT.NONE);
+ viewGroup.setText("View Defaults");
+ viewGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ viewGroup.setLayout(new GridLayout(2, false));
+
+ new Label(viewGroup, SWT.NONE).setText("Preload chunk size:");
+ preloadChunkSize = new TextAndDisable(viewGroup, SWT.BORDER, String.valueOf(CDOView.NO_PRELOAD));
+ preloadChunkSize.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ preloadChunkSize.getText().addModifyListener(modifyListener);
+ preloadChunkSize.getButton().addSelectionListener(selectionListener);
+
+ new Label(viewGroup, SWT.NONE).setText("EMF invalidation notifications:");
+ invalidationNotifications = new Button(viewGroup, SWT.CHECK);
+ invalidationNotifications.addSelectionListener(selectionListener);
+
+ initValues();
+ return composite;
+ }
+
+ protected void initValues()
+ {
+ repositoryName.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_REPOSITORY_NAME.getValue());
+ userName.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_USER_NAME.getValue());
+ connectorDescription.setText(org.eclipse.emf.internal.cdo.bundle.OM.PREF_CONNECTOR_DESCRIPTION.getValue());
+ referenceChunkSize.setValue(String.valueOf(org.eclipse.emf.internal.cdo.bundle.OM.PREF_REFERENCE_CHUNK_SIZE
+ .getValue()));
+ preloadChunkSize.setValue(String
+ .valueOf(org.eclipse.emf.internal.cdo.bundle.OM.PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE.getValue()));
+ invalidationNotifications
+ .setSelection(org.eclipse.emf.internal.cdo.bundle.OM.PREF_ENABLE_INVALIDATION_NOTIFICATIONS.getValue());
+ }
+
+ @Override
+ public boolean performOk()
+ {
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_REPOSITORY_NAME.setValue(repositoryName.getText());
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_USER_NAME.setValue(userName.getText());
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_CONNECTOR_DESCRIPTION.setValue(connectorDescription.getText());
+
+ int v1 = Integer.parseInt(referenceChunkSize.getText().getText());
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_REFERENCE_CHUNK_SIZE.setValue(v1);
+
+ int v2 = Integer.parseInt(preloadChunkSize.getText().getText());
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE.setValue(v2);
+
+ boolean v3 = invalidationNotifications.getSelection();
+ org.eclipse.emf.internal.cdo.bundle.OM.PREF_ENABLE_INVALIDATION_NOTIFICATIONS.setValue(v3);
+
+ return super.performOk();
+ }
+
+ protected void dialogChanged()
+ {
+ }
+
+ private static final class TextAndDisable extends Composite implements SelectionListener, ModifyListener
+ {
+ private Text text;
+
+ private Button disabled;
+
+ private String disabledValue;
+
+ public TextAndDisable(Composite parent, int textStyle, String disabledValue)
+ {
+ super(parent, SWT.NONE);
+ this.disabledValue = disabledValue;
+
+ GridLayout grid = new GridLayout(2, false);
+ grid.marginHeight = 0;
+ grid.marginWidth = 0;
+ setLayout(grid);
+
+ GridData gd = new GridData();
+ gd.widthHint = 32;
+
+ text = new Text(this, textStyle);
+ text.addModifyListener(this);
+ text.setLayoutData(gd);
+
+ disabled = new Button(this, SWT.CHECK);
+ disabled.setText("Disabled");
+ disabled.addSelectionListener(this);
+ disabled.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ }
+
+ public Text getText()
+ {
+ return text;
+ }
+
+ public Button getButton()
+ {
+ return disabled;
+ }
+
+ public boolean isDisabled()
+ {
+ return disabled.getSelection();
+ }
+
+ public void setDisabled(boolean disabled)
+ {
+ this.disabled.setSelection(disabled);
+ widgetSelected(null);
+ }
+
+ public void setValue(String value)
+ {
+ text.setText(value);
+ setDisabled(ObjectUtil.equals(value, disabledValue));
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e)
+ {
+ widgetSelected(e);
+ }
+
+ public void widgetSelected(SelectionEvent e)
+ {
+ if (isDisabled())
+ {
+ text.setText(disabledValue);
+ text.setEnabled(false);
+ }
+ else
+ {
+ text.setEnabled(true);
+ }
+ }
+
+ public void modifyText(ModifyEvent e)
+ {
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/PreferenceConstants.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/PreferenceConstants.java
new file mode 100644
index 0000000..59f1517
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/PreferenceConstants.java
@@ -0,0 +1,16 @@
+package org.eclipse.emf.cdo.internal.ui.preferences;
+
+/**
+ * Constant definitions for plug-in preferences
+ */
+public class PreferenceConstants {
+
+ public static final String P_PATH = "pathPreference";
+
+ public static final String P_BOOLEAN = "booleanPreference";
+
+ public static final String P_CHOICE = "choicePreference";
+
+ public static final String P_STRING = "stringPreference";
+
+}
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
index 4a87be1..8386dcf 100644
--- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Export-Package: org.eclipse.emf.cdo;version="0.8.0",
org.eclipse.emf.cdo.util;version="0.8.0",
org.eclipse.emf.internal.cdo;version="0.8.0",
org.eclipse.emf.internal.cdo.analyzer;version="0.8.0",
+ org.eclipse.emf.internal.cdo.bundle;version="0.8.0";x-friends:="org.eclipse.emf.cdo.ui",
org.eclipse.emf.internal.cdo.protocol;version="0.8.0",
org.eclipse.emf.internal.cdo.util;version="0.8.0"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 0c0f5d0..9d1e2e7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -27,6 +27,8 @@ public interface CDOView extends INotifier
{
public static final long UNSPECIFIED_DATE = CDORevision.UNSPECIFIED_DATE;
+ public static final int NO_PRELOAD = 1;
+
public int getViewID();
public Type getViewType();
@@ -41,6 +43,10 @@ public interface CDOView extends INotifier
public void setEnableInvalidationNotifications(boolean on);
+ public int getLoadRevisionCollectionChunkSize();
+
+ public void setLoadRevisionCollectionChunkSize(int loadRevisionCollectionChunkSize);
+
/**
* @see ResourceSet#getResource(URI, boolean)
*/
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 94e1888..ea63c56 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -78,7 +78,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
private int sessionID;
- private int referenceChunkSize = CDORevision.UNCHUNKED;
+ private int referenceChunkSize;
private IFailOverStrategy failOverStrategy;
@@ -132,6 +132,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession
packageRegistry = createPackageRegistry(delegate);
packageManager = createPackageManager();
revisionManager = createRevisionManager();
+ referenceChunkSize = OM.PREF_REFERENCE_CHUNK_SIZE.getValue();
}
public int getSessionID()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 757d027..f211b13 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -74,7 +74,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
private boolean enableInvalidationNotifications;
- private int loadRevisionCollectionChunkSize = 1;
+ private int loadRevisionCollectionChunkSize;
private CDOFeatureAnalyzer featureAnalyzer = CDOFeatureAnalyzer.NOOP;
@@ -90,6 +90,8 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
this.viewID = id;
this.session = session;
+ enableInvalidationNotifications = OM.PREF_ENABLE_INVALIDATION_NOTIFICATIONS.getValue();
+ loadRevisionCollectionChunkSize = OM.PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE.getValue();
}
public int getViewID()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
index 3b053f6..3e9903a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/Activator.java
@@ -3,6 +3,9 @@ package org.eclipse.emf.internal.cdo.bundle;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.net4j.internal.util.om.OSGiBundle;
+import org.eclipse.net4j.util.om.OSGiActivator;
+
import org.osgi.framework.BundleContext;
public final class Activator extends EMFPlugin
@@ -39,14 +42,14 @@ public final class Activator extends EMFPlugin
public void start(BundleContext context) throws Exception
{
super.start(context);
- OM.BUNDLE.setBundleContext(context);
+ OSGiActivator.startBundle(context, (OSGiBundle)OM.BUNDLE);
}
@Override
public void stop(BundleContext context) throws Exception
{
plugin = null;
- OM.BUNDLE.setBundleContext(null);
+ OSGiActivator.stopBundle(context, (OSGiBundle)OM.BUNDLE);
super.stop(context);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
index 7d1c596..f40a860 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/bundle/OM.java
@@ -10,9 +10,14 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.bundle;
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+
import org.eclipse.net4j.util.om.OMBundle;
import org.eclipse.net4j.util.om.OMPlatform;
import org.eclipse.net4j.util.om.log.OMLogger;
+import org.eclipse.net4j.util.om.pref.OMPreference;
+import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.net4j.util.om.trace.OMTracer;
/**
@@ -47,4 +52,24 @@ public abstract class OM
public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
public static final OMLogger LOG = BUNDLE.logger();
+
+ public static final OMPreferences PREFS = BUNDLE.preferences();
+
+ public static final OMPreference<String> PREF_REPOSITORY_NAME = //
+ PREFS.initString("PREF_REPOSITORY_NAME"); //$NON-NLS-1$
+
+ public static final OMPreference<String> PREF_USER_NAME = //
+ PREFS.initString("PREF_USER_NAME"); //$NON-NLS-1$
+
+ public static final OMPreference<String> PREF_CONNECTOR_DESCRIPTION = //
+ PREFS.initString("PREF_CONNECTOR_DESCRIPTION"); //$NON-NLS-1$
+
+ public static final OMPreference<Integer> PREF_REFERENCE_CHUNK_SIZE = //
+ PREFS.init("PREF_REFERENCE_CHUNK_SIZE", CDORevision.UNCHUNKED); //$NON-NLS-1$
+
+ public static final OMPreference<Boolean> PREF_ENABLE_INVALIDATION_NOTIFICATIONS = //
+ PREFS.init("PREF_ENABLE_INVALIDATION_NOTIFICATIONS", false); //$NON-NLS-1$
+
+ public static final OMPreference<Integer> PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE = //
+ PREFS.init("PREF_LOAD_REVISION_COLLECTION_CHUNK_SIZE", CDOView.NO_PRELOAD); //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
index 15d1f7f..ad5325c 100644
--- a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
@@ -10,8 +10,10 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui;bundle-version="[3.3.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[0.8.0,0.9.0)";visibility:=reexport
Export-Package: org.eclipse.net4j.util.internal.ui;version="0.8.0",
+ org.eclipse.net4j.util.internal.ui.views;version="0.8.0",
org.eclipse.net4j.util.ui;version="0.8.0",
org.eclipse.net4j.util.ui.actions;version="0.8.0",
+ org.eclipse.net4j.util.ui.prefs;version="0.8.0",
org.eclipse.net4j.util.ui.views;version="0.8.0",
org.eclipse.net4j.util.ui.widgets;version="0.8.0"
Eclipse-LazyStart: true
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferencePage.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferencePage.java
new file mode 100644
index 0000000..15be3e7
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferencePage.java
@@ -0,0 +1,44 @@
+package org.eclipse.net4j.util.ui.prefs;
+
+import org.eclipse.net4j.util.om.pref.OMPreferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class OMPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+ private IWorkbench workbench;
+
+ private OMPreferenceStore preferenceStore;
+
+ public OMPreferencePage(OMPreferences preferences)
+ {
+ preferenceStore = new OMPreferenceStore(preferences);
+ }
+
+ public OMPreferences getPreferences()
+ {
+ return preferenceStore.getPreferences();
+ }
+
+ public IWorkbench getWorkbench()
+ {
+ return workbench;
+ }
+
+ public void init(IWorkbench workbench)
+ {
+ this.workbench = workbench;
+ }
+
+ @Override
+ protected IPreferenceStore doGetPreferenceStore()
+ {
+ return preferenceStore;
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferenceStore.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferenceStore.java
new file mode 100644
index 0000000..760cf11
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferenceStore.java
@@ -0,0 +1,268 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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:
+ * Eike Stepper - initial API and implementation
+ **************************************************************************/
+package org.eclipse.net4j.util.ui.prefs;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.internal.ui.bundle.OM;
+import org.eclipse.net4j.util.om.pref.OMPreference;
+import org.eclipse.net4j.util.om.pref.OMPreferences;
+import org.eclipse.net4j.util.om.pref.OMPreferencesChangeEvent;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class OMPreferenceStore implements IPreferenceStore
+{
+ private OMPreferences preferences;
+
+ private List<IPropertyChangeListener> listeners = new ArrayList<IPropertyChangeListener>(0);
+
+ private IListener preferencesListener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof OMPreferencesChangeEvent)
+ {
+ OMPreferencesChangeEvent<?> e = (OMPreferencesChangeEvent<?>)event;
+ firePropertyChangeEvent(e.getPreference().getName(), e.getOldValue(), e.getNewValue());
+ }
+ }
+ };
+
+ public OMPreferenceStore(OMPreferences preferences)
+ {
+ this.preferences = preferences;
+ preferences.addListener(preferencesListener);
+ }
+
+ public void dispose()
+ {
+ preferences.removeListener(preferencesListener);
+ }
+
+ public OMPreferences getPreferences()
+ {
+ return preferences;
+ }
+
+ public void addPropertyChangeListener(IPropertyChangeListener listener)
+ {
+ synchronized (listeners)
+ {
+ if (!listeners.contains(listener))
+ {
+ listeners.add(listener);
+ }
+ }
+ }
+
+ public void removePropertyChangeListener(IPropertyChangeListener listener)
+ {
+ synchronized (listeners)
+ {
+ listeners.remove(listener);
+ }
+ }
+
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue)
+ {
+ PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
+ for (IPropertyChangeListener listener : getPropertyChangeListenerListeners())
+ {
+ try
+ {
+ listener.propertyChange(event);
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+ }
+
+ public boolean contains(String name)
+ {
+ return preferences.contains(name);
+ }
+
+ public boolean isDefault(String name)
+ {
+ return !getPreference(name).isSet();
+ }
+
+ public boolean needsSaving()
+ {
+ return preferences.isDirty();
+ }
+
+ public boolean getDefaultBoolean(String name)
+ {
+ return (Boolean)getPreference(name).getDefaultValue();
+ }
+
+ public double getDefaultDouble(String name)
+ {
+ return (Double)getPreference(name).getDefaultValue();
+ }
+
+ public float getDefaultFloat(String name)
+ {
+ return (Float)getPreference(name).getDefaultValue();
+ }
+
+ public int getDefaultInt(String name)
+ {
+ return (Integer)getPreference(name).getDefaultValue();
+ }
+
+ public long getDefaultLong(String name)
+ {
+ return (Long)getPreference(name).getDefaultValue();
+ }
+
+ public String getDefaultString(String name)
+ {
+ return (String)getPreference(name).getDefaultValue();
+ }
+
+ public void setDefault(String name, boolean value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDefault(String name, double value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDefault(String name, float value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDefault(String name, int value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDefault(String name, long value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDefault(String name, String defaultObject)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setToDefault(String name)
+ {
+ getPreference(name).unSet();
+ }
+
+ public boolean getBoolean(String name)
+ {
+ return (Boolean)getPreference(name).getValue();
+ }
+
+ public double getDouble(String name)
+ {
+ return (Double)getPreference(name).getValue();
+ }
+
+ public float getFloat(String name)
+ {
+ return (Float)getPreference(name).getValue();
+ }
+
+ public int getInt(String name)
+ {
+ return (Integer)getPreference(name).getValue();
+ }
+
+ public long getLong(String name)
+ {
+ return (Long)getPreference(name).getValue();
+ }
+
+ public String getString(String name)
+ {
+ return (String)getPreference(name).getValue();
+ }
+
+ public void putValue(String name, String value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setValue(String name, boolean value)
+ {
+ OMPreference<Boolean> pref = (OMPreference<Boolean>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ public void setValue(String name, double value)
+ {
+ OMPreference<Double> pref = (OMPreference<Double>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ public void setValue(String name, float value)
+ {
+ OMPreference<Float> pref = (OMPreference<Float>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ public void setValue(String name, int value)
+ {
+ OMPreference<Integer> pref = (OMPreference<Integer>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ public void setValue(String name, long value)
+ {
+ OMPreference<Long> pref = (OMPreference<Long>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ public void setValue(String name, String value)
+ {
+ OMPreference<String> pref = (OMPreference<String>)getPreference(name);
+ pref.setValue(value);
+ }
+
+ private IPropertyChangeListener[] getPropertyChangeListenerListeners()
+ {
+ synchronized (listeners)
+ {
+ return listeners.toArray(new IPropertyChangeListener[listeners.size()]);
+ }
+ }
+
+ private OMPreference<?> getPreference(String name)
+ {
+ OMPreference<?> pref = preferences.get(name);
+ if (pref == null)
+ {
+ throw new IllegalStateException("No preference for " + name);
+ }
+
+ return pref;
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java
index b200573..17e31f3 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/om/pref/Preferences.java
@@ -203,34 +203,54 @@ public class Preferences extends Notifier implements OMPreferences
return init(name, DEFAULT_BYTES);
}
+ public boolean contains(String name)
+ {
+ return prefs.containsKey(name);
+ }
+
+ public OMPreference<?> get(String name)
+ {
+ return prefs.get(name);
+ }
+
public OMPreference<Boolean> getBoolean(String name)
{
- return null;
+ return (OMPreference<Boolean>)get(name);
}
public OMPreference<Integer> getInteger(String name)
{
- return null;
+ return (OMPreference<Integer>)get(name);
}
public OMPreference<Long> getLong(String name)
{
- return null;
+ return (OMPreference<Long>)get(name);
}
public OMPreference<Float> getFloat(String name)
{
- return null;
+ return (OMPreference<Float>)get(name);
}
public OMPreference<Double> getDouble(String name)
{
- return null;
+ return (OMPreference<Double>)get(name);
}
public OMPreference<String> getString(String name)
{
- return null;
+ return (OMPreference<String>)get(name);
+ }
+
+ public OMPreference<String[]> getArray(String name)
+ {
+ return (OMPreference<String[]>)get(name);
+ }
+
+ public OMPreference<byte[]> getBytes(String name)
+ {
+ return (OMPreference<byte[]>)get(name);
}
public <T> void fireChangeEvent(Preference<T> preference, T oldValue, T newValue)
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java
index 80ada6a..ce22842 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/om/pref/OMPreferences.java
@@ -72,6 +72,10 @@ public interface OMPreferences extends INotifier
public OMPreference<byte[]> initBytes(String name);
+ public boolean contains(String name);
+
+ public OMPreference<?> get(String name);
+
public OMPreference<Boolean> getBoolean(String name);
public OMPreference<Integer> getInteger(String name);
@@ -83,4 +87,8 @@ public interface OMPreferences extends INotifier
public OMPreference<Double> getDouble(String name);
public OMPreference<String> getString(String name);
+
+ public OMPreference<String[]> getArray(String name);
+
+ public OMPreference<byte[]> getBytes(String name);
}