summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 04:30:16 (EDT)
committerEike Stepper2007-10-08 04:30:16 (EDT)
commitf820ac2cc3aa2ca04f94a39635c5c180b86726d8 (patch)
treea3ea7295eef262726d2f7b03b67c3b3714318547
parent95879b7b79e7659aa4a300aaf3d2e34a34cead23 (diff)
downloadcdo-f820ac2cc3aa2ca04f94a39635c5c180b86726d8.zip
cdo-f820ac2cc3aa2ca04f94a39635c5c180b86726d8.tar.gz
cdo-f820ac2cc3aa2ca04f94a39635c5c180b86726d8.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/preferences/CDOPreferencePage.java36
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/preferences/BuddiesPreferencePage.java20
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/prefs/OMPreferencePage.java122
3 files changed, 125 insertions, 53 deletions
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
index c9a0918..7f93acb 100644
--- 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
@@ -47,35 +47,13 @@ public class CDOPreferencePage extends OMPreferencePage
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)
+ protected Control createUI(Composite parent)
{
GridLayout grid = new GridLayout(1, false);
grid.marginHeight = 0;
@@ -93,23 +71,18 @@ public class CDOPreferencePage extends OMPreferencePage
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");
@@ -119,12 +92,9 @@ public class CDOPreferencePage extends OMPreferencePage
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;
@@ -162,10 +132,6 @@ public class CDOPreferencePage extends OMPreferencePage
return super.performOk();
}
- protected void dialogChanged()
- {
- }
-
private static final class TextAndDisable extends Composite implements SelectionListener, ModifyListener
{
private Text text;
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/preferences/BuddiesPreferencePage.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/preferences/BuddiesPreferencePage.java
index 3a77525..4b9f435 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/preferences/BuddiesPreferencePage.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/preferences/BuddiesPreferencePage.java
@@ -14,8 +14,6 @@ import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
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.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -37,21 +35,13 @@ public class BuddiesPreferencePage extends OMPreferencePage
private Button autoConnect;
- private ModifyListener modifyListener = new ModifyListener()
- {
- public void modifyText(ModifyEvent e)
- {
- dialogChanged();
- }
- };
-
public BuddiesPreferencePage()
{
super(OM.PREFS);
}
@Override
- protected Control createContents(Composite parent)
+ protected Control createUI(Composite parent)
{
GridLayout grid = new GridLayout(2, false);
grid.marginHeight = 0;
@@ -64,20 +54,18 @@ public class BuddiesPreferencePage extends OMPreferencePage
new Label(composite, SWT.NONE).setText("Server:");
connectorDescription = new Text(composite, SWT.BORDER);
connectorDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- connectorDescription.addModifyListener(modifyListener);
new Label(composite, SWT.NONE).setText("User ID:");
userID = new Text(composite, SWT.BORDER);
userID.setLayoutData(new GridData(100, SWT.DEFAULT));
- userID.addModifyListener(modifyListener);
new Label(composite, SWT.NONE).setText("Password:");
password = new Text(composite, SWT.BORDER | SWT.PASSWORD);
password.setLayoutData(new GridData(100, SWT.DEFAULT));
- password.addModifyListener(modifyListener);
new Label(composite, SWT.NONE);
autoConnect = new Button(composite, SWT.CHECK);
+ autoConnect.setText("Auto Connect");
initValues();
return composite;
@@ -100,8 +88,4 @@ public class BuddiesPreferencePage extends OMPreferencePage
OM.PREF_AUTO_CONNECT.setValue(autoConnect.getSelection());
return super.performOk();
}
-
- protected void dialogChanged()
- {
- }
} \ No newline at end of file
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
index 15be3e7..586d106 100644
--- 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
@@ -4,6 +4,20 @@ import org.eclipse.net4j.util.om.pref.OMPreferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.custom.CCombo;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.DateTime;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -16,6 +30,27 @@ public abstract class OMPreferencePage extends PreferencePage implements IWorkbe
private OMPreferenceStore preferenceStore;
+ 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 OMPreferencePage(OMPreferences preferences)
{
preferenceStore = new OMPreferenceStore(preferences);
@@ -41,4 +76,91 @@ public abstract class OMPreferencePage extends PreferencePage implements IWorkbe
{
return preferenceStore;
}
+
+ protected final SelectionListener getSelectionListener()
+ {
+ return selectionListener;
+ }
+
+ protected final ModifyListener getModifyListener()
+ {
+ return modifyListener;
+ }
+
+ protected void dialogChanged()
+ {
+ System.out.println("CHANGED");
+ }
+
+ @Override
+ protected final Control createContents(Composite parent)
+ {
+ Control control = createUI(parent);
+ addListeners(control);
+ return control;
+ }
+
+ protected void addListeners(Control control)
+ {
+ if (control instanceof Text)
+ {
+ Text c = (Text)control;
+ c.addModifyListener(modifyListener);
+ }
+
+ if (control instanceof Combo)
+ {
+ Combo c = (Combo)control;
+ c.addModifyListener(modifyListener);
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof CCombo)
+ {
+ CCombo c = (CCombo)control;
+ c.addModifyListener(modifyListener);
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof List)
+ {
+ List c = (List)control;
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof DateTime)
+ {
+ DateTime c = (DateTime)control;
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof Table)
+ {
+ Table c = (Table)control;
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof Tree)
+ {
+ Table c = (Table)control;
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof Button)
+ {
+ Button c = (Button)control;
+ c.addSelectionListener(selectionListener);
+ }
+
+ if (control instanceof Composite)
+ {
+ Composite c = (Composite)control;
+ for (Control child : c.getChildren())
+ {
+ addListeners(child);
+ }
+ }
+ }
+
+ protected abstract Control createUI(Composite parent);
} \ No newline at end of file