summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-09-28 10:01:05 (EDT)
committerEike Stepper2007-09-28 10:01:05 (EDT)
commitc270807d1b77658796254eac0158e781cacd8405 (patch)
tree2f3106bcc71c53588e71fa7747b09030c59ffcfe
parent31c9b0ce010c942229b70597e7e548cb825499b1 (diff)
downloadcdo-c270807d1b77658796254eac0158e781cacd8405.zip
cdo-c270807d1b77658796254eac0158e781cacd8405.tar.gz
cdo-c270807d1b77658796254eac0158e781cacd8405.tar.bz2
[204732] Add dialog for "Open Session"
https://bugs.eclipse.org/bugs/show_bug.cgi?id=204732
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java11
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java73
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java6
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java34
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java4
5 files changed, 54 insertions, 74 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
index c070a29..2567ae2 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/OpenSessionDialog.java
@@ -103,23 +103,24 @@ public class OpenSessionDialog extends TitleAreaDialog
new Label(composite, SWT.NONE).setText("Server Description:");
connector = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, connectorHistory);
- connector.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ connector.getCombo().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
if (connectorHistory.isEmpty())
{
new Label(composite, SWT.NONE);
example = new Label(composite, SWT.NONE);
- example.setText("example: tcp://estepper@dev.eclipse.org:2036");
+ example.setText("for example 'tcp://estepper@dev.eclipse.org:2036'");
example.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
}
new Label(composite, SWT.NONE).setText("Repository Name:");
repository = new HistoryText(composite, SWT.BORDER | SWT.SINGLE, repositoryHistory);
- repository.setLayoutData(new GridData(150, SWT.DEFAULT));
+ repository.getCombo().setLayoutData(new GridData(150, SWT.DEFAULT));
- new Label(composite, SWT.NONE).setText("Legacy Support:");
- legacy = new PreferenceButton(composite, SWT.CHECK, OM.PREF_LEGACY_SUPPORT);
+ new Label(composite, SWT.NONE);
+ legacy = new PreferenceButton(composite, SWT.CHECK, "Legacy Support", OM.PREF_LEGACY_SUPPORT);
+ connector.setFocus();
connector.getCombo().addFocusListener(new FocusListener()
{
public void focusGained(FocusEvent e)
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java
index 3c8d912..9f1c793 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryText.java
@@ -18,12 +18,11 @@ import org.eclipse.net4j.util.collection.IHistoryElement;
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.ui.UIUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.events.VerifyListener;
@@ -36,7 +35,7 @@ import java.lang.reflect.Method;
/**
* @author Eike Stepper
*/
-public class HistoryText extends Composite
+public class HistoryText
{
private IHistory<String> history;
@@ -55,13 +54,37 @@ public class HistoryText extends Composite
}
};
- public HistoryText(Composite parent, int comboStyle, IHistory<String> history)
+ public HistoryText(Composite parent, int style, IHistory<String> history)
{
- super(parent, SWT.NONE);
- setLayout(UIUtil.createGridLayout(1));
+ this.history = history;
+ history.addListener(historyListener);
- combo = createCombo(comboStyle);
+ combo = new CCombo(parent, style);
combo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ combo.addDisposeListener(new DisposeListener()
+ {
+ public void widgetDisposed(DisposeEvent e)
+ {
+ HistoryText.this.history.removeListener(historyListener);
+ }
+ });
+
+ // TODO Can't get traversal working when keyListener is added ;-(
+ // combo.addKeyListener(new KeyAdapter()
+ // {
+ // @Override
+ // public void keyPressed(KeyEvent event)
+ // {
+ // if (event.character == SWT.DEL && event.stateMask == 0 && isDropped())
+ // {
+ // int index = combo.getSelectionIndex();
+ // if (index != -1)
+ // {
+ // HistoryText.this.history.remove(index);
+ // }
+ // }
+ // }
+ // });
try
{
@@ -73,9 +96,7 @@ public class HistoryText extends Composite
OM.LOG.error(ex);
}
- this.history = history;
historyChanged();
- history.addListener(historyListener);
}
public IHistory<String> getHistory()
@@ -88,13 +109,6 @@ public class HistoryText extends Composite
return combo;
}
- @Override
- public void dispose()
- {
- history.removeListener(historyListener);
- super.dispose();
- }
-
public void addModifyListener(ModifyListener listener)
{
combo.addModifyListener(listener);
@@ -190,7 +204,6 @@ public class HistoryText extends Composite
combo.setTextLimit(limit);
}
- @Override
public boolean setFocus()
{
return combo.setFocus();
@@ -215,7 +228,7 @@ public class HistoryText extends Composite
protected void historyChanged()
{
- if (isDisposed())
+ if (combo.isDisposed())
{
return;
}
@@ -232,26 +245,4 @@ public class HistoryText extends Composite
setText(mostRecent);
}
}
-
- protected CCombo createCombo(int style)
- {
- final CCombo combo = new CCombo(this, style);
- combo.addKeyListener(new KeyAdapter()
- {
- @Override
- public void keyPressed(KeyEvent event)
- {
- if (event.character == SWT.DEL && event.stateMask == 0 && isDropped())
- {
- int index = combo.getSelectionIndex();
- if (index != -1)
- {
- history.remove(index);
- }
- }
- }
- });
-
- return combo;
- }
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java
index 3cbdb59..b29a74b 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/HistoryTextDialog.java
@@ -74,9 +74,9 @@ public class HistoryTextDialog extends InputDialog
text.setEnabled(false);
historyText = new HistoryText(composite, SWT.BORDER, history);
- historyText.moveAbove(text);
- historyText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
- historyText.addModifyListener(new ModifyListener()
+ historyText.getCombo().moveAbove(text);
+ historyText.getCombo().setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ historyText.getCombo().addModifyListener(new ModifyListener()
{
public void modifyText(ModifyEvent e)
{
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java
index 54e327c..d710c74 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/widgets/PreferenceButton.java
@@ -11,34 +11,28 @@
package org.eclipse.net4j.util.ui.widgets;
import org.eclipse.net4j.util.om.pref.OMPreference;
-import org.eclipse.net4j.util.ui.UIUtil;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
/**
* @author Eike Stepper
*/
-public class PreferenceButton extends Composite
+public class PreferenceButton
{
private OMPreference<Boolean> preference;
private Button button;
- public PreferenceButton(Composite parent, int buttonStyle, final OMPreference<Boolean> preference)
+ public PreferenceButton(Composite parent, int style, String text, final OMPreference<Boolean> preference)
{
- super(parent, SWT.NONE);
- setLayout(UIUtil.createGridLayout(1));
this.preference = preference;
- button = createButton(buttonStyle);
- button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ button = new Button(parent, style);
+ button.setText(text);
button.setSelection(preference.getValue());
button.addSelectionListener(new SelectionAdapter()
{
@@ -60,16 +54,6 @@ public class PreferenceButton extends Composite
return button;
}
- protected Button createButton(int buttonStyle)
- {
- return new Button(this, buttonStyle);
- }
-
- public void addSelectionListener(SelectionListener listener)
- {
- button.addSelectionListener(listener);
- }
-
public int getAlignment()
{
return button.getAlignment();
@@ -90,11 +74,6 @@ public class PreferenceButton extends Composite
return button.getText();
}
- public void removeSelectionListener(SelectionListener listener)
- {
- button.removeSelectionListener(listener);
- }
-
public void setAlignment(int alignment)
{
button.setAlignment(alignment);
@@ -114,4 +93,9 @@ public class PreferenceButton extends Composite
{
button.setText(string);
}
+
+ public boolean setFocus()
+ {
+ return button.setFocus();
+ }
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java
index 8ddba32..8ea898d 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/collection/History.java
@@ -87,6 +87,7 @@ public class History<T> extends Notifier implements IHistory<T>
public boolean add(T data)
{
+ lazyLoad();
boolean changed = internalAdd(data);
if (changed)
{
@@ -98,6 +99,7 @@ public class History<T> extends Notifier implements IHistory<T>
public IHistoryElement<T> remove(int index)
{
+ lazyLoad();
IHistoryElement<T> element = elements.remove(index);
if (element != null)
{
@@ -121,6 +123,7 @@ public class History<T> extends Notifier implements IHistory<T>
public T getMostRecent()
{
+ lazyLoad();
if (isEmpty())
{
return null;
@@ -131,6 +134,7 @@ public class History<T> extends Notifier implements IHistory<T>
public <D> D[] getData(D[] a)
{
+ lazyLoad();
int size = elements.size();
if (a.length < size)
{